Skip to content

Commit 00b13e5

Browse files
committed
chore: add randomizeHosts feature, remove PROVIDER_ID from .env.sample, modify user-info headers
- Added randomizeHosts field to subscription settings schema and related models. - Implemented randomizeHosts functionality in subscription service to shuffle hosts if enabled.
1 parent 940c6c2 commit 00b13e5

File tree

13 files changed

+70
-12
lines changed

13 files changed

+70
-12
lines changed

libs/contract/commands/subscription-settings/update-subscription-settings.command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export namespace UpdateSubscriptionSettingsCommand {
3838
disabledUsersRemarks: z.optional(z.array(z.string())),
3939

4040
customResponseHeaders: z.optional(z.record(z.string(), z.string())),
41+
42+
randomizeHosts: z.optional(z.boolean()),
4143
});
4244

4345
export type Request = z.infer<typeof RequestSchema>;

libs/contract/models/subscription-settings.schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const SubscriptionSettingsSchema = z.object({
2929
),
3030
),
3131

32+
randomizeHosts: z.boolean(),
33+
3234
createdAt: z
3335
.string()
3436
.datetime()

libs/contract/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remnawave/backend-contract",
3-
"version": "0.7.6",
3+
"version": "0.7.7",
44
"public": true,
55
"license": "AGPL-3.0-only",
66
"description": "A contract library for Remnawave Backend. It can be used in backend and frontend.",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-- AlterTable
2+
ALTER TABLE "admin" ALTER COLUMN "created_at" SET DEFAULT now(),
3+
ALTER COLUMN "updated_at" SET DEFAULT now();
4+
5+
-- AlterTable
6+
ALTER TABLE "api_tokens" ALTER COLUMN "created_at" SET DEFAULT now(),
7+
ALTER COLUMN "updated_at" SET DEFAULT now();
8+
9+
-- AlterTable
10+
ALTER TABLE "hwid_user_devices" ALTER COLUMN "created_at" SET DEFAULT now(),
11+
ALTER COLUMN "updated_at" SET DEFAULT now();
12+
13+
-- AlterTable
14+
ALTER TABLE "keygen" ALTER COLUMN "created_at" SET DEFAULT now(),
15+
ALTER COLUMN "updated_at" SET DEFAULT now();
16+
17+
-- AlterTable
18+
ALTER TABLE "nodes" ALTER COLUMN "created_at" SET DEFAULT now(),
19+
ALTER COLUMN "updated_at" SET DEFAULT now();
20+
21+
-- AlterTable
22+
ALTER TABLE "nodes_traffic_usage_history" ALTER COLUMN "reset_at" SET DEFAULT now();
23+
24+
-- AlterTable
25+
ALTER TABLE "nodes_usage_history" ALTER COLUMN "created_at" SET DEFAULT date_trunc('hour', now());
26+
27+
-- AlterTable
28+
ALTER TABLE "nodes_user_usage_history" ALTER COLUMN "created_at" SET DEFAULT date_trunc('hour', now()),
29+
ALTER COLUMN "updated_at" SET DEFAULT now();
30+
31+
-- AlterTable
32+
ALTER TABLE "subscription_settings" ADD COLUMN "randomize_hosts" BOOLEAN NOT NULL DEFAULT false,
33+
ALTER COLUMN "created_at" SET DEFAULT now(),
34+
ALTER COLUMN "updated_at" SET DEFAULT now();
35+
36+
-- AlterTable
37+
ALTER TABLE "subscription_templates" ALTER COLUMN "created_at" SET DEFAULT now(),
38+
ALTER COLUMN "updated_at" SET DEFAULT now();
39+
40+
-- AlterTable
41+
ALTER TABLE "user_traffic_history" ALTER COLUMN "reset_at" SET DEFAULT now();
42+
43+
-- AlterTable
44+
ALTER TABLE "users" ALTER COLUMN "created_at" SET DEFAULT now(),
45+
ALTER COLUMN "updated_at" SET DEFAULT now();
46+
47+
-- AlterTable
48+
ALTER TABLE "xray_config" ALTER COLUMN "updated_at" SET DEFAULT now();

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ model SubscriptionSettings {
293293
limitedUsersRemarks Json @map("limited_users_remarks")
294294
disabledUsersRemarks Json @map("disabled_users_remarks")
295295
customResponseHeaders Json? @map("custom_response_headers")
296+
randomizeHosts Boolean @default(false) @map("randomize_hosts")
296297
297298
createdAt DateTime @default(dbgenerated("now()")) @map("created_at")
298299
updatedAt DateTime @default(dbgenerated("now()")) @updatedAt @map("updated_at")

prisma/seed/config.seed.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ async function seedSubscriptionSettings() {
661661
serveJsonAtBaseSubscription: false,
662662
addUsernameToBaseSubscription: false,
663663
isShowCustomRemarks: true,
664+
randomizeHosts: false,
664665
},
665666
});
666667
}

src/common/config/app-config/config.schema.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export const configSchema = z
8989
),
9090
),
9191
HWID_MAX_DEVICES_ANNOUNCE: z.optional(z.string()),
92-
PROVIDER_ID: z.optional(z.string()),
9392

9493
COOKIE_AUTH_ENABLED: z
9594
.string()

src/modules/subscription-settings/entities/subscription-settings.entity.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class SubscriptionSettingsEntity implements SubscriptionSettings {
1919

2020
customResponseHeaders: Record<string, string> | null;
2121

22+
randomizeHosts: boolean;
23+
2224
createdAt: Date;
2325
updatedAt: Date;
2426
constructor(config: Partial<SubscriptionSettings>) {

src/modules/subscription-settings/models/get-subscription-settings.response.model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export class SubscriptionSettingsResponseModel {
1717

1818
public customResponseHeaders: Record<string, string> | null;
1919

20+
public randomizeHosts: boolean;
21+
2022
public createdAt: Date;
2123
public updatedAt: Date;
2224

@@ -35,6 +37,7 @@ export class SubscriptionSettingsResponseModel {
3537
this.limitedUsersRemarks = entity.limitedUsersRemarks;
3638
this.disabledUsersRemarks = entity.disabledUsersRemarks;
3739
this.customResponseHeaders = entity.customResponseHeaders;
40+
this.randomizeHosts = entity.randomizeHosts;
3841
this.createdAt = entity.createdAt;
3942
this.updatedAt = entity.updatedAt;
4043
}

src/modules/subscription-settings/subscription-settings.converter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const entityToModel = (entity: SubscriptionSettingsEntity): SubscriptionSettings
3030

3131
customResponseHeaders: entity.customResponseHeaders,
3232

33+
randomizeHosts: entity.randomizeHosts,
34+
3335
createdAt: entity.createdAt,
3436
updatedAt: entity.updatedAt,
3537
};

0 commit comments

Comments
 (0)