Update wireguard.go

pull/4926/head
xqzr 2025-07-23 19:53:52 +08:00 committed by GitHub
parent 5d149922b9
commit b192a32149
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 6 deletions

View File

@ -39,10 +39,9 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) {
config.Endpoint = c.Endpoint config.Endpoint = c.Endpoint
// default 0 // default 0
config.KeepAlive = c.KeepAlive config.KeepAlive = c.KeepAlive
config.AllowedIps = c.AllowedIPs
if c.AllowedIPs == nil { if c.AllowedIPs == nil {
config.AllowedIps = []string{"0.0.0.0/0", "::0/0"} config.AllowedIps = []string{"0.0.0.0/0", "::0/0"}
} else {
config.AllowedIps = c.AllowedIPs
} }
return config, nil return config, nil
@ -70,11 +69,10 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
return nil, errors.New("invalid WireGuard secret key: %w", err) return nil, errors.New("invalid WireGuard secret key: %w", err)
} }
config.Endpoint = c.Address
if c.Address == nil { if c.Address == nil {
// bogon ips // bogon ips
config.Endpoint = []string{"10.0.0.1", "fd59:7153:2388:b5fd:0000:0000:0000:0001"} config.Endpoint = []string{"10.0.0.1", "fd59:7153:2388:b5fd:0000:0000:0000:0001"}
} else {
config.Endpoint = c.Address
} }
if c.Peers != nil { if c.Peers != nil {
@ -88,10 +86,9 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
} }
} }
config.Mtu = c.MTU
if c.MTU == 0 { if c.MTU == 0 {
config.Mtu = 1420 config.Mtu = 1420
} else {
config.Mtu = c.MTU
} }
// these a fallback code exists in wireguard-go code, // these a fallback code exists in wireguard-go code,
// we don't need to process fallback manually // we don't need to process fallback manually