fix for proxycmd

This commit is contained in:
Matthias Bilger 2024-07-06 11:38:19 +02:00
parent 44d28d9990
commit 51a93c1626
2 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import (
"os/exec"
"net/http"
"sync"
"strings"
"time"
"io"
@ -308,7 +309,10 @@ func (c *Client) BoreTunnel(ctx context.Context, tunnel Tunnel) error {
}
} else {
// Use SSH over proxy command
cmd := exec.CommandContext(ctx, "sh", "-c", c.proxyCommand)
tmpProxyCommand := strings.Replace(c.proxyCommand, "%h", tunnel.ServerAddress, -1)
proxyCommand := strings.Replace(tmpProxyCommand, "%p", fmt.Sprintf("%d", tunnel.ServerPort), -1)
cmd := exec.CommandContext(ctx, "sh", "-c", proxyCommand)
stdin, err := cmd.StdinPipe()
if err != nil {
return fmt.Errorf("Failed to setup proxy command stdin: %v", err)

View File

@ -97,6 +97,7 @@ func main() {
dnsServer := flagSet.String("dns-server", "", "Custom DNS server")
behindProxy := flagSet.Bool("behind-proxy", false, "Whether we're running behind another reverse proxy")
pollInterval := flagSet.Int("poll-interval-ms", 2000, "Interval in milliseconds to poll for tunnel changes")
proxyCommand := flagSet.String("proxy-command", "", "ProxyCommand to use for outgoing connectin")
err := flagSet.Parse(os.Args[2:])
if err != nil {
@ -128,6 +129,7 @@ func main() {
DnsServer: *dnsServer,
BehindProxy: *behindProxy,
PollInterval: *pollInterval,
ProxyCommand: *proxyCommand,
}
ctx := context.Background()