mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-03 20:20:13 +00:00
添加 APISendIP 属性
This commit is contained in:
@@ -3,6 +3,7 @@ package panel
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -18,6 +19,7 @@ import (
|
|||||||
type Client struct {
|
type Client struct {
|
||||||
client *resty.Client
|
client *resty.Client
|
||||||
APIHost string
|
APIHost string
|
||||||
|
APISendIP string
|
||||||
Token string
|
Token string
|
||||||
NodeType string
|
NodeType string
|
||||||
NodeId int
|
NodeId int
|
||||||
@@ -29,7 +31,14 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func New(c *conf.ApiConfig) (*Client, error) {
|
func New(c *conf.ApiConfig) (*Client, error) {
|
||||||
client := resty.New()
|
var client *resty.Client
|
||||||
|
if c.APISendIP != "" {
|
||||||
|
client = resty.NewWithLocalAddr(&net.TCPAddr{
|
||||||
|
IP: net.ParseIP(c.APISendIP),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
client = resty.New()
|
||||||
|
}
|
||||||
client.SetRetryCount(3)
|
client.SetRetryCount(3)
|
||||||
if c.Timeout > 0 {
|
if c.Timeout > 0 {
|
||||||
client.SetTimeout(time.Duration(c.Timeout) * time.Second)
|
client.SetTimeout(time.Duration(c.Timeout) * time.Second)
|
||||||
@@ -69,12 +78,13 @@ func New(c *conf.ApiConfig) (*Client, error) {
|
|||||||
"token": c.Key,
|
"token": c.Key,
|
||||||
})
|
})
|
||||||
return &Client{
|
return &Client{
|
||||||
client: client,
|
client: client,
|
||||||
Token: c.Key,
|
Token: c.Key,
|
||||||
APIHost: c.APIHost,
|
APIHost: c.APIHost,
|
||||||
NodeType: c.NodeType,
|
APISendIP: c.APISendIP,
|
||||||
NodeId: c.NodeID,
|
NodeType: c.NodeType,
|
||||||
UserList: &UserListBody{},
|
NodeId: c.NodeID,
|
||||||
AliveMap: &AliveMap{},
|
UserList: &UserListBody{},
|
||||||
|
AliveMap: &AliveMap{},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type rawNodeConfig struct {
|
|||||||
|
|
||||||
type ApiConfig struct {
|
type ApiConfig struct {
|
||||||
APIHost string `json:"ApiHost"`
|
APIHost string `json:"ApiHost"`
|
||||||
|
APISendIP string `json:"ApiSendIP"`
|
||||||
NodeID int `json:"NodeID"`
|
NodeID int `json:"NodeID"`
|
||||||
Key string `json:"ApiKey"`
|
Key string `json:"ApiKey"`
|
||||||
NodeType string `json:"NodeType"`
|
NodeType string `json:"NodeType"`
|
||||||
|
|||||||
Reference in New Issue
Block a user