mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
Merge branch 'next/minor' of github.com:Start9Labs/start-os into next/major
This commit is contained in:
@@ -81,42 +81,50 @@ export class ConfigService {
|
||||
}
|
||||
|
||||
/** ${scheme}://${username}@${host}:${externalPort}${suffix} */
|
||||
launchableAddress(ui: T.ServiceInterfaceWithHostInfo): string {
|
||||
if (ui.type !== 'ui') return ''
|
||||
launchableAddress(
|
||||
interfaces: PackageDataEntry['serviceInterfaces'],
|
||||
hosts: PackageDataEntry['hosts'],
|
||||
): string {
|
||||
const ui = Object.values(interfaces).find(
|
||||
i =>
|
||||
i.type === 'ui' &&
|
||||
(i.addressInfo.scheme === 'http' ||
|
||||
i.addressInfo.sslScheme === 'https'),
|
||||
) // TODO select if multiple
|
||||
|
||||
if (!ui) return ''
|
||||
|
||||
const hostnameInfo =
|
||||
hosts[ui.addressInfo.hostId]?.hostnameInfo[ui.addressInfo.internalPort]
|
||||
|
||||
if (!hostnameInfo) return ''
|
||||
|
||||
const host = ui.hostInfo
|
||||
const addressInfo = ui.addressInfo
|
||||
const scheme = this.isHttps() ? 'https' : 'http'
|
||||
const scheme = this.isHttps()
|
||||
? ui.addressInfo.sslScheme === 'https'
|
||||
? 'https'
|
||||
: 'http'
|
||||
: ui.addressInfo.scheme === 'http'
|
||||
? 'http'
|
||||
: 'https'
|
||||
const username = addressInfo.username ? addressInfo.username + '@' : ''
|
||||
const suffix = addressInfo.suffix || ''
|
||||
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 = hostnameInfo.find(h => h.kind === 'onion')
|
||||
?.hostname as T.OnionHostname | undefined
|
||||
|
||||
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)
|
||||
}
|
||||
if (this.isTor() && onionHostname) {
|
||||
url.hostname = onionHostname.value
|
||||
} else {
|
||||
const hostname = {} as T.ExportedHostnameInfo // host.hostname
|
||||
const ipHostname = hostnameInfo.find(h => h.kind === 'ip')?.hostname as
|
||||
| T.IpHostname
|
||||
| undefined
|
||||
|
||||
if (!hostname) return ''
|
||||
if (!ipHostname) return ''
|
||||
|
||||
if (this.isTor() && hostname.kind === 'onion') {
|
||||
url.hostname = (hostname.hostname as T.ExportedOnionHostname).value
|
||||
} else {
|
||||
url.hostname = this.hostname
|
||||
url.port = String(hostname.hostname.sslPort || hostname.hostname.port)
|
||||
}
|
||||
url.hostname = this.hostname
|
||||
url.port = String(ipHostname.sslPort || ipHostname.port)
|
||||
}
|
||||
|
||||
return url.href
|
||||
|
||||
Reference in New Issue
Block a user