6ae3b46fc1
+ Refactoring of some functions + Added the retrying of all three connections + Added the documentation to the code + Improved the error messages
29 lines
497 B
Go
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)
|
|
}
|
|
}
|
|
}
|