Skip to content

Commit ac34fea

Browse files
gustavosbarretobelak
authored andcommitted
Update remoteforward example to follow configurable handlers feature
1 parent 93eb073 commit ac34fea

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: _examples/ssh-remoteforward/portforward.go

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ func main() {
1111

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

14+
forwardHandler := &ssh.ForwardedTCPHandler{}
15+
1416
server := ssh.Server{
1517
LocalPortForwardingCallback: ssh.LocalPortForwardingCallback(func(ctx ssh.Context, dhost string, dport uint32) bool {
1618
log.Println("Accepted forward", dhost, dport)
@@ -25,6 +27,10 @@ func main() {
2527
log.Println("attempt to bind", host, port, "granted")
2628
return true
2729
}),
30+
RequestHandlers: map[string]ssh.RequestHandler{
31+
"tcpip-forward": forwardHandler.HandleSSHRequest,
32+
"cancel-tcpip-forward": forwardHandler.HandleSSHRequest,
33+
},
2834
}
2935

3036
log.Fatal(server.ListenAndServe())

0 commit comments

Comments
 (0)