Crazy sekai overturns the small pond
This commit is contained in:
@@ -15,6 +15,8 @@ import (
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing-quic"
|
||||
"github.com/sagernet/sing/common"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
"github.com/sagernet/sing/common/logger"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
N "github.com/sagernet/sing/common/network"
|
||||
)
|
||||
@@ -23,6 +25,7 @@ var _ adapter.V2RayServerTransport = (*Server)(nil)
|
||||
|
||||
type Server struct {
|
||||
ctx context.Context
|
||||
logger logger.ContextLogger
|
||||
tlsConfig tls.ServerConfig
|
||||
quicConfig *quic.Config
|
||||
handler adapter.V2RayServerTransportHandler
|
||||
@@ -30,7 +33,7 @@ type Server struct {
|
||||
quicListener qtls.Listener
|
||||
}
|
||||
|
||||
func NewServer(ctx context.Context, options option.V2RayQUICOptions, tlsConfig tls.ServerConfig, handler adapter.V2RayServerTransportHandler) (adapter.V2RayServerTransport, error) {
|
||||
func NewServer(ctx context.Context, logger logger.ContextLogger, options option.V2RayQUICOptions, tlsConfig tls.ServerConfig, handler adapter.V2RayServerTransportHandler) (adapter.V2RayServerTransport, error) {
|
||||
quicConfig := &quic.Config{
|
||||
DisablePathMTUDiscovery: !C.IsLinux && !C.IsWindows,
|
||||
}
|
||||
@@ -39,6 +42,7 @@ func NewServer(ctx context.Context, options option.V2RayQUICOptions, tlsConfig t
|
||||
}
|
||||
server := &Server{
|
||||
ctx: ctx,
|
||||
logger: logger,
|
||||
tlsConfig: tlsConfig,
|
||||
quicConfig: quicConfig,
|
||||
handler: handler,
|
||||
@@ -73,8 +77,8 @@ func (s *Server) acceptLoop() {
|
||||
}
|
||||
go func() {
|
||||
hErr := s.streamAcceptLoop(conn)
|
||||
if hErr != nil {
|
||||
s.handler.NewError(conn.Context(), hErr)
|
||||
if hErr != nil && !E.IsClosedOrCanceled(hErr) {
|
||||
s.logger.ErrorContext(conn.Context(), hErr)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -86,7 +90,7 @@ func (s *Server) streamAcceptLoop(conn quic.Connection) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
go s.handler.NewConnection(conn.Context(), &StreamWrapper{Conn: conn, Stream: stream}, M.Metadata{})
|
||||
go s.handler.NewConnectionEx(conn.Context(), &StreamWrapper{Conn: conn, Stream: stream}, M.SocksaddrFromNet(conn.RemoteAddr()), M.Socksaddr{}, nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user