feat: tunnel TS exports, port forward labels, and db migrations

- Add TS derive and type annotations to all tunnel API param structs
- Export tunnel bindings to a tunnel/ subdirectory with index generation
- Change port forward label from String to Option<String>
- Add TunnelDatabase::init() with default subnet creation
- Add tunnel migration framework with m_00_port_forward_entry migration
  to convert legacy string-only port forwards to the new entry format
This commit is contained in:
Aiden McClelland
2026-03-12 13:38:01 -06:00
parent fd54e9ca91
commit c485edfa12
32 changed files with 288 additions and 39 deletions

View File

@@ -6,5 +6,5 @@ export type AddPackageSignerParams = {
id: PackageId
signer: Guid
versions: string | null
merge?: boolean
merge: boolean
}

View File

@@ -26,7 +26,7 @@ export type ServerInfo = {
zram: boolean
governor: Governor | null
smtp: SmtpValue | null
ifconfigUrl: string
echoipUrls: string[]
ram: number
devices: Array<LshwDevice>
kiosk: boolean | null

View File

@@ -306,3 +306,4 @@ export { WifiInfo } from './WifiInfo'
export { WifiListInfo } from './WifiListInfo'
export { WifiListOut } from './WifiListOut'
export { WifiSsidParams } from './WifiSsidParams'
export * as Tunnel from './tunnel'

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AddDeviceParams = {
subnet: string
name: string
ip: string | null
}

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AnyVerifyingKey } from './AnyVerifyingKey'
export type AddKeyParams = { name: string; key: AnyVerifyingKey }

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AddPortForwardParams = {
source: string
target: string
label: string | null
}

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type AddSubnetParams = { name: string }

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type GatewayId = string

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type GatewayType = 'inbound-outbound' | 'outbound-only'

View File

@@ -0,0 +1,13 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { NetworkInterfaceType } from './NetworkInterfaceType'
export type IpInfo = {
name: string
scopeId: number
deviceType: NetworkInterfaceType | null
subnets: string[]
lanIp: string[]
wanIp: string | null
ntpServers: string[]
dnsServers: string[]
}

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ListDevicesParams = { subnet: string }

View File

@@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { GatewayType } from './GatewayType'
import type { IpInfo } from './IpInfo'
export type NetworkInterfaceInfo = {
name: string | null
secure: boolean | null
ipInfo: IpInfo | null
type: GatewayType | null
}

View File

@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type NetworkInterfaceType =
| 'ethernet'
| 'wireless'
| 'bridge'
| 'wireguard'
| 'loopback'

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type PortForwardEntry = {
target: string
label: string | null
enabled: boolean
}

View File

@@ -1,3 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PortForwardEntry } from './PortForwardEntry'
export type PortForwards = { [key: string]: string }
export type PortForwards = { [key: string]: PortForwardEntry }

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type RemoveDeviceParams = { subnet: string; ip: string }

View File

@@ -0,0 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AnyVerifyingKey } from './AnyVerifyingKey'
export type RemoveKeyParams = { key: AnyVerifyingKey }

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type RemovePortForwardParams = { source: string }

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type SetPasswordParams = { password: string }

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type SetPortForwardEnabledParams = { source: string; enabled: boolean }

View File

@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ShowConfigParams = {
subnet: string
ip: string
wanAddr: string | null
}

View File

@@ -0,0 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type SubnetParams = { subnet: string }

View File

@@ -1,5 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AnyVerifyingKey } from './AnyVerifyingKey'
import type { GatewayId } from './GatewayId'
import type { NetworkInterfaceInfo } from './NetworkInterfaceInfo'
import type { PortForwards } from './PortForwards'
import type { Sessions } from './Sessions'
import type { SignerInfo } from './SignerInfo'
@@ -11,7 +13,7 @@ export type TunnelDatabase = {
sessions: Sessions
password: string | null
authPubkeys: { [key: AnyVerifyingKey]: SignerInfo }
gateways: { [key: AnyVerifyingKey]: SignerInfo }
gateways: { [key: GatewayId]: NetworkInterfaceInfo }
wg: WgServer
portForwards: PortForwards
}

View File

@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type UpdatePortForwardLabelParams = {
source: string
label: string | null
}

View File

@@ -0,0 +1,35 @@
export { AddDeviceParams } from './AddDeviceParams'
export { AddKeyParams } from './AddKeyParams'
export { AddPortForwardParams } from './AddPortForwardParams'
export { AddSubnetParams } from './AddSubnetParams'
export { AnyVerifyingKey } from './AnyVerifyingKey'
export { Base64 } from './Base64'
export { GatewayId } from './GatewayId'
export { GatewayType } from './GatewayType'
export { IpInfo } from './IpInfo'
export { ListDevicesParams } from './ListDevicesParams'
export { NetworkInterfaceInfo } from './NetworkInterfaceInfo'
export { NetworkInterfaceType } from './NetworkInterfaceType'
export { Pem } from './Pem'
export { PortForwardEntry } from './PortForwardEntry'
export { PortForwards } from './PortForwards'
export { RemoveDeviceParams } from './RemoveDeviceParams'
export { RemoveKeyParams } from './RemoveKeyParams'
export { RemovePortForwardParams } from './RemovePortForwardParams'
export { Sessions } from './Sessions'
export { Session } from './Session'
export { SetPasswordParams } from './SetPasswordParams'
export { SetPortForwardEnabledParams } from './SetPortForwardEnabledParams'
export { ShowConfigParams } from './ShowConfigParams'
export { SignerInfo } from './SignerInfo'
export { SubnetParams } from './SubnetParams'
export { TunnelCertData } from './TunnelCertData'
export { TunnelDatabase } from './TunnelDatabase'
export { TunnelUpdateResult } from './TunnelUpdateResult'
export { UpdatePortForwardLabelParams } from './UpdatePortForwardLabelParams'
export { WebserverInfo } from './WebserverInfo'
export { WgConfig } from './WgConfig'
export { WgServer } from './WgServer'
export { WgSubnetClients } from './WgSubnetClients'
export { WgSubnetConfig } from './WgSubnetConfig'
export { WgSubnetMap } from './WgSubnetMap'