mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-11-30 08:28:10 +00:00
Refactored proxy producers structure
This commit is contained in:
1 parent
8fe2280232
commit
ea00b2458c
9 files changed
+420
-414
No files matched your search
+3
-3
@@ -6,11 +6,11 @@
|
||||
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
|
||||
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
||||
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
|
||||
* @updated: 2022/6/16 14:23:56
|
||||
* @version: 2.0.1
|
||||
* @updated: 2022/6/16 14:37:15
|
||||
* @version: 2.0.2
|
||||
* @author: Peng-YM
|
||||
* @github: https://github.com/Peng-YM/Sub-Store
|
||||
* @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46
|
||||
*/
|
||||
|
||||
!function(){var createModuleFactory=function(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}},_$buffer_2=createModuleFactory((function(t,e){(function(t){(function(){"use strict";e.Buffer=r,e.SlowBuffer=function(t){return+t!=t&&(t=0),r.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=r.prototype,e}function r(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return n(t,e,r)}function n(e,n,o){if("string"==typeof e)return function(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=0|s(e,n),u=t(o),i=u.write(e,n);return i!==o&&(u=u.slice(0,i)),u}(e,n);if(ArrayBuffer.isView(e))return i(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(B(e,ArrayBuffer)||e&&B(e.buffer,ArrayBuffer))return function(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n)).__proto__=r.prototype,o}(e,n,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var u=e.valueOf&&e.valueOf();if(null!=u&&u!==e)return r.from(u,n,o);var c=function(e){if(r.isBuffer(e)){var n=0|a(e.length),o=t(n);return 0===o.length||e.copy(o,0,0,n),o}return void 0!==e.length?"number"!=typeof e.length||T(e.length)?t(0):i(e):"Buffer"===e.type&&Array.isArray(e.data)?i(e.data):void 0}(e);if(c)return c;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return r.from(e[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function o(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(e){return o(e),t(e<0?0:0|a(e))}function i(e){for(var r=e.length<0?0:0|a(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function a(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function s(t,e){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||B(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var u=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return L(t).length;default:if(u)return o?-1:D(t).length;e=(""+e).toLowerCase(),u=!0}}function c(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function l(t,e,n,o,u){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),T(n=+n)&&(n=u?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(u)return-1;n=t.length-1}else if(n<0){if(!u)return-1;n=0}if("string"==typeof e&&(e=r.from(e,o)),r.isBuffer(e))return 0===e.length?-1:p(t,e,n,o,u);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?u?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):p(t,[e],n,o,u);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,o){var u,i=1,a=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;i=2,a/=2,s/=2,r/=2}function c(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o){var l=-1;for(u=r;u<a;u++)if(c(t,u)===c(e,-1===l?0:u-l)){if(-1===l&&(l=u),u-l+1===s)return l*i}else-1!==l&&(u-=u-l),l=-1}else for(r+s>a&&(r=a-s),u=r;u>=0;u--){for(var p=!0,f=0;f<s;f++)if(c(t,u+f)!==c(e,f)){p=!1;break}if(p)return u}return-1}function f(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var u=e.length;n>u/2&&(n=u/2);for(var i=0;i<n;++i){var a=parseInt(e.substr(2*i,2),16);if(T(a))return i;t[r+i]=a}return i}function h(t,e,r,n){return P(D(e,t.length-r),t,r,n)}function _(t,e,r,n){return P(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function d(t,e,r,n){return _(t,e,r,n)}function y(t,e,r,n){return P(L(e),t,r,n)}function g(t,e,r,n){return P(function(t,e){for(var r,n,o,u=[],i=0;i<t.length&&!((e-=2)<0);++i)n=(r=t.charCodeAt(i))>>8Line truncated
|
||||
!function(){var createModuleFactory=function(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}},_$buffer_2=createModuleFactory((function(t,e){(function(t){(function(){"use strict";e.Buffer=r,e.SlowBuffer=function(t){return+t!=t&&(t=0),r.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=r.prototype,e}function r(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return n(t,e,r)}function n(e,n,o){if("string"==typeof e)return function(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=0|s(e,n),u=t(o),i=u.write(e,n);return i!==o&&(u=u.slice(0,i)),u}(e,n);if(ArrayBuffer.isView(e))return i(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(B(e,ArrayBuffer)||e&&B(e.buffer,ArrayBuffer))return function(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n)).__proto__=r.prototype,o}(e,n,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var u=e.valueOf&&e.valueOf();if(null!=u&&u!==e)return r.from(u,n,o);var c=function(e){if(r.isBuffer(e)){var n=0|a(e.length),o=t(n);return 0===o.length||e.copy(o,0,0,n),o}return void 0!==e.length?"number"!=typeof e.length||T(e.length)?t(0):i(e):"Buffer"===e.type&&Array.isArray(e.data)?i(e.data):void 0}(e);if(c)return c;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return r.from(e[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function o(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(e){return o(e),t(e<0?0:0|a(e))}function i(e){for(var r=e.length<0?0:0|a(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function a(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function s(t,e){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||B(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var u=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return L(t).length;default:if(u)return o?-1:D(t).length;e=(""+e).toLowerCase(),u=!0}}function c(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function l(t,e,n,o,u){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),T(n=+n)&&(n=u?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(u)return-1;n=t.length-1}else if(n<0){if(!u)return-1;n=0}if("string"==typeof e&&(e=r.from(e,o)),r.isBuffer(e))return 0===e.length?-1:p(t,e,n,o,u);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?u?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):p(t,[e],n,o,u);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,o){var u,i=1,a=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;i=2,a/=2,s/=2,r/=2}function c(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(o){var l=-1;for(u=r;u<a;u++)if(c(t,u)===c(e,-1===l?0:u-l)){if(-1===l&&(l=u),u-l+1===s)return l*i}else-1!==l&&(u-=u-l),l=-1}else for(r+s>a&&(r=a-s),u=r;u>=0;u--){for(var p=!0,f=0;f<s;f++)if(c(t,u+f)!==c(e,f)){p=!1;break}if(p)return u}return-1}function f(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var u=e.length;n>u/2&&(n=u/2);for(var i=0;i<n;++i){var a=parseInt(e.substr(2*i,2),16);if(T(a))return i;t[r+i]=a}return i}function h(t,e,r,n){return P(D(e,t.length-r),t,r,n)}function _(t,e,r,n){return P(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function d(t,e,r,n){return _(t,e,r,n)}function y(t,e,r,n){return P(L(e),t,r,n)}function g(t,e,r,n){return P(function(t,e){for(var r,n,o,u=[],i=0;i<t.length&&!((e-=2)<0);++i)n=(r=t.charCodeAt(i))>>8Line truncated
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.2",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
export default function Clash_Producer() {
|
||||
const type = 'ALL';
|
||||
const produce = (proxies) => {
|
||||
return (
|
||||
'proxies:\n' +
|
||||
proxies
|
||||
.map((proxy) => {
|
||||
delete proxy.supported;
|
||||
return ' - ' + JSON.stringify(proxy) + '\n';
|
||||
})
|
||||
.join('')
|
||||
);
|
||||
};
|
||||
return { type, produce };
|
||||
}
|
||||
@@ -1,410 +1,8 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
function QX_Producer() {
|
||||
const targetPlatform = 'QX';
|
||||
const produce = (proxy) => {
|
||||
let obfs_opts;
|
||||
let tls_opts;
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
obfs_opts = '';
|
||||
if (proxy.plugin === 'obfs') {
|
||||
const { host, mode } = proxy['plugin-opts'];
|
||||
obfs_opts = `,obfs=${mode}${
|
||||
host ? ',obfs-host=' + host : ''
|
||||
}`;
|
||||
}
|
||||
if (proxy.plugin === 'v2ray-plugin') {
|
||||
const { tls, host, path } = proxy['plugin-opts'];
|
||||
obfs_opts = `,obfs=${tls ? 'wss' : 'ws'}${
|
||||
host ? ',obfs-host=' + host : ''
|
||||
}${path ? ',obfs-uri=' + path : ''}`;
|
||||
}
|
||||
return `shadowsocks=${proxy.server}:${proxy.port},method=${
|
||||
proxy.cipher
|
||||
},password=${proxy.password}${obfs_opts}${
|
||||
proxy.tfo ? ',fast-open=true' : ',fast-open=false'
|
||||
}${proxy.udp ? ',udp-relay=true' : ',udp-relay=false'},tag=${
|
||||
proxy.name
|
||||
}`;
|
||||
case 'ssr':
|
||||
return `shadowsocks=${proxy.server}:${proxy.port},method=${
|
||||
proxy.cipher
|
||||
},password=${proxy.password},ssr-protocol=${proxy.protocol}${
|
||||
proxy['protocol-param']
|
||||
? ',ssr-protocol-param=' + proxy['protocol-param']
|
||||
: ''
|
||||
}${proxy.obfs ? ',obfs=' + proxy.obfs : ''}${
|
||||
proxy['obfs-param']
|
||||
? ',obfs-host=' + proxy['obfs-param']
|
||||
: ''
|
||||
},fast-open=${proxy.tfo || false}${
|
||||
proxy.udp ? ',udp-relay=true' : ',udp-relay=false'
|
||||
},tag=${proxy.name}`;
|
||||
case 'vmess':
|
||||
obfs_opts = '';
|
||||
if (proxy.network === 'ws') {
|
||||
// websocket
|
||||
if (proxy.tls) {
|
||||
// ws-tls
|
||||
obfs_opts = `,obfs=wss${
|
||||
proxy.sni ? ',obfs-host=' + proxy.sni : ''
|
||||
}${
|
||||
proxy['ws-opts'].path
|
||||
? ',obfs-uri=' + proxy['ws-opts'].path
|
||||
: ''
|
||||
},tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
}`;
|
||||
} else {
|
||||
// ws
|
||||
obfs_opts = `,obfs=ws${
|
||||
proxy['ws-opts'].headers.Host
|
||||
? ',obfs-host=' + proxy['ws-opts'].headers.Host
|
||||
: ''
|
||||
}${
|
||||
proxy['ws-opts'].path
|
||||
? ',obfs-uri=' + proxy['ws-opts'].path
|
||||
: ''
|
||||
}`;
|
||||
}
|
||||
} else {
|
||||
// tcp
|
||||
if (proxy.tls) {
|
||||
obfs_opts = `,obfs=over-tls${
|
||||
proxy.sni ? ',obfs-host=' + proxy.sni : ''
|
||||
},tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
}`;
|
||||
}
|
||||
}
|
||||
let result = `vmess=${proxy.server}:${proxy.port},method=${
|
||||
proxy.cipher === 'auto' ? 'none' : proxy.cipher
|
||||
},password=${proxy.uuid}${obfs_opts},fast-open=${
|
||||
proxy.tfo || false
|
||||
}${proxy.udp ? ',udp-relay=true' : ',udp-relay=false'}`;
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== 'undefined') {
|
||||
result += `,aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
result += `,tag=${proxy.name}`;
|
||||
return result;
|
||||
case 'trojan':
|
||||
return `trojan=${proxy.server}:${proxy.port},password=${
|
||||
proxy.password
|
||||
}${
|
||||
proxy.sni ? ',tls-host=' + proxy.sni : ''
|
||||
},over-tls=true,tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
},fast-open=${proxy.tfo || false}${
|
||||
proxy.udp ? ',udp-relay=true' : ',udp-relay=false'
|
||||
},tag=${proxy.name}`;
|
||||
case 'http':
|
||||
tls_opts = '';
|
||||
if (proxy.tls) {
|
||||
tls_opts = `,over-tls=true,tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
}${proxy.sni ? ',tls-host=' + proxy.sni : ''}`;
|
||||
}
|
||||
return `http=${proxy.server}:${proxy.port},username=${
|
||||
proxy.username
|
||||
},password=${proxy.password}${tls_opts},fast-open=${
|
||||
proxy.tfo || false
|
||||
},tag=${proxy.name}`;
|
||||
}
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
|
||||
);
|
||||
};
|
||||
return { produce };
|
||||
}
|
||||
|
||||
function Loon_Producer() {
|
||||
const targetPlatform = 'Loon';
|
||||
const produce = (proxy) => {
|
||||
let obfs_opts = '',
|
||||
tls_opts = '',
|
||||
udp_opts = '',
|
||||
tfo_opts = '';
|
||||
if (typeof proxy.udp !== 'undefined') {
|
||||
udp_opts = proxy.udp ? ',udp=true' : ',udp=false';
|
||||
}
|
||||
tfo_opts = `,fast-open=${proxy.tfo || false}`;
|
||||
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
obfs_opts = ',,';
|
||||
if (proxy.plugin) {
|
||||
if (proxy.plugin === 'obfs') {
|
||||
const { mode, host } = proxy['plugin-opts'];
|
||||
obfs_opts = `,${mode},${host || ''}`;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support obfs option: ${proxy.obfs}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return `${proxy.name}=shadowsocks,${proxy.server},${proxy.port},${proxy.cipher},"${proxy.password}"${obfs_opts}${udp_opts}${tfo_opts}`;
|
||||
case 'ssr':
|
||||
return `${proxy.name}=shadowsocksr,${proxy.server},${
|
||||
proxy.port
|
||||
},${proxy.cipher},"${proxy.password}",${proxy.protocol},{${
|
||||
proxy['protocol-param'] || ''
|
||||
}},${proxy.obfs},{${
|
||||
proxy['obfs-param'] || ''
|
||||
}}${udp_opts}${tfo_opts}`;
|
||||
case 'vmess':
|
||||
obfs_opts = '';
|
||||
if (proxy.network === 'ws') {
|
||||
const host = proxy['ws-opts'].headers.Host || proxy.server;
|
||||
obfs_opts = `,transport:ws,host:${host},path:${
|
||||
proxy['ws-opts'].path || '/'
|
||||
}`;
|
||||
} else {
|
||||
obfs_opts = `,transport:tcp`;
|
||||
}
|
||||
if (proxy.tls) {
|
||||
obfs_opts += `${
|
||||
proxy.sni ? ',tls-name:' + proxy.sni : ''
|
||||
},skip-cert-verify:${proxy['skip-cert-verify'] || 'false'}`;
|
||||
}
|
||||
let result = `${proxy.name}=vmess,${proxy.server},${
|
||||
proxy.port
|
||||
},${proxy.cipher === 'auto' ? 'none' : proxy.cipher},"${
|
||||
proxy.uuid
|
||||
}",over-tls:${proxy.tls || 'false'}${obfs_opts}`;
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== 'undefined') {
|
||||
result += `,vmess-aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
return result;
|
||||
case 'trojan':
|
||||
return `${proxy.name}=trojan,${proxy.server},${proxy.port},"${
|
||||
proxy.password
|
||||
}"${
|
||||
proxy.sni ? ',tls-name:' + proxy.sni : ''
|
||||
},skip-cert-verify:${
|
||||
proxy['skip-cert-verify'] || 'false'
|
||||
}${udp_opts}`;
|
||||
case 'http':
|
||||
tls_opts = '';
|
||||
const base = `${proxy.name}=${proxy.tls ? 'http' : 'https'},${
|
||||
proxy.server
|
||||
},${proxy.port},${proxy.username || ''},${
|
||||
proxy.password || ''
|
||||
}`;
|
||||
if (proxy.tls) {
|
||||
// https
|
||||
tls_opts = `${
|
||||
proxy.sni ? ',tls-name:' + proxy.sni : ''
|
||||
},skip-cert-verify:${proxy['skip-cert-verify']}`;
|
||||
return base + tls_opts;
|
||||
} else return base;
|
||||
}
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
|
||||
);
|
||||
};
|
||||
return { produce };
|
||||
}
|
||||
|
||||
function Surge_Producer() {
|
||||
const targetPlatform = 'Surge';
|
||||
const produce = (proxy) => {
|
||||
let result = '';
|
||||
let obfs_opts, tls_opts;
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
obfs_opts = '';
|
||||
if (proxy.plugin) {
|
||||
const { host, mode } = proxy['plugin-opts'];
|
||||
if (proxy.plugin === 'obfs') {
|
||||
obfs_opts = `,obfs=${mode}${
|
||||
host ? ',obfs-host=' + host : ''
|
||||
}`;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support obfs option: ${proxy.obfs}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
result = `${proxy.name}=ss,${proxy.server}, ${
|
||||
proxy.port
|
||||
},encrypt-method=${proxy.cipher},password=${
|
||||
proxy.password
|
||||
}${obfs_opts},tfo=${proxy.tfo || 'false'},udp-relay=${
|
||||
proxy.udp || 'false'
|
||||
}`;
|
||||
break;
|
||||
case 'vmess':
|
||||
tls_opts = '';
|
||||
result = `${proxy.name}=vmess,${proxy.server},${
|
||||
proxy.port
|
||||
},username=${proxy.uuid},tls=${proxy.tls || 'false'},tfo=${
|
||||
proxy.tfo || 'false'
|
||||
}`;
|
||||
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== 'undefined') {
|
||||
result += `,vmess-aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
if (proxy.network === 'ws') {
|
||||
const path = proxy['ws-opts'].path || '/';
|
||||
const wsHeaders = Object.entries(proxy['ws-opts'].headers)
|
||||
.map(([key, value]) => `${key}:"${value}"`)
|
||||
.join('|');
|
||||
result += `,ws=true${path ? ',ws-path=' + path : ''}${
|
||||
wsHeaders ? ',ws-headers=' + wsHeaders : ''
|
||||
}`;
|
||||
}
|
||||
if (proxy.tls) {
|
||||
result += `${
|
||||
typeof proxy['skip-cert-verify'] !== 'undefined'
|
||||
? ',skip-cert-verify=' + proxy['skip-cert-verify']
|
||||
: ''
|
||||
}`;
|
||||
result += proxy.sni ? `,sni=${proxy.sni}` : '';
|
||||
}
|
||||
break;
|
||||
case 'trojan':
|
||||
result = `${proxy.name}=trojan,${proxy.server},${
|
||||
proxy.port
|
||||
},password=${proxy.password}${
|
||||
typeof proxy['skip-cert-verify'] !== 'undefined'
|
||||
? ',skip-cert-verify=' + proxy['skip-cert-verify']
|
||||
: ''
|
||||
}${proxy.sni ? ',sni=' + proxy.sni : ''},tfo=${
|
||||
proxy.tfo || 'false'
|
||||
},udp-relay=${proxy.udp || 'false'}`;
|
||||
break;
|
||||
case 'http':
|
||||
if (proxy.tls) {
|
||||
tls_opts = `,skip-cert-verify=${proxy['skip-cert-verify']},sni=${proxy.sni}`;
|
||||
}
|
||||
result = `${proxy.name}=${proxy.tls ? 'https' : 'http'},${
|
||||
proxy.server
|
||||
},${proxy.port}${
|
||||
proxy.username ? ',username=' + proxy.username : ''
|
||||
}${
|
||||
proxy.password ? ',password=' + proxy.password : ''
|
||||
}${tls_opts},tfo=${proxy.tfo || 'false'}`;
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
|
||||
);
|
||||
}
|
||||
|
||||
// handle surge hybrid param
|
||||
result +=
|
||||
proxy['surge-hybrid'] !== undefined
|
||||
? `,hybrid=${proxy['surge-hybrid']}`
|
||||
: '';
|
||||
return result;
|
||||
};
|
||||
return { produce };
|
||||
}
|
||||
|
||||
function Clash_Producer() {
|
||||
const type = 'ALL';
|
||||
const produce = (proxies) => {
|
||||
return (
|
||||
'proxies:\n' +
|
||||
proxies
|
||||
.map((proxy) => {
|
||||
delete proxy.supported;
|
||||
return ' - ' + JSON.stringify(proxy) + '\n';
|
||||
})
|
||||
.join('')
|
||||
);
|
||||
};
|
||||
return { type, produce };
|
||||
}
|
||||
|
||||
function URI_Producer() {
|
||||
const type = 'SINGLE';
|
||||
const produce = (proxy) => {
|
||||
let result = '';
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
||||
result = `ss://${Base64.encode(userinfo)}@${proxy.server}:${
|
||||
proxy.port
|
||||
}/`;
|
||||
if (proxy.plugin) {
|
||||
result += '?plugin=';
|
||||
const opts = proxy['plugin-opts'];
|
||||
switch (proxy.plugin) {
|
||||
case 'obfs':
|
||||
result += encodeURIComponent(
|
||||
`simple-obfs;obfs=${opts.mode}${
|
||||
opts.host ? ';obfs-host=' + opts.host : ''
|
||||
}`,
|
||||
);
|
||||
break;
|
||||
case 'v2ray-plugin':
|
||||
result += encodeURIComponent(
|
||||
`v2ray-plugin;obfs=${opts.mode}${
|
||||
opts.host ? ';obfs-host' + opts.host : ''
|
||||
}${opts.tls ? ';tls' : ''}`,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Unsupported plugin option: ${proxy.plugin}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
result += `#${encodeURIComponent(proxy.name)}`;
|
||||
break;
|
||||
case 'ssr':
|
||||
result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${
|
||||
proxy.cipher
|
||||
}:${proxy.obfs}:${Base64.encode(proxy.password)}/`;
|
||||
result += `?remarks=${Base64.encode(proxy.name)}${
|
||||
proxy['obfs-param']
|
||||
? '&obfsparam=' + Base64.encode(proxy['obfs-param'])
|
||||
: ''
|
||||
}${
|
||||
proxy['protocol-param']
|
||||
? '&protocolparam=' +
|
||||
Base64.encode(proxy['protocol-param'])
|
||||
: ''
|
||||
}`;
|
||||
result = 'ssr://' + Base64.encode(result);
|
||||
break;
|
||||
case 'vmess':
|
||||
// V2RayN URI format
|
||||
result = {
|
||||
ps: proxy.name,
|
||||
add: proxy.server,
|
||||
port: proxy.port,
|
||||
id: proxy.uuid,
|
||||
type: '',
|
||||
aid: 0,
|
||||
net: proxy.network || 'tcp',
|
||||
tls: proxy.tls ? 'tls' : '',
|
||||
};
|
||||
// obfs
|
||||
if (proxy.network === 'ws') {
|
||||
result.path = proxy['ws-opts'].path || '/';
|
||||
result.host = proxy['ws-opts'].headers.Host || proxy.server;
|
||||
}
|
||||
result = 'vmess://' + Base64.encode(JSON.stringify(result));
|
||||
break;
|
||||
case 'trojan':
|
||||
result = `trojan://${proxy.password}@${proxy.server}:${
|
||||
proxy.port
|
||||
}#${encodeURIComponent(proxy.name)}`;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Cannot handle proxy type: ${proxy.type}`);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
return { type, produce };
|
||||
}
|
||||
import Surge_Producer from './surge';
|
||||
import Clash_Producer from './clash';
|
||||
import Loon_Producer from './loon';
|
||||
import URI_Producer from './uri';
|
||||
import QX_Producer from './qx';
|
||||
|
||||
function JSON_Producer() {
|
||||
const type = 'ALL';
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
|
||||
export default function Loon_Producer() {
|
||||
const targetPlatform = 'Loon';
|
||||
const produce = (proxy) => {
|
||||
let obfs_opts = '',
|
||||
tls_opts = '',
|
||||
udp_opts = '',
|
||||
tfo_opts = '';
|
||||
if (typeof proxy.udp !== 'undefined') {
|
||||
udp_opts = proxy.udp ? ',udp=true' : ',udp=false';
|
||||
}
|
||||
tfo_opts = `,fast-open=${proxy.tfo || false}`;
|
||||
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
obfs_opts = ',,';
|
||||
if (proxy.plugin) {
|
||||
if (proxy.plugin === 'obfs') {
|
||||
const { mode, host } = proxy['plugin-opts'];
|
||||
obfs_opts = `,${mode},${host || ''}`;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support obfs option: ${proxy.obfs}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return `${proxy.name}=shadowsocks,${proxy.server},${proxy.port},${proxy.cipher},"${proxy.password}"${obfs_opts}${udp_opts}${tfo_opts}`;
|
||||
case 'ssr':
|
||||
return `${proxy.name}=shadowsocksr,${proxy.server},${
|
||||
proxy.port
|
||||
},${proxy.cipher},"${proxy.password}",${proxy.protocol},{${
|
||||
proxy['protocol-param'] || ''
|
||||
}},${proxy.obfs},{${
|
||||
proxy['obfs-param'] || ''
|
||||
}}${udp_opts}${tfo_opts}`;
|
||||
case 'vmess':
|
||||
obfs_opts = '';
|
||||
if (proxy.network === 'ws') {
|
||||
const host = proxy['ws-opts'].headers.Host || proxy.server;
|
||||
obfs_opts = `,transport:ws,host:${host},path:${
|
||||
proxy['ws-opts'].path || '/'
|
||||
}`;
|
||||
} else {
|
||||
obfs_opts = `,transport:tcp`;
|
||||
}
|
||||
if (proxy.tls) {
|
||||
obfs_opts += `${
|
||||
proxy.sni ? ',tls-name:' + proxy.sni : ''
|
||||
},skip-cert-verify:${proxy['skip-cert-verify'] || 'false'}`;
|
||||
}
|
||||
let result = `${proxy.name}=vmess,${proxy.server},${
|
||||
proxy.port
|
||||
},${proxy.cipher === 'auto' ? 'none' : proxy.cipher},"${
|
||||
proxy.uuid
|
||||
}",over-tls:${proxy.tls || 'false'}${obfs_opts}`;
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== 'undefined') {
|
||||
result += `,vmess-aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
return result;
|
||||
case 'trojan':
|
||||
return `${proxy.name}=trojan,${proxy.server},${proxy.port},"${
|
||||
proxy.password
|
||||
}"${
|
||||
proxy.sni ? ',tls-name:' + proxy.sni : ''
|
||||
},skip-cert-verify:${
|
||||
proxy['skip-cert-verify'] || 'false'
|
||||
}${udp_opts}`;
|
||||
case 'http':
|
||||
tls_opts = '';
|
||||
const base = `${proxy.name}=${proxy.tls ? 'http' : 'https'},${
|
||||
proxy.server
|
||||
},${proxy.port},${proxy.username || ''},${
|
||||
proxy.password || ''
|
||||
}`;
|
||||
if (proxy.tls) {
|
||||
// https
|
||||
tls_opts = `${
|
||||
proxy.sni ? ',tls-name:' + proxy.sni : ''
|
||||
},skip-cert-verify:${proxy['skip-cert-verify']}`;
|
||||
return base + tls_opts;
|
||||
} else return base;
|
||||
}
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
|
||||
);
|
||||
};
|
||||
return { produce };
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
export default function QX_Producer() {
|
||||
const targetPlatform = 'QX';
|
||||
const produce = (proxy) => {
|
||||
let obfs_opts;
|
||||
let tls_opts;
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
obfs_opts = '';
|
||||
if (proxy.plugin === 'obfs') {
|
||||
const { host, mode } = proxy['plugin-opts'];
|
||||
obfs_opts = `,obfs=${mode}${
|
||||
host ? ',obfs-host=' + host : ''
|
||||
}`;
|
||||
}
|
||||
if (proxy.plugin === 'v2ray-plugin') {
|
||||
const { tls, host, path } = proxy['plugin-opts'];
|
||||
obfs_opts = `,obfs=${tls ? 'wss' : 'ws'}${
|
||||
host ? ',obfs-host=' + host : ''
|
||||
}${path ? ',obfs-uri=' + path : ''}`;
|
||||
}
|
||||
return `shadowsocks=${proxy.server}:${proxy.port},method=${
|
||||
proxy.cipher
|
||||
},password=${proxy.password}${obfs_opts}${
|
||||
proxy.tfo ? ',fast-open=true' : ',fast-open=false'
|
||||
}${proxy.udp ? ',udp-relay=true' : ',udp-relay=false'},tag=${
|
||||
proxy.name
|
||||
}`;
|
||||
case 'ssr':
|
||||
return `shadowsocks=${proxy.server}:${proxy.port},method=${
|
||||
proxy.cipher
|
||||
},password=${proxy.password},ssr-protocol=${proxy.protocol}${
|
||||
proxy['protocol-param']
|
||||
? ',ssr-protocol-param=' + proxy['protocol-param']
|
||||
: ''
|
||||
}${proxy.obfs ? ',obfs=' + proxy.obfs : ''}${
|
||||
proxy['obfs-param']
|
||||
? ',obfs-host=' + proxy['obfs-param']
|
||||
: ''
|
||||
},fast-open=${proxy.tfo || false}${
|
||||
proxy.udp ? ',udp-relay=true' : ',udp-relay=false'
|
||||
},tag=${proxy.name}`;
|
||||
case 'vmess':
|
||||
obfs_opts = '';
|
||||
if (proxy.network === 'ws') {
|
||||
// websocket
|
||||
if (proxy.tls) {
|
||||
// ws-tls
|
||||
obfs_opts = `,obfs=wss${
|
||||
proxy.sni ? ',obfs-host=' + proxy.sni : ''
|
||||
}${
|
||||
proxy['ws-opts'].path
|
||||
? ',obfs-uri=' + proxy['ws-opts'].path
|
||||
: ''
|
||||
},tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
}`;
|
||||
} else {
|
||||
// ws
|
||||
obfs_opts = `,obfs=ws${
|
||||
proxy['ws-opts'].headers.Host
|
||||
? ',obfs-host=' + proxy['ws-opts'].headers.Host
|
||||
: ''
|
||||
}${
|
||||
proxy['ws-opts'].path
|
||||
? ',obfs-uri=' + proxy['ws-opts'].path
|
||||
: ''
|
||||
}`;
|
||||
}
|
||||
} else {
|
||||
// tcp
|
||||
if (proxy.tls) {
|
||||
obfs_opts = `,obfs=over-tls${
|
||||
proxy.sni ? ',obfs-host=' + proxy.sni : ''
|
||||
},tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
}`;
|
||||
}
|
||||
}
|
||||
let result = `vmess=${proxy.server}:${proxy.port},method=${
|
||||
proxy.cipher === 'auto' ? 'none' : proxy.cipher
|
||||
},password=${proxy.uuid}${obfs_opts},fast-open=${
|
||||
proxy.tfo || false
|
||||
}${proxy.udp ? ',udp-relay=true' : ',udp-relay=false'}`;
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== 'undefined') {
|
||||
result += `,aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
result += `,tag=${proxy.name}`;
|
||||
return result;
|
||||
case 'trojan':
|
||||
return `trojan=${proxy.server}:${proxy.port},password=${
|
||||
proxy.password
|
||||
}${
|
||||
proxy.sni ? ',tls-host=' + proxy.sni : ''
|
||||
},over-tls=true,tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
},fast-open=${proxy.tfo || false}${
|
||||
proxy.udp ? ',udp-relay=true' : ',udp-relay=false'
|
||||
},tag=${proxy.name}`;
|
||||
case 'http':
|
||||
tls_opts = '';
|
||||
if (proxy.tls) {
|
||||
tls_opts = `,over-tls=true,tls-verification=${
|
||||
proxy['skip-cert-verify'] ? 'false' : 'true'
|
||||
}${proxy.sni ? ',tls-host=' + proxy.sni : ''}`;
|
||||
}
|
||||
return `http=${proxy.server}:${proxy.port},username=${
|
||||
proxy.username
|
||||
},password=${proxy.password}${tls_opts},fast-open=${
|
||||
proxy.tfo || false
|
||||
},tag=${proxy.name}`;
|
||||
}
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
|
||||
);
|
||||
};
|
||||
return { produce };
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
|
||||
export default function Surge_Producer() {
|
||||
const targetPlatform = 'Surge';
|
||||
const produce = (proxy) => {
|
||||
let result = '';
|
||||
let obfs_opts, tls_opts;
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
obfs_opts = '';
|
||||
if (proxy.plugin) {
|
||||
const { host, mode } = proxy['plugin-opts'];
|
||||
if (proxy.plugin === 'obfs') {
|
||||
obfs_opts = `,obfs=${mode}${
|
||||
host ? ',obfs-host=' + host : ''
|
||||
}`;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support obfs option: ${proxy.obfs}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
result = `${proxy.name}=ss,${proxy.server}, ${
|
||||
proxy.port
|
||||
},encrypt-method=${proxy.cipher},password=${
|
||||
proxy.password
|
||||
}${obfs_opts},tfo=${proxy.tfo || 'false'},udp-relay=${
|
||||
proxy.udp || 'false'
|
||||
}`;
|
||||
break;
|
||||
case 'vmess':
|
||||
tls_opts = '';
|
||||
result = `${proxy.name}=vmess,${proxy.server},${
|
||||
proxy.port
|
||||
},username=${proxy.uuid},tls=${proxy.tls || 'false'},tfo=${
|
||||
proxy.tfo || 'false'
|
||||
}`;
|
||||
|
||||
if (proxy.alterId === 0) proxy['vmess-aead'] = true;
|
||||
if (typeof proxy['vmess-aead'] !== 'undefined') {
|
||||
result += `,vmess-aead=${proxy['vmess-aead']}`;
|
||||
}
|
||||
if (proxy.network === 'ws') {
|
||||
const path = proxy['ws-opts'].path || '/';
|
||||
const wsHeaders = Object.entries(proxy['ws-opts'].headers)
|
||||
.map(([key, value]) => `${key}:"${value}"`)
|
||||
.join('|');
|
||||
result += `,ws=true${path ? ',ws-path=' + path : ''}${
|
||||
wsHeaders ? ',ws-headers=' + wsHeaders : ''
|
||||
}`;
|
||||
}
|
||||
if (proxy.tls) {
|
||||
result += `${
|
||||
typeof proxy['skip-cert-verify'] !== 'undefined'
|
||||
? ',skip-cert-verify=' + proxy['skip-cert-verify']
|
||||
: ''
|
||||
}`;
|
||||
result += proxy.sni ? `,sni=${proxy.sni}` : '';
|
||||
}
|
||||
break;
|
||||
case 'trojan':
|
||||
result = `${proxy.name}=trojan,${proxy.server},${
|
||||
proxy.port
|
||||
},password=${proxy.password}${
|
||||
typeof proxy['skip-cert-verify'] !== 'undefined'
|
||||
? ',skip-cert-verify=' + proxy['skip-cert-verify']
|
||||
: ''
|
||||
}${proxy.sni ? ',sni=' + proxy.sni : ''},tfo=${
|
||||
proxy.tfo || 'false'
|
||||
},udp-relay=${proxy.udp || 'false'}`;
|
||||
break;
|
||||
case 'http':
|
||||
if (proxy.tls) {
|
||||
tls_opts = `,skip-cert-verify=${proxy['skip-cert-verify']},sni=${proxy.sni}`;
|
||||
}
|
||||
result = `${proxy.name}=${proxy.tls ? 'https' : 'http'},${
|
||||
proxy.server
|
||||
},${proxy.port}${
|
||||
proxy.username ? ',username=' + proxy.username : ''
|
||||
}${
|
||||
proxy.password ? ',password=' + proxy.password : ''
|
||||
}${tls_opts},tfo=${proxy.tfo || 'false'}`;
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Platform ${targetPlatform} does not support proxy type: ${proxy.type}`,
|
||||
);
|
||||
}
|
||||
|
||||
// handle surge hybrid param
|
||||
result +=
|
||||
proxy['surge-hybrid'] !== undefined
|
||||
? `,hybrid=${proxy['surge-hybrid']}`
|
||||
: '';
|
||||
return result;
|
||||
};
|
||||
return { produce };
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/* eslint-disable no-case-declarations */
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
export default function URI_Producer() {
|
||||
const type = 'SINGLE';
|
||||
const produce = (proxy) => {
|
||||
let result = '';
|
||||
switch (proxy.type) {
|
||||
case 'ss':
|
||||
const userinfo = `${proxy.cipher}:${proxy.password}`;
|
||||
result = `ss://${Base64.encode(userinfo)}@${proxy.server}:${
|
||||
proxy.port
|
||||
}/`;
|
||||
if (proxy.plugin) {
|
||||
result += '?plugin=';
|
||||
const opts = proxy['plugin-opts'];
|
||||
switch (proxy.plugin) {
|
||||
case 'obfs':
|
||||
result += encodeURIComponent(
|
||||
`simple-obfs;obfs=${opts.mode}${
|
||||
opts.host ? ';obfs-host=' + opts.host : ''
|
||||
}`,
|
||||
);
|
||||
break;
|
||||
case 'v2ray-plugin':
|
||||
result += encodeURIComponent(
|
||||
`v2ray-plugin;obfs=${opts.mode}${
|
||||
opts.host ? ';obfs-host' + opts.host : ''
|
||||
}${opts.tls ? ';tls' : ''}`,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Unsupported plugin option: ${proxy.plugin}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
result += `#${encodeURIComponent(proxy.name)}`;
|
||||
break;
|
||||
case 'ssr':
|
||||
result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${
|
||||
proxy.cipher
|
||||
}:${proxy.obfs}:${Base64.encode(proxy.password)}/`;
|
||||
result += `?remarks=${Base64.encode(proxy.name)}${
|
||||
proxy['obfs-param']
|
||||
? '&obfsparam=' + Base64.encode(proxy['obfs-param'])
|
||||
: ''
|
||||
}${
|
||||
proxy['protocol-param']
|
||||
? '&protocolparam=' +
|
||||
Base64.encode(proxy['protocol-param'])
|
||||
: ''
|
||||
}`;
|
||||
result = 'ssr://' + Base64.encode(result);
|
||||
break;
|
||||
case 'vmess':
|
||||
// V2RayN URI format
|
||||
result = {
|
||||
ps: proxy.name,
|
||||
add: proxy.server,
|
||||
port: proxy.port,
|
||||
id: proxy.uuid,
|
||||
type: '',
|
||||
aid: 0,
|
||||
net: proxy.network || 'tcp',
|
||||
tls: proxy.tls ? 'tls' : '',
|
||||
};
|
||||
// obfs
|
||||
if (proxy.network === 'ws') {
|
||||
result.path = proxy['ws-opts'].path || '/';
|
||||
result.host = proxy['ws-opts'].headers.Host || proxy.server;
|
||||
}
|
||||
result = 'vmess://' + Base64.encode(JSON.stringify(result));
|
||||
break;
|
||||
case 'trojan':
|
||||
result = `trojan://${proxy.password}@${proxy.server}:${
|
||||
proxy.port
|
||||
}#${encodeURIComponent(proxy.name)}`;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Cannot handle proxy type: ${proxy.type}`);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
return { type, produce };
|
||||
}
|
||||
Vendored
+3
-3
@@ -6,11 +6,11 @@
|
||||
* ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗
|
||||
* ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
||||
* Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket!
|
||||
* @updated: 2022/6/16 14:23:56
|
||||
* @version: 2.0.1
|
||||
* @updated: 2022/6/16 14:37:15
|
||||
* @version: 2.0.2
|
||||
* @author: Peng-YM
|
||||
* @github: https://github.com/Peng-YM/Sub-Store
|
||||
* @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46
|
||||
*/
|
||||
|
||||
!function(){var createModuleFactory=function(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}},_$buffer_2=createModuleFactory((function(t,e){(function(t){(function(){"use strict";e.Buffer=r,e.SlowBuffer=function(t){return+t!=t&&(t=0),r.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=r.prototype,e}function r(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return n(t,e,r)}function n(e,n,o){if("string"==typeof e)return function(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=0|s(e,n),a=t(o),u=a.write(e,n);return u!==o&&(a=a.slice(0,u)),a}(e,n);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return function(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n)).__proto__=r.prototype,o}(e,n,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var a=e.valueOf&&e.valueOf();if(null!=a&&a!==e)return r.from(a,n,o);var c=function(e){if(r.isBuffer(e)){var n=0|i(e.length),o=t(n);return 0===o.length||e.copy(o,0,0,n),o}return void 0!==e.length?"number"!=typeof e.length||k(e.length)?t(0):u(e):"Buffer"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(c)return c;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return r.from(e[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function o(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(e){return o(e),t(e<0?0:0|i(e))}function u(e){for(var r=e.length<0?0:0|i(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function i(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function s(t,e){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var a=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return P(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return T(t).length;default:if(a)return o?-1:P(t).length;e=(""+e).toLowerCase(),a=!0}}function c(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function l(t,e,n,o,a){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),k(n=+n)&&(n=a?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(a)return-1;n=t.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof e&&(e=r.from(e,o)),r.isBuffer(e))return 0===e.length?-1:p(t,e,n,o,a);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):p(t,[e],n,o,a);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,o){var a,u=1,i=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;u=2,i/=2,s/=2,r/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var l=-1;for(a=r;a<i;a++)if(c(t,a)===c(e,-1===l?0:a-l)){if(-1===l&&(l=a),a-l+1===s)return l*u}else-1!==l&&(a-=a-l),l=-1}else for(r+s>i&&(r=i-s),a=r;a>=0;a--){for(var p=!0,f=0;f<s;f++)if(c(t,a+f)!==c(e,f)){p=!1;break}if(p)return a}return-1}function f(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var a=e.length;n>a/2&&(n=a/2);for(var u=0;u<n;++u){var i=parseInt(e.substr(2*u,2),16);if(k(i))return u;t[r+u]=i}return u}function _(t,e,r,n){return R(P(e,t.length-r),t,r,n)}function h(t,e,r,n){return R(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function d(t,e,r,n){return h(t,e,r,n)}function y(t,e,r,n){return R(T(e),t,r,n)}function v(t,e,r,n){return R(function(t,e){for(var r,n,o,a=[],u=0;u<t.length&&!((e-=2)<0);++u)n=(r=t.charCodeAt(u))>>8Line truncated
|
||||
!function(){var createModuleFactory=function(t){var e;return function(r){return e||t(e={exports:{},parent:r},e.exports),e.exports}},_$buffer_2=createModuleFactory((function(t,e){(function(t){(function(){"use strict";e.Buffer=r,e.SlowBuffer=function(t){return+t!=t&&(t=0),r.alloc(+t)},e.INSPECT_MAX_BYTES=50;function t(t){if(t>2147483647)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=r.prototype,e}function r(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return n(t,e,r)}function n(e,n,o){if("string"==typeof e)return function(e,n){if("string"==typeof n&&""!==n||(n="utf8"),!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=0|s(e,n),a=t(o),u=a.write(e,n);return u!==o&&(a=a.slice(0,u)),a}(e,n);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return function(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return(o=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n)).__proto__=r.prototype,o}(e,n,o);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var a=e.valueOf&&e.valueOf();if(null!=a&&a!==e)return r.from(a,n,o);var c=function(e){if(r.isBuffer(e)){var n=0|i(e.length),o=t(n);return 0===o.length||e.copy(o,0,0,n),o}return void 0!==e.length?"number"!=typeof e.length||k(e.length)?t(0):u(e):"Buffer"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(c)return c;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return r.from(e[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function o(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(e){return o(e),t(e<0?0:0|i(e))}function u(e){for(var r=e.length<0?0:0|i(e.length),n=t(r),o=0;o<r;o+=1)n[o]=255&e[o];return n}function i(t){if(t>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|t}function s(t,e){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||j(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===n)return 0;for(var a=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return P(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return R(t).length;default:if(a)return o?-1:P(t).length;e=(""+e).toLowerCase(),a=!0}}function c(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function l(t,e,n,o,a){if(0===t.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),k(n=+n)&&(n=a?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(a)return-1;n=t.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof e&&(e=r.from(e,o)),r.isBuffer(e))return 0===e.length?-1:p(t,e,n,o,a);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):p(t,[e],n,o,a);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,o){var a,u=1,i=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;u=2,i/=2,s/=2,r/=2}function c(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var l=-1;for(a=r;a<i;a++)if(c(t,a)===c(e,-1===l?0:a-l)){if(-1===l&&(l=a),a-l+1===s)return l*u}else-1!==l&&(a-=a-l),l=-1}else for(r+s>i&&(r=i-s),a=r;a>=0;a--){for(var p=!0,f=0;f<s;f++)if(c(t,a+f)!==c(e,f)){p=!1;break}if(p)return a}return-1}function f(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var a=e.length;n>a/2&&(n=a/2);for(var u=0;u<n;++u){var i=parseInt(e.substr(2*u,2),16);if(k(i))return u;t[r+u]=i}return u}function _(t,e,r,n){return T(P(e,t.length-r),t,r,n)}function h(t,e,r,n){return T(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function d(t,e,r,n){return h(t,e,r,n)}function y(t,e,r,n){return T(R(e),t,r,n)}function v(t,e,r,n){return T(function(t,e){for(var r,n,o,a=[],u=0;u<t.length&&!((e-=2)<0);++u)n=(r=t.charCodeAt(u))>>8Line truncated
|
||||
Reference in new issue
Block a user