mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-07-04 10:09:50 +00:00
feat: add shadowsocks2022 support for v2raysocks
This commit is contained in:
parent
05ff6dff1b
commit
3926463c59
@ -14,6 +14,8 @@ import (
|
|||||||
|
|
||||||
"github.com/bitly/go-simplejson"
|
"github.com/bitly/go-simplejson"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
|
"github.com/sagernet/sing-shadowsocks/shadowaead_2022"
|
||||||
|
C "github.com/sagernet/sing/common"
|
||||||
|
|
||||||
"github.com/XrayR-project/XrayR/api"
|
"github.com/XrayR-project/XrayR/api"
|
||||||
)
|
)
|
||||||
@ -325,21 +327,28 @@ func (c *APIClient) ParseTrojanNodeResponse(nodeInfoResponse *simplejson.Json) (
|
|||||||
return nodeinfo, nil
|
return nodeinfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseSSNodeResponse parse the response for the given nodeinfor format
|
// ParseSSNodeResponse parse the response for the given nodeinfo format
|
||||||
func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *simplejson.Json) (*api.NodeInfo, error) {
|
func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *simplejson.Json) (*api.NodeInfo, error) {
|
||||||
var method string
|
var method, serverPsk string
|
||||||
tmpInboundInfo := nodeInfoResponse.Get("inbounds").MustArray()
|
tmpInboundInfo := nodeInfoResponse.Get("inbounds").MustArray()
|
||||||
marshalByte, _ := json.Marshal(tmpInboundInfo[0].(map[string]interface{}))
|
marshalByte, _ := json.Marshal(tmpInboundInfo[0].(map[string]interface{}))
|
||||||
inboundInfo, _ := simplejson.NewJson(marshalByte)
|
inboundInfo, _ := simplejson.NewJson(marshalByte)
|
||||||
|
|
||||||
port := uint32(inboundInfo.Get("port").MustUint64())
|
port := uint32(inboundInfo.Get("port").MustUint64())
|
||||||
userInfo, err := c.GetUserList()
|
method = inboundInfo.Get("settings").Get("method").MustString()
|
||||||
if err != nil {
|
// Shadowsocks 2022
|
||||||
return nil, err
|
if C.Contains(shadowaead_2022.List, method) {
|
||||||
}
|
serverPsk = inboundInfo.Get("settings").Get("password").MustString()
|
||||||
if len(*userInfo) > 0 {
|
} else {
|
||||||
method = (*userInfo)[0].Method
|
userInfo, err := c.GetUserList()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(*userInfo) > 0 {
|
||||||
|
method = (*userInfo)[0].Method
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create GeneralNodeInfo
|
// Create GeneralNodeInfo
|
||||||
nodeinfo := &api.NodeInfo{
|
nodeinfo := &api.NodeInfo{
|
||||||
NodeType: c.NodeType,
|
NodeType: c.NodeType,
|
||||||
@ -347,6 +356,7 @@ func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *simplejson.Json) (*api
|
|||||||
Port: port,
|
Port: port,
|
||||||
TransportProtocol: "tcp",
|
TransportProtocol: "tcp",
|
||||||
CypherMethod: method,
|
CypherMethod: method,
|
||||||
|
ServerKey: serverPsk,
|
||||||
}
|
}
|
||||||
|
|
||||||
return nodeinfo, nil
|
return nodeinfo, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user