feat: tunnel host and port in the panel settings, ufw kept in sync
The direct tunnel port (8446 by default) and the host agents dial for it can be set in Settings. The server moves its listeners at once and agents pick the address up from the panel: on connect and with every poll, unless TUNNEL_ADDR / TUNNEL_PORT pin it locally. ufw: run with a C locale (the output is translated), do not adopt rules that existed before the panel, skip loopback-only listeners, re-open what saved forwards need on start and when the integration is turned on, move the shared tunnel rule with the port and drop it when no direct forward is left. The last ufw error is shown in Settings. The forwards page shows the real tunnel and panel ports.
This commit is contained in:
1 parent
08fc2d79a8
commit
bcfe909aaa
15 files changed
+540
-97
No files matched your search
@@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"strconv"
|
||||
|
||||
lpra "github.com/x-grk/longpolling-remote-access"
|
||||
)
|
||||
@@ -14,6 +15,8 @@ const (
|
||||
cfgSetupDone = "setup_done"
|
||||
cfgInstallCode = "install_code"
|
||||
cfgUfwEnabled = "ufw_enabled"
|
||||
cfgTunnelHost = "tunnel_host"
|
||||
cfgTunnelPort = "tunnel_port"
|
||||
)
|
||||
|
||||
// DefaultHostAddress is the public URL agents dial by default. It is baked into
|
||||
@@ -88,6 +91,24 @@ func (db *DB) SetUfwEnabled(on bool) error {
|
||||
return db.SetConfig(cfgUfwEnabled, "0")
|
||||
}
|
||||
|
||||
// TunnelHost is the host agents dial for the direct tunnel. Empty means the
|
||||
// host of the URL they already reach the panel on.
|
||||
func (db *DB) TunnelHost() string {
|
||||
v, _ := db.GetConfig(cfgTunnelHost)
|
||||
return v
|
||||
}
|
||||
|
||||
// TunnelPort is the direct-tunnel port set in Settings, or 0 when it is left
|
||||
// at the port of the server's -tunnel address.
|
||||
func (db *DB) TunnelPort() int {
|
||||
v, _ := db.GetConfig(cfgTunnelPort)
|
||||
n, _ := strconv.Atoi(v)
|
||||
if n < 1 || n > 65535 {
|
||||
return 0
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (db *DB) SetupDone() bool {
|
||||
v, _ := db.GetConfig(cfgSetupDone)
|
||||
return v == "1"
|
||||
|
||||
Reference in new issue
Block a user