Skip to content

Commit

Permalink
chore: 端口号允许为 0
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Feb 3, 2024
1 parent 395c6e4 commit b19b49d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.205",
"version": "2.14.206",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
24 changes: 12 additions & 12 deletions backend/src/core/proxy-utils/producers/sing-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const httpParser = (proxy = {}) => {
server_port: parseInt(`${proxy.port}`, 10),
tls: { enabled: false, server_name: proxy.server, insecure: false },
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy.username) parsedProxy.username = proxy.username;
if (proxy.password) parsedProxy.password = proxy.password;
Expand All @@ -252,7 +252,7 @@ const socks5Parser = (proxy = {}) => {
password: proxy.password,
version: '5',
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy.username) parsedProxy.username = proxy.username;
if (proxy.password) parsedProxy.password = proxy.password;
Expand Down Expand Up @@ -287,7 +287,7 @@ const shadowTLSParser = (proxy = {}) => {
},
},
};
if (stPart.server_port < 1 || stPart.server_port > 65535)
if (stPart.server_port < 0 || stPart.server_port > 65535)
throw '端口值非法';
if (proxy['fast-open'] === true) stPart.udp_fragment = true;
tfoParser(proxy, stPart);
Expand All @@ -303,7 +303,7 @@ const ssParser = (proxy = {}) => {
method: proxy.cipher,
password: proxy.password,
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy.uot) parsedProxy.udp_over_tcp = true;
if (proxy['udp-over-tcp']) parsedProxy.udp_over_tcp = true;
Expand Down Expand Up @@ -379,7 +379,7 @@ const ssrParser = (proxy = {}) => {
obfs: proxy.obfs,
protocol: proxy.protocol,
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy['obfs-param']) parsedProxy.obfs_param = proxy['obfs-param'];
if (proxy['protocol-param'] && proxy['protocol-param'] !== '')
Expand Down Expand Up @@ -412,7 +412,7 @@ const vmessParser = (proxy = {}) => {
].indexOf(parsedProxy.security) === -1
)
parsedProxy.security = 'auto';
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy.xudp) parsedProxy.packet_encoding = 'xudp';
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
Expand All @@ -436,7 +436,7 @@ const vlessParser = (proxy = {}) => {
uuid: proxy.uuid,
tls: { enabled: false, server_name: proxy.server, insecure: false },
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
if (proxy.flow === 'xtls-rprx-vision') parsedProxy.flow = proxy.flow;
Expand All @@ -457,7 +457,7 @@ const trojanParser = (proxy = {}) => {
password: proxy.password,
tls: { enabled: true, server_name: proxy.server, insecure: false },
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
if (proxy.network === 'grpc') grpcParser(proxy, parsedProxy);
Expand All @@ -477,7 +477,7 @@ const hysteriaParser = (proxy = {}) => {
disable_mtu_discovery: false,
tls: { enabled: true, server_name: proxy.server, insecure: false },
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy.auth_str) parsedProxy.auth_str = `${proxy.auth_str}`;
if (proxy['auth-str']) parsedProxy.auth_str = `${proxy['auth-str']}`;
Expand Down Expand Up @@ -524,7 +524,7 @@ const hysteria2Parser = (proxy = {}) => {
obfs: {},
tls: { enabled: true, server_name: proxy.server, insecure: false },
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
Expand All @@ -547,7 +547,7 @@ const tuic5Parser = (proxy = {}) => {
password: proxy.password,
tls: { enabled: true, server_name: proxy.server, insecure: false },
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
if (
Expand Down Expand Up @@ -583,7 +583,7 @@ const wireguardParser = (proxy = {}) => {
pre_shared_key: proxy['pre-shared-key'],
reserved: [],
};
if (parsedProxy.server_port < 1 || parsedProxy.server_port > 65535)
if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
throw 'invalid port';
if (proxy['fast-open']) parsedProxy.udp_fragment = true;
if (typeof proxy.reserved === 'string') {
Expand Down

0 comments on commit b19b49d

Please sign in to comment.