出问题那个用户对应的客户端订阅参数

This commit is contained in:
CN-JS-HuiBai
2026-04-15 14:17:32 +08:00
parent d188a2060b
commit d82b7b1ca6
3 changed files with 6 additions and 13 deletions

View File

@@ -135,12 +135,10 @@ if ! [[ "$NODE_COUNT" =~ ^[0-9]+$ ]] || [[ "$NODE_COUNT" -lt 1 ]]; then
fi fi
declare -a NODE_IDS declare -a NODE_IDS
declare -a NODE_TYPES
declare -a NODE_TAGS declare -a NODE_TAGS
for ((i=1; i<=NODE_COUNT; i++)); do for ((i=1; i<=NODE_COUNT; i++)); do
DEFAULT_NODE_ID="" DEFAULT_NODE_ID=""
DEFAULT_NODE_TYPE="${NODE_TYPE:-vless}"
DEFAULT_NODE_TAG="" DEFAULT_NODE_TAG=""
if [[ "$i" -eq 1 && -n "$NODE_ID" ]]; then if [[ "$i" -eq 1 && -n "$NODE_ID" ]]; then
DEFAULT_NODE_ID="$NODE_ID" DEFAULT_NODE_ID="$NODE_ID"
@@ -151,12 +149,9 @@ for ((i=1; i<=NODE_COUNT; i++)); do
echo -e "${RED}Node ID is required for node #$i${NC}" echo -e "${RED}Node ID is required for node #$i${NC}"
exit 1 exit 1
fi fi
read -p "Enter Node Type for node #$i [${DEFAULT_NODE_TYPE}]: " INPUT_TYPE
CURRENT_NODE_TYPE=${INPUT_TYPE:-$DEFAULT_NODE_TYPE}
read -p "Enter Tag for node #$i (optional) [${DEFAULT_NODE_TAG}]: " INPUT_TAG read -p "Enter Tag for node #$i (optional) [${DEFAULT_NODE_TAG}]: " INPUT_TAG
CURRENT_NODE_TAG=${INPUT_TAG:-$DEFAULT_NODE_TAG} CURRENT_NODE_TAG=${INPUT_TAG:-$DEFAULT_NODE_TAG}
NODE_IDS+=("$CURRENT_NODE_ID") NODE_IDS+=("$CURRENT_NODE_ID")
NODE_TYPES+=("$CURRENT_NODE_TYPE")
NODE_TAGS+=("$CURRENT_NODE_TAG") NODE_TAGS+=("$CURRENT_NODE_TAG")
done done
@@ -190,7 +185,6 @@ if [[ "$NODE_COUNT" -eq 1 ]]; then
SERVICE_JSON+=$(cat <<EOF SERVICE_JSON+=$(cat <<EOF
, ,
"node_id": ${NODE_IDS[0]}, "node_id": ${NODE_IDS[0]},
"node_type": "${NODE_TYPES[0]}",
"config_node_id": ${NODE_IDS[0]}, "config_node_id": ${NODE_IDS[0]},
"user_node_id": ${NODE_IDS[0]} "user_node_id": ${NODE_IDS[0]}
EOF EOF
@@ -203,8 +197,7 @@ SERVICE_JSON+=$',
{ {
"node_id": ${NODE_IDS[$i]}, "node_id": ${NODE_IDS[$i]},
"config_node_id": ${NODE_IDS[$i]}, "config_node_id": ${NODE_IDS[$i]},
"user_node_id": ${NODE_IDS[$i]}, "user_node_id": ${NODE_IDS[$i]}
"node_type": "${NODE_TYPES[$i]}"
EOF EOF
) )
if [[ -n "${NODE_TAGS[$i]}" ]]; then if [[ -n "${NODE_TAGS[$i]}" ]]; then

View File

@@ -12,7 +12,7 @@ type XBoardServiceOptions struct {
NodeID int `json:"node_id"` NodeID int `json:"node_id"`
ConfigNodeID int `json:"config_node_id,omitempty"` ConfigNodeID int `json:"config_node_id,omitempty"`
UserNodeID int `json:"user_node_id,omitempty"` UserNodeID int `json:"user_node_id,omitempty"`
NodeType string `json:"node_type"` NodeType string `json:"node_type,omitempty"`
SyncInterval badoption.Duration `json:"sync_interval,omitempty"` SyncInterval badoption.Duration `json:"sync_interval,omitempty"`
ReportInterval badoption.Duration `json:"report_interval,omitempty"` ReportInterval badoption.Duration `json:"report_interval,omitempty"`
Nodes []XBoardNodeOptions `json:"nodes,omitempty"` Nodes []XBoardNodeOptions `json:"nodes,omitempty"`

View File

@@ -1038,9 +1038,9 @@ func normalizePanelNodeType(nodeType string) string {
func (s *Service) panelRequest(method string, baseURL string, endpoint string, nodeID int, payload []byte, contentType string) (http.Header, []byte, int, error) { func (s *Service) panelRequest(method string, baseURL string, endpoint string, nodeID int, payload []byte, contentType string) (http.Header, []byte, int, error) {
nodeType := normalizePanelNodeType(s.options.NodeType) nodeType := normalizePanelNodeType(s.options.NodeType)
nodeTypeCandidates := []string{nodeType} nodeTypeCandidates := []string{""}
if nodeType != "" { if nodeType != "" {
nodeTypeCandidates = append(nodeTypeCandidates, "") nodeTypeCandidates = append(nodeTypeCandidates, nodeType)
} }
var lastHeader http.Header var lastHeader http.Header
@@ -1089,8 +1089,8 @@ func (s *Service) panelRequest(method string, baseURL string, endpoint string, n
lastBody = responseBody lastBody = responseBody
lastStatus = resp.StatusCode lastStatus = resp.StatusCode
if resp.StatusCode == 400 && candidate != "" && strings.Contains(string(responseBody), "Server does not exist") && index+1 < len(nodeTypeCandidates) { if resp.StatusCode == 400 && candidate == "" && strings.Contains(string(responseBody), "Server does not exist") && index+1 < len(nodeTypeCandidates) {
s.logger.Warn("Xboard panel request failed with node_type=", candidate, ", retrying without node_type") s.logger.Warn("Xboard panel request failed without node_type, retrying with configured node_type=", nodeType)
continue continue
} }