feat!: support listen to the unix (close #4671)

Starting from this commit, the HTTP server related config all move to the scheme
This commit is contained in:
Andy Hsu
2023-07-04 17:56:02 +08:00
parent 59dbf4496f
commit 7d20a01dba
4 changed files with 53 additions and 24 deletions

View File

@ -20,11 +20,13 @@ type Database struct {
}
type Scheme struct {
DisableHttp bool `json:"disable_http" env:"DISABLE_HTTP"`
Https bool `json:"https" env:"HTTPS"`
ForceHttps bool `json:"force_https" env:"FORCE_HTTPS"`
CertFile string `json:"cert_file" env:"CERT_FILE"`
KeyFile string `json:"key_file" env:"KEY_FILE"`
Address string `json:"address" env:"ADDR"`
HttpPort int `json:"http_port" env:"HTTP_PORT"`
HttpsPort int `json:"https_port" env:"HTTPS_PORT"`
ForceHttps bool `json:"force_https" env:"FORCE_HTTPS"`
CertFile string `json:"cert_file" env:"CERT_FILE"`
KeyFile string `json:"key_file" env:"KEY_FILE"`
UnixFile string `json:"unix_file" env:"UNIX_FILE"`
}
type LogConfig struct {
@ -38,9 +40,6 @@ type LogConfig struct {
type Config struct {
Force bool `json:"force" env:"FORCE"`
Address string `json:"address" env:"ADDR"`
Port int `json:"port" env:"PORT"`
HttpsPort int `json:"https_port" env:"HTTPS_PORT"`
SiteURL string `json:"site_url" env:"SITE_URL"`
Cdn string `json:"cdn" env:"CDN"`
JwtSecret string `json:"jwt_secret" env:"JWT_SECRET"`
@ -61,9 +60,15 @@ func DefaultConfig() *Config {
logPath := filepath.Join(flags.DataDir, "log/log.log")
dbPath := filepath.Join(flags.DataDir, "data.db")
return &Config{
Address: "0.0.0.0",
Port: 5244,
HttpsPort: 5245,
Scheme: Scheme{
Address: "0.0.0.0",
UnixFile: "",
HttpPort: 5244,
HttpsPort: -1,
ForceHttps: false,
CertFile: "",
KeyFile: "",
},
JwtSecret: random.String(16),
TokenExpiresIn: 48,
TempDir: tempDir,