add p2p option for tun handler

This commit is contained in:
ginuerzh
2024-04-26 20:56:56 +08:00
parent f2a5089c29
commit 332a3a1cd0
3 changed files with 38 additions and 33 deletions

View File

@ -12,7 +12,6 @@ import (
"github.com/go-gost/core/handler"
"github.com/go-gost/core/hop"
md "github.com/go-gost/core/metadata"
"github.com/go-gost/core/router"
tun_util "github.com/go-gost/x/internal/util/tun"
"github.com/go-gost/x/registry"
"github.com/songgao/water/waterutil"
@ -109,23 +108,6 @@ func (h *tunHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.
return h.handleServer(ctx, conn, config, log)
}
func (h *tunHandler) findRouteFor(ctx context.Context, dst net.IP, router router.Router) net.Addr {
if v, ok := h.routes.Load(ipToTunRouteKey(dst)); ok {
return v.(net.Addr)
}
if router == nil {
return nil
}
if route := router.GetRoute(ctx, dst); route != nil && route.Gateway != nil {
if v, ok := h.routes.Load(ipToTunRouteKey(route.Gateway)); ok {
return v.(net.Addr)
}
}
return nil
}
var mIPProts = map[waterutil.IPProtocol]string{
waterutil.HOPOPT: "HOPOPT",
waterutil.ICMP: "ICMP",