mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-08 05:19:54 +00:00
fix: fix incorrect conversion between integer type
This commit is contained in:
parent
84db0453cb
commit
e46dc1d8d7
@ -31,7 +31,7 @@ type NodeStatus struct {
|
||||
type NodeInfo struct {
|
||||
NodeType string // Must be V2ray, Trojan, and Shadowsocks
|
||||
NodeID int
|
||||
Port int
|
||||
Port uint32
|
||||
SpeedLimit uint64 // Bps
|
||||
AlterID uint16
|
||||
TransportProtocol string
|
||||
@ -50,7 +50,7 @@ type UserInfo struct {
|
||||
UID int
|
||||
Email string
|
||||
Passwd string
|
||||
Port int
|
||||
Port uint32
|
||||
Method string
|
||||
SpeedLimit uint64 // Bps
|
||||
DeviceLimit int
|
||||
|
@ -9,7 +9,7 @@ type NodeInfoResponse struct {
|
||||
Method string `json:"method"`
|
||||
TrafficRate float64 `json:"trafficRate"`
|
||||
RawServerString string `json:"outServer"`
|
||||
Port int `json:"outPort"`
|
||||
Port uint32 `json:"outPort"`
|
||||
AlterId uint16 `json:"alterId"`
|
||||
Network string `json:"network"`
|
||||
Security string `json:"security"`
|
||||
|
@ -411,11 +411,8 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *NodeInfoResponse) (
|
||||
|
||||
// ParseSSNodeResponse parse the response for the given nodeinfor format
|
||||
func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *NodeInfoResponse) (*api.NodeInfo, error) {
|
||||
var port int = 0
|
||||
var speedlimit uint64 = 0
|
||||
|
||||
port = nodeInfoResponse.Port
|
||||
|
||||
if c.SpeedLimit > 0 {
|
||||
speedlimit = uint64((c.SpeedLimit * 1000000) / 8)
|
||||
} else {
|
||||
@ -425,7 +422,7 @@ func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *NodeInfoResponse) (*ap
|
||||
nodeinfo := &api.NodeInfo{
|
||||
NodeType: c.NodeType,
|
||||
NodeID: c.NodeID,
|
||||
Port: port,
|
||||
Port: nodeInfoResponse.Port,
|
||||
SpeedLimit: speedlimit,
|
||||
TransportProtocol: "tcp",
|
||||
CypherMethod: nodeInfoResponse.Method,
|
||||
|
@ -20,7 +20,7 @@ type V2rayNodeInfo struct {
|
||||
Cert string `json:"pem"`
|
||||
V2License string `json:"v2_license"`
|
||||
V2AlterID uint16 `json:"v2_alter_id"`
|
||||
V2Port int `json:"v2_port"`
|
||||
V2Port uint32 `json:"v2_port"`
|
||||
V2Method string `json:"v2_method"`
|
||||
V2Net string `json:"v2_net"`
|
||||
V2Type string `json:"v2_type"`
|
||||
@ -37,7 +37,7 @@ type ShadowsocksNodeInfo struct {
|
||||
SpeedLimit uint64 `json:"speed_limit"`
|
||||
ClientLimit int `json:"client_limit"`
|
||||
Method string `json:"method"`
|
||||
Port int `json:"port"`
|
||||
Port uint32 `json:"port"`
|
||||
}
|
||||
|
||||
type TrojanNodeInfo struct {
|
||||
@ -46,7 +46,7 @@ type TrojanNodeInfo struct {
|
||||
SpeedLimit uint64 `json:"speed_limit"`
|
||||
ClientLimit int `json:"client_limit"`
|
||||
PushPort int `json:"push_port"`
|
||||
TrojanPort int `json:"trojan_port"`
|
||||
TrojanPort uint32 `json:"trojan_port"`
|
||||
}
|
||||
|
||||
// Node status report
|
||||
|
@ -49,7 +49,7 @@ type UserResponse struct {
|
||||
ID int `json:"id"`
|
||||
Email string `json:"email"`
|
||||
Passwd string `json:"passwd"`
|
||||
Port int `json:"port"`
|
||||
Port uint32 `json:"port"`
|
||||
Method string `json:"method"`
|
||||
SpeedLimit float64 `json:"node_speedlimit"`
|
||||
DeviceLimit int `json:"node_connector"`
|
||||
|
@ -382,10 +382,12 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *NodeInfoResponse) (
|
||||
}
|
||||
//nodeInfo.RawServerString = strings.ToLower(nodeInfo.RawServerString)
|
||||
serverConf := strings.Split(nodeInfoResponse.RawServerString, ";")
|
||||
port, err := strconv.Atoi(serverConf[1])
|
||||
|
||||
parsedPort, err := strconv.ParseInt(serverConf[1], 10, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
port := uint32(parsedPort)
|
||||
|
||||
parsedAlterID, err := strconv.ParseInt(serverConf[2], 10, 16)
|
||||
if err != nil {
|
||||
@ -467,7 +469,7 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *NodeInfoResponse) (
|
||||
|
||||
// ParseSSNodeResponse parse the response for the given nodeinfor format
|
||||
func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *NodeInfoResponse) (*api.NodeInfo, error) {
|
||||
var port int = 0
|
||||
var port uint32 = 0
|
||||
var speedlimit uint64 = 0
|
||||
var method string
|
||||
path := "/mod_mu/users"
|
||||
@ -524,10 +526,11 @@ func (c *APIClient) ParseSSPluginNodeResponse(nodeInfoResponse *NodeInfoResponse
|
||||
var speedlimit uint64 = 0
|
||||
|
||||
serverConf := strings.Split(nodeInfoResponse.RawServerString, ";")
|
||||
port, err := strconv.Atoi(serverConf[1])
|
||||
parsedPort, err := strconv.ParseInt(serverConf[1], 10, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
port := uint32(parsedPort)
|
||||
port = port - 1 // Shadowsocks-Plugin requires two ports, one for ss the other for other stream protocol
|
||||
if port <= 0 {
|
||||
return nil, fmt.Errorf("Shadowsocks-Plugin listen port must bigger than 1")
|
||||
@ -618,10 +621,11 @@ func (c *APIClient) ParseTrojanNodeResponse(nodeInfoResponse *NodeInfoResponse)
|
||||
p = outsidePort
|
||||
}
|
||||
|
||||
port, err := strconv.Atoi(p)
|
||||
parsedPort, err := strconv.ParseInt(p, 10, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
port := uint32(parsedPort)
|
||||
|
||||
serverConf := strings.Split(nodeInfoResponse.RawServerString, ";")
|
||||
extraServerConf := strings.Split(serverConf[1], "|")
|
||||
@ -742,10 +746,11 @@ func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*a
|
||||
speedlimit = uint64((nodeInfoResponse.SpeedLimit * 1000000) / 8)
|
||||
}
|
||||
|
||||
port, err := strconv.Atoi(nodeConfig.OffsetPortNode)
|
||||
parsedPort, err := strconv.ParseInt(nodeConfig.OffsetPortNode, 10, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
port := uint32(parsedPort)
|
||||
|
||||
if c.NodeType == "Shadowsocks" {
|
||||
transportProtocol = "tcp"
|
||||
|
@ -219,7 +219,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
|
||||
user.Email = response.Get("data").GetIndex(i).Get("secret").MustString()
|
||||
user.Passwd = response.Get("data").GetIndex(i).Get("secret").MustString()
|
||||
user.Method = response.Get("data").GetIndex(i).Get("cipher").MustString()
|
||||
user.Port = response.Get("data").GetIndex(i).Get("port").MustInt()
|
||||
user.Port = uint32(response.Get("data").GetIndex(i).Get("port").MustUint64())
|
||||
case "Trojan":
|
||||
user.UUID = response.Get("data").GetIndex(i).Get("trojan_user").Get("password").MustString()
|
||||
user.Email = response.Get("data").GetIndex(i).Get("trojan_user").Get("password").MustString()
|
||||
@ -308,7 +308,7 @@ func (c *APIClient) ParseTrojanNodeResponse(nodeInfoResponse *simplejson.Json) (
|
||||
if c.EnableXTLS {
|
||||
TLSType = "xtls"
|
||||
}
|
||||
port := nodeInfoResponse.Get("local_port").MustInt()
|
||||
port := uint32(nodeInfoResponse.Get("local_port").MustUint64())
|
||||
host := nodeInfoResponse.Get("ssl").Get("sni").MustString()
|
||||
|
||||
// Create GeneralNodeInfo
|
||||
@ -326,7 +326,7 @@ func (c *APIClient) ParseTrojanNodeResponse(nodeInfoResponse *simplejson.Json) (
|
||||
|
||||
// ParseSSNodeResponse parse the response for the given nodeinfor format
|
||||
func (c *APIClient) ParseSSNodeResponse() (*api.NodeInfo, error) {
|
||||
var port int
|
||||
var port uint32
|
||||
var method string
|
||||
userInfo, err := c.GetUserList()
|
||||
if err != nil {
|
||||
@ -372,7 +372,7 @@ func (c *APIClient) ParseV2rayNodeResponse(nodeInfoResponse *simplejson.Json) (*
|
||||
return nil, fmt.Errorf("Unable to find inbound(s) in the nodeInfo.")
|
||||
}
|
||||
|
||||
port := inboundInfo.Get("port").MustInt()
|
||||
port := uint32(inboundInfo.Get("port").MustUint64())
|
||||
transportProtocol := inboundInfo.Get("streamSettings").Get("network").MustString()
|
||||
|
||||
switch transportProtocol {
|
||||
|
@ -27,7 +27,7 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
||||
|
||||
// Build Port
|
||||
portList := &conf.PortList{
|
||||
Range: []conf.PortRange{{From: uint32(nodeInfo.Port), To: uint32(nodeInfo.Port)}},
|
||||
Range: []conf.PortRange{{From: nodeInfo.Port, To: nodeInfo.Port}},
|
||||
}
|
||||
inboundDetourConfig.PortList = portList
|
||||
// Build Tag
|
||||
|
Loading…
x
Reference in New Issue
Block a user