feat: optimize code

This commit is contained in:
fengcaiwen
2023-09-05 19:28:57 +08:00
committed by naison
parent a7ca7853f5
commit 29f5c191a5
2 changed files with 47 additions and 31 deletions

View File

@@ -31,6 +31,12 @@ func (h *tunHandler) HandleClient(ctx context.Context, tun net.Conn) {
}
d.SetTunInboundHandler(func(tunInbound <-chan *DataElem, tunOutbound chan<- *DataElem) {
for {
select {
case <-ctx.Done():
return
default:
}
packetConn, err := getRemotePacketConn(ctx, h.chain)
if err != nil {
log.Debugf("[tun-client] %s - %s: %s", tun.LocalAddr(), remoteAddr, err)