From 7e7f06b31f8d12fe30c38f95c072becb2005754b Mon Sep 17 00:00:00 2001 From: Merlijn Wajer Date: Sat, 3 Jun 2017 21:10:51 +0200 Subject: [PATCH] Cleanups & comments --- sshd.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sshd.go b/sshd.go index bf7d1be..7809e93 100644 --- a/sshd.go +++ b/sshd.go @@ -118,11 +118,11 @@ func main() { PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { authmutex.Lock() defer authmutex.Unlock() - if deviceinfo, found := authorisedKeys[string(key.Marshal())]; found { + if clientinfo, found := authorisedKeys[string(key.Marshal())]; found { return &ssh.Permissions{ - CriticalOptions: map[string]string{"name": deviceinfo.Comment, - "localports": deviceinfo.LocalPorts, - "remoteports": deviceinfo.RemotePorts}, + CriticalOptions: map[string]string{"name": clientinfo.Comment, + "localports": clientinfo.LocalPorts, + "remoteports": clientinfo.RemotePorts}, }, nil } @@ -174,6 +174,9 @@ func main() { client.AllowedLocalPorts, _ = parsePorts(allowedLocalPorts) client.AllowedRemotePorts, _ = parsePorts(allowedRemotePorts) + // Start the clean-up function: will wait for the socket to be + // closed (either by remote, protocol or deadline/timeout) + // and close any listeners if any go func() { err := client.SshConn.Wait() client.ListenMutex.Lock() @@ -213,7 +216,7 @@ func handleChannel(client *sshClient, newChannel ssh.NewChannel) { return } - newChannel.Reject(ssh.Prohibited, fmt.Sprintf("Only \"direct-tcpip\" is accepted")) + newChannel.Reject(ssh.Prohibited, "Only \"direct-tcpip\" is accepted") /* // XXX: Use this only for testing purposes -- I add this in if/when I // want to use the ssh escape sequences from ssh (those only work in an