|
|
@@ -113,6 +113,9 @@ func (r *Router) routeConnection(ctx context.Context, conn net.Conn, metadata ad
|
|
|
}
|
|
|
case *R.RuleActionReject:
|
|
|
buf.ReleaseMulti(buffers)
|
|
|
+ if action.Method == C.RuleActionRejectMethodReply {
|
|
|
+ return E.New("reject method `reply` is not supported for TCP connections")
|
|
|
+ }
|
|
|
return action.Error(ctx)
|
|
|
case *R.RuleActionHijackDNS:
|
|
|
for _, buffer := range buffers {
|
|
|
@@ -228,6 +231,9 @@ func (r *Router) routePacketConnection(ctx context.Context, conn N.PacketConn, m
|
|
|
}
|
|
|
case *R.RuleActionReject:
|
|
|
N.ReleaseMultiPacketBuffer(packetBuffers)
|
|
|
+ if action.Method == C.RuleActionRejectMethodReply {
|
|
|
+ return E.New("reject method `reply` is not supported for UDP connections")
|
|
|
+ }
|
|
|
return action.Error(ctx)
|
|
|
case *R.RuleActionHijackDNS:
|
|
|
return r.hijackDNSPacket(ctx, conn, packetBuffers, metadata, onClose)
|
|
|
@@ -267,6 +273,16 @@ func (r *Router) PreMatch(metadata adapter.InboundContext, routeContext tun.Dire
|
|
|
if selectedRule != nil {
|
|
|
switch action := selectedRule.Action().(type) {
|
|
|
case *R.RuleActionReject:
|
|
|
+ switch metadata.Network {
|
|
|
+ case N.NetworkTCP:
|
|
|
+ if action.Method == C.RuleActionRejectMethodReply {
|
|
|
+ return nil, E.New("reject method `reply` is not supported for TCP connections")
|
|
|
+ }
|
|
|
+ case N.NetworkUDP:
|
|
|
+ if action.Method == C.RuleActionRejectMethodReply {
|
|
|
+ return nil, E.New("reject method `reply` is not supported for UDP connections")
|
|
|
+ }
|
|
|
+ }
|
|
|
return nil, action.Error(context.Background())
|
|
|
case *R.RuleActionRoute:
|
|
|
if routeContext == nil {
|