mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
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:
@@ -8,6 +8,7 @@ import { PatchDB } from 'patch-db-client'
|
||||
import { QRComponent } from 'src/app/components/qr/qr.component'
|
||||
import { map } from 'rxjs'
|
||||
import { T } from '@start9labs/start-sdk'
|
||||
import { addressHostToUrl } from '@start9labs/start-sdk/cjs/lib/util/getServiceInterface'
|
||||
|
||||
type MappedInterface = T.ServiceInterface & {
|
||||
addresses: MappedAddress[]
|
||||
@@ -33,10 +34,14 @@ export class AppInterfacesPage {
|
||||
.sort(iface =>
|
||||
iface.name.toLowerCase() > iface.name.toLowerCase() ? -1 : 1,
|
||||
)
|
||||
.map(iface => ({
|
||||
...iface,
|
||||
addresses: getAddresses(iface),
|
||||
}))
|
||||
.map(iface => {
|
||||
// TODO @Matt
|
||||
const host = {} as any
|
||||
return {
|
||||
...iface,
|
||||
addresses: getAddresses(iface, host),
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
ui: sorted.filter(val => val.type === 'ui'),
|
||||
@@ -99,66 +104,40 @@ export class AppInterfacesItemComponent {
|
||||
}
|
||||
|
||||
function getAddresses(
|
||||
serviceInterface: T.ServiceInterfaceWithHostInfo,
|
||||
serviceInterface: T.ServiceInterface,
|
||||
host: T.Host,
|
||||
): MappedAddress[] {
|
||||
const host = serviceInterface.hostInfo
|
||||
const addressInfo = serviceInterface.addressInfo
|
||||
const username = addressInfo.username ? addressInfo.username + '@' : ''
|
||||
const suffix = addressInfo.suffix || ''
|
||||
|
||||
const hostnames = host.kind === 'multi' ? host.hostnames : [] // TODO: non-multi
|
||||
const hostnames =
|
||||
host.kind === 'multi' ? host.hostnameInfo[addressInfo.internalPort] : [] // TODO: non-multi
|
||||
/* host.hostname
|
||||
? [host.hostname]
|
||||
: [] */
|
||||
|
||||
const addresses: MappedAddress[] = []
|
||||
|
||||
hostnames.forEach(h => {
|
||||
return hostnames.flatMap(h => {
|
||||
let name = ''
|
||||
let hostname = ''
|
||||
|
||||
if (h.kind === 'onion') {
|
||||
name = 'Tor'
|
||||
hostname = h.hostname.value
|
||||
} else {
|
||||
const hostnameKind = h.hostname.kind
|
||||
|
||||
if (hostnameKind === 'domain') {
|
||||
name = 'Domain'
|
||||
hostname = `${h.hostname.subdomain}.${h.hostname.domain}`
|
||||
} else {
|
||||
name =
|
||||
hostnameKind === 'local'
|
||||
? 'Local'
|
||||
: `${h.networkInterfaceId} (${hostnameKind})`
|
||||
hostname = h.hostname.value
|
||||
}
|
||||
}
|
||||
|
||||
if (h.hostname.sslPort) {
|
||||
const port = h.hostname.sslPort === 443 ? '' : `:${h.hostname.sslPort}`
|
||||
const scheme = addressInfo.bindOptions.addSsl?.scheme
|
||||
? `${addressInfo.bindOptions.addSsl.scheme}://`
|
||||
: ''
|
||||
|
||||
addresses.push({
|
||||
name: name === 'Tor' ? 'Tor (HTTPS)' : name,
|
||||
url: `${scheme}${username}${hostname}${port}${suffix}`,
|
||||
})
|
||||
}
|
||||
|
||||
if (h.hostname.port) {
|
||||
const port = h.hostname.port === 80 ? '' : `:${h.hostname.port}`
|
||||
const scheme = addressInfo.bindOptions.scheme
|
||||
? `${addressInfo.bindOptions.scheme}://`
|
||||
: ''
|
||||
|
||||
addresses.push({
|
||||
name: name === 'Tor' ? 'Tor (HTTP)' : name,
|
||||
url: `${scheme}${username}${hostname}${port}${suffix}`,
|
||||
})
|
||||
}
|
||||
return addressHostToUrl(addressInfo, h).map(url => ({
|
||||
name,
|
||||
url,
|
||||
}))
|
||||
})
|
||||
|
||||
return addresses
|
||||
}
|
||||
|
||||
@@ -1422,66 +1422,11 @@ export module Mock {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'abcdefg',
|
||||
bindOptions: {
|
||||
scheme: 'http',
|
||||
preferredExternalPort: 80,
|
||||
addSsl: {
|
||||
// addXForwardedHeaders: false,
|
||||
preferredExternalPort: 443,
|
||||
scheme: 'https',
|
||||
alpn: { specified: ['http/1.1', 'h2'] },
|
||||
},
|
||||
secure: null,
|
||||
},
|
||||
internalPort: 80,
|
||||
scheme: 'http',
|
||||
sslScheme: 'https',
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'abcdefg',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: null,
|
||||
sslPort: 1234,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'bitcoin-ui-address.onion',
|
||||
port: 80,
|
||||
sslPort: 443,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: null,
|
||||
sslPort: 1234,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: null,
|
||||
sslPort: 1234,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
rpc: {
|
||||
id: 'rpc',
|
||||
@@ -1495,66 +1440,11 @@ export module Mock {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'bcdefgh',
|
||||
bindOptions: {
|
||||
scheme: 'http',
|
||||
preferredExternalPort: 80,
|
||||
addSsl: {
|
||||
// addXForwardedHeaders: false,
|
||||
preferredExternalPort: 443,
|
||||
scheme: 'https',
|
||||
alpn: { specified: ['http/1.1'] },
|
||||
},
|
||||
secure: null,
|
||||
},
|
||||
internalPort: 8332,
|
||||
scheme: 'http',
|
||||
sslScheme: 'https',
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'bcdefgh',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: null,
|
||||
sslPort: 2345,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'bitcoin-rpc-address.onion',
|
||||
port: 80,
|
||||
sslPort: 443,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: null,
|
||||
sslPort: 2345,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: null,
|
||||
sslPort: 2345,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
p2p: {
|
||||
id: 'p2p',
|
||||
@@ -1568,63 +1458,11 @@ export module Mock {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'cdefghi',
|
||||
bindOptions: {
|
||||
scheme: 'bitcoin',
|
||||
preferredExternalPort: 8333,
|
||||
addSsl: null,
|
||||
secure: {
|
||||
ssl: false,
|
||||
},
|
||||
},
|
||||
internalPort: 8333,
|
||||
scheme: 'bitcoin',
|
||||
sslScheme: null,
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'cdefghi',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 3456,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'bitcoin-p2p-address.onion',
|
||||
port: 8333,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 3456,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 3456,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
currentDependencies: {},
|
||||
@@ -1660,101 +1498,11 @@ export module Mock {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'hijklmnop',
|
||||
bindOptions: {
|
||||
scheme: 'http',
|
||||
preferredExternalPort: 80,
|
||||
addSsl: {
|
||||
// addXForwardedHeaders: false,
|
||||
preferredExternalPort: 443,
|
||||
scheme: 'https',
|
||||
alpn: { specified: ['http/1.1', 'h2'] },
|
||||
},
|
||||
secure: {
|
||||
ssl: true,
|
||||
},
|
||||
},
|
||||
internalPort: 80,
|
||||
scheme: 'http',
|
||||
sslScheme: 'https',
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'hijklmnop',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: null,
|
||||
sslPort: 4567,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'proxy-ui-address.onion',
|
||||
port: 80,
|
||||
sslPort: 443,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: null,
|
||||
sslPort: 4567,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: null,
|
||||
sslPort: 4567,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'wlan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: null,
|
||||
sslPort: 4567,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'wlan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.7',
|
||||
port: null,
|
||||
sslPort: 4567,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'wlan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: null,
|
||||
sslPort: 4567,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
currentDependencies: {
|
||||
@@ -1801,63 +1549,11 @@ export module Mock {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'qrstuv',
|
||||
bindOptions: {
|
||||
scheme: 'grpc',
|
||||
preferredExternalPort: 10009,
|
||||
addSsl: null,
|
||||
secure: {
|
||||
ssl: true,
|
||||
},
|
||||
},
|
||||
internalPort: 10009,
|
||||
scheme: null,
|
||||
sslScheme: 'grpc',
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'qrstuv',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'lnd-grpc-address.onion',
|
||||
port: 10009,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
lndconnect: {
|
||||
id: 'lndconnect',
|
||||
@@ -1871,63 +1567,11 @@ export module Mock {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'qrstuv',
|
||||
bindOptions: {
|
||||
scheme: 'lndconnect',
|
||||
preferredExternalPort: 10009,
|
||||
addSsl: null,
|
||||
secure: {
|
||||
ssl: true,
|
||||
},
|
||||
},
|
||||
internalPort: 10009,
|
||||
scheme: null,
|
||||
sslScheme: 'lndconnect',
|
||||
suffix: 'cert=askjdfbjadnaskjnd&macaroon=ksjbdfnhjasbndjksand',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'qrstuv',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'lnd-grpc-address.onion',
|
||||
port: 10009,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
p2p: {
|
||||
id: 'p2p',
|
||||
@@ -1941,63 +1585,11 @@ export module Mock {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'rstuvw',
|
||||
bindOptions: {
|
||||
scheme: null,
|
||||
preferredExternalPort: 9735,
|
||||
addSsl: null,
|
||||
secure: {
|
||||
ssl: true,
|
||||
},
|
||||
},
|
||||
internalPort: 9735,
|
||||
scheme: 'lightning',
|
||||
sslScheme: null,
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'rstuvw',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 6789,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'lnd-p2p-address.onion',
|
||||
port: 9735,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 6789,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 6789,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
currentDependencies: {
|
||||
|
||||
@@ -141,66 +141,11 @@ export const mockPatchData: DataModel = {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'abcdefg',
|
||||
bindOptions: {
|
||||
scheme: 'http',
|
||||
preferredExternalPort: 80,
|
||||
addSsl: {
|
||||
// addXForwardedHeaders: false,
|
||||
preferredExternalPort: 443,
|
||||
scheme: 'https',
|
||||
alpn: { specified: ['http/1.1', 'h2'] },
|
||||
},
|
||||
secure: null,
|
||||
},
|
||||
internalPort: 80,
|
||||
scheme: 'http',
|
||||
sslScheme: 'https',
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'abcdefg',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: null,
|
||||
sslPort: 1234,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'bitcoin-ui-address.onion',
|
||||
port: 80,
|
||||
sslPort: 443,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: null,
|
||||
sslPort: 1234,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: null,
|
||||
sslPort: 1234,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
rpc: {
|
||||
id: 'rpc',
|
||||
@@ -214,66 +159,11 @@ export const mockPatchData: DataModel = {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'bcdefgh',
|
||||
bindOptions: {
|
||||
scheme: 'http',
|
||||
preferredExternalPort: 80,
|
||||
addSsl: {
|
||||
// addXForwardedHeaders: false,
|
||||
preferredExternalPort: 443,
|
||||
scheme: 'https',
|
||||
alpn: { specified: ['http/1.1'] },
|
||||
},
|
||||
secure: null,
|
||||
},
|
||||
internalPort: 8332,
|
||||
scheme: 'http',
|
||||
sslScheme: 'https',
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'bcdefgh',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: null,
|
||||
sslPort: 2345,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'bitcoin-rpc-address.onion',
|
||||
port: 80,
|
||||
sslPort: 443,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: null,
|
||||
sslPort: 2345,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: null,
|
||||
sslPort: 2345,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
p2p: {
|
||||
id: 'p2p',
|
||||
@@ -287,63 +177,11 @@ export const mockPatchData: DataModel = {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'cdefghi',
|
||||
bindOptions: {
|
||||
scheme: 'bitcoin',
|
||||
preferredExternalPort: 8333,
|
||||
addSsl: null,
|
||||
secure: {
|
||||
ssl: false,
|
||||
},
|
||||
},
|
||||
internalPort: 8333,
|
||||
scheme: 'bitcoin',
|
||||
sslScheme: null,
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'cdefghi',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 3456,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'bitcoin-p2p-address.onion',
|
||||
port: 8333,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 3456,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 3456,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
currentDependencies: {},
|
||||
@@ -382,63 +220,11 @@ export const mockPatchData: DataModel = {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'qrstuv',
|
||||
bindOptions: {
|
||||
scheme: 'grpc',
|
||||
preferredExternalPort: 10009,
|
||||
addSsl: null,
|
||||
secure: {
|
||||
ssl: true,
|
||||
},
|
||||
},
|
||||
internalPort: 10009,
|
||||
scheme: null,
|
||||
sslScheme: 'grpc',
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'qrstuv',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'lnd-grpc-address.onion',
|
||||
port: 10009,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
lndconnect: {
|
||||
id: 'lndconnect',
|
||||
@@ -452,63 +238,11 @@ export const mockPatchData: DataModel = {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'qrstuv',
|
||||
bindOptions: {
|
||||
scheme: 'lndconnect',
|
||||
preferredExternalPort: 10009,
|
||||
addSsl: null,
|
||||
secure: {
|
||||
ssl: true,
|
||||
},
|
||||
},
|
||||
internalPort: 10009,
|
||||
scheme: null,
|
||||
sslScheme: 'lndconnect',
|
||||
suffix: 'cert=askjdfbjadnaskjnd&macaroon=ksjbdfnhjasbndjksand',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'qrstuv',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'lnd-grpc-address.onion',
|
||||
port: 10009,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 5678,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
p2p: {
|
||||
id: 'p2p',
|
||||
@@ -522,61 +256,11 @@ export const mockPatchData: DataModel = {
|
||||
addressInfo: {
|
||||
username: null,
|
||||
hostId: 'rstuvw',
|
||||
bindOptions: {
|
||||
scheme: null,
|
||||
preferredExternalPort: 9735,
|
||||
addSsl: null,
|
||||
secure: { ssl: true },
|
||||
},
|
||||
internalPort: 8333,
|
||||
scheme: 'bitcoin',
|
||||
sslScheme: null,
|
||||
suffix: '',
|
||||
},
|
||||
hostInfo: {
|
||||
id: 'rstuvw',
|
||||
kind: 'multi',
|
||||
hostnames: [
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'local',
|
||||
value: 'adjective-noun.local',
|
||||
port: 6789,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'onion',
|
||||
hostname: {
|
||||
value: 'lnd-p2p-address.onion',
|
||||
port: 9735,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv4',
|
||||
value: '192.168.1.5',
|
||||
port: 6789,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'ip',
|
||||
networkInterfaceId: 'elan0',
|
||||
public: false,
|
||||
hostname: {
|
||||
kind: 'ipv6',
|
||||
value: '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
|
||||
port: 6789,
|
||||
sslPort: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
currentDependencies: {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Inject, Injectable } from '@angular/core'
|
||||
import { WINDOW } from '@ng-web-apis/common'
|
||||
import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
|
||||
import { ConfigService } from './config.service'
|
||||
import { T } from '@start9labs/start-sdk'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -13,8 +14,10 @@ export class UiLauncherService {
|
||||
) {}
|
||||
|
||||
launch(interfaces: PackageDataEntry['serviceInterfaces']): void {
|
||||
// TODO @Matt
|
||||
const host = {} as any
|
||||
this.windowRef.open(
|
||||
this.config.launchableAddress(interfaces),
|
||||
this.config.launchableAddress(interfaces, host),
|
||||
'_blank',
|
||||
'noreferrer',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user