Files
lmvpn_server/internal/vpn/diag.go
T
kevin 4b82340a9f fix: dynamic firewall config + UFW support + anti-spoof bug fix
Root cause: UFW FORWARD policy DROP overrides lmvpn_nat accept rules.
DNS (small UDP) worked but TCP packets were silently dropped.

- Add firewall_linux.go: dynamic NAT/forward/UFW config from ApplySettings
- Add firewall_darwin.go/firewall_other.go: stubs
- Fix anti-spoof bug in switch.go: return dropPacket sentinel instead of
  nil, so spoofed packets are no longer written to TUN
- Simplify install_linux.sh: remove hardcoded subnets and NAT config
- Add UFW detection to diag panel
2026-07-08 20:11:15 +08:00

59 lines
1.5 KiB
Go

package vpn
import (
"os"
"runtime"
)
type DiagResult struct {
Platform string `json:"platform"`
IsRoot bool `json:"is_root"`
HasCapNetAdmin *bool `json:"has_cap_net_admin"`
CapNetAdminNote string `json:"cap_net_admin_note,omitempty"`
IPForward *bool `json:"ip_forward"`
IPForwardNote string `json:"ip_forward_note,omitempty"`
Masquerade *bool `json:"masquerade"`
MasqueradeNote string `json:"masquerade_note,omitempty"`
IP6Forward *bool `json:"ip6_forward"`
IP6ForwardNote string `json:"ip6_forward_note,omitempty"`
Masquerade6 *bool `json:"masquerade6"`
Masquerade6Note string `json:"masquerade6_note,omitempty"`
UFWActive *bool `json:"ufw_active"`
UFWForwardNote string `json:"ufw_forward_note,omitempty"`
TUNCreate string `json:"tun_create"`
TUNRunning bool `json:"tun_running"`
TUNName string `json:"tun_name,omitempty"`
}
func Diag(svc *VpnService) DiagResult {
r := DiagResult{Platform: runtime.GOOS, IsRoot: os.Getuid() == 0}
if svc != nil {
svc.mu.RLock()
r.TUNRunning = svc.running
if svc.tun != nil {
r.TUNName = svc.tun.Name()
}
svc.mu.RUnlock()
}
if r.TUNRunning {
r.TUNCreate = "ok: " + r.TUNName
} else {
r.TUNCreate = testTUNCreate()
}
fillPlatformDiag(&r)
return r
}
func testTUNCreate() string {
t, err := CreateTUN("")
if err != nil {
return "fail: " + err.Error()
}
name := t.Name()
_ = t.Close()
return "ok: " + name
}