mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-12 21:26:32 -05:00
refine socks config
This commit is contained in:
parent
c6a7389817
commit
c5f09c64a2
@ -1,20 +0,0 @@
|
||||
package socks
|
||||
|
||||
import (
|
||||
"v2ray.com/core/common/protocol"
|
||||
)
|
||||
|
||||
func (this *Account) Equals(another protocol.Account) bool {
|
||||
if account, ok := another.(*Account); ok {
|
||||
return this.Username == account.Username
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *Account) AsAccount() (protocol.Account, error) {
|
||||
return this, nil
|
||||
}
|
||||
|
||||
func NewAccount() protocol.AsAccount {
|
||||
return &Account{}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package socks
|
||||
|
||||
import (
|
||||
"v2ray.com/core/common/protocol"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
google_protobuf "github.com/golang/protobuf/ptypes/any"
|
||||
)
|
||||
|
||||
func AccountEquals(a, b *google_protobuf.Any) bool {
|
||||
accountA := new(Account)
|
||||
if err := ptypes.UnmarshalAny(a, accountA); err != nil {
|
||||
return false
|
||||
}
|
||||
accountB := new(Account)
|
||||
if err := ptypes.UnmarshalAny(b, accountB); err != nil {
|
||||
return false
|
||||
}
|
||||
return accountA.Equals(accountB)
|
||||
}
|
||||
|
||||
func (this *Account) AsAny() (*google_protobuf.Any, error) {
|
||||
return ptypes.MarshalAny(this)
|
||||
}
|
||||
|
||||
type ClientConfig struct {
|
||||
Servers []*protocol.ServerSpec
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: v2ray.com/core/proxy/socks/client_config.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package socks is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
v2ray.com/core/proxy/socks/client_config.proto
|
||||
v2ray.com/core/proxy/socks/server_config.proto
|
||||
|
||||
It has these top-level messages:
|
||||
Account
|
||||
ServerConfig
|
||||
*/
|
||||
package socks
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type Account struct {
|
||||
Username string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"`
|
||||
Password string `protobuf:"bytes,2,opt,name=password" json:"password,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Account) Reset() { *m = Account{} }
|
||||
func (m *Account) String() string { return proto.CompactTextString(m) }
|
||||
func (*Account) ProtoMessage() {}
|
||||
func (*Account) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Account)(nil), "com.v2ray.core.proxy.socks.Account")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("v2ray.com/core/proxy/socks/client_config.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 146 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x2b, 0x33, 0x2a, 0x4a,
|
||||
0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x28, 0xca, 0xaf, 0xa8,
|
||||
0xd4, 0x2f, 0xce, 0x4f, 0xce, 0x2e, 0xd6, 0x4f, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0x89, 0x4f, 0xce,
|
||||
0xcf, 0x4b, 0xcb, 0x4c, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x4a, 0xce, 0xcf, 0x85,
|
||||
0xeb, 0x29, 0x4a, 0xd5, 0x03, 0xab, 0xd7, 0x03, 0xab, 0x57, 0x72, 0xe4, 0x62, 0x77, 0x4c, 0x4e,
|
||||
0xce, 0x2f, 0xcd, 0x2b, 0x11, 0x92, 0xe2, 0xe2, 0x28, 0x2d, 0x4e, 0x2d, 0xca, 0x4b, 0xcc, 0x4d,
|
||||
0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x82, 0xf3, 0x41, 0x72, 0x05, 0x89, 0xc5, 0xc5, 0xe5,
|
||||
0xf9, 0x45, 0x29, 0x12, 0x4c, 0x10, 0x39, 0x18, 0xdf, 0x89, 0x3d, 0x8a, 0x15, 0x6c, 0x56, 0x12,
|
||||
0x1b, 0xd8, 0x3a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe9, 0xf0, 0x36, 0x26, 0xa0, 0x00,
|
||||
0x00, 0x00,
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package com.v2ray.core.proxy.socks;
|
||||
option go_package = "socks";
|
||||
|
||||
message Account {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
// +build json
|
||||
|
||||
package socks
|
||||
|
||||
import (
|
||||
@ -9,9 +7,50 @@ import (
|
||||
"v2ray.com/core/common"
|
||||
"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"
|
||||
)
|
||||
|
||||
func (this *Account) Equals(another protocol.Account) bool {
|
||||
if account, ok := another.(*Account); ok {
|
||||
return this.Username == account.Username
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *Account) AsAccount() (protocol.Account, error) {
|
||||
return this, nil
|
||||
}
|
||||
|
||||
func NewAccount() protocol.AsAccount {
|
||||
return &Account{}
|
||||
}
|
||||
|
||||
func (this *Account) AsAny() (*google_protobuf.Any, error) {
|
||||
return ptypes.MarshalAny(this)
|
||||
}
|
||||
|
||||
func (this *ServerConfig) HasAccount(username, password string) bool {
|
||||
if this.Accounts == nil {
|
||||
return false
|
||||
}
|
||||
storedPassed, found := this.Accounts[username]
|
||||
if !found {
|
||||
return false
|
||||
}
|
||||
return storedPassed == password
|
||||
}
|
||||
|
||||
func (this *ServerConfig) GetNetAddress() v2net.Address {
|
||||
if this.Address == nil {
|
||||
return v2net.LocalHostIP
|
||||
}
|
||||
return this.Address.AsAddress()
|
||||
}
|
||||
|
||||
const (
|
||||
AuthMethodNoAuth = "noauth"
|
||||
AuthMethodUserPass = "password"
|
||||
@ -31,9 +70,9 @@ func (this *ServerConfig) UnmarshalJSON(data []byte) error {
|
||||
return errors.New("Socks: Failed to parse config: " + err.Error())
|
||||
}
|
||||
if rawConfig.AuthMethod == AuthMethodNoAuth {
|
||||
this.AuthType = ServerConfig_NO_AUTH
|
||||
this.AuthType = AuthType_NO_AUTH
|
||||
} else if rawConfig.AuthMethod == AuthMethodUserPass {
|
||||
this.AuthType = ServerConfig_PASSWORD
|
||||
this.AuthType = AuthType_PASSWORD
|
||||
} else {
|
||||
log.Error("Socks: Unknown auth method: ", rawConfig.AuthMethod)
|
||||
return common.ErrBadConfiguration
|
147
proxy/socks/config.pb.go
Normal file
147
proxy/socks/config.pb.go
Normal file
@ -0,0 +1,147 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: v2ray.com/core/proxy/socks/config.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package socks is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
v2ray.com/core/proxy/socks/config.proto
|
||||
|
||||
It has these top-level messages:
|
||||
Account
|
||||
ServerConfig
|
||||
ClientConfig
|
||||
*/
|
||||
package socks
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import com_v2ray_core_common_net "v2ray.com/core/common/net"
|
||||
import com_v2ray_core_common_protocol1 "v2ray.com/core/common/protocol"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type AuthType int32
|
||||
|
||||
const (
|
||||
AuthType_NO_AUTH AuthType = 0
|
||||
AuthType_PASSWORD AuthType = 1
|
||||
)
|
||||
|
||||
var AuthType_name = map[int32]string{
|
||||
0: "NO_AUTH",
|
||||
1: "PASSWORD",
|
||||
}
|
||||
var AuthType_value = map[string]int32{
|
||||
"NO_AUTH": 0,
|
||||
"PASSWORD": 1,
|
||||
}
|
||||
|
||||
func (x AuthType) String() string {
|
||||
return proto.EnumName(AuthType_name, int32(x))
|
||||
}
|
||||
func (AuthType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
type Account struct {
|
||||
Username string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"`
|
||||
Password string `protobuf:"bytes,2,opt,name=password" json:"password,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Account) Reset() { *m = Account{} }
|
||||
func (m *Account) String() string { return proto.CompactTextString(m) }
|
||||
func (*Account) ProtoMessage() {}
|
||||
func (*Account) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
type ServerConfig struct {
|
||||
AuthType AuthType `protobuf:"varint,1,opt,name=auth_type,json=authType,enum=com.v2ray.core.proxy.socks.AuthType" json:"auth_type,omitempty"`
|
||||
Accounts map[string]string `protobuf:"bytes,2,rep,name=accounts" json:"accounts,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
Address *com_v2ray_core_common_net.AddressPB `protobuf:"bytes,3,opt,name=address" json:"address,omitempty"`
|
||||
UdpEnabled bool `protobuf:"varint,4,opt,name=udp_enabled,json=udpEnabled" json:"udp_enabled,omitempty"`
|
||||
Timeout uint32 `protobuf:"varint,5,opt,name=timeout" json:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ServerConfig) Reset() { *m = ServerConfig{} }
|
||||
func (m *ServerConfig) String() string { return proto.CompactTextString(m) }
|
||||
func (*ServerConfig) ProtoMessage() {}
|
||||
func (*ServerConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
|
||||
func (m *ServerConfig) GetAccounts() map[string]string {
|
||||
if m != nil {
|
||||
return m.Accounts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ServerConfig) GetAddress() *com_v2ray_core_common_net.AddressPB {
|
||||
if m != nil {
|
||||
return m.Address
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ClientConfig struct {
|
||||
Server []*com_v2ray_core_common_protocol1.ServerSpecPB `protobuf:"bytes,1,rep,name=server" json:"server,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ClientConfig) Reset() { *m = ClientConfig{} }
|
||||
func (m *ClientConfig) String() string { return proto.CompactTextString(m) }
|
||||
func (*ClientConfig) ProtoMessage() {}
|
||||
func (*ClientConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||
|
||||
func (m *ClientConfig) GetServer() []*com_v2ray_core_common_protocol1.ServerSpecPB {
|
||||
if m != nil {
|
||||
return m.Server
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Account)(nil), "com.v2ray.core.proxy.socks.Account")
|
||||
proto.RegisterType((*ServerConfig)(nil), "com.v2ray.core.proxy.socks.ServerConfig")
|
||||
proto.RegisterType((*ClientConfig)(nil), "com.v2ray.core.proxy.socks.ClientConfig")
|
||||
proto.RegisterEnum("com.v2ray.core.proxy.socks.AuthType", AuthType_name, AuthType_value)
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("v2ray.com/core/proxy/socks/config.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 419 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x7c, 0x91, 0x5f, 0x8b, 0xd3, 0x40,
|
||||
0x14, 0xc5, 0x4d, 0x6b, 0x37, 0xd9, 0xdb, 0xae, 0x94, 0xc1, 0x87, 0x90, 0x17, 0x43, 0x51, 0x0c,
|
||||
0x22, 0x13, 0xa9, 0x20, 0xa2, 0x20, 0xa4, 0xbb, 0x0b, 0x3e, 0xb9, 0x65, 0x5a, 0x11, 0x7c, 0x29,
|
||||
0xb3, 0x93, 0xab, 0x5b, 0x36, 0x99, 0x19, 0x66, 0x26, 0xd5, 0x7c, 0x58, 0xbf, 0x8b, 0x6c, 0x26,
|
||||
0x59, 0xfc, 0xb7, 0xbe, 0xcd, 0xcd, 0x3d, 0xf7, 0xe4, 0x9e, 0xdf, 0x85, 0xa7, 0x87, 0xa5, 0xe1,
|
||||
0x2d, 0x15, 0xaa, 0xce, 0x85, 0x32, 0x98, 0x6b, 0xa3, 0xbe, 0xb7, 0xb9, 0x55, 0xe2, 0xda, 0xe6,
|
||||
0x42, 0xc9, 0x2f, 0xfb, 0xaf, 0x54, 0x1b, 0xe5, 0x14, 0x49, 0x84, 0xaa, 0xe9, 0x20, 0x36, 0x48,
|
||||
0x3b, 0x21, 0xed, 0x84, 0xc9, 0x9f, 0x26, 0x42, 0xd5, 0xb5, 0x92, 0xb9, 0x44, 0x97, 0xf3, 0xb2,
|
||||
0x34, 0x68, 0xad, 0x37, 0x49, 0x5e, 0xfc, 0x5b, 0xd8, 0x35, 0x85, 0x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73, 0x18, 0x5f, 0x63, 0xdb, 0x63, 0xbe,
|
||||
0x79, 0x92, 0x87, 0x30, 0x39, 0xf0, 0xaa, 0xc1, 0x1e, 0xaf, 0x2f, 0xde, 0x8c, 0x5e, 0x07, 0x8b,
|
||||
0x2d, 0xcc, 0x4e, 0xab, 0x3d, 0x4a, 0xd7, 0xe3, 0x3d, 0x83, 0x23, 0x7f, 0xc7, 0x38, 0xe8, 0xc8,
|
||||
0x3c, 0xbf, 0x23, 0xc6, 0x70, 0xf5, 0x9e, 0xce, 0x46, 0xa3, 0x58, 0xaf, 0x58, 0x3f, 0xfb, 0xec,
|
||||
0x09, 0x44, 0x03, 0x77, 0x32, 0x85, 0xf0, 0xc3, 0xc5, 0xae, 0xf8, 0xb8, 0x7d, 0x3f, 0xbf, 0x47,
|
||||
0x66, 0x10, 0xad, 0x8b, 0xcd, 0xe6, 0xd3, 0x05, 0x3b, 0x9b, 0x07, 0xab, 0xf0, 0xf3, 0xa4, 0x43,
|
||||
0x7c, 0x79, 0xd4, 0xd9, 0xbd, 0xfc, 0x19, 0x00, 0x00, 0xff, 0xff, 0x13, 0x18, 0x73, 0xfe, 0xd1,
|
||||
0x02, 0x00, 0x00,
|
||||
}
|
@ -4,15 +4,26 @@ package com.v2ray.core.proxy.socks;
|
||||
option go_package = "socks";
|
||||
|
||||
import "v2ray.com/core/common/net/address.proto";
|
||||
import "v2ray.com/core/common/protocol/server_spec.proto";
|
||||
|
||||
message Account {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
|
||||
enum AuthType {
|
||||
NO_AUTH = 0;
|
||||
PASSWORD = 1;
|
||||
}
|
||||
|
||||
message ServerConfig {
|
||||
enum AuthType {
|
||||
NO_AUTH = 0;
|
||||
PASSWORD = 1;
|
||||
}
|
||||
AuthType auth_type = 1;
|
||||
map<string, string> accounts = 2;
|
||||
com.v2ray.core.common.net.AddressPB address = 3;
|
||||
bool udp_enabled = 4;
|
||||
uint32 timeout = 5;
|
||||
}
|
||||
|
||||
message ClientConfig {
|
||||
repeated com.v2ray.core.common.protocol.ServerSpecPB server = 1;
|
||||
}
|
@ -38,9 +38,12 @@ func (this *ClientConfig) UnmarshalJSON(data []byte) error {
|
||||
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||||
return errors.New("Socks|Client: Failed to parse config: " + err.Error())
|
||||
}
|
||||
this.Servers = make([]*protocol.ServerSpec, len(jsonConfig.Servers))
|
||||
this.Server = make([]*protocol.ServerSpecPB, len(jsonConfig.Servers))
|
||||
for idx, serverConfig := range jsonConfig.Servers {
|
||||
server := protocol.NewServerSpec(NewAccount, v2net.TCPDestination(serverConfig.Address.AsAddress(), serverConfig.Port), protocol.AlwaysValid())
|
||||
server := &protocol.ServerSpecPB{
|
||||
Address: serverConfig.Address,
|
||||
Port: uint32(serverConfig.Port),
|
||||
}
|
||||
for _, rawUser := range serverConfig.Users {
|
||||
user := new(protocol.User)
|
||||
if err := json.Unmarshal(rawUser, user); err != nil {
|
||||
@ -55,9 +58,9 @@ func (this *ClientConfig) UnmarshalJSON(data []byte) error {
|
||||
return err
|
||||
}
|
||||
user.Account = anyAccount
|
||||
server.AddUser(user)
|
||||
server.Users = append(server.Users, user)
|
||||
}
|
||||
this.Servers[idx] = server
|
||||
this.Server[idx] = server
|
||||
}
|
||||
return nil
|
||||
}
|
@ -129,7 +129,7 @@ func (this *Server) handleConnection(connection internet.Connection) {
|
||||
|
||||
func (this *Server) handleSocks5(clientAddr v2net.Destination, reader *v2io.BufferedReader, writer *v2io.BufferedWriter, auth protocol.Socks5AuthenticationRequest) error {
|
||||
expectedAuthMethod := protocol.AuthNotRequired
|
||||
if this.config.AuthType == ServerConfig_PASSWORD {
|
||||
if this.config.AuthType == AuthType_PASSWORD {
|
||||
expectedAuthMethod = protocol.AuthUserPass
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ func (this *Server) handleSocks5(clientAddr v2net.Destination, reader *v2io.Buff
|
||||
log.Error("Socks: failed to write authentication: ", err)
|
||||
return err
|
||||
}
|
||||
if this.config.AuthType == ServerConfig_PASSWORD {
|
||||
if this.config.AuthType == AuthType_PASSWORD {
|
||||
upRequest, err := protocol.ReadUserPassRequest(reader)
|
||||
if err != nil {
|
||||
log.Warning("Socks: failed to read username and password: ", err)
|
||||
|
@ -1,23 +0,0 @@
|
||||
package socks
|
||||
|
||||
import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
)
|
||||
|
||||
func (this *ServerConfig) HasAccount(username, password string) bool {
|
||||
if this.Accounts == nil {
|
||||
return false
|
||||
}
|
||||
storedPassed, found := this.Accounts[username]
|
||||
if !found {
|
||||
return false
|
||||
}
|
||||
return storedPassed == password
|
||||
}
|
||||
|
||||
func (this *ServerConfig) GetNetAddress() v2net.Address {
|
||||
if this.Address == nil {
|
||||
return v2net.LocalHostIP
|
||||
}
|
||||
return this.Address.AsAddress()
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: v2ray.com/core/proxy/socks/server_config.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
package socks
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import com_v2ray_core_common_net "v2ray.com/core/common/net"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type ServerConfig_AuthType int32
|
||||
|
||||
const (
|
||||
ServerConfig_NO_AUTH ServerConfig_AuthType = 0
|
||||
ServerConfig_PASSWORD ServerConfig_AuthType = 1
|
||||
)
|
||||
|
||||
var ServerConfig_AuthType_name = map[int32]string{
|
||||
0: "NO_AUTH",
|
||||
1: "PASSWORD",
|
||||
}
|
||||
var ServerConfig_AuthType_value = map[string]int32{
|
||||
"NO_AUTH": 0,
|
||||
"PASSWORD": 1,
|
||||
}
|
||||
|
||||
func (x ServerConfig_AuthType) String() string {
|
||||
return proto.EnumName(ServerConfig_AuthType_name, int32(x))
|
||||
}
|
||||
func (ServerConfig_AuthType) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{0, 0} }
|
||||
|
||||
type ServerConfig struct {
|
||||
AuthType ServerConfig_AuthType `protobuf:"varint,1,opt,name=auth_type,json=authType,enum=com.v2ray.core.proxy.socks.ServerConfig_AuthType" json:"auth_type,omitempty"`
|
||||
Accounts map[string]string `protobuf:"bytes,2,rep,name=accounts" json:"accounts,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
Address *com_v2ray_core_common_net.AddressPB `protobuf:"bytes,3,opt,name=address" json:"address,omitempty"`
|
||||
UdpEnabled bool `protobuf:"varint,4,opt,name=udp_enabled,json=udpEnabled" json:"udp_enabled,omitempty"`
|
||||
Timeout uint32 `protobuf:"varint,5,opt,name=timeout" json:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ServerConfig) Reset() { *m = ServerConfig{} }
|
||||
func (m *ServerConfig) String() string { return proto.CompactTextString(m) }
|
||||
func (*ServerConfig) ProtoMessage() {}
|
||||
func (*ServerConfig) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
|
||||
|
||||
func (m *ServerConfig) GetAccounts() map[string]string {
|
||||
if m != nil {
|
||||
return m.Accounts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ServerConfig) GetAddress() *com_v2ray_core_common_net.AddressPB {
|
||||
if m != nil {
|
||||
return m.Address
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*ServerConfig)(nil), "com.v2ray.core.proxy.socks.ServerConfig")
|
||||
proto.RegisterEnum("com.v2ray.core.proxy.socks.ServerConfig_AuthType", ServerConfig_AuthType_name, ServerConfig_AuthType_value)
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("v2ray.com/core/proxy/socks/server_config.proto", fileDescriptor1) }
|
||||
|
||||
var fileDescriptor1 = []byte{
|
||||
// 345 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x91, 0xd1, 0x4b, 0xeb, 0x30,
|
||||
0x14, 0xc6, 0x6f, 0xd7, 0xbb, 0xdb, 0x2e, 0xdd, 0x2e, 0x23, 0xf8, 0x50, 0xf6, 0x62, 0x19, 0x8a,
|
||||
0x7d, 0x4a, 0xb1, 0x82, 0x88, 0x82, 0xd0, 0xe9, 0xc0, 0xa7, 0x6d, 0x64, 0x13, 0xc1, 0x97, 0xd2,
|
||||
0xa5, 0x47, 0x37, 0xb6, 0x36, 0x25, 0x4d, 0x86, 0xfd, 0x33, 0xfc, 0x8f, 0xc5, 0x74, 0x1b, 0x3a,
|
||||
0x10, 0x7c, 0x3b, 0xe7, 0xf0, 0x7d, 0xbf, 0xe4, 0x7c, 0x07, 0x91, 0x4d, 0x28, 0x92, 0x8a, 0x30,
|
||||
0x9e, 0x05, 0x8c, 0x0b, 0x08, 0x0a, 0xc1, 0xdf, 0xaa, 0xa0, 0xe4, 0x6c, 0x55, 0x06, 0x25, 0x88,
|
||||
0x0d, 0x88, 0x98, 0xf1, 0xfc, 0x65, 0xf9, 0x4a, 0x0a, 0xc1, 0x25, 0xc7, 0x3d, 0xc6, 0xb3, 0xbd,
|
||||
0x47, 0x00, 0xd1, 0x7a, 0xa2, 0xf5, 0xbd, 0xb3, 0x03, 0x16, 0xe3, 0x59, 0xc6, 0xf3, 0x20, 0x07,
|
||||
0x19, 0x24, 0x69, 0x2a, 0xa0, 0x2c, 0x6b, 0x48, 0xff, 0xdd, 0x44, 0xed, 0xa9, 0x86, 0xdf, 0x69,
|
||||
0x36, 0x1e, 0xa1, 0x56, 0xa2, 0xe4, 0x22, 0x96, 0x55, 0x01, 0xae, 0xe1, 0x19, 0xfe, 0xff, 0xf0,
|
||||
0x9c, 0xfc, 0xfc, 0x12, 0xf9, 0x6a, 0x26, 0x91, 0x92,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, 0x00, 0x00,
|
||||
}
|
Loading…
Reference in New Issue
Block a user