support multi host hopefully
This commit is contained in:
13
config.go
13
config.go
@@ -10,9 +10,9 @@ import (
|
||||
|
||||
type (
|
||||
Config struct {
|
||||
Cert Cert
|
||||
Port int
|
||||
Endpoints map[string]Endpoint
|
||||
Cert Cert
|
||||
Port int
|
||||
Domains map[string]map[string]Endpoint
|
||||
}
|
||||
|
||||
Cert struct {
|
||||
@@ -21,7 +21,6 @@ type (
|
||||
}
|
||||
|
||||
Endpoint struct {
|
||||
From string
|
||||
To string
|
||||
BasicAuth string
|
||||
}
|
||||
@@ -34,7 +33,7 @@ func NewConfig() (Config, error) {
|
||||
fs.StringVar(&c.Cert.CRT, "crt", "", "path to .crt")
|
||||
fs.StringVar(&c.Cert.Key, "key", "", "path to .key")
|
||||
fs.IntVar(&c.Port, "p", 56112, "port to listen on")
|
||||
f := fs.String("f", "/dev/null", `file of {endpoints:{"": {from:"", to:"", basicAuth:""}}}`)
|
||||
f := fs.String("f", "/dev/null", `file of {domain:{"":{"": {to:"", basicAuth:""}}}}`)
|
||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||
return c, err
|
||||
}
|
||||
@@ -43,8 +42,8 @@ func NewConfig() (Config, error) {
|
||||
return c, err
|
||||
} else if err := yaml.Unmarshal(b, &c); err != nil {
|
||||
return c, err
|
||||
} else if len(c.Endpoints) == 0 {
|
||||
return c, fmt.Errorf("no endpoints configured")
|
||||
} else if len(c.Domains) == 0 {
|
||||
return c, fmt.Errorf("no domains configured")
|
||||
}
|
||||
|
||||
return c, nil
|
||||
|
||||
Reference in New Issue
Block a user