mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-08 05:19:54 +00:00
feat: update sspanel model (#467)
This commit is contained in:
parent
42a2226769
commit
78f2f88296
@ -59,17 +59,13 @@ type NodeInfo struct {
|
|||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
UID int
|
UID int
|
||||||
Email string
|
Email string
|
||||||
|
UUID string
|
||||||
Passwd string
|
Passwd string
|
||||||
Port uint32
|
Port uint32
|
||||||
|
AlterID uint16
|
||||||
Method string
|
Method string
|
||||||
SpeedLimit uint64 // Bps
|
SpeedLimit uint64 // Bps
|
||||||
DeviceLimit int
|
DeviceLimit int
|
||||||
Protocol string
|
|
||||||
ProtocolParam string
|
|
||||||
Obfs string
|
|
||||||
ObfsParam string
|
|
||||||
UUID string
|
|
||||||
AlterID uint16
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type OnlineUser struct {
|
type OnlineUser struct {
|
||||||
|
@ -8,7 +8,6 @@ type NodeInfoResponse struct {
|
|||||||
Class int `json:"node_class"`
|
Class int `json:"node_class"`
|
||||||
SpeedLimit float64 `json:"node_speedlimit"`
|
SpeedLimit float64 `json:"node_speedlimit"`
|
||||||
TrafficRate float64 `json:"traffic_rate"`
|
TrafficRate float64 `json:"traffic_rate"`
|
||||||
MuOnly int `json:"mu_only"`
|
|
||||||
Sort int `json:"sort"`
|
Sort int `json:"sort"`
|
||||||
RawServerString string `json:"server"`
|
RawServerString string `json:"server"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
@ -17,22 +16,17 @@ type NodeInfoResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CustomConfig struct {
|
type CustomConfig struct {
|
||||||
OffsetPortUser string `json:"offset_port_user"`
|
|
||||||
OffsetPortNode string `json:"offset_port_node"`
|
OffsetPortNode string `json:"offset_port_node"`
|
||||||
ServerSub string `json:"server_sub"`
|
|
||||||
Host string `json:"host"`
|
Host string `json:"host"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
V2Port string `json:"v2_port"`
|
|
||||||
TLS string `json:"tls"`
|
TLS string `json:"tls"`
|
||||||
EnableVless string `json:"enable_vless"`
|
EnableVless string `json:"enable_vless"`
|
||||||
AlterID string `json:"alter_id"`
|
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
Security string `json:"security"`
|
Security string `json:"security"`
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
VerifyCert bool `json:"verify_cert"`
|
VerifyCert bool `json:"verify_cert"`
|
||||||
Obfs string `json:"obfs"`
|
Obfs string `json:"obfs"`
|
||||||
Header json.RawMessage `json:"header"`
|
Header json.RawMessage `json:"header"`
|
||||||
TrojanPort string `json:"trojan_port"`
|
|
||||||
AllowInsecure string `json:"allow_insecure"`
|
AllowInsecure string `json:"allow_insecure"`
|
||||||
Servicename string `json:"servicename"`
|
Servicename string `json:"servicename"`
|
||||||
EnableXtls string `json:"enable_xtls"`
|
EnableXtls string `json:"enable_xtls"`
|
||||||
@ -42,20 +36,12 @@ type CustomConfig struct {
|
|||||||
// UserResponse is the response of user
|
// UserResponse is the response of user
|
||||||
type UserResponse struct {
|
type UserResponse struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Email string `json:"email"`
|
|
||||||
Passwd string `json:"passwd"`
|
Passwd string `json:"passwd"`
|
||||||
Port uint32 `json:"port"`
|
Port uint32 `json:"port"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
SpeedLimit float64 `json:"node_speedlimit"`
|
SpeedLimit float64 `json:"node_speedlimit"`
|
||||||
DeviceLimit int `json:"node_connector"`
|
DeviceLimit int `json:"node_iplimit"`
|
||||||
Protocol string `json:"protocol"`
|
|
||||||
ProtocolParam string `json:"protocol_param"`
|
|
||||||
Obfs string `json:"obfs"`
|
|
||||||
ObfsParam string `json:"obfs_param"`
|
|
||||||
ForbiddenIP string `json:"forbidden_ip"`
|
|
||||||
ForbiddenPort string `json:"forbidden_port"`
|
|
||||||
UUID string `json:"uuid"`
|
UUID string `json:"uuid"`
|
||||||
MultiUser int `json:"is_multi_user"`
|
|
||||||
AliveIP int `json:"alive_ip"`
|
AliveIP int `json:"alive_ip"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +56,7 @@ type PostData struct {
|
|||||||
Data interface{} `json:"data"`
|
Data interface{} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SystemLoad is the data structure of systemload
|
// SystemLoad is the data structure of system load
|
||||||
type SystemLoad struct {
|
type SystemLoad struct {
|
||||||
Uptime string `json:"uptime"`
|
Uptime string `json:"uptime"`
|
||||||
Load string `json:"load"`
|
Load string `json:"load"`
|
||||||
|
@ -518,17 +518,6 @@ func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *NodeInfoResponse) (*ap
|
|||||||
if err := json.Unmarshal(response.Data, userListResponse); err != nil {
|
if err := json.Unmarshal(response.Data, userListResponse); err != nil {
|
||||||
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(userListResponse), err)
|
return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(userListResponse), err)
|
||||||
}
|
}
|
||||||
// Find the multi-user
|
|
||||||
for _, u := range *userListResponse {
|
|
||||||
if u.MultiUser > 0 {
|
|
||||||
port = u.Port
|
|
||||||
method = u.Method
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if port == 0 || method == "" {
|
|
||||||
return nil, fmt.Errorf("cant find the single port multi user")
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.SpeedLimit > 0 {
|
if c.SpeedLimit > 0 {
|
||||||
speedLimit = uint64((c.SpeedLimit * 1000000) / 8)
|
speedLimit = uint64((c.SpeedLimit * 1000000) / 8)
|
||||||
@ -728,17 +717,12 @@ func (c *APIClient) ParseUserListResponse(userInfoResponse *[]UserResponse) (*[]
|
|||||||
}
|
}
|
||||||
userList = append(userList, api.UserInfo{
|
userList = append(userList, api.UserInfo{
|
||||||
UID: user.ID,
|
UID: user.ID,
|
||||||
Email: user.Email,
|
|
||||||
UUID: user.UUID,
|
UUID: user.UUID,
|
||||||
Passwd: user.Passwd,
|
Passwd: user.Passwd,
|
||||||
SpeedLimit: speedLimit,
|
SpeedLimit: speedLimit,
|
||||||
DeviceLimit: deviceLimit,
|
DeviceLimit: deviceLimit,
|
||||||
Port: user.Port,
|
Port: user.Port,
|
||||||
Method: user.Method,
|
Method: user.Method,
|
||||||
Protocol: user.Protocol,
|
|
||||||
ProtocolParam: user.ProtocolParam,
|
|
||||||
Obfs: user.Obfs,
|
|
||||||
ObfsParam: user.ObfsParam,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,12 +770,6 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a
|
|||||||
transportProtocol = nodeConfig.Network
|
transportProtocol = nodeConfig.Network
|
||||||
tlsType = nodeConfig.Security
|
tlsType = nodeConfig.Security
|
||||||
|
|
||||||
if parsedAlterID, err := strconv.ParseInt(nodeConfig.AlterID, 10, 16); err != nil {
|
|
||||||
return nil, err
|
|
||||||
} else {
|
|
||||||
alterID = uint16(parsedAlterID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if tlsType == "tls" || tlsType == "xtls" {
|
if tlsType == "tls" || tlsType == "xtls" {
|
||||||
enableTLS = true
|
enableTLS = true
|
||||||
}
|
}
|
||||||
@ -804,10 +782,7 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a
|
|||||||
tlsType = "tls"
|
tlsType = "tls"
|
||||||
transportProtocol = "tcp"
|
transportProtocol = "tcp"
|
||||||
|
|
||||||
// Select security type
|
if nodeConfig.Security != "" {
|
||||||
if nodeConfig.EnableXtls == "1" {
|
|
||||||
tlsType = "xtls"
|
|
||||||
} else if nodeConfig.Security != "" {
|
|
||||||
tlsType = nodeConfig.Security // try to read security from config
|
tlsType = nodeConfig.Security // try to read security from config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user