feat: SDWAN data plane + UDP punch port fix + TUN reader
SDWAN: - protocol: add SDWANConfig/SDWANPeer/SDWANPacket structs, MsgTunnel type - server: sdwan.go (JSON file store), sdwan_api.go (Get/Set/broadcast/route) - server: push SDWAN config on login, announce peer online/offline events - server: RouteSDWANPacket routes TUN packets between nodes via signaling - client: TUN device setup (optun), tunReadLoop reads IP packets - client: handle SDWANConfig/SDWANPeer/SDWANDel push messages - client: apply routes (per-node /32 + broad CIDR fallback) UDP punch fix: - nat/detect: capture LocalPort from STUN UDP socket for punch binding - client: pass publicPort + localPort through login and punch config - coordinator: include PublicPort in PunchParams for both sides - protocol: add PublicPort to LoginReq and ReportBasic Other: - server: use client-reported PublicIP instead of raw r.RemoteAddr - server: update PublicIP/Port from ReportBasic if provided - client: config file loading with zero-value defaults backfill - .gitignore: exclude run/, *.pid, *.log, sdwan.json - go.mod: add golang.org/x/sys for TUN ioctl
This commit is contained in:
@@ -51,6 +51,34 @@ func main() {
|
||||
var fileCfg config.ClientConfig
|
||||
if err := json.Unmarshal(data, &fileCfg); err == nil {
|
||||
cfg = fileCfg
|
||||
// fill defaults for missing fields
|
||||
if cfg.ServerPort == 0 {
|
||||
cfg.ServerPort = config.DefaultWSPort
|
||||
}
|
||||
if cfg.STUNUDP1 == 0 {
|
||||
cfg.STUNUDP1 = config.DefaultSTUNUDP1
|
||||
}
|
||||
if cfg.STUNUDP2 == 0 {
|
||||
cfg.STUNUDP2 = config.DefaultSTUNUDP2
|
||||
}
|
||||
if cfg.STUNTCP1 == 0 {
|
||||
cfg.STUNTCP1 = config.DefaultSTUNTCP1
|
||||
}
|
||||
if cfg.STUNTCP2 == 0 {
|
||||
cfg.STUNTCP2 = config.DefaultSTUNTCP2
|
||||
}
|
||||
if cfg.RelayPort == 0 {
|
||||
cfg.RelayPort = config.DefaultRelayPort
|
||||
}
|
||||
if cfg.MaxRelayLoad == 0 {
|
||||
cfg.MaxRelayLoad = config.DefaultMaxRelayLoad
|
||||
}
|
||||
if cfg.ShareBandwidth == 0 {
|
||||
cfg.ShareBandwidth = 10
|
||||
}
|
||||
if cfg.LogLevel == 0 {
|
||||
cfg.LogLevel = 1
|
||||
}
|
||||
log.Printf("[main] loaded config from %s", *configFile)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user