remove unused code.

This commit is contained in:
Ginder Singh
2026-03-19 15:16:44 -04:00
parent 593805bf6f
commit d7904580ed
2 changed files with 4 additions and 40 deletions

View File

@@ -90,13 +90,15 @@ NEDNSSettings(servers: ["10.0.0.1"])
includedRoutes = [NEIPv4Route.default()]
func protectSocket(_ fd: Int) throws {
let index = Int32(if_nametoindex("en0"))
setsockopt(Int32(fd), IPPROTO_IP, IP_BOUND_IF, &index, ...)
// No action needed - iOS Network Extension sockets
// automatically bypass VPN tunnel
}
// DNS Proxy: 127.0.0.1:53
```
**Note:** iOS Network Extensions run in separate process - sockets automatically bypass VPN.
## Protocol Support
| Protocol | Support |

View File

@@ -29,7 +29,6 @@ type UDPForwarder struct {
type udpConn struct {
tunEP *gonet.UDPConn
upstreamConn *net.UDPConn
lastActivity time.Time
cancel context.CancelFunc
}
@@ -44,9 +43,6 @@ func NewUDPForwarder(s *stack.Stack, protectSocket func(fd int) error, ctx conte
// Create gVisor UDP forwarder with handler callback
f.forwarder = udp.NewForwarder(s, f.handlePacket)
// Start cleanup goroutine
go f.cleanupStaleConnections()
return f
}
@@ -85,7 +81,6 @@ func (f *UDPForwarder) handlePacket(req *udp.ForwarderRequest) {
ctrld.ProxyLogger.Load().Debug().Msgf("[UDP] New session: %s:%d -> %s:%d (total: %d)",
srcAddr, id.RemotePort, dstAddr, id.LocalPort, len(f.connections))
}
conn.lastActivity = time.Now()
f.mu.Unlock()
}
@@ -144,7 +139,6 @@ func (f *UDPForwarder) createConnection(req *udp.ForwarderRequest, connKey strin
udpConnection := &udpConn{
tunEP: tunConn,
upstreamConn: upstreamConn,
lastActivity: time.Now(),
cancel: cancel,
}
@@ -176,10 +170,6 @@ func (f *UDPForwarder) forwardTunToUpstream(conn *udpConn, ctx context.Context)
if err != nil {
return
}
f.mu.Lock()
conn.lastActivity = time.Now()
f.mu.Unlock()
}
}
@@ -219,34 +209,6 @@ func (f *UDPForwarder) forwardUpstreamToTun(conn *udpConn, ctx context.Context,
if err != nil {
return
}
f.mu.Lock()
conn.lastActivity = time.Now()
f.mu.Unlock()
}
}
func (f *UDPForwarder) cleanupStaleConnections() {
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for {
select {
case <-f.ctx.Done():
return
case <-ticker.C:
f.mu.Lock()
now := time.Now()
for key, conn := range f.connections {
if now.Sub(conn.lastActivity) > 60*time.Second {
conn.cancel()
conn.tunEP.Close()
conn.upstreamConn.Close()
delete(f.connections, key)
}
}
f.mu.Unlock()
}
}
}