1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-07 01:46:33 -05:00
v2fly/app/router/json/json.go

27 lines
550 B
Go
Raw Normal View History

2015-11-14 08:24:56 -05:00
package json
import (
"encoding/json"
2015-11-22 06:05:21 -05:00
"github.com/v2ray/v2ray-core/common/log"
2015-11-14 08:24:56 -05:00
)
type RouterConfig struct {
StrategyValue string `json:"strategy"`
SettingsValue json.RawMessage `json:"settings"`
}
func (this *RouterConfig) Strategy() string {
return this.StrategyValue
}
func (this *RouterConfig) Settings() interface{} {
2015-11-22 06:05:21 -05:00
settings := CreateRouterConfig(this.Strategy())
err := json.Unmarshal(this.SettingsValue, settings)
if err != nil {
log.Error("Failed to load router settings: %v", err)
return nil
}
return settings
2015-11-14 08:24:56 -05:00
}