-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
421 lines (377 loc) · 13 KB
/
index.html
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<!DOCTYPE html>
<html lang="en">
<!-- v6.0.2 -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link id="favicon" rel="shortcut icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAACXBIWXMAAAB2AAAAdgFOeyYIAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAHtQTFRF1wA4tgAssQAy2gA42wA3sQAssQAssQAssgAtrgAs2gA3rgAsrgAsswAtuQAvumN3uwAvvAAvwwAxxAAxywAz0QA11QA21gA21wA22QA32gA32gE42gI538/O39DO41R241V241Z353uU53yU532U8uTh8+Lg8+Ph9O7pqtzwrgAAAAx0Uk5TICMkvL3DxMXG+fn6epd/sQAAAHlJREFUGBkFwUFuAjEMAMCJ7WURJ279/xerSkDIxp0Z8nwC9vu7vlk/d4BxNHXzGPsFOFfFU2YCxDGC1QtAKl4ASAXEYTZCAcepJwgAoBUwuxdsBfQELrUDwGPsP/EGIHNumZ0DkJ/fvsa9xi0y9LXnZo6oYwDouf4B/zQuUnii1xAAAAAASUVORK5CYII=">
<title>Random Config</title>
<style>
/* Reset and Box Model */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Root Variables */
:root {
--bg: #fff;
--text: #212121;
--header: #000;
--link: #3b73e6;
--code: #e6e6e6;
--border: #e8e8e8;
--input-bg: #f4f4f4;
--link-hover: #0056b3;
}
@media only screen and (prefers-color-scheme: dark) {
body:not([data-theme='light']) {
--bg: #1a1a1a;
--text: #f4f4f4;
--header: #f4f4f4;
--link: #7aaeff;
--code: #3b3b3b;
--border: #3b3b3b;
--input-bg: #2a2a2a;
}
}
[data-theme='dark'] {
--bg: #1a1a1a;
--text: #f4f4f4;
--header: #f4f4f4;
--link: #7aaeff;
--code: #3b3b3b;
--border: #3b3b3b;
--input-bg: #2a2a2a;
}
/* Body Styles */
body {
background-color: var(--bg);
color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
line-height: 1.6;
text-align: center;
margin: 50px auto;
}
/* Container */
.container {
background-color: var(--bg);
border-radius: 10px;
padding: 30px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
max-width: 800px;
margin: auto;
}
/* Text Elements */
h1, h2, h3, h4, h5, h6 {
color: var(--header);
margin-bottom: 1rem;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.6rem; }
h4 { font-size: 1.4rem; }
h5 { font-size: 1.2rem; }
h6 { font-size: 1rem; }
/* Links */
a {
color: var(--link);
text-decoration: none;
transition: color 0.3s;
}
a:hover {
color: var(--link-hover);
text-decoration: underline;
}
/* Form Elements */
input, textarea, select {
font-family: inherit;
background-color: var(--input-bg);
border: 1px solid var(--border);
border-radius: 4px;
padding: 0.5rem;
margin-bottom: 1rem;
color: var(--text);
width: calc(100% - 20px);
transition: border-color 0.3s;
}
textarea {
height: 400px;
resize: none;
overflow-y: auto;
}
button, input[type="text"], input[type="password"], input[type="email"], textarea {
font-size: 0.9rem;
}
input:focus, textarea:focus {
outline: none;
border-color: var(--link);
box-shadow: 0 0 0 2px rgba(59, 115, 230, 0.1);
}
button, [type='submit'], [type='button'], [type='reset'] {
font-family: inherit;
background-color: var(--link);
color: var(--bg);
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
transition: background-color 0.3s, transform 0.2s;
margin: 5px;
}
button:hover {
background-color: var(--link-hover);
transform: translateY(-2px); /* Slight lift effect */
}
/* Miscellaneous */
hr {
border: 1px solid var(--border);
margin: 20px 0;
}
progress {
display: block;
width: 100%;
margin-bottom: 1rem;
}
/* Scrollbar Styles for Textarea */
textarea::-webkit-scrollbar {
width: 8px;
}
textarea::-webkit-scrollbar-track {
background: var(--input-bg);
border-radius: 5px;
}
textarea::-webkit-scrollbar-thumb {
background: var(--link);
border-radius: 5px;
}
textarea::-webkit-scrollbar-thumb:hover {
background: var(--link-hover);
}
/* Utility Classes */
.small { font-size: 0.9rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.padding { padding: 1rem; }
[hidden] {
display: none;
}
</style>
</head>
<body>
<div class="container">
<h1><a href="https://github.com/GFW4Fun/xray_bulk_config_with_random_cdn_ip_range">🔗Bulk Config With Random IP Range</a></h1>
<div>
<input type="text" id="inputConfig" placeholder="Enter a config of warp/wireguard/vmess/vless/tuic/trojan/ss/ssr/hysteria/hy2..." />
</div>
<label>CIDR IP Ranges (Default Cloudflare Range):</label>
<textarea id="ipranges" placeholder="Enter CIDR ranges here...">173.245.48.0/20
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22
141.101.64.0/18
108.162.192.0/18
190.93.240.0/20
188.114.96.0/20
197.234.240.0/22
198.41.128.0/17
162.158.0.0/15
104.16.0.0/13
104.24.0.0/14
172.64.0.0/13
131.0.72.0/22</textarea>
<textarea id="result" placeholder="Result..." readonly></textarea>
<input type="range" min="100" max="1000000" step="100" id="outputCount" value="2000" oninput="updateOutputCountValue()">
<button id="generateButton" onclick="pickRandomIPs()">⚙️Generate Random Config (2000)</button>
<button id="copyToClipboard" onclick="copyToClipboard()">📋Copy Result to Clipboard</button>
<hr>
<h4>Paste > V2rayN > Ctrl+A > Ctrl+R > Sort by result!</h4>
</div>
<script>
// Base64 encoding with UTF-8 support
function base64Encode(str) {
const utf8String = unescape(encodeURIComponent(str));
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
let output = '';
let buffer = 0;
let bitsAccumulated = 0;
for (let i = 0; i < utf8String.length; i++) {
buffer = (buffer << 8) | utf8String.charCodeAt(i);
bitsAccumulated += 8;
while (bitsAccumulated >= 6) {
output += chars[(buffer >> (bitsAccumulated - 6)) & 0x3F];
bitsAccumulated -= 6;
}
}
if (bitsAccumulated > 0) {output += chars[(buffer << (6 - bitsAccumulated)) & 0x3F];}
while (output.length % 4) {output += '=';}
return output;
}
// Base64 decoding with UTF-8 support
function base64Decode(str) {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
let output = '';
let buffer = 0;
let bitsAccumulated = 0;
for (let i = 0; i < str.length; i++) {
if (str[i] === '=') break;
buffer = (buffer << 6) | chars.indexOf(str[i]);
bitsAccumulated += 6;
while (bitsAccumulated >= 8) {
output += String.fromCharCode((buffer >> (bitsAccumulated - 8)) & 0xFF);
bitsAccumulated -= 8;
}
}
return decodeURIComponent(escape(output));
}
function updateOutputCountValue() {
const count = document.getElementById('outputCount').value;
document.getElementById('generateButton').innerText = `⚙️Generate Random Config (${count})`;
}
// Update the detectConfigType function
function detectConfigType(inputConfig) {
const regex = /^(vmess|ss|vless|wireguard|trojan|tuic|hysteria|hy2|ssr|warp):\/\//;
const match = inputConfig.match(regex);
return match ? match[1] : 'unknown';
}
// Update the replaceIPInConfig function
function replaceIPInConfig(inputConfig, ipOrAddress) {
const configType = detectConfigType(inputConfig);
const addressStr = ipOrAddress.toString();
let result = '';
const regexPatterns = {
vmess: /^vmess:\/\/(.*)/,
ss: /^(ss:\/\/[^@]+@)[^:]+(:.+)$/,
vless: /^(vless:\/\/[^@]+)@([^:]+)(:.+)$/,
wireguard: /^(wireguard:\/\/[^@]+@)[^:]+(:.+)$/,
trojan: /^(trojan:\/\/[^@]+@)[^:]+(:.+)$/,
tuic: /^(tuic:\/\/[^@]+@)[^:]+(:.+)$/,
hysteria: /^(hysteria:\/\/)([^:]+):(\d+)(\?.*?)(#.*)?$/,
hy2: /^(hy2:\/\/[^@]+@)[^:]+(:.+)$/,
ssr: /^(ssr:\/\/)(.*)/,
warp: /^(warp:\/\/)([^:]+)(:\d+)(.*)/
};
switch (configType) {
case 'vmess':
const vmessMatch = inputConfig.match(regexPatterns.vmess);
if (vmessMatch) {
const vmessConfig = JSON.parse(base64Decode(vmessMatch[1])); // Decode base64
vmessConfig.add = addressStr; // Replace IP address in "add"
result = `vmess://${base64Encode(JSON.stringify(vmessConfig))}\n\n`; // Encode back to base64
}
break;
case 'ss':
const ssMatch = inputConfig.match(regexPatterns.ss);
if (ssMatch) {
result = `${ssMatch[1]}${addressStr}${ssMatch[2]}\n\n`;
}
break;
case 'vless':
const vlessMatch = inputConfig.match(regexPatterns.vless);
if (vlessMatch) {
result = `${vlessMatch[1]}@${addressStr}${vlessMatch[3]}\n\n`;
}
break;
case 'wireguard':
const wireguardMatch = inputConfig.match(regexPatterns.wireguard);
if (wireguardMatch) {
result = `${wireguardMatch[1]}${addressStr}${wireguardMatch[2]}\n\n`;
}
break;
case 'trojan':
const trojanMatch = inputConfig.match(regexPatterns.trojan);
if (trojanMatch) {
result = `${trojanMatch[1]}${addressStr}${trojanMatch[2]}\n\n`;
}
break;
case 'tuic':
const tuicMatch = inputConfig.match(regexPatterns.tuic);
if (tuicMatch) {
result = `${tuicMatch[1]}${addressStr}${tuicMatch[2]}\n\n`;
}
break;
case 'hysteria':
const hysteriaMatch = inputConfig.match(regexPatterns.hysteria);
if (hysteriaMatch) {
result = `${hysteriaMatch[1]}${addressStr}:${hysteriaMatch[3]}${hysteriaMatch[4] || ''}${hysteriaMatch[5] || ''}\n\n`;
}
break;
case 'hy2':
const hy2Match = inputConfig.match(regexPatterns.hy2);
if (hy2Match) {
result = `${hy2Match[1]}${addressStr}${hy2Match[2]}\n\n`;
}
break;
case 'ssr':
const ssrMatch = inputConfig.match(regexPatterns.ssr);
if (ssrMatch) {
const ssrConfig = base64Decode(ssrMatch[2]); // Decode base64
const ssrParts = ssrConfig.split(':');
ssrParts[0] = addressStr; // Replace IP address in first part
result = `ssr://${base64Encode(ssrParts.join(':'))}\n\n`; // Encode back to base64
}
break;
case 'warp':
const warpMatch = inputConfig.match(regexPatterns.warp);
if (warpMatch) {
result = `${warpMatch[1]}${addressStr}${warpMatch[3]}${warpMatch[4] || ''}\n\n`;
}
break;
default:
result = inputConfig;
break;
}
return result;
}
function cidrToRange(cidr) {
const [base, mask] = cidr.split('/');
const baseParts = base.split('.').map(Number);
const max = Math.pow(2, 32 - mask);
const start = (baseParts[0] << 24) | (baseParts[1] << 16) | (baseParts[2] << 8) | baseParts[3];
return [start, start + max - 1];
}
function getRandomIPFromCIDR(cidr) {
const [start, end] = cidrToRange(cidr);
const randomIP = Math.floor(Math.random() * (end - start + 1)) + start;
return convertIPToString(randomIP);
}
function convertIPToString(ip) {
return [
(ip >>> 24) & 255,
(ip >>> 16) & 255,
(ip >>> 8) & 255,
ip & 255
].join('.');
}
function pickRandomIPs() {
const count = parseInt(document.getElementById('outputCount').value);
const resultTextarea = document.getElementById('result');
const inputConfig = document.getElementById('inputConfig').value.trim();
const cidrListText = document.getElementById('ipranges').value;
const cidrList = cidrListText.split('\n').filter(line => line.trim() !== '');
if (detectConfigType(inputConfig) === 'unknown' || cidrList.length === 0) {
alert("No/bad config/range!\nEnter valid config/range.");
return;
}
let results = new Set();
while (results.size < count) {
const randomCIDR = cidrList[Math.floor(Math.random() * cidrList.length)];
const newIP = getRandomIPFromCIDR(randomCIDR);
results.add(replaceIPInConfig(inputConfig, newIP));
}
resultTextarea.value = Array.from(results).join('');
}
function copyToClipboard() {
const copyText = document.getElementById("result");
if (copyText.value.length !== 0) {
copyText.select();
document.execCommand("copy");
alert("Copied the result!");
} else {
alert("Result is empty!");
}
}
</script>
</body>
</html>