fix: 处理 IPv6 地址 URI

This commit is contained in:
xream 2023-12-08 17:53:07 +08:00
parent 8918479b9e
commit 69726cd5c4
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 14 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.14.114", "version": "2.14.115",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -214,6 +214,12 @@ function safeMatch(parser, line) {
} }
function lastParse(proxy) { function lastParse(proxy) {
if (proxy.server) {
proxy.server = proxy.server
.trim()
.replace(/^\[/, '')
.replace(/\]$/, '');
}
if (proxy.type === 'trojan') { if (proxy.type === 'trojan') {
if (proxy.network === 'tcp') { if (proxy.network === 'tcp') {
delete proxy.network; delete proxy.network;

View File

@ -1,10 +1,14 @@
/* eslint-disable no-case-declarations */ /* eslint-disable no-case-declarations */
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import { isIPv6 } from '@/utils';
export default function URI_Producer() { export default function URI_Producer() {
const type = 'SINGLE'; const type = 'SINGLE';
const produce = (proxy) => { const produce = (proxy) => {
let result = ''; let result = '';
if (proxy.server && isIPv6(proxy.server)) {
proxy.server = `[${proxy.server}]`;
}
switch (proxy.type) { switch (proxy.type) {
case 'ss': case 'ss':
const userinfo = `${proxy.cipher}:${proxy.password}`; const userinfo = `${proxy.cipher}:${proxy.password}`;
@ -246,7 +250,9 @@ export default function URI_Producer() {
} }
if (proxy['tls-fingerprint']) { if (proxy['tls-fingerprint']) {
hysteria2params.push( hysteria2params.push(
`pinSHA256=${encodeURIComponent(proxy['tls-fingerprint'])}`, `pinSHA256=${encodeURIComponent(
proxy['tls-fingerprint'],
)}`,
); );
} }
if (proxy.tfo) { if (proxy.tfo) {