mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 18:11:28 +00:00
Fix stack wireguard device returning non-nil interface containing nil pointer
This commit is contained in:
parent
657b05fd96
commit
b004b9ec81
|
@ -109,9 +109,17 @@ func (w *StackDevice) DialContext(ctx context.Context, network string, destinati
|
||||||
}
|
}
|
||||||
switch N.NetworkName(network) {
|
switch N.NetworkName(network) {
|
||||||
case N.NetworkTCP:
|
case N.NetworkTCP:
|
||||||
return gonet.DialTCPWithBind(ctx, w.stack, bind, addr, networkProtocol)
|
tcpConn, err := gonet.DialTCPWithBind(ctx, w.stack, bind, addr, networkProtocol)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return tcpConn, nil
|
||||||
case N.NetworkUDP:
|
case N.NetworkUDP:
|
||||||
return gonet.DialUDP(w.stack, &bind, &addr, networkProtocol)
|
udpConn, err := gonet.DialUDP(w.stack, &bind, &addr, networkProtocol)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return udpConn, nil
|
||||||
default:
|
default:
|
||||||
return nil, E.Extend(N.ErrUnknownNetwork, network)
|
return nil, E.Extend(N.ErrUnknownNetwork, network)
|
||||||
}
|
}
|
||||||
|
@ -129,7 +137,11 @@ func (w *StackDevice) ListenPacket(ctx context.Context, destination M.Socksaddr)
|
||||||
networkProtocol = header.IPv6ProtocolNumber
|
networkProtocol = header.IPv6ProtocolNumber
|
||||||
bind.Addr = w.addr6
|
bind.Addr = w.addr6
|
||||||
}
|
}
|
||||||
return gonet.DialUDP(w.stack, &bind, nil, networkProtocol)
|
udpConn, err := gonet.DialUDP(w.stack, &bind, nil, networkProtocol)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return udpConn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *StackDevice) Start() error {
|
func (w *StackDevice) Start() error {
|
||||||
|
|
Loading…
Reference in a new issue