Skip to content

Commit cc77e42

Browse files
committed
Remove -port flag
1 parent d3ceb5b commit cc77e42

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ var (
2020
pathDb = filepath.Join(pathClidle, "db.json")
2121
pathHostKey = filepath.Join(pathClidle, "hostkey")
2222

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)")
2524

2625
teaOptions = []tea.ProgramOption{tea.WithAltScreen(), tea.WithOutput(os.Stderr)}
2726
)

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import (
1919

2020
func main() {
2121
flag.Parse()
22-
if *flagServe {
23-
runServer(*flagPort)
22+
if addr := *flagServe; addr != "" {
23+
runServer(addr)
2424
} else {
2525
runCli()
2626
}
@@ -42,14 +42,14 @@ func runCli() {
4242
os.Exit(exitCode)
4343
}
4444

45-
func runServer(port int) {
45+
func runServer(addr string) {
4646
withHostKey := wish.WithHostKeyPath(pathHostKey)
4747
if pem, ok := os.LookupEnv(envHostKey); ok {
4848
withHostKey = wish.WithHostKeyPEM([]byte(pem))
4949
}
5050

5151
server, err := wish.NewServer(
52-
wish.WithAddress(fmt.Sprintf("0.0.0.0:%d", port)),
52+
wish.WithAddress(addr),
5353
wish.WithMaxTimeout(30*time.Minute),
5454
wish.WithMiddleware(
5555
bm.Middleware(func(s ssh.Session) (tea.Model, []tea.ProgramOption) {

0 commit comments

Comments
 (0)