完善通道创建与同步流程
This commit is contained in:
@@ -21,7 +21,7 @@ func Init() {
|
||||
// todo 从环境变量中获取参数
|
||||
Client = client{
|
||||
url: "http://103.139.212.110:9989",
|
||||
token: "tHDarLc1ct6M9NMAxeO98lN2YsEadYSx.anVpcA==.MTc0MzA4MTAwMQ==",
|
||||
token: "PhdnRF3z6VF2sPgygTSl1Xx6QJN0yFIK.anVpcA==.MTc0MzE2ODAwMQ==",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,11 +279,11 @@ type PortConfigsReq struct {
|
||||
}
|
||||
|
||||
type AutoEdgeConfig struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
Isp string `json:"isp"`
|
||||
Count int `json:"count"`
|
||||
PacketLoss int `json:"packet_loss"`
|
||||
Province string `json:"province,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Isp string `json:"isp,omitempty"`
|
||||
Count int `json:"count,omitempty"`
|
||||
PacketLoss int `json:"packet_loss,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Gateway) GatewayPortConfigs(params []PortConfigsReq) error {
|
||||
@@ -319,7 +319,7 @@ func (c *Gateway) GatewayPortConfigs(params []PortConfigsReq) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if result["code"] != 0 {
|
||||
if result["code"].(float64) != 0 {
|
||||
return errors.New("failed to configure port")
|
||||
}
|
||||
|
||||
@@ -395,14 +395,9 @@ func (c *Gateway) GatewayPortActive(param PortActiveReq) (*PortActiveResp, error
|
||||
|
||||
// endregion
|
||||
|
||||
func (c *Gateway) requestGateway(method string, url string, data any) (*http.Response, error) {
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *Gateway) requestGateway(method string, url string, data string) (*http.Response, error) {
|
||||
url = fmt.Sprintf("http://%s:%s@%s:9990%s", c.username, c.password, c.url, url)
|
||||
req, err := http.NewRequest(method, url, strings.NewReader(string(jsonData)))
|
||||
req, err := http.NewRequest(method, url, strings.NewReader(data))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user