mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-09-15 21:00:27 +00:00
warp: add address/port option to override peer endpoint
This commit is contained in:
@@ -87,7 +87,14 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
}
|
||||
}
|
||||
peer := config.Peers[0]
|
||||
hostParts := strings.Split(peer.Endpoint.Host, ":")
|
||||
peerAddress := strings.Split(peer.Endpoint.Host, ":")[0]
|
||||
peerPort := uint16(peer.Endpoint.Ports[rand.Intn(len(peer.Endpoint.Ports))])
|
||||
if options.Address != "" {
|
||||
peerAddress = options.Address
|
||||
if options.Port != 0 {
|
||||
peerPort = options.Port
|
||||
}
|
||||
}
|
||||
var amnezia *option.WireGuardAmnezia
|
||||
if options.Amnezia != nil {
|
||||
amnezia = &option.WireGuardAmnezia{
|
||||
@@ -130,8 +137,8 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
PrivateKey: config.PrivateKey,
|
||||
Peers: []option.WireGuardPeer{
|
||||
{
|
||||
Address: hostParts[0],
|
||||
Port: uint16(peer.Endpoint.Ports[rand.Intn(len(peer.Endpoint.Ports))]),
|
||||
Address: peerAddress,
|
||||
Port: peerPort,
|
||||
PublicKey: peer.PublicKey,
|
||||
AllowedIPs: badoption.Listable[netip.Prefix]{
|
||||
netip.MustParsePrefix("0.0.0.0/0"),
|
||||
|
||||
Reference in New Issue
Block a user