[release] version 0.5.2
This commit is contained in:
parent
913e88896b
commit
4e70cdfc60
|
@ -67,6 +67,7 @@ const ConfigManagement = () => {
|
||||||
HTTPPort: config.HTTPConfig.HTTPPort,
|
HTTPPort: config.HTTPConfig.HTTPPort,
|
||||||
HTTPSPort: config.HTTPConfig.HTTPSPort,
|
HTTPSPort: config.HTTPConfig.HTTPSPort,
|
||||||
SSLEmail: config.HTTPConfig.SSLEmail,
|
SSLEmail: config.HTTPConfig.SSLEmail,
|
||||||
|
UseWildcardCertificate: config.HTTPConfig.UseWildcardCertificate,
|
||||||
HTTPSCertificateMode: config.HTTPConfig.HTTPSCertificateMode,
|
HTTPSCertificateMode: config.HTTPConfig.HTTPSCertificateMode,
|
||||||
DNSChallengeProvider: config.HTTPConfig.DNSChallengeProvider,
|
DNSChallengeProvider: config.HTTPConfig.DNSChallengeProvider,
|
||||||
|
|
||||||
|
@ -99,6 +100,7 @@ const ConfigManagement = () => {
|
||||||
HTTPPort: values.HTTPPort,
|
HTTPPort: values.HTTPPort,
|
||||||
HTTPSPort: values.HTTPSPort,
|
HTTPSPort: values.HTTPSPort,
|
||||||
SSLEmail: values.SSLEmail,
|
SSLEmail: values.SSLEmail,
|
||||||
|
UseWildcardCertificate: values.UseWildcardCertificate,
|
||||||
HTTPSCertificateMode: values.HTTPSCertificateMode,
|
HTTPSCertificateMode: values.HTTPSCertificateMode,
|
||||||
DNSChallengeProvider: values.DNSChallengeProvider,
|
DNSChallengeProvider: values.DNSChallengeProvider,
|
||||||
},
|
},
|
||||||
|
@ -381,8 +383,13 @@ const ConfigManagement = () => {
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{
|
<CosmosCheckbox
|
||||||
formik.values.HTTPSCertificateMode === "LETSENCRYPT" && (
|
label={"Use Wildcard Certificate for *." + formik.values.Hostname}
|
||||||
|
name="UseWildcardCertificate"
|
||||||
|
formik={formik}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{formik.values.HTTPSCertificateMode === "LETSENCRYPT" && (
|
||||||
<CosmosInputText
|
<CosmosInputText
|
||||||
name="SSLEmail"
|
name="SSLEmail"
|
||||||
label="Email address for Let's Encrypt"
|
label="Email address for Let's Encrypt"
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import * as API from '../../api';
|
import * as API from '../../api';
|
||||||
import { Formik } from 'formik';
|
import { Formik } from 'formik';
|
||||||
import { CosmosInputPassword, CosmosInputText, CosmosSelect } from '../config/users/formShortcuts';
|
import { CosmosCheckbox, CosmosInputPassword, CosmosInputText, CosmosSelect } from '../config/users/formShortcuts';
|
||||||
import AnimateButton from '../../components/@extended/AnimateButton';
|
import AnimateButton from '../../components/@extended/AnimateButton';
|
||||||
import { Box } from '@mui/system';
|
import { Box } from '@mui/system';
|
||||||
// ================================|| LOGIN ||================================ //
|
// ================================|| LOGIN ||================================ //
|
||||||
|
@ -224,7 +224,8 @@ const NewInstall = () => {
|
||||||
<div>
|
<div>
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
HTTPSCertificateMode: "LETSENCRYPT"
|
HTTPSCertificateMode: "LETSENCRYPT",
|
||||||
|
UseWildcardCertificate: false,
|
||||||
}}
|
}}
|
||||||
validationSchema={Yup.object().shape({
|
validationSchema={Yup.object().shape({
|
||||||
SSLEmail: Yup.string().when('HTTPSCertificateMode', {
|
SSLEmail: Yup.string().when('HTTPSCertificateMode', {
|
||||||
|
@ -253,6 +254,7 @@ const NewInstall = () => {
|
||||||
step: "3",
|
step: "3",
|
||||||
HTTPSCertificateMode: values.HTTPSCertificateMode,
|
HTTPSCertificateMode: values.HTTPSCertificateMode,
|
||||||
SSLEmail: values.SSLEmail,
|
SSLEmail: values.SSLEmail,
|
||||||
|
UseWildcardCertificate: values.UseWildcardCertificate,
|
||||||
TLSKey: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSKey : '',
|
TLSKey: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSKey : '',
|
||||||
TLSCert: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSCert : '',
|
TLSCert: values.HTTPSCertificateMode === "PROVIDED" ? values.TLSCert : '',
|
||||||
Hostname: values.Hostname,
|
Hostname: values.Hostname,
|
||||||
|
@ -321,11 +323,19 @@ const NewInstall = () => {
|
||||||
formik={formik}
|
formik={formik}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<CosmosCheckbox
|
||||||
|
label={"Use Wildcard Certificate for *." + formik.values.Hostname}
|
||||||
|
name="UseWildcardCertificate"
|
||||||
|
formik={formik}
|
||||||
|
/>
|
||||||
|
|
||||||
{formik.errors.submit && (
|
{formik.errors.submit && (
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<FormHelperText error>{formik.errors.submit}</FormHelperText>
|
<FormHelperText error>{formik.errors.submit}</FormHelperText>
|
||||||
</Grid>
|
</Grid>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<AnimateButton>
|
<AnimateButton>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.5.1",
|
"version": "0.5.2",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -38,7 +38,7 @@ func startHTTPSServer(router *mux.Router, tlsCert string, tlsKey string) {
|
||||||
|
|
||||||
cfg := simplecert.Default
|
cfg := simplecert.Default
|
||||||
|
|
||||||
cfg.Domains = utils.GetAllHostnames()
|
cfg.Domains = utils.GetAllHostnames(false, false)
|
||||||
cfg.CacheDir = "/config/certificates"
|
cfg.CacheDir = "/config/certificates"
|
||||||
cfg.SSLEmail = config.HTTPConfig.SSLEmail
|
cfg.SSLEmail = config.HTTPConfig.SSLEmail
|
||||||
cfg.HTTPAddress = "0.0.0.0:"+serverPortHTTP
|
cfg.HTTPAddress = "0.0.0.0:"+serverPortHTTP
|
||||||
|
@ -153,7 +153,7 @@ func StartServer() {
|
||||||
var tlsCert = HTTPConfig.TLSCert
|
var tlsCert = HTTPConfig.TLSCert
|
||||||
var tlsKey= HTTPConfig.TLSKey
|
var tlsKey= HTTPConfig.TLSKey
|
||||||
|
|
||||||
domains := utils.GetAllHostnames()
|
domains := utils.GetAllHostnames(true, true)
|
||||||
oldDomains := baseMainConfig.HTTPConfig.TLSKeyHostsCached
|
oldDomains := baseMainConfig.HTTPConfig.TLSKeyHostsCached
|
||||||
|
|
||||||
NeedsRefresh := (tlsCert == "" || tlsKey == "") || !utils.StringArrayEquals(domains, oldDomains)
|
NeedsRefresh := (tlsCert == "" || tlsKey == "") || !utils.StringArrayEquals(domains, oldDomains)
|
||||||
|
|
|
@ -32,6 +32,7 @@ type NewInstallJSON struct {
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
Step string `json:"step"`
|
Step string `json:"step"`
|
||||||
SSLEmail string `json:"sslEmail",validate:"omitempty,email"`
|
SSLEmail string `json:"sslEmail",validate:"omitempty,email"`
|
||||||
|
UseWildcardCertificate bool `json:"useWildcardCertificate",validate:"omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminJSON struct {
|
type AdminJSON struct {
|
||||||
|
@ -106,6 +107,7 @@ func NewInstallRoute(w http.ResponseWriter, req *http.Request) {
|
||||||
// HTTPS Certificate Mode & Certs & Let's Encrypt
|
// HTTPS Certificate Mode & Certs & Let's Encrypt
|
||||||
newConfig.HTTPConfig.HTTPSCertificateMode = request.HTTPSCertificateMode
|
newConfig.HTTPConfig.HTTPSCertificateMode = request.HTTPSCertificateMode
|
||||||
newConfig.HTTPConfig.SSLEmail = request.SSLEmail
|
newConfig.HTTPConfig.SSLEmail = request.SSLEmail
|
||||||
|
newConfig.HTTPConfig.UseWildcardCertificate = request.UseWildcardCertificate
|
||||||
newConfig.HTTPConfig.TLSCert = request.TLSCert
|
newConfig.HTTPConfig.TLSCert = request.TLSCert
|
||||||
newConfig.HTTPConfig.TLSKey = request.TLSKey
|
newConfig.HTTPConfig.TLSKey = request.TLSKey
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ func EnsureHostname(next http.Handler) http.Handler {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
hostnames := GetAllHostnames()
|
hostnames := GetAllHostnames(false, false)
|
||||||
|
|
||||||
reqHostNoPort := strings.Split(r.Host, ":")[0]
|
reqHostNoPort := strings.Split(r.Host, ":")[0]
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ func IsValidHostname(hostname string) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
hostnames := GetAllHostnames()
|
hostnames := GetAllHostnames(false, false)
|
||||||
|
|
||||||
reqHostNoPort := strings.Split(hostname, ":")[0]
|
reqHostNoPort := strings.Split(hostname, ":")[0]
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ type HTTPConfig struct {
|
||||||
ProxyConfig ProxyConfig
|
ProxyConfig ProxyConfig
|
||||||
Hostname string `validate:"required,excludesall=0x2C/ "`
|
Hostname string `validate:"required,excludesall=0x2C/ "`
|
||||||
SSLEmail string `validate:"omitempty,email"`
|
SSLEmail string `validate:"omitempty,email"`
|
||||||
|
UseWildcardCertificate bool
|
||||||
AcceptAllInsecureHostname bool
|
AcceptAllInsecureHostname bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -294,16 +294,29 @@ func RestartServer() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllHostnames() []string {
|
func GetAllHostnames(applyWildCard bool, removePorts bool) []string {
|
||||||
hostnames := []string{
|
mainHostname := GetMainConfig().HTTPConfig.Hostname
|
||||||
GetMainConfig().HTTPConfig.Hostname,
|
|
||||||
|
if applyWildCard && MainConfig.HTTPConfig.UseWildcardCertificate {
|
||||||
|
mainHostname = "*." + mainHostname
|
||||||
|
Log("Using wildcard certificate for " + mainHostname + " and all subdomains.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostnames := []string{
|
||||||
|
mainHostname,
|
||||||
|
}
|
||||||
|
|
||||||
proxies := GetMainConfig().HTTPConfig.ProxyConfig.Routes
|
proxies := GetMainConfig().HTTPConfig.ProxyConfig.Routes
|
||||||
for _, proxy := range proxies {
|
for _, proxy := range proxies {
|
||||||
if proxy.UseHost && proxy.Host != "" && strings.Contains(proxy.Host, ".") && !strings.Contains(proxy.Host, ",") && !strings.Contains(proxy.Host, " ") {
|
if proxy.UseHost && proxy.Host != "" && strings.Contains(proxy.Host, ".") && !strings.Contains(proxy.Host, ",") && !strings.Contains(proxy.Host, " ") {
|
||||||
|
if removePorts {
|
||||||
|
hostnames = append(hostnames, strings.Split(proxy.Host, ":")[0])
|
||||||
|
} else {
|
||||||
hostnames = append(hostnames, proxy.Host)
|
hostnames = append(hostnames, proxy.Host)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// remove doubles
|
// remove doubles
|
||||||
seen := make(map[string]bool)
|
seen := make(map[string]bool)
|
||||||
uniqueHostnames := []string{}
|
uniqueHostnames := []string{}
|
||||||
|
@ -313,6 +326,20 @@ func GetAllHostnames() []string {
|
||||||
uniqueHostnames = append(uniqueHostnames, hostname)
|
uniqueHostnames = append(uniqueHostnames, hostname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if applyWildCard && MainConfig.HTTPConfig.UseWildcardCertificate {
|
||||||
|
filteredHostnames := []string{
|
||||||
|
mainHostname,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, hostname := range uniqueHostnames {
|
||||||
|
if hostname != mainHostname && !strings.HasSuffix(hostname, mainHostname[1:]) {
|
||||||
|
filteredHostnames = append(filteredHostnames, hostname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uniqueHostnames = filteredHostnames
|
||||||
|
}
|
||||||
|
|
||||||
Debug("Hostnames are " + strings.Join(uniqueHostnames, ", "))
|
Debug("Hostnames are " + strings.Join(uniqueHostnames, ", "))
|
||||||
return uniqueHostnames
|
return uniqueHostnames
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue