fix routedDispatch

This commit is contained in:
yuzuki999
2023-09-25 16:20:12 +08:00
parent 94817e0f82
commit 2d44470f24

View File

@@ -414,15 +414,14 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
} }
sessionInbound := session.InboundFromContext(ctx) sessionInbound := session.InboundFromContext(ctx)
if sessionInbound.User != nil {
if l != nil { if l != nil {
// del connect count // del connect count
if sessionInbound.User != nil {
if destination.Network == net.Network_TCP { if destination.Network == net.Network_TCP {
defer func() { defer func() {
l.ConnLimiter.DelConnCount(sessionInbound.User.Email, sessionInbound.Source.Address.IP().String()) l.ConnLimiter.DelConnCount(sessionInbound.User.Email, sessionInbound.Source.Address.IP().String())
}() }()
} }
}
} else { } else {
var err error var err error
l, err = limiter.GetLimiter(sessionInbound.Tag) l, err = limiter.GetLimiter(sessionInbound.Tag)
@@ -430,13 +429,13 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
newError("get limiter ", sessionInbound.Tag, " error: ", err).AtWarning().WriteToLog(session.ExportIDToError(ctx)) newError("get limiter ", sessionInbound.Tag, " error: ", err).AtWarning().WriteToLog(session.ExportIDToError(ctx))
} }
} }
if l != nil {
var destStr string var destStr string
if destination.Address.Family().IsDomain() { if destination.Address.Family().IsDomain() {
destStr = destination.Address.Domain() destStr = destination.Address.Domain()
} else { } else {
destStr = destination.Address.IP().String() destStr = destination.Address.IP().String()
} }
if l != nil {
if l.CheckDomainRule(destStr) { if l.CheckDomainRule(destStr) {
newError(fmt.Sprintf( newError(fmt.Sprintf(
"User %s access domain %s reject by rule", "User %s access domain %s reject by rule",
@@ -458,6 +457,7 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
} }
} }
} }
}
var handler outbound.Handler var handler outbound.Handler