mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 06:59:03 +08:00
feat: produceArtifact 支持 Stash internal (Fixes #271)
This commit is contained in:
parent
059c4bd148
commit
4966132397
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.173",
|
"version": "2.14.174",
|
||||||
"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": {
|
||||||
|
@ -2,241 +2,243 @@ import { isPresent } from '@/core/proxy-utils/producers/utils';
|
|||||||
|
|
||||||
export default function Stash_Producer() {
|
export default function Stash_Producer() {
|
||||||
const type = 'ALL';
|
const type = 'ALL';
|
||||||
const produce = (proxies) => {
|
const produce = (proxies, type, opts = {}) => {
|
||||||
// https://stash.wiki/proxy-protocols/proxy-types#shadowsocks
|
// https://stash.wiki/proxy-protocols/proxy-types#shadowsocks
|
||||||
return (
|
const list = proxies
|
||||||
'proxies:\n' +
|
.filter((proxy) => {
|
||||||
proxies
|
if (opts['include-unsupported-proxy']) return true;
|
||||||
.filter((proxy) => {
|
if (
|
||||||
if (
|
![
|
||||||
|
'ss',
|
||||||
|
'ssr',
|
||||||
|
'vmess',
|
||||||
|
'socks5',
|
||||||
|
'http',
|
||||||
|
'snell',
|
||||||
|
'trojan',
|
||||||
|
'tuic',
|
||||||
|
'vless',
|
||||||
|
'wireguard',
|
||||||
|
'hysteria',
|
||||||
|
'hysteria2',
|
||||||
|
].includes(proxy.type) ||
|
||||||
|
(proxy.type === 'ss' &&
|
||||||
![
|
![
|
||||||
'ss',
|
'aes-128-gcm',
|
||||||
'ssr',
|
'aes-192-gcm',
|
||||||
'vmess',
|
'aes-256-gcm',
|
||||||
'socks5',
|
'aes-128-cfb',
|
||||||
'http',
|
'aes-192-cfb',
|
||||||
'snell',
|
'aes-256-cfb',
|
||||||
'trojan',
|
'aes-128-ctr',
|
||||||
'tuic',
|
'aes-192-ctr',
|
||||||
'vless',
|
'aes-256-ctr',
|
||||||
'wireguard',
|
'rc4-md5',
|
||||||
'hysteria',
|
'chacha20-ietf',
|
||||||
'hysteria2',
|
'xchacha20',
|
||||||
].includes(proxy.type) ||
|
'chacha20-ietf-poly1305',
|
||||||
(proxy.type === 'ss' &&
|
'xchacha20-ietf-poly1305',
|
||||||
![
|
].includes(proxy.cipher)) ||
|
||||||
'aes-128-gcm',
|
(proxy.type === 'snell' && String(proxy.version) === '4') ||
|
||||||
'aes-192-gcm',
|
(proxy.type === 'vless' && proxy['reality-opts'])
|
||||||
'aes-256-gcm',
|
) {
|
||||||
'aes-128-cfb',
|
return false;
|
||||||
'aes-192-cfb',
|
}
|
||||||
'aes-256-cfb',
|
return true;
|
||||||
'aes-128-ctr',
|
})
|
||||||
'aes-192-ctr',
|
.map((proxy) => {
|
||||||
'aes-256-ctr',
|
if (proxy.type === 'vmess') {
|
||||||
'rc4-md5',
|
// handle vmess aead
|
||||||
'chacha20-ietf',
|
if (isPresent(proxy, 'aead')) {
|
||||||
'xchacha20',
|
if (proxy.aead) {
|
||||||
'chacha20-ietf-poly1305',
|
proxy.alterId = 0;
|
||||||
'xchacha20-ietf-poly1305',
|
}
|
||||||
].includes(proxy.cipher)) ||
|
delete proxy.aead;
|
||||||
(proxy.type === 'snell' &&
|
|
||||||
String(proxy.version) === '4') ||
|
|
||||||
(proxy.type === 'vless' && proxy['reality-opts'])
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
if (isPresent(proxy, 'sni')) {
|
||||||
})
|
proxy.servername = proxy.sni;
|
||||||
.map((proxy) => {
|
delete proxy.sni;
|
||||||
if (proxy.type === 'vmess') {
|
|
||||||
// handle vmess aead
|
|
||||||
if (isPresent(proxy, 'aead')) {
|
|
||||||
if (proxy.aead) {
|
|
||||||
proxy.alterId = 0;
|
|
||||||
}
|
|
||||||
delete proxy.aead;
|
|
||||||
}
|
|
||||||
if (isPresent(proxy, 'sni')) {
|
|
||||||
proxy.servername = proxy.sni;
|
|
||||||
delete proxy.sni;
|
|
||||||
}
|
|
||||||
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/docs/config.yaml#L400
|
|
||||||
// https://stash.wiki/proxy-protocols/proxy-types#vmess
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'cipher') &&
|
|
||||||
![
|
|
||||||
'auto',
|
|
||||||
'aes-128-gcm',
|
|
||||||
'chacha20-poly1305',
|
|
||||||
'none',
|
|
||||||
].includes(proxy.cipher)
|
|
||||||
) {
|
|
||||||
proxy.cipher = 'auto';
|
|
||||||
}
|
|
||||||
} else if (proxy.type === 'tuic') {
|
|
||||||
if (isPresent(proxy, 'alpn')) {
|
|
||||||
proxy.alpn = Array.isArray(proxy.alpn)
|
|
||||||
? proxy.alpn
|
|
||||||
: [proxy.alpn];
|
|
||||||
} else {
|
|
||||||
proxy.alpn = ['h3'];
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'tfo') &&
|
|
||||||
!isPresent(proxy, 'fast-open')
|
|
||||||
) {
|
|
||||||
proxy['fast-open'] = proxy.tfo;
|
|
||||||
delete proxy.tfo;
|
|
||||||
}
|
|
||||||
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/adapter/outbound/tuic.go#L197
|
|
||||||
if (
|
|
||||||
(!proxy.token || proxy.token.length === 0) &&
|
|
||||||
!isPresent(proxy, 'version')
|
|
||||||
) {
|
|
||||||
proxy.version = 5;
|
|
||||||
}
|
|
||||||
} else if (proxy.type === 'hysteria') {
|
|
||||||
// auth_str 将会在未来某个时候删除 但是有的机场不规范
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'auth_str') &&
|
|
||||||
!isPresent(proxy, 'auth-str')
|
|
||||||
) {
|
|
||||||
proxy['auth-str'] = proxy['auth_str'];
|
|
||||||
}
|
|
||||||
if (isPresent(proxy, 'alpn')) {
|
|
||||||
proxy.alpn = Array.isArray(proxy.alpn)
|
|
||||||
? proxy.alpn
|
|
||||||
: [proxy.alpn];
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'tfo') &&
|
|
||||||
!isPresent(proxy, 'fast-open')
|
|
||||||
) {
|
|
||||||
proxy['fast-open'] = proxy.tfo;
|
|
||||||
delete proxy.tfo;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'down') &&
|
|
||||||
!isPresent(proxy, 'down-speed')
|
|
||||||
) {
|
|
||||||
proxy['down-speed'] = proxy.down;
|
|
||||||
delete proxy.down;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'up') &&
|
|
||||||
!isPresent(proxy, 'up-speed')
|
|
||||||
) {
|
|
||||||
proxy['up-speed'] = proxy.up;
|
|
||||||
delete proxy.up;
|
|
||||||
}
|
|
||||||
if (isPresent(proxy, 'down-speed')) {
|
|
||||||
proxy['down-speed'] =
|
|
||||||
`${proxy['down-speed']}`.match(/\d+/)?.[0] || 0;
|
|
||||||
}
|
|
||||||
if (isPresent(proxy, 'up-speed')) {
|
|
||||||
proxy['up-speed'] =
|
|
||||||
`${proxy['up-speed']}`.match(/\d+/)?.[0] || 0;
|
|
||||||
}
|
|
||||||
} else if (proxy.type === 'hysteria2') {
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'password') &&
|
|
||||||
!isPresent(proxy, 'auth')
|
|
||||||
) {
|
|
||||||
proxy.auth = proxy.password;
|
|
||||||
delete proxy.password;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'tfo') &&
|
|
||||||
!isPresent(proxy, 'fast-open')
|
|
||||||
) {
|
|
||||||
proxy['fast-open'] = proxy.tfo;
|
|
||||||
delete proxy.tfo;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'down') &&
|
|
||||||
!isPresent(proxy, 'down-speed')
|
|
||||||
) {
|
|
||||||
proxy['down-speed'] = proxy.down;
|
|
||||||
delete proxy.down;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isPresent(proxy, 'up') &&
|
|
||||||
!isPresent(proxy, 'up-speed')
|
|
||||||
) {
|
|
||||||
proxy['up-speed'] = proxy.up;
|
|
||||||
delete proxy.up;
|
|
||||||
}
|
|
||||||
if (isPresent(proxy, 'down-speed')) {
|
|
||||||
proxy['down-speed'] =
|
|
||||||
`${proxy['down-speed']}`.match(/\d+/)?.[0] || 0;
|
|
||||||
}
|
|
||||||
if (isPresent(proxy, 'up-speed')) {
|
|
||||||
proxy['up-speed'] =
|
|
||||||
`${proxy['up-speed']}`.match(/\d+/)?.[0] || 0;
|
|
||||||
}
|
|
||||||
} else if (proxy.type === 'wireguard') {
|
|
||||||
proxy.keepalive =
|
|
||||||
proxy.keepalive ?? proxy['persistent-keepalive'];
|
|
||||||
proxy['persistent-keepalive'] = proxy.keepalive;
|
|
||||||
proxy['preshared-key'] =
|
|
||||||
proxy['preshared-key'] ?? proxy['pre-shared-key'];
|
|
||||||
proxy['pre-shared-key'] = proxy['preshared-key'];
|
|
||||||
} else if (proxy.type === 'vless') {
|
|
||||||
if (isPresent(proxy, 'sni')) {
|
|
||||||
proxy.servername = proxy.sni;
|
|
||||||
delete proxy.sni;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/docs/config.yaml#L400
|
||||||
|
// https://stash.wiki/proxy-protocols/proxy-types#vmess
|
||||||
if (
|
if (
|
||||||
['vmess', 'vless'].includes(proxy.type) &&
|
isPresent(proxy, 'cipher') &&
|
||||||
proxy.network === 'http'
|
![
|
||||||
|
'auto',
|
||||||
|
'aes-128-gcm',
|
||||||
|
'chacha20-poly1305',
|
||||||
|
'none',
|
||||||
|
].includes(proxy.cipher)
|
||||||
) {
|
) {
|
||||||
let httpPath = proxy['http-opts']?.path;
|
proxy.cipher = 'auto';
|
||||||
if (
|
}
|
||||||
isPresent(proxy, 'http-opts.path') &&
|
} else if (proxy.type === 'tuic') {
|
||||||
!Array.isArray(httpPath)
|
if (isPresent(proxy, 'alpn')) {
|
||||||
) {
|
proxy.alpn = Array.isArray(proxy.alpn)
|
||||||
proxy['http-opts'].path = [httpPath];
|
? proxy.alpn
|
||||||
}
|
: [proxy.alpn];
|
||||||
let httpHost = proxy['http-opts']?.headers?.Host;
|
} else {
|
||||||
if (
|
proxy.alpn = ['h3'];
|
||||||
isPresent(proxy, 'http-opts.headers.Host') &&
|
|
||||||
!Array.isArray(httpHost)
|
|
||||||
) {
|
|
||||||
proxy['http-opts'].headers.Host = [httpHost];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(
|
isPresent(proxy, 'tfo') &&
|
||||||
proxy.type,
|
!isPresent(proxy, 'fast-open')
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
delete proxy.tls;
|
proxy['fast-open'] = proxy.tfo;
|
||||||
|
delete proxy.tfo;
|
||||||
}
|
}
|
||||||
if (proxy['tls-fingerprint']) {
|
// https://github.com/MetaCubeX/Clash.Meta/blob/Alpha/adapter/outbound/tuic.go#L197
|
||||||
proxy.fingerprint = proxy['tls-fingerprint'];
|
|
||||||
}
|
|
||||||
delete proxy['tls-fingerprint'];
|
|
||||||
|
|
||||||
if (proxy['test-url']) {
|
|
||||||
proxy['benchmark-url'] = proxy['test-url'];
|
|
||||||
delete proxy['test-url'];
|
|
||||||
}
|
|
||||||
|
|
||||||
delete proxy.subName;
|
|
||||||
delete proxy.collectionName;
|
|
||||||
if (
|
if (
|
||||||
['grpc'].includes(proxy.network) &&
|
(!proxy.token || proxy.token.length === 0) &&
|
||||||
proxy[`${proxy.network}-opts`]
|
!isPresent(proxy, 'version')
|
||||||
) {
|
) {
|
||||||
delete proxy[`${proxy.network}-opts`]['_grpc-type'];
|
proxy.version = 5;
|
||||||
}
|
}
|
||||||
return ' - ' + JSON.stringify(proxy) + '\n';
|
} else if (proxy.type === 'hysteria') {
|
||||||
})
|
// auth_str 将会在未来某个时候删除 但是有的机场不规范
|
||||||
.join('')
|
if (
|
||||||
);
|
isPresent(proxy, 'auth_str') &&
|
||||||
|
!isPresent(proxy, 'auth-str')
|
||||||
|
) {
|
||||||
|
proxy['auth-str'] = proxy['auth_str'];
|
||||||
|
}
|
||||||
|
if (isPresent(proxy, 'alpn')) {
|
||||||
|
proxy.alpn = Array.isArray(proxy.alpn)
|
||||||
|
? proxy.alpn
|
||||||
|
: [proxy.alpn];
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'tfo') &&
|
||||||
|
!isPresent(proxy, 'fast-open')
|
||||||
|
) {
|
||||||
|
proxy['fast-open'] = proxy.tfo;
|
||||||
|
delete proxy.tfo;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'down') &&
|
||||||
|
!isPresent(proxy, 'down-speed')
|
||||||
|
) {
|
||||||
|
proxy['down-speed'] = proxy.down;
|
||||||
|
delete proxy.down;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'up') &&
|
||||||
|
!isPresent(proxy, 'up-speed')
|
||||||
|
) {
|
||||||
|
proxy['up-speed'] = proxy.up;
|
||||||
|
delete proxy.up;
|
||||||
|
}
|
||||||
|
if (isPresent(proxy, 'down-speed')) {
|
||||||
|
proxy['down-speed'] =
|
||||||
|
`${proxy['down-speed']}`.match(/\d+/)?.[0] || 0;
|
||||||
|
}
|
||||||
|
if (isPresent(proxy, 'up-speed')) {
|
||||||
|
proxy['up-speed'] =
|
||||||
|
`${proxy['up-speed']}`.match(/\d+/)?.[0] || 0;
|
||||||
|
}
|
||||||
|
} else if (proxy.type === 'hysteria2') {
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'password') &&
|
||||||
|
!isPresent(proxy, 'auth')
|
||||||
|
) {
|
||||||
|
proxy.auth = proxy.password;
|
||||||
|
delete proxy.password;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'tfo') &&
|
||||||
|
!isPresent(proxy, 'fast-open')
|
||||||
|
) {
|
||||||
|
proxy['fast-open'] = proxy.tfo;
|
||||||
|
delete proxy.tfo;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'down') &&
|
||||||
|
!isPresent(proxy, 'down-speed')
|
||||||
|
) {
|
||||||
|
proxy['down-speed'] = proxy.down;
|
||||||
|
delete proxy.down;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'up') &&
|
||||||
|
!isPresent(proxy, 'up-speed')
|
||||||
|
) {
|
||||||
|
proxy['up-speed'] = proxy.up;
|
||||||
|
delete proxy.up;
|
||||||
|
}
|
||||||
|
if (isPresent(proxy, 'down-speed')) {
|
||||||
|
proxy['down-speed'] =
|
||||||
|
`${proxy['down-speed']}`.match(/\d+/)?.[0] || 0;
|
||||||
|
}
|
||||||
|
if (isPresent(proxy, 'up-speed')) {
|
||||||
|
proxy['up-speed'] =
|
||||||
|
`${proxy['up-speed']}`.match(/\d+/)?.[0] || 0;
|
||||||
|
}
|
||||||
|
} else if (proxy.type === 'wireguard') {
|
||||||
|
proxy.keepalive =
|
||||||
|
proxy.keepalive ?? proxy['persistent-keepalive'];
|
||||||
|
proxy['persistent-keepalive'] = proxy.keepalive;
|
||||||
|
proxy['preshared-key'] =
|
||||||
|
proxy['preshared-key'] ?? proxy['pre-shared-key'];
|
||||||
|
proxy['pre-shared-key'] = proxy['preshared-key'];
|
||||||
|
} else if (proxy.type === 'vless') {
|
||||||
|
if (isPresent(proxy, 'sni')) {
|
||||||
|
proxy.servername = proxy.sni;
|
||||||
|
delete proxy.sni;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
['vmess', 'vless'].includes(proxy.type) &&
|
||||||
|
proxy.network === 'http'
|
||||||
|
) {
|
||||||
|
let httpPath = proxy['http-opts']?.path;
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'http-opts.path') &&
|
||||||
|
!Array.isArray(httpPath)
|
||||||
|
) {
|
||||||
|
proxy['http-opts'].path = [httpPath];
|
||||||
|
}
|
||||||
|
let httpHost = proxy['http-opts']?.headers?.Host;
|
||||||
|
if (
|
||||||
|
isPresent(proxy, 'http-opts.headers.Host') &&
|
||||||
|
!Array.isArray(httpHost)
|
||||||
|
) {
|
||||||
|
proxy['http-opts'].headers.Host = [httpHost];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
['trojan', 'tuic', 'hysteria', 'hysteria2'].includes(
|
||||||
|
proxy.type,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
delete proxy.tls;
|
||||||
|
}
|
||||||
|
if (proxy['tls-fingerprint']) {
|
||||||
|
proxy.fingerprint = proxy['tls-fingerprint'];
|
||||||
|
}
|
||||||
|
delete proxy['tls-fingerprint'];
|
||||||
|
|
||||||
|
if (proxy['test-url']) {
|
||||||
|
proxy['benchmark-url'] = proxy['test-url'];
|
||||||
|
delete proxy['test-url'];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete proxy.subName;
|
||||||
|
delete proxy.collectionName;
|
||||||
|
if (
|
||||||
|
['grpc'].includes(proxy.network) &&
|
||||||
|
proxy[`${proxy.network}-opts`]
|
||||||
|
) {
|
||||||
|
delete proxy[`${proxy.network}-opts`]['_grpc-type'];
|
||||||
|
}
|
||||||
|
return proxy;
|
||||||
|
});
|
||||||
|
return type === 'internal'
|
||||||
|
? list
|
||||||
|
: 'proxies:\n' +
|
||||||
|
list
|
||||||
|
.map((proxy) => ' - ' + JSON.stringify(proxy) + '\n')
|
||||||
|
.join('');
|
||||||
};
|
};
|
||||||
return { type, produce };
|
return { type, produce };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user