Skip to content

Commit

Permalink
update network interfaces types
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDHill committed Feb 17, 2024
1 parent fab13db commit eae75c1
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 10 deletions.
4 changes: 3 additions & 1 deletion sdk/lib/interfaces/Host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ type PortOptionsByKnownProtocol =
}
type PortOptionsByProtocol = PortOptionsByKnownProtocol | PortOptions

export type HostKind = "static" | "single" | "multi"

const hasStringProtocol = object({
protocol: string,
}).test
Expand All @@ -95,7 +97,7 @@ export class Host {
constructor(
readonly options: {
effects: Effects
kind: "static" | "single" | "multi"
kind: HostKind
id: string
},
) {}
Expand Down
73 changes: 67 additions & 6 deletions sdk/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export * as configTypes from "./config/configTypes"
import { InputSpec } from "./config/configTypes"
import { DependenciesReceipt } from "./config/setupConfig"
import { PortOptions } from "./interfaces/Host"
import { HostKind, PortOptions } from "./interfaces/Host"
import { Daemons } from "./mainFn/Daemons"
import { Overlay } from "./util/Overlay"
import { UrlString } from "./util/getNetworkInterface"
import { NetworkInterfaceType, Signals } from "./util/utils"

Expand Down Expand Up @@ -165,7 +164,7 @@ export type ActionMetadata = {
group?: string
}
export declare const hostName: unique symbol
export type HostName = string & { [hostName]: never }
export type Hostname = string & { [hostName]: never }
/** ${scheme}://${username}@${host}:${externalPort}${suffix} */
export type Address = {
username: string | null
Expand All @@ -174,6 +173,68 @@ export type Address = {
suffix: string
}

export type ListenKind = "onion" | "ip"

export type ListenInfoBase = {
kind: ListenKind
}

export type ListenInfoOnion = ListenInfoBase & {
kind: "onion"
}

export type ListenInfoIp = ListenInfoBase & {
kind: "ip"
interfaceId: string
}

export type ListenInfo = ListenInfoOnion | ListenInfoIp

export type HostBase = {
id: string
kind: HostKind
}

export type SingleHost = HostBase & {
kind: "single" | "static"
} & (
| {
listen: null
hostname: null
}
| {
listen: ListenInfoOnion
hostname: string
}
| {
listen: ListenInfoIp
hostname:
| string
| { domain: string; subdomain: string | null; port: number }
}
)

export type MultiHost = HostBase & {
kind: "multi"
} & {
hostnames:
| {
listen: null
hostname: null
}
| {
listen: ListenInfoOnion
hostname: string
}
| {
listen: ListenInfoIp
hostname: (
| string
| { domain: string; subdomain: string | null; port: number }
)[]
}
}

export type InterfaceId = string

export type NetworkInterface = {
Expand All @@ -189,7 +250,7 @@ export type NetworkInterface = {
/** All URIs */
addresses: Address[]

/** The netowrk interface could be serveral types, something like ui, p2p, or network */
/** The network interface could be several types, something like ui, p2p, or network */
type: NetworkInterfaceType
}
// prettier-ignore
Expand Down Expand Up @@ -246,13 +307,13 @@ export type Effects = {
hostId: string
packageId?: string
callback: () => void
}): Promise<[HostName]>
}): Promise<[Hostname]>
getHostnames(options: {
kind?: "multi"
packageId?: string
hostId: string
callback: () => void
}): Promise<[HostName, ...HostName[]]>
}): Promise<[Hostname, ...Hostname[]]>

// /**
// * Run rsync between two volumes. This is used to backup data between volumes.
Expand Down
26 changes: 25 additions & 1 deletion web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"check:install-wiz": "tsc --project projects/install-wizard/tsconfig.json --noEmit --skipLibCheck",
"check:setup": "tsc --project projects/setup-wizard/tsconfig.json --noEmit --skipLibCheck",
"check:ui": "tsc --project projects/ui/tsconfig.json --noEmit --skipLibCheck",
"build:deps": "rm -rf .angular/cache && cd ../patch-db/client && npm ci && npm run build",
"build:deps": "rm -rf .angular/cache && (cd ../patch-db/client && npm ci && npm run build) && (cd ../sdk && make bundle)",
"build:dui": "ng run diagnostic-ui:build",
"build:install-wiz": "ng run install-wizard:build",
"build:setup": "ng run setup-wizard:build",
Expand Down Expand Up @@ -50,6 +50,7 @@
"@ng-web-apis/resize-observer": "^2.0.0",
"@start9labs/argon2": "^0.2.2",
"@start9labs/emver": "^0.1.5",
"@start9labs/start-sdk": "file:../sdk/dist",
"@taiga-ui/addon-charts": "3.20.0",
"@taiga-ui/cdk": "3.20.0",
"@taiga-ui/core": "3.20.0",
Expand All @@ -72,7 +73,7 @@
"mustache": "^4.2.0",
"ng-qrcode": "^7.0.0",
"node-jose": "^2.2.0",
"patch-db-client": "file: ../../../patch-db/client",
"patch-db-client": "file:../patch-db/client",
"pbkdf2": "^3.1.2",
"rxjs": "^7.8.1",
"swiper": "^8.2.4",
Expand Down

0 comments on commit eae75c1

Please sign in to comment.