improve: 为 linux 添加可靠的网卡绑定
This commit is contained in:
@@ -38,7 +38,7 @@ func Guardian() {
|
||||
if e == nil {
|
||||
for _, eth := range interfaces {
|
||||
log.Debugf("使用 %s 网口登录 ", eth.Name)
|
||||
e = Login(eth.Addr, true)
|
||||
e = Login(ð, true)
|
||||
if e != nil {
|
||||
log.Errorln("网口 ", eth.Name+" 登录出错: ", e)
|
||||
}
|
||||
|
||||
@@ -6,15 +6,14 @@ import (
|
||||
"github.com/Mmx233/BitSrunLoginGo/pkg/srun"
|
||||
"github.com/Mmx233/BitSrunLoginGo/tools"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Login 登录逻辑
|
||||
func Login(localAddr net.Addr, debugOutput bool) error {
|
||||
func Login(eth *tools.Eth, debugOutput bool) error {
|
||||
// 登录状态检查
|
||||
|
||||
httpClient := tools.HttpPackSelect(localAddr).Client
|
||||
httpClient := tools.HttpPackSelect(eth).Client
|
||||
conf := &srun.Conf{
|
||||
Https: global.Config.Settings.Basic.Https,
|
||||
LoginInfo: srun.LoginInfo{
|
||||
@@ -38,12 +37,6 @@ func Login(localAddr net.Addr, debugOutput bool) error {
|
||||
return e
|
||||
}
|
||||
|
||||
if localAddr != nil && global.Config.Settings.Basic.UseDhcpIP {
|
||||
ip = localAddr.(*net.TCPAddr).IP.String()
|
||||
} else if global.Flags.ClientIP != "" {
|
||||
ip = global.Flags.ClientIP
|
||||
}
|
||||
|
||||
log.Debugln("认证客户端 ip: ", ip)
|
||||
|
||||
// 登录执行
|
||||
|
||||
@@ -11,13 +11,10 @@ var Flags struct {
|
||||
RunningDaemon bool
|
||||
//强制daemon
|
||||
Daemon bool
|
||||
//指定 client ip
|
||||
ClientIP string
|
||||
}
|
||||
|
||||
func initFlags() {
|
||||
flag.StringVar(&Flags.Path, "config", "Config.yaml", "config path")
|
||||
flag.StringVar(&Flags.ClientIP, "ip", "", "client ip for login")
|
||||
flag.BoolVar(&Flags.RunningDaemon, "running-daemon", false, "")
|
||||
flag.BoolVar(&Flags.Daemon, "daemon", false, "")
|
||||
flag.Parse()
|
||||
|
||||
@@ -19,7 +19,6 @@ 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 {
|
||||
|
||||
Reference in New Issue
Block a user