Skip to content

Commit 42cb9fb

Browse files
committed
feat: enhance MihomoGeneratorService with additional proxy options
- Add optional 'public-key' and 'short-id' fields to NetworkConfig interface - Update proxy node creation to include publicKey, shortId, and clientFingerprint - Introduce reality-opts for proxy nodes when publicKey is provided
1 parent 5c7156d commit 42cb9fb

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/modules/subscription-template/generators/mihomo.generator.service.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ interface NetworkConfig {
2525
};
2626
'v2ray-http-upgrade'?: boolean;
2727
'v2ray-http-upgrade-fast-open'?: boolean;
28+
'public-key'?: string;
29+
'short-id'?: string;
2830
}
2931

3032
interface ProxyNode {
@@ -133,13 +135,16 @@ export class MihomoGeneratorService {
133135
server: host.address,
134136
port: Number(host.port),
135137
network: host.network || 'tcp',
136-
tls: host.tls === 'tls',
138+
tls: ['reality', 'tls'].includes(host.tls),
137139
sni: host.sni || '',
138140
host: host.host[0],
139141
path: host.path || '',
140142
headers: '',
141143
udp: true,
142144
alpn: host.alpn,
145+
publicKey: host.publicKey,
146+
shortId: host.shortId,
147+
clientFingerprint: host.fingerprint,
143148
});
144149

145150
switch (host.protocol) {
@@ -184,8 +189,25 @@ export class MihomoGeneratorService {
184189
headers: string;
185190
udp: boolean;
186191
alpn?: string;
192+
publicKey?: string;
193+
shortId?: string;
194+
clientFingerprint?: string;
187195
}): ProxyNode {
188-
const { server, port, remark, tls, sni, alpn, udp, host, path, headers } = params;
196+
const {
197+
server,
198+
port,
199+
remark,
200+
tls,
201+
sni,
202+
alpn,
203+
udp,
204+
host,
205+
path,
206+
headers,
207+
publicKey,
208+
shortId,
209+
clientFingerprint,
210+
} = params;
189211
let { type, network } = params;
190212

191213
if (type === 'shadowsocks') {
@@ -256,6 +278,14 @@ export class MihomoGeneratorService {
256278
node[`${network}-opts`] = netOpts;
257279
}
258280

281+
if (publicKey) {
282+
node['reality-opts'] = {
283+
'public-key': publicKey,
284+
'short-id': shortId,
285+
};
286+
node['client-fingerprint'] = clientFingerprint || 'chrome';
287+
}
288+
259289
return node;
260290
}
261291

0 commit comments

Comments
 (0)