Skip to content

Commit

Permalink
feat: 支持从 Clash 订阅中读取 v2ray-plugin mux 信息
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed May 4, 2020
1 parent b627eb5 commit f06f279
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/provider/ClashProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ export const parseClashConfig = (proxyList: ReadonlyArray<any>, udpRelay?: boole
...(item['plugin-opts'].tls === true ? {
skipCertVerify: item['plugin-opts']['skip-cert-verify'] === true,
} : null),
...(typeof item['plugin-opts'].mux === 'boolean' ? {
mux: item['plugin-opts'].mux,
} : null),
} : null),
} as ShadowsocksNodeConfig;
}
Expand Down
40 changes: 40 additions & 0 deletions lib/provider/__tests__/ClashProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,46 @@ test('trojan configurations', t => {
);
});

test('shadowsocks v2ray mux', async t => {
t.deepEqual(
parseClashConfig([{
name: 'ss-v2ray-mux',
type: 'ss',
server: 'server',
port: 443,
cipher: 'chacha20-ietf-poly1305',
password: 'password',
plugin: 'v2ray-plugin',
'plugin-opts': {
mode: 'websocket',
mux: true,
tls: true,
headers: {
custom: 'value'
},
'skip-cert-verify': true,
}
}]),
[{
type: NodeTypeEnum.Shadowsocks,
nodeName: 'ss-v2ray-mux',
hostname: 'server',
port: 443,
method: 'chacha20-ietf-poly1305',
password: 'password',
obfs: 'wss',
'obfs-host': 'server',
'obfs-uri': '/',
mux: true,
'udp-relay': false,
skipCertVerify: true,
wsHeaders: {
custom: 'value',
},
}]
);
});

test('ClashProvider relayUrl', async t => {
const provider = new ClashProvider('test', {
type: SupportProviderEnum.Clash,
Expand Down

0 comments on commit f06f279

Please sign in to comment.