进一步修复和面板通信的故障
This commit is contained in:
@@ -189,9 +189,8 @@ func (s *Service) setupNode() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) fetchConfig() (*XNodeConfig, error) {
|
func (s *Service) fetchConfig() (*XNodeConfig, error) {
|
||||||
url := fmt.Sprintf("%s/api/v1/server/UniProxy/config?node_id=%d&node_type=%s", s.options.PanelURL, s.options.NodeID, s.options.NodeType)
|
url := fmt.Sprintf("%s/api/v1/server/UniProxy/config?node_id=%d&node_type=%s&token=%s", s.options.PanelURL, s.options.NodeID, s.options.NodeType, s.options.Key)
|
||||||
req, _ := http.NewRequest("GET", url, nil)
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
req.Header.Set("Authorization", s.options.Key)
|
|
||||||
req.Header.Set("User-Agent", "sing-box/xboard")
|
req.Header.Set("User-Agent", "sing-box/xboard")
|
||||||
|
|
||||||
resp, err := s.httpClient.Do(req)
|
resp, err := s.httpClient.Do(req)
|
||||||
@@ -352,11 +351,10 @@ func (s *Service) reportTraffic() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) pushTraffic(data any) error {
|
func (s *Service) pushTraffic(data any) error {
|
||||||
url := fmt.Sprintf("%s/api/v1/server/UniProxy/push?node_id=%d&node_type=%s", s.options.PanelURL, s.options.NodeID, s.options.NodeType)
|
url := fmt.Sprintf("%s/api/v1/server/UniProxy/push?node_id=%d&node_type=%s&token=%s", s.options.PanelURL, s.options.NodeID, s.options.NodeType, s.options.Key)
|
||||||
body, _ := json.Marshal(data)
|
body, _ := json.Marshal(data)
|
||||||
|
|
||||||
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
|
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
|
||||||
req.Header.Set("Authorization", s.options.Key)
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set("User-Agent", "sing-box/xboard")
|
req.Header.Set("User-Agent", "sing-box/xboard")
|
||||||
|
|
||||||
@@ -390,9 +388,8 @@ type XUser struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) fetchUsers() ([]XUser, error) {
|
func (s *Service) fetchUsers() ([]XUser, error) {
|
||||||
url := fmt.Sprintf("%s/api/v1/server/UniProxy/user?node_id=%d&node_type=%s", s.options.PanelURL, s.options.NodeID, s.options.NodeType)
|
url := fmt.Sprintf("%s/api/v1/server/UniProxy/user?node_id=%d&node_type=%s&token=%s", s.options.PanelURL, s.options.NodeID, s.options.NodeType, s.options.Key)
|
||||||
req, _ := http.NewRequest("GET", url, nil)
|
req, _ := http.NewRequest("GET", url, nil)
|
||||||
req.Header.Set("Authorization", s.options.Key)
|
|
||||||
req.Header.Set("User-Agent", "sing-box/xboard")
|
req.Header.Set("User-Agent", "sing-box/xboard")
|
||||||
|
|
||||||
resp, err := s.httpClient.Do(req)
|
resp, err := s.httpClient.Do(req)
|
||||||
|
|||||||
Reference in New Issue
Block a user