|
|
@@ -12,11 +12,12 @@ import (
|
|
|
|
|
|
// Config is the config for Point server.
|
|
|
type Config struct {
|
|
|
- PortValue uint16 `json:"port"` // Port of this Point server.
|
|
|
- LogConfigValue *LogConfig `json:"log"`
|
|
|
- InboundConfigValue *ConnectionConfig `json:"inbound"`
|
|
|
- OutboundConfigValue *ConnectionConfig `json:"outbound"`
|
|
|
- InboundDetoursValue []*InboundDetourConfig `json:"inboundDetour"`
|
|
|
+ PortValue uint16 `json:"port"` // Port of this Point server.
|
|
|
+ LogConfigValue *LogConfig `json:"log"`
|
|
|
+ InboundConfigValue *ConnectionConfig `json:"inbound"`
|
|
|
+ OutboundConfigValue *ConnectionConfig `json:"outbound"`
|
|
|
+ InboundDetoursValue []*InboundDetourConfig `json:"inboundDetour"`
|
|
|
+ OutboundDetoursValue []*OutboundDetourConfig `json:"outboundDetour"`
|
|
|
}
|
|
|
|
|
|
func (config *Config) Port() uint16 {
|
|
|
@@ -52,6 +53,14 @@ func (this *Config) InboundDetours() []config.InboundDetourConfig {
|
|
|
return detours
|
|
|
}
|
|
|
|
|
|
+func (this *Config) OutboundDetours() []config.OutboundDetourConfig {
|
|
|
+ detours := make([]config.OutboundDetourConfig, len(this.OutboundDetoursValue))
|
|
|
+ for idx, detour := range this.OutboundDetoursValue {
|
|
|
+ detours[idx] = detour
|
|
|
+ }
|
|
|
+ return detours
|
|
|
+}
|
|
|
+
|
|
|
func LoadConfig(file string) (*Config, error) {
|
|
|
fixedFile := os.ExpandEnv(file)
|
|
|
rawConfig, err := ioutil.ReadFile(fixedFile)
|