refactor: remove proxy IP from installer, config, and global settings

This commit is contained in:
Claus Lohmar 2026-06-15 04:51:49 +00:00
parent 9edd6f1038
commit 5663364b12
5 changed files with 5 additions and 38 deletions

View file

@ -47,7 +47,6 @@ IMAP_HOST_DEFAULT="imap.openxchange.eu"
IMAP_PORT_DEFAULT="993" IMAP_PORT_DEFAULT="993"
NEXTWKS_URL_DEFAULT="https://wks.lohmar.co.uk" NEXTWKS_URL_DEFAULT="https://wks.lohmar.co.uk"
AUTH_URL_DEFAULT="https://auth.lohmar.co.uk" AUTH_URL_DEFAULT="https://auth.lohmar.co.uk"
PROXY_IP_DEFAULT="172.16.0.10"
# ============================================================ # ============================================================
# AUTO-CLONE: if running standalone (not from repo), clone first # AUTO-CLONE: if running standalone (not from repo), clone first
@ -124,8 +123,6 @@ gather_inputs() {
NEXTWKS_URL="${NEXTWKS_URL:-$NEXTWKS_URL_DEFAULT}" NEXTWKS_URL="${NEXTWKS_URL:-$NEXTWKS_URL_DEFAULT}"
read -p " Auth URL [$AUTH_URL_DEFAULT]: " AUTH_URL read -p " Auth URL [$AUTH_URL_DEFAULT]: " AUTH_URL
AUTH_URL="${AUTH_URL:-$AUTH_URL_DEFAULT}" AUTH_URL="${AUTH_URL:-$AUTH_URL_DEFAULT}"
read -p " Reverse Proxy [$PROXY_IP_DEFAULT]: " PROXY_IP
PROXY_IP="${PROXY_IP:-$PROXY_IP_DEFAULT}"
# Extract domains from URLs # Extract domains from URLs
NEXTWKS_DOMAIN=$(echo "$NEXTWKS_URL" | sed 's|https\?://||;s|/.*||') NEXTWKS_DOMAIN=$(echo "$NEXTWKS_URL" | sed 's|https\?://||;s|/.*||')
@ -138,7 +135,6 @@ gather_inputs() {
info " Admin: ${ADMIN_UNAME} (${ADMIN_EMAIL:-no email})" info " Admin: ${ADMIN_UNAME} (${ADMIN_EMAIL:-no email})"
info " NextWks: ${NEXTWKS_URL}" info " NextWks: ${NEXTWKS_URL}"
info " Auth: ${AUTH_URL}" info " Auth: ${AUTH_URL}"
info " Proxy: ${PROXY_IP}"
echo "" echo ""
read -p " Install with these settings? [Y/n]: " CONFIRM read -p " Install with these settings? [Y/n]: " CONFIRM
[ "$CONFIRM" = "n" ] || [ "$CONFIRM" = "N" ] && { echo "Aborted."; exit 0; } [ "$CONFIRM" = "n" ] || [ "$CONFIRM" = "N" ] && { echo "Aborted."; exit 0; }
@ -155,7 +151,6 @@ ADMIN_UNAME="${ADMIN_UNAME}"
ADMIN_EMAIL="${ADMIN_EMAIL}" ADMIN_EMAIL="${ADMIN_EMAIL}"
NEXTWKS_URL="${NEXTWKS_URL}" NEXTWKS_URL="${NEXTWKS_URL}"
AUTH_URL="${AUTH_URL}" AUTH_URL="${AUTH_URL}"
PROXY_IP="${PROXY_IP}"
ENVEOF ENVEOF
success "Settings saved to $ENV_FILE" success "Settings saved to $ENV_FILE"
} }
@ -249,8 +244,6 @@ smtp:
imap: imap:
host: "${IMAP_HOST}" host: "${IMAP_HOST}"
port: ${IMAP_PORT} port: ${IMAP_PORT}
proxy:
ip: "${PROXY_IP}"
session: session:
secret: "${SESSION_KEY}" secret: "${SESSION_KEY}"
expiry_minutes: 60 expiry_minutes: 60

View file

