update config
This commit is contained in:
parent
f0981298b8
commit
35ddf5cf43
@ -147,13 +147,17 @@ func buildServiceConfig(url *url.URL) (*config.ServiceConfig, error) {
|
|||||||
md.Del("auth")
|
md.Del("auth")
|
||||||
|
|
||||||
tlsConfig := &config.TLSConfig{
|
tlsConfig := &config.TLSConfig{
|
||||||
Cert: metadata.GetString(md, "cert"),
|
CertFile: metadata.GetString(md, "certFile"),
|
||||||
Key: metadata.GetString(md, "key"),
|
KeyFile: metadata.GetString(md, "keyFile"),
|
||||||
CA: metadata.GetString(md, "ca"),
|
CAFile: metadata.GetString(md, "caFile"),
|
||||||
|
}
|
||||||
|
md.Del("certFile")
|
||||||
|
md.Del("keyFile")
|
||||||
|
md.Del("caFile")
|
||||||
|
|
||||||
|
if tlsConfig.CertFile == "" {
|
||||||
|
tlsConfig = nil
|
||||||
}
|
}
|
||||||
md.Del("cert")
|
|
||||||
md.Del("key")
|
|
||||||
md.Del("ca")
|
|
||||||
|
|
||||||
svc.Handler = &config.HandlerConfig{
|
svc.Handler = &config.HandlerConfig{
|
||||||
Type: handler,
|
Type: handler,
|
||||||
@ -220,17 +224,21 @@ func buildNodeConfig(url *url.URL) (*config.NodeConfig, error) {
|
|||||||
md.Del("auth")
|
md.Del("auth")
|
||||||
|
|
||||||
tlsConfig := &config.TLSConfig{
|
tlsConfig := &config.TLSConfig{
|
||||||
CA: metadata.GetString(md, "ca"),
|
CAFile: metadata.GetString(md, "caFile"),
|
||||||
Secure: metadata.GetBool(md, "secure"),
|
Secure: metadata.GetBool(md, "secure"),
|
||||||
ServerName: metadata.GetString(md, "serverName"),
|
ServerName: metadata.GetString(md, "serverName"),
|
||||||
}
|
}
|
||||||
if tlsConfig.ServerName == "" {
|
if tlsConfig.ServerName == "" {
|
||||||
tlsConfig.ServerName = url.Hostname()
|
tlsConfig.ServerName = url.Hostname()
|
||||||
}
|
}
|
||||||
md.Del("ca")
|
md.Del("caFile")
|
||||||
md.Del("secure")
|
md.Del("secure")
|
||||||
md.Del("serverName")
|
md.Del("serverName")
|
||||||
|
|
||||||
|
if !tlsConfig.Secure && tlsConfig.CAFile == "" {
|
||||||
|
tlsConfig = nil
|
||||||
|
}
|
||||||
|
|
||||||
node.Connector = &config.ConnectorConfig{
|
node.Connector = &config.ConnectorConfig{
|
||||||
Type: connector,
|
Type: connector,
|
||||||
Auth: auth,
|
Auth: auth,
|
||||||
|
@ -319,11 +319,11 @@ func selectorFromConfig(cfg *config.SelectorConfig) chain.Selector {
|
|||||||
|
|
||||||
var strategy chain.Strategy
|
var strategy chain.Strategy
|
||||||
switch cfg.Strategy {
|
switch cfg.Strategy {
|
||||||
case "round":
|
case "round", "rr":
|
||||||
strategy = chain.RoundRobinStrategy()
|
strategy = chain.RoundRobinStrategy()
|
||||||
case "random":
|
case "random", "rand":
|
||||||
strategy = chain.RandomStrategy()
|
strategy = chain.RandomStrategy()
|
||||||
case "fifo":
|
case "fifo", "ha":
|
||||||
strategy = chain.FIFOStrategy()
|
strategy = chain.FIFOStrategy()
|
||||||
default:
|
default:
|
||||||
strategy = chain.RoundRobinStrategy()
|
strategy = chain.RoundRobinStrategy()
|
||||||
|
@ -15,22 +15,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadServerTLSConfig(cfg *config.TLSConfig) (*tls.Config, error) {
|
func loadServerTLSConfig(cfg *config.TLSConfig) (*tls.Config, error) {
|
||||||
return tls_util.LoadServerConfig(cfg.Cert, cfg.Key, cfg.CA)
|
return tls_util.LoadServerConfig(cfg.CertFile, cfg.KeyFile, cfg.CAFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadClientTLSConfig(cfg *config.TLSConfig) (*tls.Config, error) {
|
func loadClientTLSConfig(cfg *config.TLSConfig) (*tls.Config, error) {
|
||||||
return tls_util.LoadClientConfig(cfg.Cert, cfg.Key, cfg.CA, cfg.Secure, cfg.ServerName)
|
return tls_util.LoadClientConfig(cfg.CertFile, cfg.KeyFile, cfg.CAFile, cfg.Secure, cfg.ServerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildDefaultTLSConfig(cfg *config.TLSConfig) {
|
func buildDefaultTLSConfig(cfg *config.TLSConfig) {
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
cfg = &config.TLSConfig{
|
cfg = &config.TLSConfig{
|
||||||
Cert: "cert.pem",
|
CertFile: "cert.pem",
|
||||||
Key: "key.pem",
|
KeyFile: "key.pem",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsConfig, err := loadConfig(cfg.Cert, cfg.Key)
|
tlsConfig, err := loadConfig(cfg.CertFile, cfg.KeyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// generate random self-signed certificate.
|
// generate random self-signed certificate.
|
||||||
cert, err := genCertificate()
|
cert, err := genCertificate()
|
||||||
|
@ -31,9 +31,9 @@ type ProfilingConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type TLSConfig struct {
|
type TLSConfig struct {
|
||||||
Cert string `yaml:",omitempty"`
|
CertFile string `yaml:"certFile,omitempty"`
|
||||||
Key string `yaml:",omitempty"`
|
KeyFile string `yaml:"keyFile,omitempty"`
|
||||||
CA string `yaml:",omitempty"`
|
CAFile string `yaml:"caFile,omitempty"`
|
||||||
Secure bool `yaml:",omitempty"`
|
Secure bool `yaml:",omitempty"`
|
||||||
ServerName string `yaml:"serverName,omitempty"`
|
ServerName string `yaml:"serverName,omitempty"`
|
||||||
}
|
}
|
||||||
@ -45,8 +45,8 @@ type AuthConfig struct {
|
|||||||
|
|
||||||
type SelectorConfig struct {
|
type SelectorConfig struct {
|
||||||
Strategy string
|
Strategy string
|
||||||
MaxFails int
|
MaxFails int `yaml:"maxFails"`
|
||||||
FailTimeout time.Duration
|
FailTimeout time.Duration `yaml:"failTimeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BypassConfig struct {
|
type BypassConfig struct {
|
||||||
@ -143,9 +143,9 @@ type HopConfig struct {
|
|||||||
type NodeConfig struct {
|
type NodeConfig struct {
|
||||||
Name string
|
Name string
|
||||||
Addr string `yaml:",omitempty"`
|
Addr string `yaml:",omitempty"`
|
||||||
Dialer *DialerConfig `yaml:",omitempty"`
|
|
||||||
Connector *ConnectorConfig `yaml:",omitempty"`
|
|
||||||
Bypass string `yaml:",omitempty"`
|
Bypass string `yaml:",omitempty"`
|
||||||
|
Connector *ConnectorConfig `yaml:",omitempty"`
|
||||||
|
Dialer *DialerConfig `yaml:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user