-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmain.go
More file actions
160 lines (143 loc) · 6.34 KB
/
main.go
File metadata and controls
160 lines (143 loc) · 6.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package main
import (
_ "embed"
"fmt"
"io"
"log"
"net/http"
"os"
"strings"
"github.com/hiddify/ray2sing/ray2sing"
"github.com/sagernet/sing-box/experimental/libbox"
_ "github.com/sagernet/sing-box/include"
)
var examples = map[string][]string{
"hysteria": {
"hysteria://host:443?protocol=udp&auth=123456&peer=sni.domain&insecure=1&upmbps=100&downmbps=100&alpn=hysteria&obfs=xplus&obfsParam=123456#remarks",
"hysteria://ip:999/?mport=6000-21000&insecure=1&auth=483f8ef7-8480-490d-92fb-1fc392fb34b6&upmbps=30&downmbps=70&alpn=h3",
},
"ssconf": {
"ssconf://s3.amazonaws.com/beedynconprd/ng4lf90ip01zstlyle4r0t56x1qli4cvmt2ws6nh0kdz1jpgzyedogxt3mpxfbxi.json#BeePass",
},
"reality": {
"vless://409f106a-b2f2-4416-b186-5429c9979cd9@54.38.144.4:2053?encryption=none&flow=&fp=chrome&pbk=SbVKOEMjK0sIlbwg4akyBg5mL5KZwwB-ed4eEE7YnRc&security=reality&serviceName=xyz&sid=&sni=discordapp.com&type=grpc#رایگان | REALITY | @EliV2ray | FR🇫🇷 | 0️⃣1️⃣",
},
"vless": {
"vless://25da296e-1d96-48ae-9867-4342796cd742@172.67.149.95:443?encryption=none&fp=chrome&host=vless.229feb8b52a0e7e117ea76f8b591bcb3.workers.dev&path=%2F%3Fed%3D2048&security=tls&sni=vless.229feb8b52a0e7e117ea76f8b591bcb3.workers.dev&type=ws#رایگان | VLESS | @Helix_Servers | US🇺🇸 | 0️⃣1️⃣",
"vless://25da296e-1d96-48ae-9867-4342796cd742@172.67.149.95:443?encryption=none&fp=chrome&host=vless.229feb8b52a0e7e117ea76f8b591bcb3.workers.dev&path=%2F%3Fed%3D2048&security=tls1sni=vless.229feb8b52a0e7e117ea76f8b591bcb3.workers.dev&type=ws&core=xray#رایگان | VLESS | @Helix_Servers | US🇺🇸 | 0️⃣1️⃣",
},
"vmess": {
"vmess://eyJhZGQiOiI1MS4xNjEuMTMwLjE3MyIsImFpZCI6IjAiLCJhbHBuIjoiIiwiZnAiOiIiLCJob3N0IjoiIiwiaWQiOiJkNDNlZTVlMy0xYjA3LTU2ZDctYjJlYS04ZDIyYzQ0ZmRjNjYiLCJuZXQiOiJ0Y3AiLCJwYXRoIjoiIiwicG9ydCI6IjgwODAiLCJzY3kiOiJjaGFjaGEyMC1wb2x5MTMwNSIsInNuaSI6IiIsInRscyI6IiIsInR5cGUiOiJub25lIiwidiI6IjIiLCJwcyI6Ilx1MDYzMVx1MDYyN1x1MDZjY1x1MDZhZlx1MDYyN1x1MDY0NiB8IFZNRVNTIHwgQFdhdGFzaGlfVlBOIHwgQVVcdWQ4M2NcdWRkZTZcdWQ4M2NcdWRkZmEgfCAwXHVmZTBmXHUyMGUzMVx1ZmUwZlx1MjBlMyJ9",
},
"ss": {
"ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTp0T3dPeXZsWGlZNUFUSkFVT3BYTlBO@5.35.34.107:55990#%D8%B1%D8%A7%DB%8C%DA%AF%D8%A7%D9%86+%7C+SS+%7C+%40iP_CF+%7C+RU%F0%9F%87%B7%F0%9F%87%BA+%7C+0%EF%B8%8F%E2%83%A31%EF%B8%8F%E2%83%A3",
},
"tuic": {
"tuic://3618921b-adeb-4bd3-a2a0-f98b72a674b1:dongtaiwang@108.181.24.7:23450?allow_insecure=1&alpn=h3&congestion_control=bbr&sni=www.google.com&udp_relay_mode=native#رایگان | TUIC | @V2rayCollector | CA🇨🇦 | 0️⃣1️⃣",
},
"hy2": {
"hysteria2://letmein@example.com/?insecure=1&obfs=salamander&obfs-password=gawrgura&pinSHA256=deadbeef&sni=real.example.com",
},
"ssh": {
"ssh://user:pass@server:22/?pk=pk&hk=hk",
},
"trojan": {
"trojan://your_password@aws-ar-buenosaires-1.f1cflineb.com:443?host=aws-ar-buenosaires-1.f1cflineb.com&path=%2Ff1rocket&security=tls&sni=aws-ar-buenosaires-1.f1cflineb.com&type=ws#رایگان | TROJAN | @VmessProtocol | RELAY🚩 | 0️⃣1️⃣",
},
"wg": {
"wg://[server]:222/?pk=[private_key]&local_address=10.0.0.2/24&peer_pk=[peer_public_key]&pre_shared_key=[pre_shared_key]&workers=[workers]&mtu=[mtu]&reserved=0,0,0",
"wg://server.com:5319?publicKey=verypublicKeyss&privateKey=veryprivatekey&presharedKey=verysharedkey&ip=10.0.0.1&mtu=1380&keepalive=30&udp=1&reserved=0,0,0&ifp=5-10#direct%20WireGuard",
},
"warp": {
"#profile-title: Hiddify WARP\nwarp://p1@auto#Local -> warp://p2@auto#Remote",
"warp://key@host:1234/#WARPkey",
"warp://engage.cloudflareclient.com:2408#WARPnoKey",
"warp://key@engage.cloudflareclient.com:2408/?ifp=5-10#WARPparam",
"warp://auto/#WARP_auto",
},
"chain": {
"warp://auto&&detour=warp://auto",
"vless://409f106a-b2f2-4416-b186-5429c9979cd9@54.38.144.4:2053?encryption=none&flow=&fp=chrome&pbk=SbVKOEMjK0sIlbwg4akyBg5mL5KZwwB-ed4eEE7YnRc&security=reality&serviceName=xyz&sid=&sni=discordapp.com&type=grpc#رایگان | REALITY | @EliV2ray | FR🇫🇷 | 0️⃣1️⃣&&detour=tuic://3618921b-adeb-4bd3-a2a0-f98b72a674b1:dongtaiwang@108.181.24.7:23450?allow_insecure=1&alpn=h3&congestion_control=bbr&sni=www.google.com&udp_relay_mode=native#رایگان | TUIC | @V2rayCollector | CA🇨🇦 | 0️⃣1️⃣",
},
"socks": {
"socks://a:b@c:80?v=4",
},
"http": {
"phttp://a:b@c:80/?path=ssss",
"phttps://a:b@c:80/?path=ssss&sni=d&insecure=1",
},
"direct": {
"direct://?fragment=tlshello,1-2,1-4#Fragment",
"xdirect://?fragment=tlshello,1-2,1-4#Fragment",
},
"awg": {`
[Interface]
PrivateKey = private=
Jc = 1
Jmin = 1
Jmax = 2
S1 = 0
S2 = 0
S3 = 0
S4 = 0
Address = 10.20.33.158/32
DNS = 10.20.128.1
[Peer]
PublicKey = pub=
AllowedIPs = 0.0.0.0/0
Endpoint = 81.24.100.226:8080
PersistentKeepalive = 15
`},
"awg2": {
"awg://W0ludGVyZmFjZV0KUHJpdmF0ZUtleSA9IG1BVEVmbDVRUWJwZFliZWNFa0lSSnRCZHhMcEtZSSt0bmdvN3pNRUtqWDA9CkpjID0gMQpKbWluID0gMQpKbWF4ID0gMgpTMSA9IDAKUzIgPSAwClMzID0gMApTNCA9IDAKQWRkcmVzcyA9IDEwLjIwLjMzLjE1OC8zMgpETlMgPSAxMC4yMC4xMjguMQoKW1BlZXJdClB1YmxpY0tleSA9IDVGOGUzNWdaUUxzeG1kd1JLWldERFN3Uzh5RTZKMTZPUFd0Z09uSE4xVUk9CkFsbG93ZWRJUHMgPSAwLjAuMC4wLzAKRW5kcG9pbnQgPSAxODEuMjE0LjEwMC4yMjY6ODA4MApQZXJzaXN0ZW50S2VlcGFsaXZlID0gMTUK",
},
"wg2": {
`
[Interface]
PrivateKey = PK=
Address = 10.20.33.158/32
DNS = 10.20.128.1
[Peer]
PublicKey = pub=
AllowedIPs = 0.0.0.0/0
Endpoint = 8.1.10.26:8080
PersistentKeepalive = 15
`},
}
func main() {
// Replace "path/to/your/config/file" with the actual path to your config file
var configs string
if len(os.Args) > 1 {
if len(examples[os.Args[1]]) != 0 {
configs = strings.Join(examples[os.Args[1]], "\n")
fmt.Printf("%s\n", configs)
} else {
configs = strings.Join(os.Args[1:], "\n")
}
} else {
configs = read()
}
clash_conf, err := ray2sing.Ray2Singbox(libbox.BaseContext(nil), configs, false)
if err != nil {
log.Fatalf("Failed to parse config: %v", err)
}
fmt.Printf("Parsed config: \n%+v\n", string(clash_conf))
fmt.Printf("==============\n===========\n=============")
}
func read() string {
url := "https://raw.githubusercontent.com/ImMyron/V2ray/main/V2ray.txt"
resp, err := http.Get(url)
if err != nil {
fmt.Println("Error fetching URL content:", err)
return ""
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return ""
}
fmt.Println("URL Content:")
fmt.Println(string(body))
return string(body)
}