summaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@protonmail.com>2021-07-24 18:55:24 +0200
committerLibravatar tsmethurst <tobi.smethurst@protonmail.com>2021-07-24 18:55:24 +0200
commit318e37735933e14973896b367eae9316723999ce (patch)
treee73253b5f169750b39740bb17400085507651c29 /internal/config/config.go
parentOidc (#109) (diff)
downloadgotosocial-318e37735933e14973896b367eae9316723999ce.tar.xz
allow custom ports for webserver and le
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 117b8efb5..6f943d684 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -50,6 +50,7 @@ type Config struct {
Host string `yaml:"host"`
AccountDomain string `yaml:"accountDomain"`
Protocol string `yaml:"protocol"`
+ Port int `yaml:"port"`
DBConfig *DBConfig `yaml:"db"`
TemplateConfig *TemplateConfig `yaml:"template"`
AccountsConfig *AccountsConfig `yaml:"accounts"`
@@ -150,6 +151,10 @@ func (c *Config) ParseCLIFlags(f KeyedFlags, version string) error {
return errors.New("protocol was not set")
}
+ if c.Port == 0 || f.IsSet(fn.Port) {
+ c.Port = f.Int(fn.Port)
+ }
+
// db flags
if c.DBConfig.Type == "" || f.IsSet(fn.DbType) {
c.DBConfig.Type = f.String(fn.DbType)
@@ -262,6 +267,10 @@ func (c *Config) ParseCLIFlags(f KeyedFlags, version string) error {
c.LetsEncryptConfig.Enabled = f.Bool(fn.LetsEncryptEnabled)
}
+ if c.LetsEncryptConfig.Port == 0 || f.IsSet(fn.LetsEncryptPort) {
+ c.LetsEncryptConfig.Port = f.Int(fn.LetsEncryptPort)
+ }
+
if c.LetsEncryptConfig.CertDir == "" || f.IsSet(fn.LetsEncryptCertDir) {
c.LetsEncryptConfig.CertDir = f.String(fn.LetsEncryptCertDir)
}
@@ -329,6 +338,7 @@ type Flags struct {
Host string
AccountDomain string
Protocol string
+ Port string
DbType string
DbAddress string
@@ -366,6 +376,7 @@ type Flags struct {
LetsEncryptEnabled string
LetsEncryptCertDir string
LetsEncryptEmailAddress string
+ LetsEncryptPort string
OIDCEnabled string
OIDCIdpName string
@@ -384,6 +395,7 @@ type Defaults struct {
Host string
AccountDomain string
Protocol string
+ Port int
SoftwareVersion string
DbType string
@@ -422,6 +434,7 @@ type Defaults struct {
LetsEncryptEnabled bool
LetsEncryptCertDir string
LetsEncryptEmailAddress string
+ LetsEncryptPort int
OIDCEnabled bool
OIDCIdpName string
@@ -442,6 +455,7 @@ func GetFlagNames() Flags {
Host: "host",
AccountDomain: "account-domain",
Protocol: "protocol",
+ Port: "port",
DbType: "db-type",
DbAddress: "db-address",
@@ -477,6 +491,7 @@ func GetFlagNames() Flags {
StatusesMaxMediaFiles: "statuses-max-media-files",
LetsEncryptEnabled: "letsencrypt-enabled",
+ LetsEncryptPort: "letsencrypt-port",
LetsEncryptCertDir: "letsencrypt-cert-dir",
LetsEncryptEmailAddress: "letsencrypt-email",
@@ -500,6 +515,7 @@ func GetEnvNames() Flags {
Host: "GTS_HOST",
AccountDomain: "GTS_ACCOUNT_DOMAIN",
Protocol: "GTS_PROTOCOL",
+ Port: "GTS_PORT",
DbType: "GTS_DB_TYPE",
DbAddress: "GTS_DB_ADDRESS",
@@ -535,6 +551,7 @@ func GetEnvNames() Flags {
StatusesMaxMediaFiles: "GTS_STATUSES_MAX_MEDIA_FILES",
LetsEncryptEnabled: "GTS_LETSENCRYPT_ENABLED",
+ LetsEncryptPort: "GTS_LETSENCRYPT_PORT",
LetsEncryptCertDir: "GTS_LETSENCRYPT_CERT_DIR",
LetsEncryptEmailAddress: "GTS_LETSENCRYPT_EMAIL",