From 9061ba8c8b7a10e2228240c347b876017457df82 Mon Sep 17 00:00:00 2001 From: IrineSistiana <49315432+IrineSistiana@users.noreply.github.com> Date: Sun, 6 Dec 2020 19:13:04 +0800 Subject: [PATCH] plugin: esc: fixed Auto mode --- dispatcher/plugin/functional/ecs/ecs.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dispatcher/plugin/functional/ecs/ecs.go b/dispatcher/plugin/functional/ecs/ecs.go index 59fa4683c..305374005 100644 --- a/dispatcher/plugin/functional/ecs/ecs.go +++ b/dispatcher/plugin/functional/ecs/ecs.go @@ -104,8 +104,12 @@ func (e ecsPlugin) Do(_ context.Context, qCtx *handler.Context) (err error) { if checkMsgHasECS(qCtx.Q) == false || e.args.ForceOverwrite { if e.args.Auto { - s := qCtx.From.String() - ip := net.ParseIP(s) + addr := qCtx.From.String() + ipStr, _, _ := net.SplitHostPort(addr) + if len(ipStr) == 0 { + return + } + ip := net.ParseIP(ipStr) if ip == nil { qCtx.Logf(logrus.WarnLevel, "client address [%s] can not be parsed as ip", addr) return nil