diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2016-12-22 20:26:43 +0800 |
---|---|---|
committer | Thomas Boerger <thomas@webhippie.de> | 2016-12-22 13:26:43 +0100 |
commit | 65b1875d2bba97130f2796fe915f2a342ef7869c (patch) | |
tree | 07169fa476e103ccb10811be072d2368b9c474fe /modules/ssh | |
parent | 11df7ebfc5013ce6acc302fa7808f9c7cbe684de (diff) | |
download | gitea-65b1875d2bba97130f2796fe915f2a342ef7869c.tar.gz gitea-65b1875d2bba97130f2796fe915f2a342ef7869c.zip |
New settings option for a custom SSH host (#3763) (#446)
* New settings option for a custom SSH host (#3763)
* let default ssh listen addr empty
Diffstat (limited to 'modules/ssh')
-rw-r--r-- | modules/ssh/ssh.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index b35973cc32..056ef084ef 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -110,10 +110,10 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) { } } -func listen(config *ssh.ServerConfig, port int) { - listener, err := net.Listen("tcp", "0.0.0.0:"+com.ToStr(port)) +func listen(config *ssh.ServerConfig, host string, port int) { + listener, err := net.Listen("tcp", host+":"+com.ToStr(port)) if err != nil { - panic(err) + log.Fatal(4, "Fail to start SSH server: %v", err) } for { // Once a ServerConfig has been configured, connections can be accepted. @@ -148,7 +148,7 @@ func listen(config *ssh.ServerConfig, port int) { } // Listen starts a SSH server listens on given port. -func Listen(port int) { +func Listen(host string, port int) { config := &ssh.ServerConfig{ PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { pkey, err := models.SearchPublicKeyByContent(strings.TrimSpace(string(ssh.MarshalAuthorizedKey(key)))) @@ -185,5 +185,5 @@ func Listen(port int) { } config.AddHostKey(private) - go listen(config, port) + go listen(config, host, port) } |