Skip to content

Commit 93d14f0

Browse files
committed
feat: add fixIncorrectServerNames method to XRayConfig for server name normalization
1 parent 8723695 commit 93d14f0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/common/helpers/xray-config/xray-config.validator.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,25 @@ export class XRayConfig {
280280
}
281281
}
282282

283+
public fixIncorrectServerNames(): void {
284+
for (const inbound of this.config.inbounds) {
285+
const realitySettings =
286+
inbound.protocol === 'vless' ? inbound.streamSettings?.realitySettings : null;
287+
288+
if (!realitySettings?.serverNames?.length) {
289+
continue;
290+
}
291+
292+
realitySettings.serverNames = [
293+
...new Set(
294+
realitySettings.serverNames.flatMap((name) =>
295+
name.split(',').map((part) => part.trim()),
296+
),
297+
),
298+
];
299+
}
300+
}
301+
283302
public getSortedConfig(): IXrayConfig {
284303
return this.sortObjectByKeys<IXrayConfig>(this.config);
285304
}

src/modules/config-profiles/config-profile.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export class ConfigProfileService {
270270

271271
const validatedConfig = new XRayConfig(config);
272272
validatedConfig.cleanClients();
273+
validatedConfig.fixIncorrectServerNames();
273274
const sortedConfig = validatedConfig.getSortedConfig();
274275
const inbounds = validatedConfig.getAllInbounds();
275276

0 commit comments

Comments
 (0)