diff --git a/src/modules/subscription-template/generators/mihomo.generator.service.ts b/src/modules/subscription-template/generators/mihomo.generator.service.ts index 3d1fec49..dd4ad201 100644 --- a/src/modules/subscription-template/generators/mihomo.generator.service.ts +++ b/src/modules/subscription-template/generators/mihomo.generator.service.ts @@ -72,7 +72,7 @@ export class MihomoGeneratorService { const yamlConfig = yamlConfigDb as unknown as any; const { remnawave, ...cleanConfig } = yamlConfig ?? {}; - const includeHidden = remnawave?.includeHiddenHosts ?? true; + const includeHidden = remnawave?.includeHiddenHosts ?? false; const data: ClashData = { proxies: [], diff --git a/src/modules/subscription/subscription.service.ts b/src/modules/subscription/subscription.service.ts index 5bf0f105..6d05014f 100644 --- a/src/modules/subscription/subscription.service.ts +++ b/src/modules/subscription/subscription.service.ts @@ -145,6 +145,8 @@ export class SubscriptionService { const subscriptionSettings = srrContext.subscriptionSettings; + let hwidLimitHeader: string | undefined; + if (subscriptionSettings.hwidSettings.enabled) { const isAllowed = await this.checkHwidDeviceLimit( user.response, @@ -199,6 +201,10 @@ export class SubscriptionService { return response; } + + if (isAllowed.isOk && isAllowed.response.isNewDevice) { + hwidLimitHeader = 'false'; // v2rayTUN + } } else { await this.checkAndUpsertHwidUserDevice(user.response, hwidHeaders); } @@ -243,12 +249,18 @@ export class SubscriptionService { hostsOverrides, }); + const headers = await this.getUserProfileHeadersInfo( + user.response, + isXrayExtSupported, + subscriptionSettings, + ); + + if (hwidLimitHeader !== undefined) { + headers['x-hwid-limit'] = hwidLimitHeader; + } + return new SubscriptionWithConfigResponse({ - headers: await this.getUserProfileHeadersInfo( - user.response, - isXrayExtSupported, - subscriptionSettings, - ), + headers, body: subscription.subscription, contentType: subscription.contentType, }); @@ -321,6 +333,10 @@ export class SubscriptionService { isHwidLimited = true; } + + if (isAllowed.isOk && isAllowed.response.isNewDevice) { + headers['x-hwid-limit'] = 'false'; // v2rayTUN + } } else { await this.checkAndUpsertHwidUserDevice(user, hwidHeaders); @@ -778,6 +794,7 @@ export class SubscriptionService { isSubscriptionAllowed: boolean; maxDeviceReached: boolean; hwidNotSupported: boolean; + isNewDevice: boolean; }> > { try { @@ -796,6 +813,7 @@ export class SubscriptionService { isSubscriptionAllowed: true, maxDeviceReached: false, hwidNotSupported: false, + isNewDevice: false, }); } @@ -804,6 +822,7 @@ export class SubscriptionService { isSubscriptionAllowed: false, maxDeviceReached: false, hwidNotSupported: true, + isNewDevice: false, }); } @@ -827,6 +846,7 @@ export class SubscriptionService { isSubscriptionAllowed: true, maxDeviceReached: false, hwidNotSupported: false, + isNewDevice: false, }); } } @@ -840,6 +860,7 @@ export class SubscriptionService { isSubscriptionAllowed: false, maxDeviceReached: true, hwidNotSupported: false, + isNewDevice: false, }); } @@ -848,6 +869,7 @@ export class SubscriptionService { isSubscriptionAllowed: false, maxDeviceReached: true, hwidNotSupported: false, + isNewDevice: false, }); } @@ -871,6 +893,7 @@ export class SubscriptionService { isSubscriptionAllowed: false, maxDeviceReached: true, hwidNotSupported: false, + isNewDevice: false, }); } @@ -883,6 +906,7 @@ export class SubscriptionService { isSubscriptionAllowed: true, maxDeviceReached: false, hwidNotSupported: false, + isNewDevice: true, }); } catch (error) { this.logger.error(`Error checking hwid device limit: ${error}`); @@ -890,6 +914,7 @@ export class SubscriptionService { isSubscriptionAllowed: false, maxDeviceReached: true, hwidNotSupported: false, + isNewDevice: false, }); } }