Add more context

This commit is contained in:
世界 2022-04-30 10:25:56 +08:00
parent 3a9adc8f84
commit 34cba35e3b
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
10 changed files with 45 additions and 17 deletions

View file

@ -203,8 +203,8 @@ func (s *nonePacketWriter) WritePacket(buffer *buf.Buffer, destination *M.AddrPo
return s.PacketConn.WritePacket(buffer, s.sourceAddr)
}
func (s *NoneService) NewPacketConnection(conn socks.PacketConn, metadata M.Metadata) error {
return s.handler.NewPacketConnection(conn, metadata)
func (s *NoneService) NewPacketConnection(ctx context.Context, conn socks.PacketConn, metadata M.Metadata) error {
return s.handler.NewPacketConnection(ctx, conn, metadata)
}
func (s *NoneService) HandleError(err error) {

View file

@ -217,8 +217,8 @@ func (w *serverPacketWriter) WritePacket(buffer *buf.Buffer, destination *M.Addr
return w.PacketConn.WritePacket(buffer, w.source)
}
func (s *Service) NewPacketConnection(conn socks.PacketConn, metadata M.Metadata) error {
return s.handler.NewPacketConnection(conn, metadata)
func (s *Service) NewPacketConnection(ctx context.Context, conn socks.PacketConn, metadata M.Metadata) error {
return s.handler.NewPacketConnection(ctx, conn, metadata)
}
func (s *Service) HandleError(err error) {

View file

@ -382,8 +382,8 @@ func (m *Service) newUDPSession() *serverUDPSession {
return session
}
func (s *Service) NewPacketConnection(conn socks.PacketConn, metadata M.Metadata) error {
return s.handler.NewPacketConnection(conn, metadata)
func (s *Service) NewPacketConnection(ctx context.Context, conn socks.PacketConn, metadata M.Metadata) error {
return s.handler.NewPacketConnection(ctx, conn, metadata)
}
func (s *Service) HandleError(err error) {

View file

@ -37,7 +37,7 @@ type UDPHandler interface {
}
type UDPConnectionHandler interface {
NewPacketConnection(conn PacketConn, metadata M.Metadata) error
NewPacketConnection(ctx context.Context, conn PacketConn, metadata M.Metadata) error
}
type PacketConnStub struct{}

View file

@ -134,7 +134,7 @@ func HandleConnection(ctx context.Context, conn net.Conn, authenticator auth.Aut
metadata.Protocol = "socks"
metadata.Destination = request.Destination
go func() {
err := handler.NewPacketConnection(NewAssociatePacketConn(conn, udpConn, request.Destination), metadata)
err := handler.NewPacketConnection(ctx, NewAssociatePacketConn(conn, udpConn, request.Destination), metadata)
if err != nil {
handler.HandleError(err)
}