@ -1,6 +1,6 @@
package templates package templates
templ GlobalSettings(smtpHost, smtpPort, smtpUser, smtpPass, imapHost, imapPort, nextwksURL, authURL, proxyIP, msg string) { templ GlobalSettings(smtpHost, smtpPort, smtpUser, smtpPass, imapHost, imapPort, nextwksURL, authURL, msg string) {
@Layout("global") { @Layout("global") {
<h2 style="font-size:1.15rem;font-weight:600;margin-bottom:20px">Global Settings</h2> <h2 style="font-size:1.15rem;font-weight:600;margin-bottom:20px">Global Settings</h2>
if msg != "" { if msg != "" {
@ -53,10 +53,6 @@ templ GlobalSettings(smtpHost, smtpPort, smtpUser, smtpPass, imapHost, imapPort,
<input type="text" name="auth_url" class="input" value={ authURL }/> <input type="text" name="auth_url" class="input" value={ authURL }/>
</div> </div>
</div> </div>
<div class="form-group">
<label>Reverse Proxy IP</label>
<input type="text" name="proxy_ip" class="input" value={ proxyIP }/>
</div>
</div> </div>
<button type="submit" class="btn" style="width:100%">Save Settings</button> <button type="submit" class="btn" style="width:100%">Save Settings</button>

View file

@ -8,7 +8,7 @@ package templates
import "github.com/a-h/templ" import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime" import templruntime "github.com/a-h/templ/runtime"
func GlobalSettings(smtpHost, smtpPort, smtpUser, smtpPass, imapHost, imapPort, nextwksURL, authURL, proxyIP, msg string) templ.Component { func GlobalSettings(smtpHost, smtpPort, smtpUser, smtpPass, imapHost, imapPort, nextwksURL, authURL, msg string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
@ -168,20 +168,7 @@ func GlobalSettings(smtpHost, smtpPort, smtpUser, smtpPass, imapHost, imapPort,
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\"></div></div><div class=\"form-group\"><label>Reverse Proxy IP</label> <input type=\"text\" name=\"proxy_ip\" class=\"input\" value=\"") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\"></div></div></div><button type=\"submit\" class=\"btn\" style=\"width:100%\">Save Settings</button></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.ResolveAttributeValue(proxyIP)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `core/admin/templates/global.templ`, Line: 58, Col: 69}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "\"></div></div><button type=\"submit\" class=\"btn\" style=\"width:100%\">Save Settings</button></form>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }

View file

@ -48,8 +48,7 @@ func (h *Handler) adminGlobal(w http.ResponseWriter, r *http.Request) {
cfg := readConfigRaw(h.configPath) cfg := readConfigRaw(h.configPath)
component := templates.GlobalSettings( component := templates.GlobalSettings(
cfg["smtp_host"], cfg["smtp_port"], cfg["smtp_user"], cfg["smtp_pass"], cfg["smtp_host"], cfg["smtp_port"], cfg["smtp_user"], cfg["smtp_pass"],
cfg["imap_host"], cfg["imap_port"], cfg["nextwks_url"], cfg["auth_url"], cfg["imap_host"], cfg["imap_port"], cfg["nextwks_url"], cfg["auth_url"], "",
cfg["proxy_ip"], "",
) )
component.Render(r.Context(), w) component.Render(r.Context(), w)
} }
@ -62,8 +61,7 @@ func (h *Handler) adminGlobalSave(w http.ResponseWriter, r *http.Request) {
cfg := readConfigRaw(h.configPath) cfg := readConfigRaw(h.configPath)
component := templates.GlobalSettings( component := templates.GlobalSettings(
cfg["smtp_host"], cfg["smtp_port"], cfg["smtp_user"], cfg["smtp_pass"], cfg["smtp_host"], cfg["smtp_port"], cfg["smtp_user"], cfg["smtp_pass"],
cfg["imap_host"], cfg["imap_port"], cfg["nextwks_url"], cfg["auth_url"], cfg["imap_host"], cfg["imap_port"], cfg["nextwks_url"], cfg["auth_url"], msg,
cfg["proxy_ip"], msg,
) )
component.Render(r.Context(), w) component.Render(r.Context(), w)
} }
@ -90,7 +88,6 @@ func readConfigRaw(path string) rawConfig {
cfg["nextwks_url"] = trimSuffix(cfg["nextwks_url"], "/auth/callback") cfg["nextwks_url"] = trimSuffix(cfg["nextwks_url"], "/auth/callback")
} }
cfg["auth_url"] = getNested(m, "oidc", "issuer_url") cfg["auth_url"] = getNested(m, "oidc", "issuer_url")
cfg["proxy_ip"] = getNested(m, "proxy", "ip")
return cfg return cfg
} }
@ -108,7 +105,6 @@ func writeConfigRaw(path string, r *http.Request) string {
setNested(m, r.FormValue("smtp_pass"), "smtp", "password") setNested(m, r.FormValue("smtp_pass"), "smtp", "password")
setNested(m, r.FormValue("imap_host"), "imap", "host") setNested(m, r.FormValue("imap_host"), "imap", "host")
setNested(m, r.FormValue("imap_port"), "imap", "port") setNested(m, r.FormValue("imap_port"), "imap", "port")
setNested(m, r.FormValue("proxy_ip"), "proxy", "ip")
nextwks := r.FormValue("nextwks_url") nextwks := r.FormValue("nextwks_url")
if nextwks != "" { if nextwks != "" {
setNested(m, nextwks+"/auth/callback", "oidc", "redirect_url") setNested(m, nextwks+"/auth/callback", "oidc", "redirect_url")

View file

@ -16,7 +16,6 @@ type Config struct {
OIDC OIDCConfig `yaml:"oidc"` OIDC OIDCConfig `yaml:"oidc"`
SMTP SMTPConfig `yaml:"smtp"` SMTP SMTPConfig `yaml:"smtp"`
IMAP IMAPConfig `yaml:"imap"` IMAP IMAPConfig `yaml:"imap"`
Proxy ProxyConfig `yaml:"proxy"`
Session SessionConfig `yaml:"session"` Session SessionConfig `yaml:"session"`
} }
@ -62,10 +61,6 @@ type IMAPConfig struct {
Port int `yaml:"port"` Port int `yaml:"port"`
} }
type ProxyConfig struct {
IP string `yaml:"ip"`
}
type SessionConfig struct { type SessionConfig struct {
Secret string `yaml:"secret"` Secret string `yaml:"secret"`
ExpiryMinutes int `yaml:"expiry_minutes"` ExpiryMinutes int `yaml:"expiry_minutes"`