Skip to content

Commit 0319fc9

Browse files
committed
feature: Unix socket custom ssh port
1 parent 7af7da3 commit 0319fc9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

app/handlers/tunnel.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ func OpenTunnel(c *fiber.Ctx) error {
1515
}
1616
}
1717

18+
sshPort := c.FormValue("ssh_port")
19+
if len(sshPort) < 1 {
20+
sshPort = "22"
21+
}
22+
1823
port := bridge.CreateTunnel(
1924
c.FormValue("remote_host"),
2025
c.FormValue("remote_port"),
2126
c.FormValue("username"),
2227
c.FormValue("password"),
28+
sshPort,
2329
)
2430

2531
return c.JSON(port)

internal/bridge/ssh_tunnel.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type Tunnel struct {
4242

4343
var mut sync.Mutex = sync.Mutex{}
4444

45-
func CreateTunnel(remoteHost, remotePort, username, password string) int {
45+
func CreateTunnel(remoteHost, remotePort, username, password, sshPort string) int {
4646
ch := make(chan int)
4747
time.AfterFunc(30*time.Second, func() {
4848
ch <- 1
@@ -93,7 +93,7 @@ func CreateTunnel(remoteHost, remotePort, username, password string) int {
9393
hostKeys: ssh.InsecureIgnoreHostKey(),
9494
user: username,
9595
mode: '>',
96-
hostAddr: net.JoinHostPort(remoteHost, "22"),
96+
hostAddr: net.JoinHostPort(remoteHost, sshPort),
9797
dialAddr: dial,
9898
dialType: dialType,
9999
bindAddr: net.JoinHostPort("127.0.0.1", fmt.Sprintf("%d", port)),

0 commit comments

Comments
 (0)