File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 20
20
pathDb = filepath .Join (pathClidle , "db.json" )
21
21
pathHostKey = filepath .Join (pathClidle , "hostkey" )
22
22
23
- flagServe = flag .Bool ("serve" , false , "Spawns an SSH server" )
24
- flagPort = flag .Int ("port" , 22 , "Changes the server port" )
23
+ flagServe = flag .String ("serve" , "" , "Spawns an SSH server on the given address (format: 0.0.0.0:1337)" )
25
24
26
25
teaOptions = []tea.ProgramOption {tea .WithAltScreen (), tea .WithOutput (os .Stderr )}
27
26
)
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ import (
19
19
20
20
func main () {
21
21
flag .Parse ()
22
- if * flagServe {
23
- runServer (* flagPort )
22
+ if addr := * flagServe ; addr != "" {
23
+ runServer (addr )
24
24
} else {
25
25
runCli ()
26
26
}
@@ -42,14 +42,14 @@ func runCli() {
42
42
os .Exit (exitCode )
43
43
}
44
44
45
- func runServer (port int ) {
45
+ func runServer (addr string ) {
46
46
withHostKey := wish .WithHostKeyPath (pathHostKey )
47
47
if pem , ok := os .LookupEnv (envHostKey ); ok {
48
48
withHostKey = wish .WithHostKeyPEM ([]byte (pem ))
49
49
}
50
50
51
51
server , err := wish .NewServer (
52
- wish .WithAddress (fmt . Sprintf ( "0.0.0.0:%d" , port ) ),
52
+ wish .WithAddress (addr ),
53
53
wish .WithMaxTimeout (30 * time .Minute ),
54
54
wish .WithMiddleware (
55
55
bm .Middleware (func (s ssh.Session ) (tea.Model , []tea.ProgramOption ) {
You can’t perform that action at this time.
0 commit comments