mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-05 08:56:49 -05:00
27 lines
550 B
Go
27 lines
550 B
Go
package json
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/v2ray/v2ray-core/common/log"
|
|
)
|
|
|
|
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{} {
|
|
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
|
|
}
|