fixing tunnel_host
This commit is contained in:
parent
39819c291c
commit
19693b99a0
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nixc/reverse-ssh-traefik/internal/buildinfo"
|
"github.com/nixc/reverse-ssh-traefik/internal/buildinfo"
|
||||||
|
|
@ -37,12 +38,22 @@ func main() {
|
||||||
authUser := envOr("TUNNEL_AUTH_USER", "")
|
authUser := envOr("TUNNEL_AUTH_USER", "")
|
||||||
authPass := envOr("TUNNEL_AUTH_PASS", "")
|
authPass := envOr("TUNNEL_AUTH_PASS", "")
|
||||||
|
|
||||||
localHost := envOr("TUNNEL_HOST", "127.0.0.1")
|
// Backend: trim so compose/YAML stray spaces do not defeat the override (empty → default).
|
||||||
localPortStr := envOr("TUNNEL_PORT", "8080")
|
rawHost := strings.TrimSpace(os.Getenv("TUNNEL_HOST"))
|
||||||
|
localHost := rawHost
|
||||||
|
if localHost == "" {
|
||||||
|
localHost = "127.0.0.1"
|
||||||
|
}
|
||||||
|
localPortStr := strings.TrimSpace(os.Getenv("TUNNEL_PORT"))
|
||||||
|
if localPortStr == "" {
|
||||||
|
localPortStr = "8080"
|
||||||
|
}
|
||||||
localPort, err := strconv.Atoi(localPortStr)
|
localPort, err := strconv.Atoi(localPortStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Invalid TUNNEL_PORT=%q: %v", localPortStr, err)
|
log.Fatalf("Invalid TUNNEL_PORT=%q: %v", localPortStr, err)
|
||||||
}
|
}
|
||||||
|
log.Printf("tunnel-client config: TUNNEL_HOST env raw=%q → backend host %q; TUNNEL_PORT=%q → %d",
|
||||||
|
os.Getenv("TUNNEL_HOST"), localHost, os.Getenv("TUNNEL_PORT"), localPort)
|
||||||
|
|
||||||
// Load the private key.
|
// Load the private key.
|
||||||
signer, err := client.LoadPrivateKey(keyPath)
|
signer, err := client.LoadPrivateKey(keyPath)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ func SetupTunnel(client *ssh.Client, domain string, localHost string, localPort
|
||||||
}
|
}
|
||||||
defer listener.Close()
|
defer listener.Close()
|
||||||
|
|
||||||
log.Printf("Reverse tunnel established: %s -> %s:%d", domain, localHost, localPort)
|
log.Printf("Reverse tunnel established: Host(%s) → backend %s:%d", domain, localHost, localPort)
|
||||||
|
|
||||||
// Step 3: Accept connections from the server and forward to local service.
|
// Step 3: Accept connections from the server and forward to local service.
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue