Meow
2026-06-19 06:31:21 +08:00
committed by GitHub
parent 6412738486
commit 711aea4e34
15 changed files with 208 additions and 151 deletions
+10 -6
View File
@@ -19,24 +19,25 @@ import (
type Listener struct {
encoding.UnimplementedGRPCServiceServer
ctx context.Context
handler internet.ConnHandler
local net.Addr
config *Config
ctx context.Context
handler internet.ConnHandler
local net.Addr
config *Config
trustedXForwardedFor []string
s *grpc.Server
}
func (l Listener) Tun(server encoding.GRPCService_TunServer) error {
tunCtx, cancel := context.WithCancel(l.ctx)
l.handler(encoding.NewHunkConn(server, cancel))
l.handler(encoding.NewHunkConn(server, cancel, l.trustedXForwardedFor))
<-tunCtx.Done()
return nil
}
func (l Listener) TunMulti(server encoding.GRPCService_TunMultiServer) error {
tunCtx, cancel := context.WithCancel(l.ctx)
l.handler(encoding.NewMultiHunkConn(server, cancel))
l.handler(encoding.NewMultiHunkConn(server, cancel, l.trustedXForwardedFor))
<-tunCtx.Done()
return nil
}
@@ -74,6 +75,9 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i
}
listener.ctx = ctx
if settings.SocketSettings != nil {
listener.trustedXForwardedFor = settings.SocketSettings.TrustedXForwardedFor
}
config := tls.ConfigFromStreamSettings(settings)