add dns handler

This commit is contained in:
ginuerzh
2021-12-29 23:45:58 +08:00
parent 8600ee7c5d
commit 9b3d7e1110
15 changed files with 541 additions and 39 deletions

View File

@ -2,6 +2,7 @@ package tun
import (
"context"
"errors"
"fmt"
"io"
"net"
@ -124,7 +125,12 @@ func (h *tunHandler) handleLoop(ctx context.Context, conn net.Conn, addr net.Add
if err != nil {
return err
}
pc = &packetConn{cc}
var ok bool
pc, ok = cc.(net.PacketConn)
if !ok {
return errors.New("invalid connnection")
}
} else {
if h.md.tcpMode {
if addr != nil {