From 9a3e508ce8832c46708c1991b41e78531ac7d13a Mon Sep 17 00:00:00 2001
From: Tom Wiesing
Date: Thu, 2 Nov 2023 14:44:09 +0100
Subject: [PATCH] Use PanelDomain in help texts
---
internal/config/http.go | 5 +++--
internal/dis/component/auth/panel/ssh.go | 8 +++++---
internal/dis/component/auth/panel/templates/ssh.html | 6 +++---
internal/dis/component/ssh2/server_handler.go | 2 +-
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/internal/config/http.go b/internal/config/http.go
index 7284ed4..a9896ef 100644
--- a/internal/config/http.go
+++ b/internal/config/http.go
@@ -41,7 +41,8 @@ type HTTPConfig struct {
PhpMyAdmin validators.NullableBool `yaml:"phpmyadmin" validate:"bool" default:"false"`
}
-func (hcfg HTTPConfig) PublicTopDomain() string {
+// PanelDomain is the domain name where the control panel runs.
+func (hcfg HTTPConfig) PanelDomain() string {
// if we have panel domain enabled, then return it
if hcfg.Panel.Set && hcfg.Panel.Value {
return hcfg.PrimaryDomain
@@ -81,7 +82,7 @@ func (hcfg HTTPConfig) optionalURL(domain string, enabled validators.NullableBoo
func (hcfg HTTPConfig) JoinPath(elem ...string) *url.URL {
u := url.URL{
Scheme: "http",
- Host: hcfg.PublicTopDomain(),
+ Host: hcfg.PanelDomain(),
Path: "/",
}
if hcfg.HTTPSEnabled() {
diff --git a/internal/dis/component/auth/panel/ssh.go b/internal/dis/component/auth/panel/ssh.go
index ad7f8ca..25bb9d9 100644
--- a/internal/dis/component/auth/panel/ssh.go
+++ b/internal/dis/component/auth/panel/ssh.go
@@ -34,8 +34,9 @@ type SSHTemplateContext struct {
Keys []models.Keys
- Domain string // domain name of the distillery
- Port uint16 // public port of the distillery ssh servers
+ Domain string // domain name of the distillery
+ PanelDomain string // domain name of the panel
+ Port uint16 // public port of the distillery ssh servers
Slug string // slug of the wisski
Hostname string // hostname of an example wisski
@@ -62,7 +63,8 @@ func (panel *UserPanel) sshRoute(ctx context.Context) http.Handler {
return sc, err
}
- sc.Domain = panel.Config.HTTP.PublicTopDomain()
+ sc.Domain = panel.Config.HTTP.PrimaryDomain
+ sc.PanelDomain = panel.Config.HTTP.PanelDomain()
sc.Port = panel.Config.Listen.SSHPort
// pick the first domain that the user has access to as an example
diff --git a/internal/dis/component/auth/panel/templates/ssh.html b/internal/dis/component/auth/panel/templates/ssh.html
index e86a82c..7b9e752 100644
--- a/internal/dis/component/auth/panel/templates/ssh.html
+++ b/internal/dis/component/auth/panel/templates/ssh.html
@@ -72,7 +72,7 @@
From a Linux (or Mac, or Windows 11) command line you may use:
- ssh -J {{ .Domain }}:{{ .Port }} www-data@{{ .Hostname }}
+ ssh -J {{ .PanelDomain }}:{{ .Port }} www-data@{{ .Hostname }}
You may also place the following into your $HOME/.ssh/config file:
@@ -83,7 +83,7 @@
User www-data
Host {{ .Domain }}.proxy
User www-data
- Hostname {{ .Domain }}
+ Hostname {{ .PanelDomain }}
Port {{ .Port }}
@@ -110,7 +110,7 @@ Host {{ .Domain }}.proxy
-ssh -p {{ .Port }} {{ .Domain }} -L 7200:triplestore:7200
+ssh -p {{ .Port }} {{ .PanelDomain }} -L 7200:triplestore:7200
diff --git a/internal/dis/component/ssh2/server_handler.go b/internal/dis/component/ssh2/server_handler.go
index 0119d2d..f1ae256 100644
--- a/internal/dis/component/ssh2/server_handler.go
+++ b/internal/dis/component/ssh2/server_handler.go
@@ -45,7 +45,7 @@ func (ssh2 *SSH2) handleConnection(session ssh.Session) {
{"${SLUG}", slug},
{"${HOSTNAME}", slug + "." + ssh2.Config.HTTP.PrimaryDomain},
- {"${DOMAIN}", ssh2.Config.HTTP.PublicTopDomain()},
+ {"${DOMAIN}", ssh2.Config.HTTP.PanelDomain()},
{"${PORT}", strconv.FormatUint(uint64(ssh2.Config.Listen.SSHPort), 10)},
{"${HELP_URL}", ssh2.Config.HTTP.JoinPath("user", "ssh").String()},