From becd4287ae8cb0398518400fddf27dc048c4176b Mon Sep 17 00:00:00 2001 From: Yuzuki616 Date: Mon, 19 May 2025 16:02:27 +0900 Subject: [PATCH] reactor: update deps --- go.mod | 2 +- go.sum | 2 ++ handler/node.go | 28 ++++++---------------------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index f8d6b5c..1068308 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.24.2 require ( github.com/InazumaV/Ratte-Core-Xray v0.0.0-20250420021044-42b0d35bcd79 - github.com/InazumaV/Ratte-Interface v0.0.0-20250505045848-a0068c2a9be9 + github.com/InazumaV/Ratte-Interface v0.0.0-20250519063521-202abe204fd8 github.com/InazumaV/Ratte-Panel-V2b v0.0.0-20250420013203-72f8abe3e919 github.com/fsnotify/fsnotify v1.7.0 github.com/go-acme/lego/v4 v4.18.0 diff --git a/go.sum b/go.sum index 66dde28..2095f50 100644 --- a/go.sum +++ b/go.sum @@ -65,6 +65,8 @@ github.com/InazumaV/Ratte-Core-Xray v0.0.0-20250420021044-42b0d35bcd79 h1:PruEu6 github.com/InazumaV/Ratte-Core-Xray v0.0.0-20250420021044-42b0d35bcd79/go.mod h1:GGt1mWh9rdkPD9jT/iKM170Oqk1xm8s1ujH+QIW1nGk= github.com/InazumaV/Ratte-Interface v0.0.0-20250505045848-a0068c2a9be9 h1:+adxGP0iY0EYP8iuva/q0IUgUSwIBEz8ZXWVuW8PTTA= github.com/InazumaV/Ratte-Interface v0.0.0-20250505045848-a0068c2a9be9/go.mod h1:UxqxslbpT8Q4qMldSNI6VCX5WFXWDbvE4fXpymp73kA= +github.com/InazumaV/Ratte-Interface v0.0.0-20250519063521-202abe204fd8 h1:WjSGJqB9zmNuJ0Iv0Exo6PdKHMnJ1Z2vdGb/Vc5X9l0= +github.com/InazumaV/Ratte-Interface v0.0.0-20250519063521-202abe204fd8/go.mod h1:UxqxslbpT8Q4qMldSNI6VCX5WFXWDbvE4fXpymp73kA= github.com/InazumaV/Ratte-Panel-V2b v0.0.0-20250420013203-72f8abe3e919 h1:+Fp5s8BVpk3vQC7N/x3a6sTRZNSU8Jd8G4MenyLnK3g= github.com/InazumaV/Ratte-Panel-V2b v0.0.0-20250420013203-72f8abe3e919/go.mod h1:5EkRRTlqZqG3rp3aP6QiPlrPJKpWtwt5gBtJduFv35E= github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJSGpevP+8Pk5bANX7fJacO2w04aqLiC5I= diff --git a/handler/node.go b/handler/node.go index 03ad972..98f9d98 100644 --- a/handler/node.go +++ b/handler/node.go @@ -6,6 +6,7 @@ import ( "github.com/InazumaV/Ratte-Interface/panel" "github.com/InazumaV/Ratte/common/maps" "github.com/InazumaV/Ratte/common/number" + "strconv" ) func (h *Handler) PullNodeHandle(n *panel.NodeInfo) error { @@ -15,7 +16,7 @@ func (h *Handler) PullNodeHandle(n *panel.NodeInfo) error { return fmt.Errorf("del node error: %w", err) } } else { - if n.TlsType() != panel.NoTls { + if n.Security == "" { h.needTls = true err := h.acme.CreateCert(h.Cert.CertPath, h.Cert.KeyPath, h.Cert.Domain) if err != nil { @@ -23,33 +24,16 @@ func (h *Handler) PullNodeHandle(n *panel.NodeInfo) error { } } } - var protocol, port string - switch n.Type { - case "vmess": - protocol = "vmess" - port = n.VMess.Port - case "vless": - protocol = "vless" - port = n.VLess.Port - case "shadowsocks": - protocol = "shadowsocks" - port = n.Shadowsocks.Port - case "trojan": - protocol = "trojan" - port = n.Trojan.Port - case "other": - protocol = "other" - port = n.Other.Port - } + if h.Hook.BeforeAddNode != "" { - err := h.execHookCmd(h.Hook.BeforeAddNode, h.nodeName, protocol, port) + err := h.execHookCmd(h.Hook.BeforeAddNode, h.nodeName, n.Type, strconv.Itoa(n.Port)) if err != nil { h.l.WithError(err).Error("Exec before add node hook failed") } } ni := (*core.NodeInfo)(n) - ni.OtherOptions = maps.Merge[string, any](ni.OtherOptions, h.Options.Expand) + ni.Options = maps.Merge[string, any](ni.Options, h.Options.Expand) ni.Limit.IPLimit = number.SelectBigger(ni.Limit.IPLimit, h.Limit.IPLimit) ni.Limit.SpeedLimit = number.SelectBigger(ni.Limit.SpeedLimit, uint64(h.Limit.SpeedLimit)) err := h.c.AddNode(&core.AddNodeParams{ @@ -64,7 +48,7 @@ func (h *Handler) PullNodeHandle(n *panel.NodeInfo) error { return fmt.Errorf("add node error: %w", err) } if h.Hook.AfterAddNode != "" { - err = h.execHookCmd(h.Hook.AfterAddNode, h.nodeName, protocol, port) + err = h.execHookCmd(h.Hook.AfterAddNode, h.nodeName, ni.Type, strconv.Itoa(ni.Port)) if err != nil { h.l.WithError(err).Warn("Exec after add node hook failed") }