1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-08 10:15:53 -05:00

Convert point server config to interface for testibility

This commit is contained in:
V2Ray
2015-09-19 15:07:10 +02:00
parent 76cb92f918
commit 729312f3b5
4 changed files with 88 additions and 56 deletions

View File

@@ -1,28 +1,17 @@
package core
import (
"encoding/json"
)
// User is the user account that is used for connection to a Point
type User struct {
Id ID `json:"id"` // The ID of this User.
}
type ConnectionConfig struct {
Protocol string `json:"protocol"`
File string `json:"file"`
type ConnectionConfig interface {
Protocol() string
Content() []byte
}
// Config is the config for Point server.
type Config struct {
Port uint16 `json:"port"` // Port of this Point server.
InboundConfig ConnectionConfig `json:"inbound"`
OutboundConfig ConnectionConfig `json:"outbound"`
}
func LoadConfig(rawConfig []byte) (Config, error) {
config := Config{}
err := json.Unmarshal(rawConfig, &config)
return config, err
type PointConfig interface {
Port() uint16
InboundConfig() ConnectionConfig
OutboundConfig() ConnectionConfig
}