Reject invalid connection
This commit is contained in:
parent
ebfabf7406
commit
4095dcbf05
1 changed files with 6 additions and 0 deletions
|
|
@ -700,6 +700,9 @@ func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata ad
|
|||
if !common.Contains(detour.Network(), N.NetworkTCP) {
|
||||
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 {
|
||||
trackerConn, tracker := r.clashServer.RoutedConnection(ctx, conn, metadata, matchedRule)
|
||||
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) {
|
||||
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 {
|
||||
trackerConn, tracker := r.clashServer.RoutedPacketConnection(ctx, conn, metadata, matchedRule)
|
||||
defer tracker.Leave()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue