mirror of
https://github.com/InazumaV/Ratte.git
synced 2026-02-04 04:30:09 +00:00
reactor: update deps
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user