mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
remove no need interface, fix interval type for v2board v1.7.4dev
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
package panel
|
||||
|
||||
type Panel interface {
|
||||
GetNodeInfo() (nodeInfo *NodeInfo, err error)
|
||||
GetUserList() (userList []UserInfo, err error)
|
||||
ReportUserTraffic(userTraffic []UserTraffic) (err error)
|
||||
Describe() ClientInfo
|
||||
Debug()
|
||||
}
|
||||
@@ -2,9 +2,11 @@ package panel
|
||||
|
||||
import (
|
||||
"github.com/goccy/go-json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type NodeInfo struct {
|
||||
@@ -73,13 +75,24 @@ func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error) {
|
||||
}
|
||||
nodeInfo.Routes = nil
|
||||
if _, ok := nodeInfo.BaseConfig.PullInterval.(int); !ok {
|
||||
i, _ := strconv.Atoi(nodeInfo.BaseConfig.PullInterval.(string))
|
||||
nodeInfo.BaseConfig.PullInterval = i
|
||||
nodeInfo.BaseConfig.PullInterval = intervalToTime(nodeInfo.BaseConfig.PullInterval)
|
||||
}
|
||||
if _, ok := nodeInfo.BaseConfig.PushInterval.(int); !ok {
|
||||
i, _ := strconv.Atoi(nodeInfo.BaseConfig.PushInterval.(string))
|
||||
nodeInfo.BaseConfig.PushInterval = i
|
||||
nodeInfo.BaseConfig.PushInterval = intervalToTime(nodeInfo.BaseConfig.PullInterval)
|
||||
}
|
||||
c.etag = r.Header().Get("Etag")
|
||||
return
|
||||
}
|
||||
|
||||
func intervalToTime(i interface{}) time.Duration {
|
||||
switch reflect.TypeOf(i).Kind() {
|
||||
case reflect.Int:
|
||||
return time.Duration(i.(int)) * time.Second
|
||||
case reflect.String:
|
||||
i, _ := strconv.Atoi(i.(string))
|
||||
return time.Duration(i) * time.Second
|
||||
case reflect.Float64:
|
||||
return time.Duration(i.(float64)) * time.Second
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var client Panel
|
||||
var client *Client
|
||||
|
||||
func init() {
|
||||
c, err := New(&conf.ApiConfig{
|
||||
|
||||
@@ -32,7 +32,7 @@ type Client struct {
|
||||
etag string
|
||||
}
|
||||
|
||||
func New(c *conf.ApiConfig) (Panel, error) {
|
||||
func New(c *conf.ApiConfig) (*Client, error) {
|
||||
client := resty.New()
|
||||
client.SetRetryCount(3)
|
||||
if c.Timeout > 0 {
|
||||
|
||||
Reference in New Issue
Block a user