mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-01 08:17:25 +00:00
protobuf for net
This commit is contained in:
@@ -13,9 +13,9 @@ import (
|
||||
|
||||
func (this *ClientConfig) UnmarshalJSON(data []byte) error {
|
||||
type ServerConfig struct {
|
||||
Address *v2net.AddressJson `json:"address"`
|
||||
Port v2net.Port `json:"port"`
|
||||
Users []json.RawMessage `json:"users"`
|
||||
Address *v2net.AddressPB `json:"address"`
|
||||
Port v2net.Port `json:"port"`
|
||||
Users []json.RawMessage `json:"users"`
|
||||
}
|
||||
type JsonConfig struct {
|
||||
Servers []*ServerConfig `json:"servers"`
|
||||
@@ -26,7 +26,7 @@ func (this *ClientConfig) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
this.Servers = make([]*protocol.ServerSpec, len(jsonConfig.Servers))
|
||||
for idx, serverConfig := range jsonConfig.Servers {
|
||||
server := protocol.NewServerSpec(v2net.TCPDestination(serverConfig.Address.Address, serverConfig.Port), protocol.AlwaysValid())
|
||||
server := protocol.NewServerSpec(v2net.TCPDestination(serverConfig.Address.AsAddress(), serverConfig.Port), protocol.AlwaysValid())
|
||||
for _, rawUser := range serverConfig.Users {
|
||||
user := new(protocol.User)
|
||||
if err := json.Unmarshal(rawUser, user); err != nil {
|
||||
|
||||
@@ -19,11 +19,11 @@ const (
|
||||
|
||||
func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
type SocksConfig struct {
|
||||
AuthMethod string `json:"auth"`
|
||||
Accounts []*Account `json:"accounts"`
|
||||
UDP bool `json:"udp"`
|
||||
Host *v2net.AddressJson `json:"ip"`
|
||||
Timeout uint32 `json:"timeout"`
|
||||
AuthMethod string `json:"auth"`
|
||||
Accounts []*Account `json:"accounts"`
|
||||
UDP bool `json:"udp"`
|
||||
Host *v2net.AddressPB `json:"ip"`
|
||||
Timeout uint32 `json:"timeout"`
|
||||
}
|
||||
|
||||
rawConfig := new(SocksConfig)
|
||||
@@ -48,7 +48,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
|
||||
this.UDPEnabled = rawConfig.UDP
|
||||
if rawConfig.Host != nil {
|
||||
this.Address = rawConfig.Host.Address
|
||||
this.Address = rawConfig.Host.AsAddress()
|
||||
} else {
|
||||
this.Address = v2net.LocalHostIP
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user