mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 23:32:02 +00:00
Added global constants files for use in this and other projects
This commit is contained in:
@@ -174,7 +174,7 @@ func LoadConfig(path string) (*Config, error) {
|
||||
if value, found := submap["intervalMs"]; found {
|
||||
controllerConfig.Profile.Memory.Interval = time.Duration(value.(int)) * time.Millisecond
|
||||
} else {
|
||||
controllerConfig.Profile.Memory.Interval = 15 * time.Second
|
||||
controllerConfig.Profile.Memory.Interval = DefaultProfileMemoryInterval
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,9 +288,9 @@ func LoadConfig(path string) (*Config, error) {
|
||||
}
|
||||
}
|
||||
|
||||
controllerConfig.HealthChecks.BoltCheck.Interval = 30 * time.Second
|
||||
controllerConfig.HealthChecks.BoltCheck.Timeout = 20 * time.Second
|
||||
controllerConfig.HealthChecks.BoltCheck.InitialDelay = 30 * time.Second
|
||||
controllerConfig.HealthChecks.BoltCheck.Interval = DefaultHealthChecksBoltCheckInterval
|
||||
controllerConfig.HealthChecks.BoltCheck.Timeout = DefaultHealthChecksBoltCheckTimeout
|
||||
controllerConfig.HealthChecks.BoltCheck.InitialDelay = DefaultHealthChecksBoltCheckInitialDelay
|
||||
|
||||
if value, found := cfgmap["healthChecks"]; found {
|
||||
if healthChecksMap, ok := value.(map[interface{}]interface{}); ok {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package controller
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
DefaultProfileMemoryInterval = 15 * time.Second
|
||||
DefaultHealthChecksBoltCheckInterval = 30 * time.Second
|
||||
DefaultHealthChecksBoltCheckTimeout = 20 * time.Second
|
||||
DefaultHealthChecksBoltCheckInitialDelay = 30 * time.Second
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
package network
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
DefaultNetworkOptionsCycleSeconds = 60
|
||||
DefaultNetworkOptionsRouteTimeout = 10 * time.Second
|
||||
DefaultNetworkOptionsCreateCircuitRetries = 3
|
||||
DefaultNetworkOptionsCtrlChanLatencyInterval = 10 * time.Second
|
||||
DefaultNetworkOptionsPendingLinkTimeout = 10 * time.Second
|
||||
DefaultNetworkOptionsSmartRerouteFraction = 0.02
|
||||
DefaultNetworkOptionsSmartRerouteCap = 4
|
||||
)
|
||||
@@ -36,14 +36,14 @@ type Options struct {
|
||||
|
||||
func DefaultOptions() *Options {
|
||||
options := &Options{
|
||||
CycleSeconds: 60,
|
||||
RouteTimeout: 10 * time.Second,
|
||||
CreateCircuitRetries: 3,
|
||||
CtrlChanLatencyInterval: 10 * time.Second,
|
||||
PendingLinkTimeout: 10 * time.Second,
|
||||
CycleSeconds: DefaultNetworkOptionsCycleSeconds,
|
||||
RouteTimeout: DefaultNetworkOptionsRouteTimeout,
|
||||
CreateCircuitRetries: DefaultNetworkOptionsCreateCircuitRetries,
|
||||
CtrlChanLatencyInterval: DefaultNetworkOptionsCtrlChanLatencyInterval,
|
||||
PendingLinkTimeout: DefaultNetworkOptionsPendingLinkTimeout,
|
||||
}
|
||||
options.Smart.RerouteFraction = 0.02
|
||||
options.Smart.RerouteCap = 4
|
||||
options.Smart.RerouteFraction = DefaultNetworkOptionsSmartRerouteFraction
|
||||
options.Smart.RerouteCap = DefaultNetworkOptionsSmartRerouteCap
|
||||
return options
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package forwarder
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
DefaultLatencyProbeInterval = 10 * time.Second
|
||||
DefaultLatencyProbeTimeout = 10 * time.Second
|
||||
DefaultXgressCloseCheckInterval = 5 * time.Second
|
||||
DefaultXgressDialDwellTime = 0
|
||||
DefaultFaultTxInterval = 15 * time.Second
|
||||
DefaultIdleTxInterval = 60 * time.Second
|
||||
DefaultIdleCircuitTimeout = 60 * time.Second
|
||||
DefaultXgressDialWorkerQueueLength = 1000
|
||||
MinXgressDialWorkerQueueLength = 1
|
||||
MaxXgressDialWorkerQueueLength = 10000
|
||||
DefaultXgressDialWorkerCount = 10
|
||||
MinXgressDialWorkerCount = 1
|
||||
MaxXgressDialWorkerCount = 10000
|
||||
DefaultLinkDialQueueLength = 1000
|
||||
MinLinkDialWorkerQueueLength = 1
|
||||
MaxLinkDialWorkerQueueLength = 10000
|
||||
DefaultLinkDialWorkerCount = 10
|
||||
MinLinkDialWorkerCount = 1
|
||||
MaxLinkDialWorkerCount = 10000
|
||||
)
|
||||
+24
-23
@@ -18,6 +18,7 @@ package forwarder
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -40,20 +41,20 @@ type WorkerPoolOptions struct {
|
||||
|
||||
func DefaultOptions() *Options {
|
||||
return &Options{
|
||||
LatencyProbeInterval: 10 * time.Second,
|
||||
LatencyProbeTimeout: 10 * time.Second,
|
||||
XgressCloseCheckInterval: 5 * time.Second,
|
||||
XgressDialDwellTime: 0,
|
||||
FaultTxInterval: 15 * time.Second,
|
||||
IdleTxInterval: 60 * time.Second,
|
||||
IdleCircuitTimeout: 60 * time.Second,
|
||||
LatencyProbeInterval: DefaultLatencyProbeInterval,
|
||||
LatencyProbeTimeout: DefaultLatencyProbeTimeout,
|
||||
XgressCloseCheckInterval: DefaultXgressCloseCheckInterval,
|
||||
XgressDialDwellTime: DefaultXgressDialDwellTime,
|
||||
FaultTxInterval: DefaultFaultTxInterval,
|
||||
IdleTxInterval: DefaultIdleTxInterval,
|
||||
IdleCircuitTimeout: DefaultIdleCircuitTimeout,
|
||||
XgressDial: WorkerPoolOptions{
|
||||
QueueLength: 1000,
|
||||
WorkerCount: 10,
|
||||
QueueLength: DefaultXgressDialWorkerQueueLength,
|
||||
WorkerCount: DefaultXgressDialWorkerCount,
|
||||
},
|
||||
LinkDial: WorkerPoolOptions{
|
||||
QueueLength: 1000,
|
||||
WorkerCount: 10,
|
||||
QueueLength: DefaultLinkDialQueueLength,
|
||||
WorkerCount: DefaultLinkDialWorkerCount,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -119,45 +120,45 @@ func LoadOptions(src map[interface{}]interface{}) (*Options, error) {
|
||||
|
||||
if value, found := src["xgressDialQueueLength"]; found {
|
||||
if length, ok := value.(int); ok {
|
||||
if length <= 0 || length > 10000 {
|
||||
return nil, errors.New("invalid value for 'xgressDialQueueLength', expected integer between 1 and 1000")
|
||||
if length < MinXgressDialWorkerQueueLength || length > MaxXgressDialWorkerQueueLength {
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'xgressDialQueueLength', expected integer between %v and %v", MinXgressDialWorkerQueueLength, MaxXgressDialWorkerQueueLength))
|
||||
}
|
||||
options.XgressDial.QueueLength = uint16(length)
|
||||
} else {
|
||||
return nil, errors.New("invalid value for 'xgressDialQueueLength', expected integer between 1 and 1000")
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'xgressDialQueueLength', expected integer between %v and %v", MinXgressDialWorkerQueueLength, MaxXgressDialWorkerQueueLength))
|
||||
}
|
||||
}
|
||||
|
||||
if value, found := src["xgressDialWorkerCount"]; found {
|
||||
if workers, ok := value.(int); ok {
|
||||
if workers <= 0 || workers > 10000 {
|
||||
return nil, errors.New("invalid value for 'xgressDialWorkerCount', expected integer between 1 and 1000")
|
||||
if workers < MinXgressDialWorkerCount || workers > MaxXgressDialWorkerCount {
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'xgressDialWorkerCount', expected integer between %v and %v", MinXgressDialWorkerCount, MaxXgressDialWorkerCount))
|
||||
}
|
||||
options.XgressDial.WorkerCount = uint16(workers)
|
||||
} else {
|
||||
return nil, errors.New("invalid value for 'xgressDialWorkerCount', expected integer between 1 and 1000")
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'xgressDialWorkerCount', expected integer between %v and %v", MinXgressDialWorkerCount, MaxXgressDialWorkerCount))
|
||||
}
|
||||
}
|
||||
|
||||
if value, found := src["linkDialQueueLength"]; found {
|
||||
if length, ok := value.(int); ok {
|
||||
if length <= 0 || length > 10000 {
|
||||
return nil, errors.New("invalid value for 'linkDialQueueLength', expected integer between 1 and 1000")
|
||||
if length < MinLinkDialWorkerQueueLength || length > MaxLinkDialWorkerQueueLength {
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'linkDialQueueLength', expected integer between %v and %v", MinLinkDialWorkerQueueLength, MaxLinkDialWorkerQueueLength))
|
||||
}
|
||||
options.LinkDial.QueueLength = uint16(length)
|
||||
} else {
|
||||
return nil, errors.New("invalid value for 'linkDialQueueLength', expected integer between 1 and 1000")
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'linkDialQueueLength', expected integer between %v and %v", MinLinkDialWorkerQueueLength, MaxLinkDialWorkerQueueLength))
|
||||
}
|
||||
}
|
||||
|
||||
if value, found := src["linkDialWorkerCount"]; found {
|
||||
if workers, ok := value.(int); ok {
|
||||
if workers <= 0 || workers > 10000 {
|
||||
return nil, errors.New("invalid value for 'linkDialWorkerCount', expected integer between 10 and 1000")
|
||||
if workers <= MinLinkDialWorkerCount || workers > MaxLinkDialWorkerCount {
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'linkDialWorkerCount', expected integer between %v and %v", MinLinkDialWorkerCount, MaxLinkDialWorkerCount))
|
||||
}
|
||||
options.LinkDial.WorkerCount = uint16(workers)
|
||||
} else {
|
||||
return nil, errors.New("invalid value for 'linkDialWorkerCount', expected integer between 10 and 1000")
|
||||
return nil, errors.New(fmt.Sprintf("invalid value for 'linkDialWorkerCount', expected integer between %v and %v", MinLinkDialWorkerCount, MaxLinkDialWorkerCount))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-16
@@ -17,7 +17,6 @@
|
||||
package xweb
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/openziti/foundation/identity/identity"
|
||||
@@ -180,9 +179,9 @@ type TimeoutOptions struct {
|
||||
|
||||
// Default defaults all HTTP timeout options
|
||||
func (timeoutOptions *TimeoutOptions) Default() {
|
||||
timeoutOptions.WriteTimeout = time.Second * 10
|
||||
timeoutOptions.ReadTimeout = time.Second * 5
|
||||
timeoutOptions.IdleTimeout = time.Second * 5
|
||||
timeoutOptions.WriteTimeout = DefaultHttpWriteTimeout
|
||||
timeoutOptions.ReadTimeout = DefaultHttpReadTimeout
|
||||
timeoutOptions.IdleTimeout = DefaultHttpIdleTimeout
|
||||
}
|
||||
|
||||
// Parse parses a config map
|
||||
@@ -252,18 +251,10 @@ type TlsVersionOptions struct {
|
||||
maxTLSVersionStr string
|
||||
}
|
||||
|
||||
// tlsVersionMap is a map of configuration strings to TLS version identifiers
|
||||
var tlsVersionMap = map[string]int{
|
||||
"TLS1.0": tls.VersionTLS10,
|
||||
"TLS1.1": tls.VersionTLS11,
|
||||
"TLS1.2": tls.VersionTLS12,
|
||||
"TLS1.3": tls.VersionTLS13,
|
||||
}
|
||||
|
||||
// Default defaults TLS versions
|
||||
func (tlsVersionOptions *TlsVersionOptions) Default() {
|
||||
tlsVersionOptions.MinTLSVersion = tls.VersionTLS12
|
||||
tlsVersionOptions.MaxTLSVersion = tls.VersionTLS13
|
||||
tlsVersionOptions.MinTLSVersion = MinTLSVersion
|
||||
tlsVersionOptions.MaxTLSVersion = MaxTLSVersion
|
||||
}
|
||||
|
||||
// Parse parses a config map
|
||||
@@ -271,7 +262,7 @@ func (tlsVersionOptions *TlsVersionOptions) Parse(config map[interface{}]interfa
|
||||
if interfaceVal, ok := config["minTLSVersion"]; ok {
|
||||
var ok bool
|
||||
if tlsVersionOptions.minTLSVersionStr, ok = interfaceVal.(string); ok {
|
||||
if minTLSVersion, ok := tlsVersionMap[tlsVersionOptions.minTLSVersionStr]; ok {
|
||||
if minTLSVersion, ok := TlsVersionMap[tlsVersionOptions.minTLSVersionStr]; ok {
|
||||
tlsVersionOptions.MinTLSVersion = minTLSVersion
|
||||
} else {
|
||||
return fmt.Errorf("could not use value for minTLSVersion, invalid value [%s]", tlsVersionOptions.minTLSVersionStr)
|
||||
@@ -284,7 +275,7 @@ func (tlsVersionOptions *TlsVersionOptions) Parse(config map[interface{}]interfa
|
||||
if interfaceVal, ok := config["maxTLSVersion"]; ok {
|
||||
var ok bool
|
||||
if tlsVersionOptions.maxTLSVersionStr, ok = interfaceVal.(string); ok {
|
||||
if maxTLSVersion, ok := tlsVersionMap[tlsVersionOptions.maxTLSVersionStr]; ok {
|
||||
if maxTLSVersion, ok := TlsVersionMap[tlsVersionOptions.maxTLSVersionStr]; ok {
|
||||
tlsVersionOptions.MaxTLSVersion = maxTLSVersion
|
||||
} else {
|
||||
return fmt.Errorf("could not use value for maxTLSVersion, invalid value [%s]", tlsVersionOptions.maxTLSVersionStr)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package xweb
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
MinTLSVersion = tls.VersionTLS12
|
||||
MaxTLSVersion = tls.VersionTLS13
|
||||
|
||||
DefaultHttpWriteTimeout = time.Second * 10
|
||||
DefaultHttpReadTimeout = time.Second * 5
|
||||
DefaultHttpIdleTimeout = time.Second * 5
|
||||
)
|
||||
|
||||
// TlsVersionMap is a map of configuration strings to TLS version identifiers
|
||||
var TlsVersionMap = map[string]int{
|
||||
"TLS1.0": tls.VersionTLS10,
|
||||
"TLS1.1": tls.VersionTLS11,
|
||||
"TLS1.2": tls.VersionTLS12,
|
||||
"TLS1.3": tls.VersionTLS13,
|
||||
}
|
||||
|
||||
// ReverseTlsVersionMap is a map of TLS version identifiers to configuration strings
|
||||
var ReverseTlsVersionMap = map[int]string{
|
||||
tls.VersionTLS10: "TLS1.0",
|
||||
tls.VersionTLS11: "TLS1.1",
|
||||
tls.VersionTLS12: "TLS1.2",
|
||||
tls.VersionTLS13: "TLS1.3",
|
||||
}
|
||||
Reference in New Issue
Block a user