mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-24 12:14:42 -05:00
fix: 修复只提供节点链接时空指针的问题
fix: 修复ssr分享链接加密时无法解析的问题 fix: 修复ssr解析缺少Name属性的问题 fix: 修复ssr解析时没有解码参数的问题
This commit is contained in:
parent
1788541e04
commit
38dbea4a2a
@ -18,8 +18,8 @@ func BuildSub(clashType model.ClashType, query validator.SubQuery, template stri
|
|||||||
*model.Subscription, error,
|
*model.Subscription, error,
|
||||||
) {
|
) {
|
||||||
// 定义变量
|
// 定义变量
|
||||||
var temp *model.Subscription
|
var temp = &model.Subscription{}
|
||||||
var sub *model.Subscription
|
var sub = &model.Subscription{}
|
||||||
var err error
|
var err error
|
||||||
var templateBytes []byte
|
var templateBytes []byte
|
||||||
// 加载模板
|
// 加载模板
|
||||||
|
@ -14,6 +14,7 @@ func ParseShadowsocksR(proxy string) (model.Proxy, error) {
|
|||||||
return model.Proxy{}, fmt.Errorf("无效的 ssr Url")
|
return model.Proxy{}, fmt.Errorf("无效的 ssr Url")
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
proxy = strings.TrimPrefix(proxy, "ssr://")
|
||||||
if !strings.Contains(proxy, ":") {
|
if !strings.Contains(proxy, ":") {
|
||||||
proxy, err = DecodeBase64(strings.TrimPrefix(proxy, "ssr://"))
|
proxy, err = DecodeBase64(strings.TrimPrefix(proxy, "ssr://"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -21,7 +22,7 @@ func ParseShadowsocksR(proxy string) (model.Proxy, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 分割
|
// 分割
|
||||||
detailsAndParams := strings.SplitN(strings.TrimPrefix(proxy, "ssr://"), "/?", 2)
|
detailsAndParams := strings.SplitN(proxy, "/?", 2)
|
||||||
parts := strings.Split(detailsAndParams[0], ":")
|
parts := strings.Split(detailsAndParams[0], ":")
|
||||||
params, err := url.ParseQuery(detailsAndParams[1])
|
params, err := url.ParseQuery(detailsAndParams[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -32,7 +33,21 @@ func ParseShadowsocksR(proxy string) (model.Proxy, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return model.Proxy{}, err
|
return model.Proxy{}, err
|
||||||
}
|
}
|
||||||
|
var obfsParam string
|
||||||
|
var protoParam string
|
||||||
|
var remarks string
|
||||||
|
if params.Get("obfsparam") != "" {
|
||||||
|
obfsParam, err = DecodeBase64(params.Get("obfsparam"))
|
||||||
|
}
|
||||||
|
if params.Get("protoparam") != "" {
|
||||||
|
protoParam, err = DecodeBase64(params.Get("protoparam"))
|
||||||
|
}
|
||||||
|
if params.Get("remarks") != "" {
|
||||||
|
remarks, err = DecodeBase64(params.Get("remarks"))
|
||||||
|
}
|
||||||
|
|
||||||
result := model.Proxy{
|
result := model.Proxy{
|
||||||
|
Name: remarks,
|
||||||
Type: "ssr",
|
Type: "ssr",
|
||||||
Server: parts[0],
|
Server: parts[0],
|
||||||
Port: port,
|
Port: port,
|
||||||
@ -40,8 +55,13 @@ func ParseShadowsocksR(proxy string) (model.Proxy, error) {
|
|||||||
Cipher: parts[3],
|
Cipher: parts[3],
|
||||||
Obfs: parts[4],
|
Obfs: parts[4],
|
||||||
Password: parts[5],
|
Password: parts[5],
|
||||||
ObfsParam: params.Get("obfsparam"),
|
ObfsParam: obfsParam,
|
||||||
ProtocolParam: params.Get("protoparam"),
|
ProtocolParam: protoParam,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if result.Name == "" {
|
||||||
|
result.Name = result.Server
|
||||||
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user