fix routedDispatch

This commit is contained in:
yuzuki999 2023-09-25 15:56:27 +08:00
parent cea6118ba6
commit 94817e0f82

View File

@ -164,12 +164,12 @@ func (d *DefaultDispatcher) getLink(ctx context.Context, network net.Network) (*
if user != nil && len(user.Email) > 0 {
limit, err = limiter.GetLimiter(sessionInbound.Tag)
if err != nil {
newError("Get limit info error: ", err).AtError().WriteToLog()
newError("get limiter ", sessionInbound.Tag, " error: ", err).AtError().WriteToLog()
common.Close(outboundLink.Writer)
common.Close(inboundLink.Writer)
common.Interrupt(outboundLink.Reader)
common.Interrupt(inboundLink.Reader)
return nil, nil, nil, newError("Get limit info error: ", err)
return nil, nil, nil, newError("get limiter ", sessionInbound.Tag, " error: ", err)
}
// Speed Limit and Device Limit
w, reject := limit.CheckLimit(user.Email,
@ -427,10 +427,7 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
var err error
l, err = limiter.GetLimiter(sessionInbound.Tag)
if err != nil {
newError("get limiter error: ", err).AtError().WriteToLog(session.ExportIDToError(ctx))
common.Close(link.Writer)
common.Interrupt(link.Reader)
return
newError("get limiter ", sessionInbound.Tag, " error: ", err).AtWarning().WriteToLog(session.ExportIDToError(ctx))
}
}
var destStr string
@ -439,25 +436,27 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.
} else {
destStr = destination.Address.IP().String()
}
if l.CheckDomainRule(destStr) {
newError(fmt.Sprintf(
"User %s access domain %s reject by rule",
sessionInbound.User.Email,
destStr)).AtWarning().WriteToLog(session.ExportIDToError(ctx))
common.Close(link.Writer)
common.Interrupt(link.Reader)
return
}
if len(protocol) != 0 {
if l.CheckProtocolRule(protocol) {
if l != nil {
if l.CheckDomainRule(destStr) {
newError(fmt.Sprintf(
"User %s access protocol %s reject by rule",
"User %s access domain %s reject by rule",
sessionInbound.User.Email,
protocol)).AtWarning().WriteToLog(session.ExportIDToError(ctx))
destStr)).AtWarning().WriteToLog(session.ExportIDToError(ctx))
common.Close(link.Writer)
common.Interrupt(link.Reader)
return
}
if len(protocol) != 0 {
if l.CheckProtocolRule(protocol) {
newError(fmt.Sprintf(
"User %s access protocol %s reject by rule",
sessionInbound.User.Email,
protocol)).AtWarning().WriteToLog(session.ExportIDToError(ctx))
common.Close(link.Writer)
common.Interrupt(link.Reader)
return
}
}
}
var handler outbound.Handler