From 547f1fe9d20added397d608a50fbf99e69f6df91 Mon Sep 17 00:00:00 2001 From: Mmx233 Date: Sun, 30 Oct 2022 14:49:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=9A=E7=BD=91=E5=8D=A1=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=94=AF=E6=8C=81=E7=9B=B4=E6=8E=A5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=BD=91=E5=8D=A1=20DHCP=20ip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/login.go | 4 ++++ models/config.go | 1 + 2 files changed, 5 insertions(+) diff --git a/controllers/login.go b/controllers/login.go index 6a04997..db68a45 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -33,6 +33,10 @@ func Login(localAddr net.Addr, debugOutput bool) error { return e } + if localAddr != nil && global.Config.Settings.Basic.UseDhcpIP { + ip = localAddr.(*net.TCPAddr).IP.String() + } + log.Debugln("认证客户端 ip: ", ip) if online { diff --git a/models/config.go b/models/config.go index 39e808b..86d509e 100644 --- a/models/config.go +++ b/models/config.go @@ -19,6 +19,7 @@ type Basic struct { SkipCertVerify bool `json:"skip_cert_verify" yaml:"skip_cert_verify" mapstructure:"skip_cert_verify"` Timeout uint `json:"timeout" yaml:"timeout" mapstructure:"timeout"` Interfaces string `json:"interfaces" yaml:"interfaces" mapstructure:"interfaces"` + UseDhcpIP bool `json:"use_dhcp_ip" yaml:"use_dhcp_ip" mapstructure:"use_dhcp_ip"` } type Log struct {