mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-03 00:22:05 +00:00
remove use of any
This commit is contained in:
72 files changed
+728
-792
No files matched your search
@@ -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) })
|
||||
}
|
||||
@@ -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) })
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
Reference in new issue
Block a user