-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathnftsb.html
More file actions
293 lines (271 loc) · 8.7 KB
/
nftsb.html
File metadata and controls
293 lines (271 loc) · 8.7 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
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
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>NeoFit sing-box</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
<style>
*, *::before, *::after {
box-sizing: border-box;
}
body {
--bg: #1e1e1e;
--fg: #c9d1d9;
--border: #555;
--card: #282c34;
--btn: #444;
--btnfg: #fff;
margin: 0;
padding: 20px;
font-family: Arial, Helvetica, sans-serif;
background: var(--bg);
color: var(--fg);
}
h1 {
text-align: center;
margin: 0 0 24px;
}
.controls {
display: flex;
gap: 10px;
flex-wrap: wrap;
justify-content: center;
margin-bottom: 16px;
}
button {
background: var(--btn);
color: var(--btnfg);
border: none;
border-radius: 20px;
padding: 10px 16px;
cursor: pointer;
}
.interface-container {
border: 1px solid var(--border);
background: var(--card);
padding: 10px;
margin-bottom: 10px;
border-radius: 6px;
}
.interface-header {
display: flex;
gap: 8px;
align-items: center;
margin-bottom: 8px;
}
input[type="text"] {
width: 100%;
padding: 8px;
border: 1px solid var(--border);
border-radius: 4px;
background: var(--card);
color: var(--fg);
}
.link-field {
display: flex;
gap: 8px;
margin-bottom: 8px;
}
.config-display {
border: 1px solid var(--border);
background: var(--card);
padding: 10px;
border-radius: 6px;
max-height: 60vh;
overflow: auto;
}
#warnings {
color: #ff6b6b;
margin-top: 8px;
}
a {
color: inherit;
text-decoration: none;
}
.back-btn {
background: #555;
margin-bottom: 16px;
}
</style>
</head>
<body>
<div class="controls">
<button class="back-btn" onclick="location.href='/'">← Назад</button>
</div>
<h1>NeoFit sing-box</h1>
<div class="controls">
<button><a href="https://yoomoney.ru/to/410012481566554">на ☕️ Юмани</a></button>
<button><a href="https://www.tinkoff.ru/rm/seroshtanov.aleksey9/HgzXr74936">на ☕️Тинькофф</a></button>
<button onclick="addInterface()">🆕Добавить интерфейс</button>
<button onclick="generateConfig()">🆗Сгенерировать конфиг</button>
<button onclick="saveConfig()">🆙Сохранить на роутер</button>
</div>
<div id="warnings"></div>
<div id="interfacesContainer"></div>
<div id="configDisplay" class="config-display" style="display:none;">
<pre><code id="output" class="language-json"></code></pre>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<script>
let config = {}, interfaceCount = 0;
function addInterface() {
interfaceCount++;
const container = document.createElement('div');
container.className = 'interface-container';
container.id = 'interface-' + interfaceCount;
const header = document.createElement('div');
header.className = 'interface-header';
const delBtn = document.createElement('button');
delBtn.textContent = '🗑️';
delBtn.title = 'Удалить интерфейс';
delBtn.onclick = () => container.remove();
const nameInput = document.createElement('input');
nameInput.type = 'text';
nameInput.placeholder = 'Название интерфейса (например, Proxy0)';
nameInput.value = 'Proxy' + (interfaceCount - 1);
nameInput.maxLength = 20;
header.appendChild(delBtn);
header.appendChild(nameInput);
container.appendChild(header);
const linksContainer = document.createElement('div');
linksContainer.className = 'links-container';
container.appendChild(linksContainer);
document.getElementById('interfacesContainer').appendChild(container);
addLinkField(linksContainer);
}
function addLinkField(container) {
const row = document.createElement('div');
row.className = 'link-field';
const input = document.createElement('input');
input.type = 'text';
input.placeholder = 'vless://...';
row.appendChild(input);
container.appendChild(row);
}
function pickIndexFromName(name, fallbackIdx) {
const m = String(name || '').match(/(\d+)$/);
return m ? parseInt(m[1], 10) : fallbackIdx;
}
function parseVlessForSingbox(link) {
const m = link.match(/vless:\/\/([^@]+)@([^:]+):(\d+)(?:\/?\?([^#]*))?(?:#(.*))?/);
if (!m) return null;
const uuid = m[1], server = m[2], server_port = parseInt(m[3], 10);
const q = new URLSearchParams(m[4] || '');
const tag = decodeURIComponent(m[5] || '').trim() || ('vless-' + server + '-' + server_port);
const o = {
type: 'vless',
tag,
server,
server_port,
uuid,
packet_encoding: q.get('pe') || 'xudp'
};
const sec = q.get('security') || 'none';
if (sec === 'tls' || sec === 'reality') {
o.tls = {
enabled: true,
server_name: q.get('sni') || server,
insecure: false,
utls: {
enabled: true,
fingerprint: q.get('fp') || 'chrome'
}
};
if (sec === 'reality') {
o.tls.reality = {
enabled: true,
public_key: q.get('pbk') || '',
short_id: q.get('sid') || ''
};
}
}
const flow = q.get('flow');
if (flow) o.flow = flow;
return o;
}
function generateConfig() {
const cfg = {
experimental: {
cache_file: { enabled: true },
clash_api: {
external_controller: '0.0.0.0:9090',
external_ui: 'ui',
access_control_allow_private_network: true
}
},
log: { level: 'debug', timestamp: true },
inbounds: [],
outbounds: [],
route: { auto_detect_interface: false, rules: [], final: 'direct' }
};
const usedTags = new Set(), usedPorts = new Set();
const interfaces = document.querySelectorAll('.interface-container');
interfaces.forEach((ic, idx) => {
const rawName = (ic.querySelector('.interface-header input[type="text"]')?.value || '').trim();
const n = pickIndexFromName(rawName, idx);
const tagInbound = ('proxy' + n).toLowerCase();
let listen_port = 1081 + n;
while (usedPorts.has(listen_port)) listen_port++;
usedPorts.add(listen_port);
cfg.inbounds.push({
type: 'mixed',
tag: tagInbound,
listen: '0.0.0.0',
listen_port,
sniff: true,
sniff_override_destination: false
});
const links = ic.querySelectorAll('.links-container input[type="text"]');
for (const inp of links) {
const raw = (inp.value || '').trim();
if (!raw || !raw.startsWith('vless://')) continue;
const o = parseVlessForSingbox(raw);
if (!o) continue;
if (!usedTags.has(o.tag)) {
cfg.outbounds.push(o);
usedTags.add(o.tag);
}
cfg.route.rules.push({
inbound: [tagInbound],
action: 'route',
outbound: o.tag
});
break;
}
});
cfg.outbounds.push({ type: 'direct', tag: 'direct' });
cfg.outbounds.push({ type: 'block', tag: 'block' });
cfg.route.rules.unshift({
network: 'udp',
port: 443,
action: 'route',
outbound: 'block'
});
config = cfg;
const out = document.getElementById('output');
out.textContent = JSON.stringify(config, null, 2);
if (window.hljs) hljs.highlightElement(out);
document.getElementById('configDisplay').style.display = 'block';
}
function saveConfig() {
const warn = document.getElementById('warnings');
if (!config || !config.inbounds || !config.inbounds.length) {
warn.innerHTML = '❌Нет конфигурации для сохранения';
return;
}
fetch('/api/singbox', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(config, null, 2)
})
.then(r => r.json())
.then(d => alert(d.message || 'Готово'))
.catch(e => {
console.error(e);
alert('Ошибка при отправке конфига');
});
}
</script>
</body>
</html>