mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-26 21:16:56 +00:00
Add openvpn and openconnect
This commit is contained in:
@@ -24,7 +24,7 @@ import (
|
||||
|
||||
var (
|
||||
_ ParallelInterfaceDialer = (*DefaultDialer)(nil)
|
||||
_ WireGuardListener = (*DefaultDialer)(nil)
|
||||
_ UDPListener = (*DefaultDialer)(nil)
|
||||
)
|
||||
|
||||
type DefaultDialer struct {
|
||||
@@ -381,7 +381,7 @@ func (d *DefaultDialer) ListenSerialInterfacePacket(ctx context.Context, destina
|
||||
return d.trackPacketConn(packetConn, nil)
|
||||
}
|
||||
|
||||
func (d *DefaultDialer) WireGuardControl() (control.Func, bool) {
|
||||
func (d *DefaultDialer) UDPListenerControl() (control.Func, bool) {
|
||||
return d.udpListener.Control, d.autoDetectBindFunc != nil && d.netns == ""
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package dialer
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing/common/control"
|
||||
)
|
||||
|
||||
type UDPListener interface {
|
||||
UDPListenerControl() (control.Func, bool)
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package dialer
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing/common/control"
|
||||
)
|
||||
|
||||
type WireGuardListener interface {
|
||||
WireGuardControl() (control.Func, bool)
|
||||
}
|
||||
@@ -22,8 +22,11 @@ import (
|
||||
const udpOutputBatchSize = 128
|
||||
|
||||
func (l *Listener) ListenUDP() (net.PacketConn, error) {
|
||||
return l.ListenUDPWithConfig(net.ListenConfig{})
|
||||
}
|
||||
|
||||
func (l *Listener) ListenUDPWithConfig(listenConfig net.ListenConfig) (net.PacketConn, error) {
|
||||
bindAddr := M.SocksaddrFrom(l.listenOptions.Listen.Build(netip.AddrFrom4([4]byte{127, 0, 0, 1})), l.listenOptions.ListenPort)
|
||||
var listenConfig net.ListenConfig
|
||||
if l.listenOptions.BindInterface != "" {
|
||||
listenConfig.Control = control.Append(listenConfig.Control, control.BindToInterface(service.FromContext[adapter.NetworkManager](l.ctx).InterfaceFinder(), l.listenOptions.BindInterface, -1))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user