mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-03 20:07:38 +03:00
Refactor error handler
This commit is contained in:
parent
30b5895320
commit
63a57e6e12
3 changed files with 3 additions and 6 deletions
|
@ -100,5 +100,5 @@ func IsTimeout(err error) bool {
|
|||
}
|
||||
|
||||
type Handler interface {
|
||||
HandleError(err error)
|
||||
NewError(ctx context.Context, err error)
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ func (s *Service[T]) NewContextPacket(ctx context.Context, key T, buffer *buf.Bu
|
|||
go func() {
|
||||
err := s.handler.NewPacketConnection(ctx, c, metadata)
|
||||
if err != nil {
|
||||
s.handler.HandleError(err)
|
||||
s.handler.NewError(ctx, err)
|
||||
}
|
||||
c.Close()
|
||||
s.nat.Delete(key)
|
||||
|
|
|
@ -19,10 +19,7 @@ import (
|
|||
N "github.com/sagernet/sing/common/network"
|
||||
)
|
||||
|
||||
type Handler interface {
|
||||
N.TCPConnectionHandler
|
||||
N.UDPConnectionHandler
|
||||
}
|
||||
type Handler = N.TCPConnectionHandler
|
||||
|
||||
func HandleConnection(ctx context.Context, conn net.Conn, authenticator auth.Authenticator, handler Handler, metadata M.Metadata) error {
|
||||
reader := std_bufio.NewReader(conn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue