SSHTunnel/AcceptClients.go
Thorsten Sommer 6ae3b46fc1 Retry, Refactoring & Doc
+ Refactoring of some functions
+ Added the retrying of all three connections
+ Added the documentation to the code
+ Improved the error messages
2015-01-02 18:01:52 +01:00

29 lines
497 B
Go

package main
import (
"golang.org/x/crypto/ssh"
"log"
"net"
)
func acceptClients(connection net.Listener, config *ssh.ClientConfig) {
// Endless loop
for {
// Accept (another) client connection:
if localConn, err := connection.Accept(); err != nil {
// Fail
log.Printf("Accepting a client failed: %s\n", err.Error())
} else {
// Success
log.Println(`Client accepted.`)
// Start the forwarding:
go forward(localConn, config)
}
}
}