mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 14:44:15 +00:00
massive refactoring for configuration
This commit is contained in:
1 parent
791ac780f0
commit
0ca7dab49b
15 files changed
+212
-147
No files matched your search
+12
-16
@@ -1,32 +1,28 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
v2net "github.com/v2ray/v2ray-core/net"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// VUser is the user account that is used for connection to a VPoint
|
||||
type VUser struct {
|
||||
Id VID // The ID of this VUser.
|
||||
Id VID `json:"id"` // The ID of this VUser.
|
||||
}
|
||||
|
||||
// VNext is the next VPoint server in the connection chain.
|
||||
type VNext struct {
|
||||
Address v2net.VAddress // Address of VNext server
|
||||
Users []VUser // User accounts for accessing VNext.
|
||||
type VConnectionConfig struct {
|
||||
Protocol string `json:"protocol"`
|
||||
File string `json:"file"`
|
||||
}
|
||||
|
||||
// VConfig is the config for VPoint server.
|
||||
type VConfig struct {
|
||||
Port uint16 // Port of this VPoint server.
|
||||
AllowedClients []VUser
|
||||
ClientProtocol string
|
||||
VNextList []VNext
|
||||
Port uint16 `json:"port"` // Port of this VPoint server.
|
||||
InboundConfig VConnectionConfig `json:"inbound"`
|
||||
OutboundConfig VConnectionConfig `json:"outbound"`
|
||||
}
|
||||
|
||||
type VConfigMarshaller interface {
|
||||
Marshal(config VConfig) ([]byte, error)
|
||||
}
|
||||
|
||||
type VConfigUnmarshaller interface {
|
||||
Unmarshal(data []byte) (VConfig, error)
|
||||
func LoadVConfig(rawConfig []byte) (VConfig, error) {
|
||||
config := VConfig{}
|
||||
err := json.Unmarshal(rawConfig, &config)
|
||||
return config, err
|
||||
}
|
||||
Reference in new issue
Block a user