Feature/network (#2622)

* Feature: Add in the clear bindings

* wip: Working on network

* fix: Make it so the config gives the url

* chore: Remove the repeated types

* chore: Add in the todo's here

* chore: UPdate and remove some poorly name var

* chore: Remove the clear-bindings impl

* chore: Remove the wrapper

* handle HostnameInfo for Host bindings

Co-authored-by: Jade <Blu-J@users.noreply.github.com>

* ??

* chore: Make the install work

* Fix: Url's not being created

* chore: Fix the local onion in url

* include port in hostname

* Chore of adding a comment just to modify.

---------

Co-authored-by: Aiden McClelland <me@drbonez.dev>
Co-authored-by: Jade <Blu-J@users.noreply.github.com>
This commit is contained in:
Jade
2024-06-06 15:39:54 -06:00
committed by GitHub
parent 412c5d68cc
commit 2c12af5af8
67 changed files with 798 additions and 1516 deletions

View File

@@ -57,12 +57,14 @@ export class ConfigService {
}
/** ${scheme}://${username}@${host}:${externalPort}${suffix} */
launchableAddress(interfaces: PackageDataEntry['serviceInterfaces']): string {
launchableAddress(
interfaces: PackageDataEntry['serviceInterfaces'],
host: T.Host,
): string {
const ui = Object.values(interfaces).find(i => i.type === 'ui')
if (!ui) return ''
const host = ui.hostInfo
const addressInfo = ui.addressInfo
const scheme = this.isHttps() ? 'https' : 'http'
const username = addressInfo.username ? addressInfo.username + '@' : ''
@@ -70,20 +72,25 @@ export class ConfigService {
const url = new URL(`${scheme}://${username}placeholder${suffix}`)
if (host.kind === 'multi') {
const onionHostname = host.hostnames.find(h => h.kind === 'onion')
?.hostname as T.ExportedOnionHostname
const onionHostname = host.addresses.find(h => h.kind === 'onion')
?.address as T.OnionHostname | undefined
if (!onionHostname)
throw new Error('Expecting that there is an onion hostname')
if (this.isTor() && onionHostname) {
url.hostname = onionHostname.value
} else {
const ipHostname = host.hostnames.find(h => h.kind === 'ip')
?.hostname as T.ExportedIpHostname
if (!ipHostname) return ''
url.hostname = this.hostname
url.port = String(ipHostname.sslPort || ipHostname.port)
}
// TODO Handle single
// else {
// const ipHostname = host.addresses.find(h => h.kind === 'ip')
// ?.hostname as T.ExportedIpHostname
// if (!ipHostname) return ''
// url.hostname = this.hostname
// url.port = String(ipHostname.sslPort || ipHostname.port)
// }
} else {
throw new Error('unimplemented')
// const hostname = {} as T.ExportedHostnameInfo // host.hostname