@@ -10,11 +10,11 @@ import (
10
10
)
11
11
12
12
type Tunnel struct {
13
- router * echo.Echo
14
- srv * http.Server
15
- ProxyHandler func (e echo.Context ) error
16
- ConnHandler func (e echo.Context ) error
17
- CloseHandler func (e echo.Context ) error
13
+ router * echo.Echo
14
+ srv * http.Server
15
+ HTTPProxyHandler func (e echo.Context ) error
16
+ SSHHandler func (e echo.Context ) error
17
+ SSHCloseHandler func (e echo.Context ) error
18
18
}
19
19
20
20
type Builder struct {
@@ -27,20 +27,20 @@ func NewBuilder() *Builder {
27
27
}
28
28
}
29
29
30
- func (t * Builder ) WithProxyHandler (handler func (e echo.Context ) error ) * Builder {
31
- t .tunnel .ProxyHandler = handler
30
+ func (t * Builder ) WithHTTPProxyHandler (handler func (e echo.Context ) error ) * Builder {
31
+ t .tunnel .HTTPProxyHandler = handler
32
32
33
33
return t
34
34
}
35
35
36
- func (t * Builder ) WithConnHandler (handler func (e echo.Context ) error ) * Builder {
37
- t .tunnel .ConnHandler = handler
36
+ func (t * Builder ) WithSSHHandler (handler func (e echo.Context ) error ) * Builder {
37
+ t .tunnel .SSHHandler = handler
38
38
39
39
return t
40
40
}
41
41
42
- func (t * Builder ) WithCloseHandler (handler func (e echo.Context ) error ) * Builder {
43
- t .tunnel .CloseHandler = handler
42
+ func (t * Builder ) WithSSHCloseHandler (handler func (e echo.Context ) error ) * Builder {
43
+ t .tunnel .SSHCloseHandler = handler
44
44
45
45
return t
46
46
}
@@ -60,29 +60,29 @@ func NewTunnel() *Tunnel {
60
60
return context .WithValue (ctx , "http-conn" , c ) //nolint:revive
61
61
},
62
62
},
63
- ConnHandler : func (_ echo.Context ) error {
63
+ SSHHandler : func (_ echo.Context ) error {
64
64
panic ("ConnHandler can not be nil" )
65
65
},
66
- CloseHandler : func (_ echo.Context ) error {
66
+ SSHCloseHandler : func (_ echo.Context ) error {
67
67
panic ("CloseHandler can not be nil" )
68
68
},
69
- ProxyHandler : func (_ echo.Context ) error {
69
+ HTTPProxyHandler : func (_ echo.Context ) error {
70
70
panic ("ProxyHandler can not be nil" )
71
71
},
72
72
}
73
73
e .GET ("/ssh/:id" , func (e echo.Context ) error {
74
- return t .ConnHandler (e )
74
+ return t .SSHHandler (e )
75
75
})
76
76
e .GET ("/ssh/close/:id" , func (e echo.Context ) error {
77
- return t .CloseHandler (e )
77
+ return t .SSHCloseHandler (e )
78
78
})
79
79
e .CONNECT ("/ssh/proxy/:addr" , func (e echo.Context ) error {
80
80
// NOTE: The CONNECT HTTP method requests that a proxy establish a HTTP tunnel to this server, and if
81
81
// successful, blindly forward data in both directions until the tunnel is closed.
82
82
//
83
83
// https://en.wikipedia.org/wiki/HTTP_tunnel
84
84
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT
85
- return t .ProxyHandler (e )
85
+ return t .HTTPProxyHandler (e )
86
86
})
87
87
88
88
return t
0 commit comments