Skip to content

Commit 6f1900f

Browse files
MattDHilldr-bonez
andauthored
limit adding gateway to StartTunnel, better copy around Tor SSL (#3033)
* limit adding gateway to StartTunnel, better copy around Tor SSL * properly differentiate ssl * exclude disconnected gateways * better error handling --------- Co-authored-by: Aiden McClelland <me@drbonez.dev>
1 parent bc62de7 commit 6f1900f

File tree

9 files changed

+91
-83
lines changed

9 files changed

+91
-83
lines changed

core/startos/src/net/host/binding.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,12 @@ impl BindInfo {
135135
}
136136
impl InterfaceFilter for NetInfo {
137137
fn filter(&self, id: &GatewayId, info: &NetworkInterfaceInfo) -> bool {
138-
if info.public() {
139-
self.public_enabled.contains(id)
140-
} else {
141-
!self.private_disabled.contains(id)
142-
}
138+
info.ip_info.is_some()
139+
&& if info.public() {
140+
self.public_enabled.contains(id)
141+
} else {
142+
!self.private_disabled.contains(id)
143+
}
143144
}
144145
}
145146

sdk/base/lib/util/getServiceInterface.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ type FormatReturnTy<
8787
export type Filled = {
8888
hostnames: HostnameInfo[]
8989

90-
toUrl: (h: HostnameInfo) => UrlString[]
90+
toUrls: (h: HostnameInfo) => {
91+
url: UrlString | null
92+
sslUrl: UrlString | null
93+
}
9194

9295
filter: <F extends Filter, Format extends Formats = "urlstring">(
9396
filter: F,
@@ -139,7 +142,7 @@ const unique = <A>(values: A[]) => Array.from(new Set(values))
139142
export const addressHostToUrl = (
140143
{ scheme, sslScheme, username, suffix }: AddressInfo,
141144
hostname: HostnameInfo,
142-
): UrlString[] => {
145+
): { url: UrlString | null; sslUrl: UrlString | null } => {
143146
const res = []
144147
const fmt = (scheme: string | null, host: HostnameInfo, port: number) => {
145148
const excludePort =
@@ -164,14 +167,16 @@ export const addressHostToUrl = (
164167
username ? `${username}@` : ""
165168
}${hostname}${excludePort ? "" : `:${port}`}${suffix}`
166169
}
170+
let url = null
167171
if (hostname.hostname.sslPort !== null) {
168-
res.push(fmt(sslScheme, hostname, hostname.hostname.sslPort))
172+
url = fmt(sslScheme, hostname, hostname.hostname.sslPort)
169173
}
174+
let sslUrl = null
170175
if (hostname.hostname.port !== null) {
171-
res.push(fmt(scheme, hostname, hostname.hostname.port))
176+
sslUrl = fmt(scheme, hostname, hostname.hostname.port)
172177
}
173178

174-
return res
179+
return { url, sslUrl }
175180
}
176181

177182
function filterRec(
@@ -223,21 +228,25 @@ export const filledAddress = (
223228
host: Host,
224229
addressInfo: AddressInfo,
225230
): FilledAddressInfo => {
226-
const toUrl = addressHostToUrl.bind(null, addressInfo)
231+
const toUrls = addressHostToUrl.bind(null, addressInfo)
232+
const toUrlArray = (h: HostnameInfo) => {
233+
const u = toUrls(h)
234+
return [u.url, u.sslUrl].filter((u) => u !== null)
235+
}
227236
const hostnames = host.hostnameInfo[addressInfo.internalPort] ?? []
228237

229238
return {
230239
...addressInfo,
231240
hostnames,
232-
toUrl,
241+
toUrls,
233242
filter: <F extends Filter, Format extends Formats = "urlstring">(
234243
filter: F,
235244
format?: Format,
236245
) => {
237246
const filtered = filterRec(hostnames, filter, false)
238247
let res: FormatReturnTy<F, Format>[] = filtered as any
239248
if (format === "hostname-info") return res
240-
const urls = filtered.flatMap(toUrl)
249+
const urls = filtered.flatMap(toUrlArray)
241250
if (format === "url") res = urls.map((u) => new URL(u)) as any
242251
else res = urls as any
243252
return res
@@ -279,28 +288,28 @@ export const filledAddress = (
279288
)
280289
},
281290
get urls() {
282-
return this.hostnames.flatMap(toUrl)
291+
return this.hostnames.flatMap(toUrlArray)
283292
},
284293
get publicUrls() {
285-
return this.publicHostnames.flatMap(toUrl)
294+
return this.publicHostnames.flatMap(toUrlArray)
286295
},
287296
get onionUrls() {
288-
return this.onionHostnames.flatMap(toUrl)
297+
return this.onionHostnames.flatMap(toUrlArray)
289298
},
290299
get localUrls() {
291-
return this.localHostnames.flatMap(toUrl)
300+
return this.localHostnames.flatMap(toUrlArray)
292301
},
293302
get ipUrls() {
294-
return this.ipHostnames.flatMap(toUrl)
303+
return this.ipHostnames.flatMap(toUrlArray)
295304
},
296305
get ipv4Urls() {
297-
return this.ipv4Hostnames.flatMap(toUrl)
306+
return this.ipv4Hostnames.flatMap(toUrlArray)
298307
},
299308
get ipv6Urls() {
300-
return this.ipv6Hostnames.flatMap(toUrl)
309+
return this.ipv6Hostnames.flatMap(toUrlArray)
301310
},
302311
get nonIpUrls() {
303-
return this.nonIpHostnames.flatMap(toUrl)
312+
return this.nonIpHostnames.flatMap(toUrlArray)
304313
},
305314
}
306315
}

web/projects/shared/src/i18n/dictionaries/de.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export default {
502502
531: 'Fehler beim Initialisieren des Servers',
503503
532: 'Abgeschlossen',
504504
533: 'Gateways',
505-
535: 'Gateway hinzufügen',
505+
535: 'StartTunnel-Gateway hinzufügen',
506506
536: 'Umbenennen',
507507
537: 'Zugriff',
508508
538: 'Öffentliche Domains',
@@ -535,10 +535,8 @@ export default {
535535
569: 'Wählen Sie eine Zertifizierungsstelle aus, um SSL/TLS-Zertifikate für diese Domain auszustellen.',
536536
570: 'Andere',
537537
571: 'Ein Name zur einfachen Identifizierung des Gateways',
538-
572: 'Wählen Sie diese Option, wenn das Gateway für den privaten Zugriff nur für autorisierte Clients konfiguriert ist. StartTunnel ist ein privates Gateway.',
539-
573: 'Wählen Sie diese Option, wenn das Gateway für uneingeschränkten öffentlichen Zugriff konfiguriert ist.',
540538
574: 'Datei',
541-
575: 'Wireguard-Konfigurationsdatei',
539+
575: 'StartTunnel-Konfigurationsdatei',
542540
576: 'Kopieren/Einfügen',
543541
577: 'Dateiinhalt',
544542
578: 'Öffentlicher Schlüssel',
@@ -550,7 +548,7 @@ export default {
550548
584: 'Verbindungen können manchmal langsam oder unzuverlässig sein',
551549
585: 'Öffentlich, wenn Sie die Adresse öffentlich teilen, andernfalls privat',
552550
586: 'Erfordert ein Tor-fähiges Gerät oder einen Browser',
553-
587: 'Nur nützlich für Clients, die HTTPS erzwingen',
551+
587: 'Nur nützlich für Clients, die SSL erzwingen',
554552
588: 'Ideal für anonyme, zensurresistente Bereitstellung und Fernzugriff',
555553
589: 'Ideal für lokalen Zugriff',
556554
590: 'Erfordert die Verbindung mit demselben lokalen Netzwerk (LAN) wie Ihr Server, entweder physisch oder über VPN',
@@ -589,4 +587,5 @@ export default {
589587
623: 'Alternative Implementierungen',
590588
624: 'Versionen',
591589
625: 'Eine andere Version auswählen',
590+
626: 'Hochladen',
592591
} satisfies i18n

web/projects/shared/src/i18n/dictionaries/en.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ export const ENGLISH = {
501501
'Error initializing server': 531,
502502
'Finished': 532, // an in, complete
503503
'Gateways': 533, // as in, a device or software that connects two different networks
504-
'Add gateway': 535, // as in, add a new network gateway to StartOS
504+
'Add StartTunnel Gateway': 535, // as in, add a new StartTunnel network gateway to StartOS
505505
'Rename': 536,
506506
'Access': 537, // as in, public or private access, almost "permission"
507507
'Public Domains': 538, // as in, internet domains
@@ -534,10 +534,8 @@ export const ENGLISH = {
534534
'Select a Certificate Authority to issue SSL/TLS certificates for this domain': 569,
535535
'Other': 570, // as in, a list option to indicate none of the options listed
536536
'A name to easily identify the gateway': 571,
537-
'select this option if the gateway is configured for private access to authorized clients only. StartTunnel is a private gateway.': 572,
538-
'select this option if the gateway is configured for unfettered public access.': 573,
539537
'File': 574, // as in, a computer file
540-
'Wireguard Config File': 575,
538+
'StartTunnel Config File': 575,
541539
'Copy/Paste': 576,
542540
'File Contents': 577,
543541
'Public Key': 578, // as in, a cryptographic public key
@@ -549,7 +547,7 @@ export const ENGLISH = {
549547
'Connections can be slow or unreliable at times': 584,
550548
'Public if you share the address publicly, otherwise private': 585,
551549
'Requires using a Tor-enabled device or browser': 586,
552-
'Only useful for clients that enforce HTTPS': 587,
550+
'Only useful for clients that require SSL': 587,
553551
'Ideal for anonymous, censorship-resistant hosting and remote access': 588,
554552
'Ideal for local access': 589,
555553
'Requires being connected to the same Local Area Network (LAN) as your server, either physically or via VPN': 590,
@@ -588,4 +586,5 @@ export const ENGLISH = {
588586
'Alternative Implementations': 623,
589587
'Versions': 624,
590588
'Select another version': 625,
589+
'Upload': 626, // as in, upload a file
591590
} as const

web/projects/shared/src/i18n/dictionaries/es.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export default {
502502
531: 'Error al inicializar el servidor',
503503
532: 'Finalizado',
504504
533: 'Puertas de enlace',
505-
535: 'Agregar puerta de enlace',
505+
535: 'Agregar puerta de enlace StartTunnel',
506506
536: 'Renombrar',
507507
537: 'Acceso',
508508
538: 'Dominios públicos',
@@ -535,10 +535,8 @@ export default {
535535
569: 'Selecciona una Autoridad Certificadora para emitir certificados SSL/TLS para este dominio.',
536536
570: 'Otro',
537537
571: 'Un nombre para identificar fácilmente la puerta de enlace',
538-
572: 'Selecciona esta opción si la puerta de enlace está configurada para acceso privado solo a clientes autorizados. StartTunnel es una puerta de enlace privada.',
539-
573: 'Selecciona esta opción si la puerta de enlace está configurada para acceso público sin restricciones.',
540538
574: 'Archivo',
541-
575: 'Archivo de configuración de Wireguard',
539+
575: 'Archivo de configuración de StartTunnel',
542540
576: 'Copiar/Pegar',
543541
577: 'Contenido del archivo',
544542
578: 'Clave pública',
@@ -550,7 +548,7 @@ export default {
550548
584: 'Las conexiones pueden ser lentas o poco confiables a veces',
551549
585: 'Público si compartes la dirección públicamente, de lo contrario privado',
552550
586: 'Requiere un dispositivo o navegador habilitado para Tor',
553-
587: 'Solo útil para clientes que imponen HTTPS',
551+
587: 'Solo útil para clientes que imponen SSL',
554552
588: 'Ideal para alojamiento y acceso remoto anónimo y resistente a la censura',
555553
589: 'Ideal para acceso local',
556554
590: 'Requiere estar conectado a la misma red de área local (LAN) que tu servidor, ya sea físicamente o mediante VPN',
@@ -589,4 +587,5 @@ export default {
589587
623: 'Implementaciones alternativas',
590588
624: 'Versiones',
591589
625: 'Seleccionar otra versión',
590+
626: 'Subir',
592591
} satisfies i18n

web/projects/shared/src/i18n/dictionaries/fr.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export default {
502502
531: "Erreur lors de l'initialisation du serveur",
503503
532: 'Terminé',
504504
533: 'Passerelles',
505-
535: 'Ajouter une passerelle',
505+
535: 'Ajouter une passerelle StartTunnel',
506506
536: 'Renommer',
507507
537: 'Accès',
508508
538: 'Domaines publics',
@@ -535,10 +535,8 @@ export default {
535535
569: 'Sélectionnez une Autorité de Certification pour émettre des certificats SSL/TLS pour ce domaine.',
536536
570: 'Autre',
537537
571: 'Un nom pour identifier facilement la passerelle',
538-
572: 'Sélectionnez cette option si la passerelle est configurée pour un accès privé uniquement aux clients autorisés. StartTunnel est une passerelle privée.',
539-
573: 'Sélectionnez cette option si la passerelle est configurée pour un accès public illimité.',
540538
574: 'Fichier',
541-
575: 'Fichier de configuration Wireguard',
539+
575: 'Fichier de configuration StartTunnel',
542540
576: 'Copier/Coller',
543541
577: 'Contenu du fichier',
544542
578: 'Clé publique',
@@ -550,7 +548,7 @@ export default {
550548
584: 'Les connexions peuvent parfois être lentes ou peu fiables',
551549
585: 'Public si vous partagez l’adresse publiquement, sinon privé',
552550
586: 'Nécessite un appareil ou un navigateur compatible Tor',
553-
587: 'Utile uniquement pour les clients qui imposent HTTPS',
551+
587: 'Utile uniquement pour les clients qui imposent SSL',
554552
588: 'Idéal pour l’hébergement et l’accès à distance anonymes et résistants à la censure',
555553
589: 'Idéal pour un accès local',
556554
590: 'Nécessite d’être connecté au même réseau local (LAN) que votre serveur, soit physiquement, soit via VPN',
@@ -589,4 +587,5 @@ export default {
589587
623: 'Implémentations alternatives',
590588
624: 'Versions',
591589
625: 'Sélectionner une autre version',
590+
626: 'Téléverser',
592591
} satisfies i18n

web/projects/shared/src/i18n/dictionaries/pl.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export default {
502502
531: 'Błąd inicjalizacji serwera',
503503
532: 'Zakończono',
504504
533: 'Bramy sieciowe',
505-
535: 'Dodaj bramę',
505+
535: 'Dodaj bramę StartTunnel',
506506
536: 'Zmień nazwę',
507507
537: 'Dostęp',
508508
538: 'Domeny publiczne',
@@ -535,10 +535,8 @@ export default {
535535
569: 'Wybierz Urząd Certyfikacji, aby wystawić certyfikaty SSL/TLS dla tej domeny.',
536536
570: 'Inne',
537537
571: 'Nazwa ułatwiająca identyfikację bramy',
538-
572: 'Wybierz tę opcję, jeśli brama jest skonfigurowana do prywatnego dostępu tylko dla autoryzowanych klientów. StartTunnel to prywatna brama.',
539-
573: 'Wybierz tę opcję, jeśli brama jest skonfigurowana do nieograniczonego publicznego dostępu.',
540538
574: 'Plik',
541-
575: 'Plik konfiguracyjny Wireguard',
539+
575: 'Plik konfiguracyjny StartTunnel',
542540
576: 'Kopiuj/Wklej',
543541
577: 'Zawartość pliku',
544542
578: 'Klucz publiczny',
@@ -550,7 +548,7 @@ export default {
550548
584: 'Połączenia mogą być czasami wolne lub niestabilne',
551549
585: 'Publiczne, jeśli udostępniasz adres publicznie, w przeciwnym razie prywatne',
552550
586: 'Wymaga urządzenia lub przeglądarki obsługującej Tor',
553-
587: 'Przydatne tylko dla klientów wymuszających HTTPS',
551+
587: 'Przydatne tylko dla klientów wymuszających SSL',
554552
588: 'Idealne do anonimowego, odpornego na cenzurę hostingu i zdalnego dostępu',
555553
589: 'Idealne do dostępu lokalnego',
556554
590: 'Wymaga połączenia z tą samą siecią lokalną (LAN) co serwer, fizycznie lub przez VPN',
@@ -589,4 +587,5 @@ export default {
589587
623: 'Alternatywne implementacje',
590588
624: 'Wersje',
591589
625: 'Wybierz inną wersję',
590+
626: 'Prześlij',
592591
} satisfies i18n

0 commit comments

Comments
 (0)