Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit236e84c

Browse files
authored
feat: add logging for forwarded TCP connections
part of#7963log TCP connections as they are forwarded by gVisor
1 parent791144d commit236e84c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎tailnet/conn.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,8 @@ func (c *Conn) DialContextUDP(ctx context.Context, ipp netip.AddrPort) (*gonet.U
943943
returnc.netStack.DialContextUDP(ctx,ipp)
944944
}
945945

946-
func (c*Conn)forwardTCP(_,dst netip.AddrPort) (handlerfunc(net.Conn),opts []tcpip.SettableSocketOption,interceptbool) {
946+
func (c*Conn)forwardTCP(src,dst netip.AddrPort) (handlerfunc(net.Conn),opts []tcpip.SettableSocketOption,interceptbool) {
947+
logger:=c.logger.Named("tcp").With(slog.F("src",src.String()),slog.F("dst",dst.String()))
947948
c.mutex.Lock()
948949
ln,ok:=c.listeners[listenKey{"tcp","",fmt.Sprint(dst.Port())}]
949950
c.mutex.Unlock()
@@ -961,10 +962,14 @@ func (c *Conn) forwardTCP(_, dst netip.AddrPort) (handler func(net.Conn), opts [
961962
defert.Stop()
962963
select {
963964
caseln.conn<-conn:
965+
logger.Info(context.Background(),"accepted connection")
964966
return
965967
case<-ln.closed:
968+
logger.Info(context.Background(),"listener closed; closing connection")
966969
case<-c.closed:
970+
logger.Info(context.Background(),"tailnet closed; closing connection")
967971
case<-t.C:
972+
logger.Info(context.Background(),"listener timed out accepting; closing connection")
968973
}
969974
_=conn.Close()
970975
},opts,true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp