remove use of any

This commit is contained in:
Darien Raymond committed 2016-10-16 14:22:21 +02:00
1 parent 5d9e6b0799
commit e33b7df34c
72 files changed
+728 -792

No files matched your search

+4 -9
View File
@@ -8,7 +8,6 @@ import (
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/common/protocol"
"v2ray.com/core/proxy/registry"
"github.com/golang/protobuf/ptypes"
google_protobuf "github.com/golang/protobuf/ptypes/any"
@@ -58,11 +57,11 @@ const (
func (this *ServerConfig) UnmarshalJSON(data []byte) error {
type SocksConfig struct {
AuthMethod string `json:"auth"`
Accounts []*Account `json:"accounts"`
UDP bool `json:"udp"`
AuthMethod string `json:"auth"`
Accounts []*Account `json:"accounts"`
UDP bool `json:"udp"`
Host *v2net.IPOrDomain `json:"ip"`
Timeout uint32 `json:"timeout"`
Timeout uint32 `json:"timeout"`
}
rawConfig := new(SocksConfig)
@@ -95,7 +94,3 @@ func (this *ServerConfig) UnmarshalJSON(data []byte) error {
}
return nil
}
func init() {
registry.RegisterInboundConfig("socks", func() interface{} { return new(ServerConfig) })
}
+3 -11
View File
@@ -6,9 +6,9 @@ import (
"encoding/json"
"errors"
"v2ray.com/core/common/loader"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/common/protocol"
"v2ray.com/core/proxy/registry"
)
func (this *Account) UnmarshalJSON(data []byte) error {
@@ -27,7 +27,7 @@ func (this *Account) UnmarshalJSON(data []byte) error {
func (this *ClientConfig) UnmarshalJSON(data []byte) error {
type ServerConfig struct {
Address *v2net.IPOrDomain `json:"address"`
Address *v2net.IPOrDomain `json:"address"`
Port v2net.Port `json:"port"`
Users []json.RawMessage `json:"users"`
}
@@ -53,18 +53,10 @@ func (this *ClientConfig) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(rawUser, account); err != nil {
return errors.New("Socks|Client: Failed to parse socks account: " + err.Error())
}
anyAccount, err := account.AsAny()
if err != nil {
return err
}
user.Account = anyAccount
user.Account = loader.NewTypedSettings(account)
server.User = append(server.User, user)
}
this.Server[idx] = server
}
return nil
}
func init() {
registry.RegisterOutboundConfig("socks", func() interface{} { return new(ClientConfig) })
}
+2 -1
View File
@@ -9,6 +9,7 @@ import (
"v2ray.com/core/app"
"v2ray.com/core/app/dispatcher"
v2io "v2ray.com/core/common/io"
"v2ray.com/core/common/loader"
"v2ray.com/core/common/log"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/proxy"
@@ -326,5 +327,5 @@ func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *
}
func init() {
registry.MustRegisterInboundHandlerCreator("socks", new(ServerFactory))
registry.MustRegisterInboundHandlerCreator(loader.GetType(new(ServerConfig)), new(ServerFactory))
}