-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7841817
commit 74995d2
Showing
3 changed files
with
94 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
vless://[email protected]:2083?encryption=none&security=tls&type=ws&host=&path=/4TLoIulw/#xray.wefuckgfw.tk%3A2083 | ||
vless://[email protected]:2083?encryption=none&security=tls&type=ws&host=&path=/4TLoIulw/#xray.wefuckgfw.tk%3A2083 | ||
vless://[email protected]:2083?encryption=none&security=tls&type=ws&path=/4TLoIulw/#xray.wefuckgfw.tk%3A2083 | ||
|
||
trojan://[email protected]:443#trojan.wefuckgfw.tk%3A443 | ||
trojan://[email protected]:443#trojan.wefuckgfw.tk%3A443 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,39 +264,87 @@ func DoReplaceCDNIpSet(inputNode string, ipResult []string) ([]string, error) { | |
//vless协议 | ||
if strings.HasPrefix(sampleNode, vlessPre) { | ||
//vless: vless://[email protected]:539?type=tcp&security=tls&sni=b.a.tk&flow=xtls-rprx-direct#abc-vless-1 | ||
//vless://[email protected]:2083?encryption=none&security=tls&type=ws&host=&path=/4TLoIulw/#xray.wefuckgfw.tk%3A2083 | ||
re := regexp.MustCompile(`@(.*?):`) | ||
|
||
nodeHost := re.FindStringSubmatch(sampleNode)[1] | ||
|
||
if strings.Index(sampleNode, "host=") != -1 { | ||
re = regexp.MustCompile(`(host=)(.*?)(&)`) | ||
sampleNode = re.ReplaceAllString(sampleNode, "$1"+nodeHost+"$3") | ||
|
||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
subStrPart3 := re.FindStringSubmatch(sampleNode)[3] | ||
sampleNode = re.ReplaceAllString(sampleNode, subStrPart1+nodeHost+subStrPart3) | ||
} else { | ||
re = regexp.MustCompile(`(@)(.*?)(:)(.*?)(\?)`) | ||
sampleNode = re.ReplaceAllString(sampleNode, "$1$2$3$4$5host="+nodeHost+"&") | ||
var subStrPart5 string | ||
if strings.Contains(sampleNode, "?") { | ||
re = regexp.MustCompile(`(@)(.*?)(:)(.*?)(\?)`) | ||
subStrPart5 = re.FindStringSubmatch(sampleNode)[5] | ||
|
||
} else { | ||
re = regexp.MustCompile(`(@)(.*?)(:)(\d+)(.*?)`) | ||
subStrPart5 = re.FindStringSubmatch(sampleNode)[5] + "?" | ||
} | ||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
subStrPart2 := re.FindStringSubmatch(sampleNode)[2] | ||
|
||
subStrPart3 := re.FindStringSubmatch(sampleNode)[3] | ||
|
||
subStrPart4 := re.FindStringSubmatch(sampleNode)[4] | ||
|
||
//subStrPart5 := re.FindStringSubmatch(sampleNode)[5] | ||
sampleNode = re.ReplaceAllString(sampleNode, subStrPart1+subStrPart2+subStrPart3+subStrPart4+subStrPart5+"host="+nodeHost+"&") | ||
|
||
} | ||
|
||
for _, ip := range ipResult { | ||
re = regexp.MustCompile(`(@)(.*?)(:)`) | ||
nodes = append(nodes, re.ReplaceAllString(sampleNode, "$1"+ip+"$3")+"\n") | ||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
subStrPart3 := re.FindStringSubmatch(sampleNode)[3] | ||
nodes = append(nodes, re.ReplaceAllString(sampleNode, subStrPart1+ip+subStrPart3)+"\r") | ||
} | ||
return nodes, nil | ||
} | ||
if strings.HasPrefix(sampleNode, trojanPre) { | ||
//trojan trojan://[email protected]:48857?type=tcp&security=tls&sni=a.b.tk&flow=xtls-rprx-direct#a.b.tk-trojan-2 | ||
re := regexp.MustCompile(`@(.*?):`) | ||
|
||
nodeHost := re.FindStringSubmatch(sampleNode)[1] | ||
|
||
if strings.Index(sampleNode, "host=") != -1 { | ||
re = regexp.MustCompile(`(host=)(.*?)(&)`) | ||
sampleNode = re.ReplaceAllString(sampleNode, "$1"+nodeHost+"$3") | ||
|
||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
subStrPart3 := re.FindStringSubmatch(sampleNode)[3] | ||
sampleNode = re.ReplaceAllString(sampleNode, subStrPart1+nodeHost+subStrPart3) | ||
} else { | ||
re = regexp.MustCompile(`(@)(.*?)(:)(.*?)(\?)`) | ||
sampleNode = re.ReplaceAllString(sampleNode, "$1$2$3$4$5host="+nodeHost+"&") | ||
//是否有额外参数 | ||
var subStrPart5 string | ||
if strings.Contains(sampleNode, "?") { | ||
re = regexp.MustCompile(`(@)(.*?)(:)(.*?)(\?)`) | ||
subStrPart5 = re.FindStringSubmatch(sampleNode)[5] | ||
|
||
} else { | ||
re = regexp.MustCompile(`(@)(.*?)(:)(\d+)(.*?)`) | ||
subStrPart5 = re.FindStringSubmatch(sampleNode)[5] + "?" | ||
|
||
} | ||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
subStrPart2 := re.FindStringSubmatch(sampleNode)[2] | ||
|
||
subStrPart3 := re.FindStringSubmatch(sampleNode)[3] | ||
|
||
subStrPart4 := re.FindStringSubmatch(sampleNode)[4] | ||
//subStrPart5 := re.FindStringSubmatch(sampleNode)[5] | ||
|
||
sampleNode = re.ReplaceAllString(sampleNode, subStrPart1+subStrPart2+subStrPart3+subStrPart4+subStrPart5+"host="+nodeHost+"&") | ||
} | ||
|
||
for _, ip := range ipResult { | ||
re = regexp.MustCompile(`(@)(.*?)(:)`) | ||
nodes = append(nodes, re.ReplaceAllString(sampleNode, "$1"+ip+"$3")+"\n") | ||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
subStrPart3 := re.FindStringSubmatch(sampleNode)[3] | ||
nodes = append(nodes, re.ReplaceAllString(sampleNode, subStrPart1+ip+subStrPart3)+"\r") | ||
} | ||
return nodes, nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"proxy-node2more/config" | ||
"regexp" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
|
@@ -36,3 +39,37 @@ func TestCaculateNodesResult(t *testing.T) { | |
HandleError(err) | ||
println(result) | ||
} | ||
|
||
func TestTrojanLink(t *testing.T) { | ||
sampleNode := "trojan://[email protected]:80?security=tls&sni=ca1.trojanvh.xyz&type=tcp&headerType=none#org-org.org_Relay_-%F0%9F%87%A8%F0%9F%87%A6CA_36" | ||
re := regexp.MustCompile(`(@)(.*?)(:)(.*?)(\?)`) | ||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
fmt.Println(subStrPart1) | ||
|
||
} | ||
|
||
func TestTrojanLink2(t *testing.T) { | ||
sampleNode := "trojan://[email protected]:443#trojan.wefuckgfw.tk%3A443" | ||
var re *regexp.Regexp | ||
if strings.Contains(sampleNode, "?") { | ||
re := regexp.MustCompile(`(@)(.*?)(:)(.*?)(\?)`) | ||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
fmt.Println(subStrPart1) | ||
} else { | ||
re := regexp.MustCompile(`(@)(.*?)(:)(\d+)(.*?)`) | ||
subStrPart1 := re.FindStringSubmatch(sampleNode)[1] | ||
subStrPart2 := re.FindStringSubmatch(sampleNode)[2] | ||
subStrPart3 := re.FindStringSubmatch(sampleNode)[3] | ||
subStrPart4 := re.FindStringSubmatch(sampleNode)[4] | ||
subStrPart5 := re.FindStringSubmatch(sampleNode)[5] | ||
|
||
fmt.Println(subStrPart1) | ||
fmt.Println(subStrPart2) | ||
fmt.Println(subStrPart3) | ||
fmt.Println(subStrPart4) | ||
fmt.Println(subStrPart5) | ||
|
||
} | ||
println(re) | ||
|
||
} |