From 3112b5ed30539a38c2712ba7efec93de8522dd54 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Thu, 18 Feb 2016 14:22:39 +0100 Subject: [PATCH] Fix: `Gateways` field is no longer ignored when the `HostName` field is present (#102) --- README.md | 1 + pkg/config/config_test.go | 12 ++++++------ pkg/config/host.go | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2b9f619f6..71bf708e8 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,7 @@ Get a released version on: https://github.com/moul/advanced-ssh-config/releases ### master (unreleased) +* Fix: `Gateways` field is no longer ignored when the `HostName` field is present ([#102](https://github.com/moul/advanced-ssh-config/issues/102)) * Ignore SIGHUP, close goroutines and export written bytes ([#112](https://github.com/moul/advanced-ssh-config/pull/112)) ([@QuentinPerez](https://github.com/QuentinPerez)) * Various documentation improvements ([@ashmatadeen](https://github.com/ashmatadeen), [@loliee](https://github.com/loliee), [@cerisier](https://github.com/cerisier)) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index b8cc89715..ac8e60016 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -863,48 +863,48 @@ func TestConfig_WriteSshConfig(t *testing.T) { # host-based configuration Host *.ddd - HostName 1.3.5.7 PasswordAuthentication yes + # HostName: 1.3.5.7 Host empty Host nnn - HostName 5.5.5.5 PasswordAuthentication yes Port 26 User mmmm # ProxyCommand nc -v 4242 + # HostName: 5.5.5.5 # Inherits: [mmm] # Gateways: [titi, direct, 1.2.3.4] Host tata - HostName 1.2.3.4 PasswordAuthentication yes Port 22 User moul # ProxyCommand nc -v 4242 + # HostName: 1.2.3.4 # Inherits: [tutu, titi, toto, tutu] # Gateways: [titi, direct, 1.2.3.4] Host titi - HostName tata Port 23 User moul # ProxyCommand nc -v 4242 + # HostName: tata Host tonton # ResolveNameservers: [a.com, 1.2.3.4] Host toto - HostName 1.2.3.4 + # HostName: 1.2.3.4 Host toutou # ResolveCommand: dig -t %h Host tutu - HostName 1.2.3.4 PasswordAuthentication yes Port 22 + # HostName: 1.2.3.4 # Inherits: [toto, tutu, *.ddd] # Gateways: [titi, direct, 1.2.3.4] diff --git a/pkg/config/host.go b/pkg/config/host.go index 0deedcf1a..6435857ab 100644 --- a/pkg/config/host.go +++ b/pkg/config/host.go @@ -709,9 +709,6 @@ func (h *Host) WriteSshConfigTo(w io.Writer) error { if h.HostKeyAlias != "" { fmt.Fprintf(w, " HostKeyAlias %s\n", h.HostKeyAlias) } - if h.HostName != "" { - fmt.Fprintf(w, " HostName %s\n", h.HostName) - } if h.IdentitiesOnly != "" { fmt.Fprintf(w, " IdentitiesOnly %s\n", h.IdentitiesOnly) } @@ -856,6 +853,9 @@ func (h *Host) WriteSshConfigTo(w io.Writer) error { } // assh fields + if h.HostName != "" { + fmt.Fprintf(w, " # HostName: %s\n", h.HostName) + } if len(h.Inherits) > 0 { fmt.Fprintf(w, " # Inherits: [%s]\n", strings.Join(h.Inherits, ", ")) }