Files
wg-easy-ca-lose/src/server/database/repositories/interface/schema.ts
T
CthulhuVRN a469ac6897 AmneziaWG 2.0: support for H1-H4 ranges (#2480)
* AmneziaWG 2.0: support for H1-H4 ranges

## Changes:
```
- [+] Added support for H1-H4 ranges
- [!] Fixed interface fields order (H1-H4 goes before I1-I5)
```

## Known issues:
```
- [!] no check for unique/overlap of H1-H4 values on settings apply:
  settings will be applied but wg interface will crash with "Invalid argument" error
```

* AmneziaWG 2.0: support for H1-H4 ranges

## Changes:
```
- [+] Added support for H1-H4 ranges
- [!] Fixed interface fields order (H1-H4 goes before I1-I5)
```

## Known issues:
```
- [!] no check for unique/overlap of H1-H4 values on settings apply:
  settings will be applied but wg interface will crash with "Invalid argument" error
```

* AmneziaWG 2.0: support for H1-H4 ranges

## Changes:
```
- [+] Added support for H1-H4 ranges
- [!] Fixed interface fields order (H1-H4 goes before I1-I5)
```

## Known issues:
```
- [!] no check for unique/overlap of H1-H4 values on settings apply:
  settings will be applied but wg interface will crash with "Invalid argument" error
```

* Update types.ts

Lint fixes

---------

Co-authored-by: CthulhuVRN <alexander@ptitsyn.info>
2026-02-17 13:27:22 +01:00

53 lines
1.4 KiB
TypeScript

import { sql, relations } from 'drizzle-orm';
import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { userConfig, hooks } from '../../schema';
// maybe support multiple interfaces in the future
export const wgInterface = sqliteTable('interfaces_table', {
name: text().primaryKey(),
device: text().notNull(),
port: int().notNull().unique(),
privateKey: text('private_key').notNull(),
publicKey: text('public_key').notNull(),
ipv4Cidr: text('ipv4_cidr').notNull(),
ipv6Cidr: text('ipv6_cidr').notNull(),
mtu: int().notNull(),
jC: int('j_c').default(7),
jMin: int('j_min').default(10),
jMax: int('j_max').default(1000),
s1: int().default(128),
s2: int().default(56),
s3: int(),
s4: int(),
h1: text(),
h2: text(),
h3: text(),
h4: text(),
i1: text(),
i2: text(),
i3: text(),
i4: text(),
i5: text(),
// does nothing yet
enabled: int({ mode: 'boolean' }).notNull(),
createdAt: text('created_at')
.notNull()
.default(sql`(CURRENT_TIMESTAMP)`),
updatedAt: text('updated_at')
.notNull()
.default(sql`(CURRENT_TIMESTAMP)`)
.$onUpdate(() => sql`(CURRENT_TIMESTAMP)`),
});
export const wgInterfaceRelations = relations(wgInterface, ({ one }) => ({
hooks: one(hooks, {
fields: [wgInterface.name],
references: [hooks.id],
}),
userConfig: one(userConfig, {
fields: [wgInterface.name],
references: [userConfig.id],
}),
}));