Skip to content

Commit

Permalink
Update remoteforward example to follow configurable handlers feature
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavosbarreto authored and belak committed Jun 19, 2019
1 parent 93eb073 commit ac34fea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions _examples/ssh-remoteforward/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func main() {

log.Println("starting ssh server on port 2222...")

forwardHandler := &ssh.ForwardedTCPHandler{}

server := ssh.Server{
LocalPortForwardingCallback: ssh.LocalPortForwardingCallback(func(ctx ssh.Context, dhost string, dport uint32) bool {
log.Println("Accepted forward", dhost, dport)
Expand All @@ -25,6 +27,10 @@ func main() {
log.Println("attempt to bind", host, port, "granted")
return true
}),
RequestHandlers: map[string]ssh.RequestHandler{
"tcpip-forward": forwardHandler.HandleSSHRequest,
"cancel-tcpip-forward": forwardHandler.HandleSSHRequest,
},
}

log.Fatal(server.ListenAndServe())
Expand Down

0 comments on commit ac34fea

Please sign in to comment.