mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-07-12 10:47:55 +03:00
Reject invalid connection
This commit is contained in:
@@ -700,6 +700,9 @@ func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata ad
|
|||||||
if !common.Contains(detour.Network(), N.NetworkTCP) {
|
if !common.Contains(detour.Network(), N.NetworkTCP) {
|
||||||
return E.New("missing supported outbound, closing connection")
|
return E.New("missing supported outbound, closing connection")
|
||||||
}
|
}
|
||||||
|
if !metadata.Destination.IsValid() && len(metadata.DestinationAddresses) == 0 {
|
||||||
|
return E.New("invalid destination address")
|
||||||
|
}
|
||||||
if r.clashServer != nil {
|
if r.clashServer != nil {
|
||||||
trackerConn, tracker := r.clashServer.RoutedConnection(ctx, conn, metadata, matchedRule)
|
trackerConn, tracker := r.clashServer.RoutedConnection(ctx, conn, metadata, matchedRule)
|
||||||
defer tracker.Leave()
|
defer tracker.Leave()
|
||||||
@@ -812,6 +815,9 @@ func (r *Router) RoutePacketConnection(ctx context.Context, conn N.PacketConn, m
|
|||||||
if !common.Contains(detour.Network(), N.NetworkUDP) {
|
if !common.Contains(detour.Network(), N.NetworkUDP) {
|
||||||
return E.New("missing supported outbound, closing packet connection")
|
return E.New("missing supported outbound, closing packet connection")
|
||||||
}
|
}
|
||||||
|
if !metadata.Destination.IsValid() && len(metadata.DestinationAddresses) == 0 {
|
||||||
|
return E.New("invalid destination address")
|
||||||
|
}
|
||||||
if r.clashServer != nil {
|
if r.clashServer != nil {
|
||||||
trackerConn, tracker := r.clashServer.RoutedPacketConnection(ctx, conn, metadata, matchedRule)
|
trackerConn, tracker := r.clashServer.RoutedPacketConnection(ctx, conn, metadata, matchedRule)
|
||||||
defer tracker.Leave()
|
defer tracker.Leave()
|
||||||
|
|||||||
Reference in New Issue
Block a user