accommodate protobuf compiler change

This commit is contained in:
Darien Raymond 2016-12-23 12:42:25 +01:00
parent d9196b4217
commit a4dfca0ef7
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
33 changed files with 679 additions and 80 deletions

View File

@ -97,6 +97,20 @@ func (m *Domain) String() string { return proto.CompactTextString(m)
func (*Domain) ProtoMessage() {}
func (*Domain) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Domain) GetType() Domain_Type {
if m != nil {
return m.Type
}
return Domain_Plain
}
func (m *Domain) GetValue() string {
if m != nil {
return m.Value
}
return ""
}
// IP for routing decision, in CIDR form.
type CIDR struct {
// IP address, should be either 4 or 16 bytes.
@ -110,6 +124,20 @@ func (m *CIDR) String() string { return proto.CompactTextString(m) }
func (*CIDR) ProtoMessage() {}
func (*CIDR) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *CIDR) GetIp() []byte {
if m != nil {
return m.Ip
}
return nil
}
func (m *CIDR) GetPrefix() uint32 {
if m != nil {
return m.Prefix
}
return 0
}
type RoutingRule struct {
Tag string `protobuf:"bytes,1,opt,name=tag" json:"tag,omitempty"`
Domain []*Domain `protobuf:"bytes,2,rep,name=domain" json:"domain,omitempty"`
@ -126,6 +154,13 @@ func (m *RoutingRule) String() string { return proto.CompactTextStrin
func (*RoutingRule) ProtoMessage() {}
func (*RoutingRule) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *RoutingRule) GetTag() string {
if m != nil {
return m.Tag
}
return ""
}
func (m *RoutingRule) GetDomain() []*Domain {
if m != nil {
return m.Domain
@ -161,6 +196,20 @@ func (m *RoutingRule) GetSourceCidr() []*CIDR {
return nil
}
func (m *RoutingRule) GetUserEmail() []string {
if m != nil {
return m.UserEmail
}
return nil
}
func (m *RoutingRule) GetInboundTag() []string {
if m != nil {
return m.InboundTag
}
return nil
}
type Config struct {
DomainStrategy Config_DomainStrategy `protobuf:"varint,1,opt,name=domain_strategy,json=domainStrategy,enum=v2ray.core.app.router.Config_DomainStrategy" json:"domain_strategy,omitempty"`
Rule []*RoutingRule `protobuf:"bytes,2,rep,name=rule" json:"rule,omitempty"`
@ -171,6 +220,13 @@ func (m *Config) String() string { return proto.CompactTextString(m)
func (*Config) ProtoMessage() {}
func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *Config) GetDomainStrategy() Config_DomainStrategy {
if m != nil {
return m.DomainStrategy
}
return Config_AsIs
}
func (m *Config) GetRule() []*RoutingRule {
if m != nil {
return m.Rule

View File

@ -95,6 +95,13 @@ func (m *FileServer_Entry) GetDirectory() string {
return ""
}
func (m *FileServer_Entry) GetPath() string {
if m != nil {
return m.Path
}
return ""
}
// XXX_OneofFuncs is for the internal use of the proto package.
func (*FileServer_Entry) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
return _FileServer_Entry_OneofMarshaler, _FileServer_Entry_OneofUnmarshaler, _FileServer_Entry_OneofSizer, []interface{}{
@ -171,6 +178,13 @@ func (m *Server) String() string { return proto.CompactTextString(m)
func (*Server) ProtoMessage() {}
func (*Server) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *Server) GetDomain() []string {
if m != nil {
return m.Domain
}
return nil
}
func (m *Server) GetSettings() *v2ray_core_common_serial.TypedMessage {
if m != nil {
return m.Settings

View File

@ -98,6 +98,41 @@ func (m *Config) String() string { return proto.CompactTextString(m)
func (*Config) ProtoMessage() {}
func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Config) GetErrorLogType() LogType {
if m != nil {
return m.ErrorLogType
}
return LogType_None
}
func (m *Config) GetErrorLogLevel() LogLevel {
if m != nil {
return m.ErrorLogLevel
}
return LogLevel_Disabled
}
func (m *Config) GetErrorLogPath() string {
if m != nil {
return m.ErrorLogPath
}
return ""
}
func (m *Config) GetAccessLogType() LogType {
if m != nil {
return m.AccessLogType
}
return LogType_None
}
func (m *Config) GetAccessLogPath() string {
if m != nil {
return m.AccessLogPath
}
return ""
}
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.common.log.Config")
proto.RegisterEnum("v2ray.core.common.log.LogType", LogType_name, LogType_value)

View File

@ -24,6 +24,13 @@ func (m *Endpoint) String() string { return proto.CompactTextString(m
func (*Endpoint) ProtoMessage() {}
func (*Endpoint) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
func (m *Endpoint) GetNetwork() Network {
if m != nil {
return m.Network
}
return Network_Unknown
}
func (m *Endpoint) GetAddress() *IPOrDomain {
if m != nil {
return m.Address
@ -31,6 +38,13 @@ func (m *Endpoint) GetAddress() *IPOrDomain {
return nil
}
func (m *Endpoint) GetPort() uint32 {
if m != nil {
return m.Port
}
return 0
}
func init() {
proto.RegisterType((*Endpoint)(nil), "v2ray.core.common.net.Endpoint")
}

View File

@ -57,6 +57,13 @@ func (m *NetworkList) String() string { return proto.CompactTextStrin
func (*NetworkList) ProtoMessage() {}
func (*NetworkList) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} }
func (m *NetworkList) GetNetwork() []Network {
if m != nil {
return m.Network
}
return nil
}
func init() {
proto.RegisterType((*NetworkList)(nil), "v2ray.core.common.net.NetworkList")
proto.RegisterEnum("v2ray.core.common.net.Network", Network_name, Network_value)

View File

@ -24,6 +24,20 @@ func (m *PortRange) String() string { return proto.CompactTextString(
func (*PortRange) ProtoMessage() {}
func (*PortRange) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} }
func (m *PortRange) GetFrom() uint32 {
if m != nil {
return m.From
}
return 0
}
func (m *PortRange) GetTo() uint32 {
if m != nil {
return m.To
}
return 0
}
func init() {
proto.RegisterType((*PortRange)(nil), "v2ray.core.common.net.PortRange")
}

View File

@ -55,6 +55,13 @@ func (m *SecurityConfig) String() string { return proto.CompactTextSt
func (*SecurityConfig) ProtoMessage() {}
func (*SecurityConfig) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
func (m *SecurityConfig) GetType() SecurityType {
if m != nil {
return m.Type
}
return SecurityType_UNKNOWN
}
func init() {
proto.RegisterType((*SecurityConfig)(nil), "v2ray.core.common.protocol.SecurityConfig")
proto.RegisterEnum("v2ray.core.common.protocol.SecurityType", SecurityType_name, SecurityType_value)

View File

@ -32,6 +32,13 @@ func (m *ServerEndpoint) GetAddress() *v2ray_core_common_net1.IPOrDomain {
return nil
}
func (m *ServerEndpoint) GetPort() uint32 {
if m != nil {
return m.Port
}
return 0
}
func (m *ServerEndpoint) GetUser() []*User {
if m != nil {
return m.User

View File

@ -26,6 +26,20 @@ func (m *User) String() string { return proto.CompactTextString(m) }
func (*User) ProtoMessage() {}
func (*User) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} }
func (m *User) GetLevel() uint32 {
if m != nil {
return m.Level
}
return 0
}
func (m *User) GetEmail() string {
if m != nil {
return m.Email
}
return ""
}
func (m *User) GetAccount() *v2ray_core_common_serial.TypedMessage {
if m != nil {
return m.Account

View File

@ -41,6 +41,20 @@ func (m *TypedMessage) String() string { return proto.CompactTextStri
func (*TypedMessage) ProtoMessage() {}
func (*TypedMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *TypedMessage) GetType() string {
if m != nil {
return m.Type
}
return ""
}
func (m *TypedMessage) GetValue() []byte {
if m != nil {
return m.Value
}
return nil
}
func init() {
proto.RegisterType((*TypedMessage)(nil), "v2ray.core.common.serial.TypedMessage")
}

View File

@ -5,18 +5,18 @@ import (
v2net "v2ray.com/core/common/net"
)
func (v *AllocationStrategyConcurrency) GetValue() uint32 {
if v == nil {
func (v *AllocationStrategy) GetConcurrencyValue() uint32 {
if v == nil || v.Concurrency == nil {
return 3
}
return v.Value
return v.Concurrency.Value
}
func (v *AllocationStrategyRefresh) GetValue() uint32 {
if v == nil {
func (v *AllocationStrategy) GetRefreshValue() uint32 {
if v == nil || v.Refresh == nil {
return 5
}
return v.Value
return v.Refresh.Value
}
func (v *InboundConnectionConfig) GetAllocationStrategyValue() *AllocationStrategy {

View File

@ -97,6 +97,13 @@ func (m *AllocationStrategyConcurrency) String() string { return prot
func (*AllocationStrategyConcurrency) ProtoMessage() {}
func (*AllocationStrategyConcurrency) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *AllocationStrategyConcurrency) GetValue() uint32 {
if m != nil {
return m.Value
}
return 0
}
type AllocationStrategyRefresh struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
}
@ -106,6 +113,13 @@ func (m *AllocationStrategyRefresh) String() string { return proto.Co
func (*AllocationStrategyRefresh) ProtoMessage() {}
func (*AllocationStrategyRefresh) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *AllocationStrategyRefresh) GetValue() uint32 {
if m != nil {
return m.Value
}
return 0
}
type AllocationStrategy struct {
Type AllocationStrategy_Type `protobuf:"varint,1,opt,name=type,enum=v2ray.core.AllocationStrategy_Type" json:"type,omitempty"`
// Number of handlers (ports) running in parallel.
@ -121,6 +135,13 @@ func (m *AllocationStrategy) String() string { return proto.CompactTe
func (*AllocationStrategy) ProtoMessage() {}
func (*AllocationStrategy) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *AllocationStrategy) GetType() AllocationStrategy_Type {
if m != nil {
return m.Type
}
return AllocationStrategy_Always
}
func (m *AllocationStrategy) GetConcurrency() *AllocationStrategyConcurrency {
if m != nil {
return m.Concurrency
@ -176,6 +197,13 @@ func (m *InboundConnectionConfig) GetListenOn() *v2ray_core_common_net1.IPOrDoma
return nil
}
func (m *InboundConnectionConfig) GetTag() string {
if m != nil {
return m.Tag
}
return ""
}
func (m *InboundConnectionConfig) GetAllocationStrategy() *AllocationStrategy {
if m != nil {
return m.AllocationStrategy
@ -190,6 +218,13 @@ func (m *InboundConnectionConfig) GetStreamSettings() *v2ray_core_transport_inte
return nil
}
func (m *InboundConnectionConfig) GetAllowPassiveConnection() bool {
if m != nil {
return m.AllowPassiveConnection
}
return false
}
// Config for an outbound connection handler.
type OutboundConnectionConfig struct {
Settings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,1,opt,name=settings" json:"settings,omitempty"`
@ -233,6 +268,13 @@ func (m *OutboundConnectionConfig) GetProxySettings() *v2ray_core_transport_inte
return nil
}
func (m *OutboundConnectionConfig) GetTag() string {
if m != nil {
return m.Tag
}
return ""
}
type Config struct {
// Inbound handler configurations. Must have at least one item.
Inbound []*InboundConnectionConfig `protobuf:"bytes,1,rep,name=inbound" json:"inbound,omitempty"`

View File

@ -45,7 +45,7 @@ func NewInboundDetourHandlerAlways(space app.Space, config *InboundConnectionCon
func (v *InboundDetourHandlerAlways) GetConnectionHandler() (proxy.InboundHandler, int) {
ich := v.ich[dice.Roll(len(v.ich))]
return ich, int(v.config.GetAllocationStrategyValue().Refresh.GetValue())
return ich, int(v.config.GetAllocationStrategyValue().GetRefreshValue())
}
func (v *InboundDetourHandlerAlways) Close() {

View File

@ -28,7 +28,7 @@ func NewInboundDetourHandlerDynamic(space app.Space, config *InboundConnectionCo
config: config,
portsInUse: make(map[v2net.Port]bool),
}
handler.ichs = make([]proxy.InboundHandler, config.GetAllocationStrategyValue().Concurrency.GetValue())
handler.ichs = make([]proxy.InboundHandler, config.GetAllocationStrategyValue().GetConcurrencyValue())
// To test configuration
ichConfig, err := config.GetTypedSettings()
@ -67,7 +67,7 @@ func (v *InboundDetourHandlerDynamic) GetConnectionHandler() (proxy.InboundHandl
v.RLock()
defer v.RUnlock()
ich := v.ichs[dice.Roll(len(v.ichs))]
until := int(v.config.GetAllocationStrategyValue().Refresh.GetValue()) - int((time.Now().Unix()-v.lastRefresh.Unix())/60/1000)
until := int(v.config.GetAllocationStrategyValue().GetRefreshValue()) - int((time.Now().Unix()-v.lastRefresh.Unix())/60/1000)
if until < 0 {
until = 0
}
@ -101,7 +101,7 @@ func (v *InboundDetourHandlerDynamic) refresh() error {
config := v.config
v.ich2Recyle = v.ichs
newIchs := make([]proxy.InboundHandler, config.GetAllocationStrategyValue().Concurrency.GetValue())
newIchs := make([]proxy.InboundHandler, config.GetAllocationStrategyValue().GetConcurrencyValue())
for idx := range newIchs {
err := retry.Timed(5, 100).On(func() error {
@ -144,7 +144,7 @@ func (v *InboundDetourHandlerDynamic) Start() error {
go func() {
for {
time.Sleep(time.Duration(v.config.GetAllocationStrategyValue().Refresh.GetValue())*time.Minute - 1)
time.Sleep(time.Duration(v.config.GetAllocationStrategyValue().GetRefreshValue())*time.Minute - 1)
v.RecyleHandles()
err := v.refresh()
if err != nil {

View File

@ -50,6 +50,13 @@ func (m *Config) GetAddress() *v2ray_core_common_net.IPOrDomain {
return nil
}
func (m *Config) GetPort() uint32 {
if m != nil {
return m.Port
}
return 0
}
func (m *Config) GetNetworkList() *v2ray_core_common_net1.NetworkList {
if m != nil {
return m.NetworkList
@ -57,6 +64,20 @@ func (m *Config) GetNetworkList() *v2ray_core_common_net1.NetworkList {
return nil
}
func (m *Config) GetTimeout() uint32 {
if m != nil {
return m.Timeout
}
return 0
}
func (m *Config) GetFollowRedirect() bool {
if m != nil {
return m.FollowRedirect
}
return false
}
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.proxy.dokodemo.Config")
}

View File

@ -59,6 +59,20 @@ func (m *Config) String() string { return proto.CompactTextString(m)
func (*Config) ProtoMessage() {}
func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Config) GetDomainStrategy() Config_DomainStrategy {
if m != nil {
return m.DomainStrategy
}
return Config_AS_IS
}
func (m *Config) GetTimeout() uint32 {
if m != nil {
return m.Timeout
}
return 0
}
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.proxy.freedom.Config")
proto.RegisterEnum("v2ray.core.proxy.freedom.Config_DomainStrategy", Config_DomainStrategy_name, Config_DomainStrategy_value)

View File

@ -39,6 +39,13 @@ func (m *ServerConfig) String() string { return proto.CompactTextStri
func (*ServerConfig) ProtoMessage() {}
func (*ServerConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *ServerConfig) GetTimeout() uint32 {
if m != nil {
return m.Timeout
}
return 0
}
// ClientConfig for HTTP proxy client.
type ClientConfig struct {
}

View File

@ -97,6 +97,27 @@ func (m *Account) String() string { return proto.CompactTextString(m)
func (*Account) ProtoMessage() {}
func (*Account) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Account) GetPassword() string {
if m != nil {
return m.Password
}
return ""
}
func (m *Account) GetCipherType() CipherType {
if m != nil {
return m.CipherType
}
return CipherType_UNKNOWN
}
func (m *Account) GetOta() Account_OneTimeAuth {
if m != nil {
return m.Ota
}
return Account_Auto
}
type ServerConfig struct {
UdpEnabled bool `protobuf:"varint,1,opt,name=udp_enabled,json=udpEnabled" json:"udp_enabled,omitempty"`
User *v2ray_core_common_protocol.User `protobuf:"bytes,2,opt,name=user" json:"user,omitempty"`
@ -107,6 +128,13 @@ func (m *ServerConfig) String() string { return proto.CompactTextStri
func (*ServerConfig) ProtoMessage() {}
func (*ServerConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *ServerConfig) GetUdpEnabled() bool {
if m != nil {
return m.UdpEnabled
}
return false
}
func (m *ServerConfig) GetUser() *v2ray_core_common_protocol.User {
if m != nil {
return m.User

View File

@ -63,6 +63,20 @@ func (m *Account) String() string { return proto.CompactTextString(m)
func (*Account) ProtoMessage() {}
func (*Account) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Account) GetUsername() string {
if m != nil {
return m.Username
}
return ""
}
func (m *Account) GetPassword() string {
if m != nil {
return m.Password
}
return ""
}
type ServerConfig struct {
AuthType AuthType `protobuf:"varint,1,opt,name=auth_type,json=authType,enum=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"`
@ -76,6 +90,13 @@ func (m *ServerConfig) String() string { return proto.CompactTextStri
func (*ServerConfig) ProtoMessage() {}
func (*ServerConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *ServerConfig) GetAuthType() AuthType {
if m != nil {
return m.AuthType
}
return AuthType_NO_AUTH
}
func (m *ServerConfig) GetAccounts() map[string]string {
if m != nil {
return m.Accounts
@ -90,6 +111,20 @@ func (m *ServerConfig) GetAddress() *v2ray_core_common_net.IPOrDomain {
return nil
}
func (m *ServerConfig) GetUdpEnabled() bool {
if m != nil {
return m.UdpEnabled
}
return false
}
func (m *ServerConfig) GetTimeout() uint32 {
if m != nil {
return m.Timeout
}
return 0
}
type ClientConfig struct {
Server []*v2ray_core_common_protocol1.ServerEndpoint `protobuf:"bytes,1,rep,name=server" json:"server,omitempty"`
}

View File

@ -43,6 +43,20 @@ func (m *Account) String() string { return proto.CompactTextString(m)
func (*Account) ProtoMessage() {}
func (*Account) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Account) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func (m *Account) GetAlterId() uint32 {
if m != nil {
return m.AlterId
}
return 0
}
func (m *Account) GetSecuritySettings() *v2ray_core_common_protocol.SecurityConfig {
if m != nil {
return m.SecuritySettings

View File

@ -40,6 +40,13 @@ func (m *DetourConfig) String() string { return proto.CompactTextStri
func (*DetourConfig) ProtoMessage() {}
func (*DetourConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *DetourConfig) GetTo() string {
if m != nil {
return m.To
}
return ""
}
type DefaultConfig struct {
AlterId uint32 `protobuf:"varint,1,opt,name=alter_id,json=alterId" json:"alter_id,omitempty"`
Level uint32 `protobuf:"varint,2,opt,name=level" json:"level,omitempty"`
@ -50,6 +57,20 @@ func (m *DefaultConfig) String() string { return proto.CompactTextStr
func (*DefaultConfig) ProtoMessage() {}
func (*DefaultConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *DefaultConfig) GetAlterId() uint32 {
if m != nil {
return m.AlterId
}
return 0
}
func (m *DefaultConfig) GetLevel() uint32 {
if m != nil {
return m.Level
}
return 0
}
type Config struct {
User []*v2ray_core_common_protocol.User `protobuf:"bytes,1,rep,name=user" json:"user,omitempty"`
Default *DefaultConfig `protobuf:"bytes,2,opt,name=default" json:"default,omitempty"`

View File

@ -44,6 +44,13 @@ func (m *NetworkSettings) String() string { return proto.CompactTextS
func (*NetworkSettings) ProtoMessage() {}
func (*NetworkSettings) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *NetworkSettings) GetNetwork() v2ray_core_common_net.Network {
if m != nil {
return m.Network
}
return v2ray_core_common_net.Network_Unknown
}
func (m *NetworkSettings) GetSettings() *v2ray_core_common_serial.TypedMessage {
if m != nil {
return m.Settings
@ -65,6 +72,13 @@ func (m *StreamConfig) String() string { return proto.CompactTextStri
func (*StreamConfig) ProtoMessage() {}
func (*StreamConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *StreamConfig) GetNetwork() v2ray_core_common_net.Network {
if m != nil {
return m.Network
}
return v2ray_core_common_net.Network_Unknown
}
func (m *StreamConfig) GetNetworkSettings() []*NetworkSettings {
if m != nil {
return m.NetworkSettings
@ -72,6 +86,13 @@ func (m *StreamConfig) GetNetworkSettings() []*NetworkSettings {
return nil
}
func (m *StreamConfig) GetSecurityType() string {
if m != nil {
return m.SecurityType
}
return ""
}
func (m *StreamConfig) GetSecuritySettings() []*v2ray_core_common_serial.TypedMessage {
if m != nil {
return m.SecuritySettings
@ -88,6 +109,13 @@ func (m *ProxyConfig) String() string { return proto.CompactTextStrin
func (*ProxyConfig) ProtoMessage() {}
func (*ProxyConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *ProxyConfig) GetTag() string {
if m != nil {
return m.Tag
}
return ""
}
func init() {
proto.RegisterType((*NetworkSettings)(nil), "v2ray.core.transport.internet.NetworkSettings")
proto.RegisterType((*StreamConfig)(nil), "v2ray.core.transport.internet.StreamConfig")

View File

@ -2,37 +2,10 @@ package http
import (
"strings"
"v2ray.com/core/common/dice"
)
func (v *Version) GetValue() string {
if v == nil {
return "1.1"
}
return v.Value
}
func (v *Method) GetValue() string {
if v == nil {
return "GET"
}
return v.Value
}
func (v *Status) GetCode() string {
if v == nil {
return "200"
}
return v.Code
}
func (v *Status) GetReason() string {
if v == nil {
return "OK"
}
return v.Reason
}
func pickString(arr []string) string {
n := len(arr)
switch n {
@ -63,8 +36,22 @@ func (v *RequestConfig) PickHeaders() []string {
return headers
}
func (v *RequestConfig) GetVersionValue() string {
if v == nil || v.Version == nil {
return "1.1"
}
return v.Version.Value
}
func (v *RequestConfig) GetMethodValue() string {
if v == nil || v.Method == nil {
return "GET"
}
return v.Method.Value
}
func (v *RequestConfig) GetFullVersion() string {
return "HTTP/" + v.Version.GetValue()
return "HTTP/" + v.GetVersionValue()
}
func (v *ResponseConfig) HasHeader(header string) bool {
@ -91,6 +78,23 @@ func (v *ResponseConfig) PickHeaders() []string {
return headers
}
func (v *ResponseConfig) GetFullVersion() string {
return "HTTP/" + v.Version.GetValue()
func (v *ResponseConfig) GetVersionValue() string {
if v == nil || v.Version == nil {
return "1.1"
}
return v.Version.Value
}
func (v *ResponseConfig) GetFullVersion() string {
return "HTTP/" + v.GetVersionValue()
}
func (v *ResponseConfig) GetStatusValue() *Status {
if v == nil || v.Status == nil {
return &Status{
Code: "200",
Reason: "OK",
}
}
return v.Status
}

View File

@ -46,6 +46,20 @@ func (m *Header) String() string { return proto.CompactTextString(m)
func (*Header) ProtoMessage() {}
func (*Header) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Header) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *Header) GetValue() []string {
if m != nil {
return m.Value
}
return nil
}
// HTTP version. Default value "1.1".
type Version struct {
Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
@ -56,6 +70,13 @@ func (m *Version) String() string { return proto.CompactTextString(m)
func (*Version) ProtoMessage() {}
func (*Version) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *Version) GetValue() string {
if m != nil {
return m.Value
}
return ""
}
// HTTP method. Default value "GET".
type Method struct {
Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
@ -66,6 +87,13 @@ func (m *Method) String() string { return proto.CompactTextString(m)
func (*Method) ProtoMessage() {}
func (*Method) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *Method) GetValue() string {
if m != nil {
return m.Value
}
return ""
}
type RequestConfig struct {
// Full HTTP version like "1.1".
Version *Version `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"`
@ -95,6 +123,13 @@ func (m *RequestConfig) GetMethod() *Method {
return nil
}
func (m *RequestConfig) GetUri() []string {
if m != nil {
return m.Uri
}
return nil
}
func (m *RequestConfig) GetHeader() []*Header {
if m != nil {
return m.Header
@ -114,6 +149,20 @@ func (m *Status) String() string { return proto.CompactTextString(m)
func (*Status) ProtoMessage() {}
func (*Status) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *Status) GetCode() string {
if m != nil {
return m.Code
}
return ""
}
func (m *Status) GetReason() string {
if m != nil {
return m.Reason
}
return ""
}
type ResponseConfig struct {
Version *Version `protobuf:"bytes,1,opt,name=version" json:"version,omitempty"`
Status *Status `protobuf:"bytes,2,opt,name=status" json:"status,omitempty"`

View File

@ -191,7 +191,7 @@ func (v *HttpConn) Close() error {
func formResponseHeader(config *ResponseConfig) *HeaderWriter {
header := buf.NewSmall()
header.AppendSupplier(serial.WriteString(strings.Join([]string{config.GetFullVersion(), config.Status.GetCode(), config.Status.GetReason()}, " ")))
header.AppendSupplier(serial.WriteString(strings.Join([]string{config.GetFullVersion(), config.GetStatusValue().Code, config.GetStatusValue().Reason}, " ")))
header.AppendSupplier(writeCRLF)
headers := config.PickHeaders()
@ -217,7 +217,7 @@ type HttpAuthenticator struct {
func (v HttpAuthenticator) GetClientWriter() *HeaderWriter {
header := buf.NewSmall()
config := v.config.Request
header.AppendSupplier(serial.WriteString(strings.Join([]string{config.Method.GetValue(), config.PickUri(), config.GetFullVersion()}, " ")))
header.AppendSupplier(serial.WriteString(strings.Join([]string{config.GetMethodValue(), config.PickUri(), config.GetFullVersion()}, " ")))
header.AppendSupplier(writeCRLF)
headers := config.PickHeaders()

View File

@ -42,6 +42,48 @@ func (m *Config) String() string { return proto.CompactTextString(m)
func (*Config) ProtoMessage() {}
func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Config) GetVersion() uint32 {
if m != nil {
return m.Version
}
return 0
}
func (m *Config) GetPadding() bool {
if m != nil {
return m.Padding
}
return false
}
func (m *Config) GetExtension() bool {
if m != nil {
return m.Extension
}
return false
}
func (m *Config) GetCsrcCount() uint32 {
if m != nil {
return m.CsrcCount
}
return 0
}
func (m *Config) GetMarker() bool {
if m != nil {
return m.Marker
}
return false
}
func (m *Config) GetPayloadType() uint32 {
if m != nil {
return m.PayloadType
}
return 0
}
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.transport.internet.headers.srtp.Config")
}

View File

@ -37,6 +37,13 @@ func (m *Config) String() string { return proto.CompactTextString(m)
func (*Config) ProtoMessage() {}
func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Config) GetVersion() uint32 {
if m != nil {
return m.Version
}
return 0
}
func init() {
proto.RegisterType((*Config)(nil), "v2ray.core.transport.internet.headers.utp.Config")
}

View File

@ -7,52 +7,52 @@ import (
"v2ray.com/core/transport/internet"
)
// GetValue returns the value of MTU settings.
func (v *MTU) GetValue() uint32 {
if v == nil {
// GetMTUValue returns the value of MTU settings.
func (v *Config) GetMTUValue() uint32 {
if v == nil || v.Mtu == nil {
return 1350
}
return v.Value
return v.Mtu.Value
}
// GetValue returns the value of TTI settings.
func (v *TTI) GetValue() uint32 {
if v == nil {
// GetTTIValue returns the value of TTI settings.
func (v *Config) GetTTIValue() uint32 {
if v == nil || v.Tti == nil {
return 50
}
return v.Value
return v.Tti.Value
}
// GetValue returns the value of UplinkCapacity settings.
func (v *UplinkCapacity) GetValue() uint32 {
if v == nil {
// GetUplinkCapacityValue returns the value of UplinkCapacity settings.
func (v *Config) GetUplinkCapacityValue() uint32 {
if v == nil || v.UplinkCapacity == nil {
return 5
}
return v.Value
return v.UplinkCapacity.Value
}
// GetValue returns the value of DownlinkCapacity settings.
func (v *DownlinkCapacity) GetValue() uint32 {
if v == nil {
// GetDownlinkCapacityValue returns the value of DownlinkCapacity settings.
func (v *Config) GetDownlinkCapacityValue() uint32 {
if v == nil || v.DownlinkCapacity == nil {
return 20
}
return v.Value
return v.DownlinkCapacity.Value
}
// GetSize returns the size of WriterBuffer in bytes.
func (v *WriteBuffer) GetSize() uint32 {
if v == nil {
// GetWriteBufferSize returns the size of WriterBuffer in bytes.
func (v *Config) GetWriteBufferSize() uint32 {
if v == nil || v.WriteBuffer == nil {
return 2 * 1024 * 1024
}
return v.Size
return v.WriteBuffer.Size
}
// GetSize returns the size of ReadBuffer in bytes.
func (v *ReadBuffer) GetSize() uint32 {
if v == nil {
// GetReadBufferSize returns the size of ReadBuffer in bytes.
func (v *Config) GetReadBufferSize() uint32 {
if v == nil || v.ReadBuffer == nil {
return 2 * 1024 * 1024
}
return v.Size
return v.ReadBuffer.Size
}
// GetSecurity returns the security settings.
@ -73,7 +73,7 @@ func (v *Config) GetPackerHeader() (internet.PacketHeader, error) {
}
func (v *Config) GetSendingInFlightSize() uint32 {
size := v.UplinkCapacity.GetValue() * 1024 * 1024 / v.Mtu.GetValue() / (1000 / v.Tti.GetValue())
size := v.GetUplinkCapacityValue() * 1024 * 1024 / v.GetMTUValue() / (1000 / v.GetTTIValue())
if size < 8 {
size = 8
}
@ -81,11 +81,11 @@ func (v *Config) GetSendingInFlightSize() uint32 {
}
func (v *Config) GetSendingBufferSize() uint32 {
return v.WriteBuffer.GetSize() / v.Mtu.GetValue()
return v.GetWriteBufferSize() / v.GetMTUValue()
}
func (v *Config) GetReceivingInFlightSize() uint32 {
size := v.DownlinkCapacity.GetValue() * 1024 * 1024 / v.Mtu.GetValue() / (1000 / v.Tti.GetValue())
size := v.GetDownlinkCapacityValue() * 1024 * 1024 / v.GetMTUValue() / (1000 / v.GetTTIValue())
if size < 8 {
size = 8
}
@ -93,14 +93,14 @@ func (v *Config) GetReceivingInFlightSize() uint32 {
}
func (v *Config) GetReceivingBufferSize() uint32 {
return v.ReadBuffer.GetSize() / v.Mtu.GetValue()
return v.GetReadBufferSize() / v.GetMTUValue()
}
func (o *ConnectionReuse) IsEnabled() bool {
if o == nil {
func (v *Config) IsConnectionReuse() bool {
if v == nil || v.ConnectionReuse == nil {
return true
}
return o.Enable
return v.ConnectionReuse.Enable
}
func init() {

View File

@ -46,6 +46,13 @@ func (m *MTU) String() string { return proto.CompactTextString(m) }
func (*MTU) ProtoMessage() {}
func (*MTU) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *MTU) GetValue() uint32 {
if m != nil {
return m.Value
}
return 0
}
// Transmission Time Interview, in milli-sec.
type TTI struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
@ -56,6 +63,13 @@ func (m *TTI) String() string { return proto.CompactTextString(m) }
func (*TTI) ProtoMessage() {}
func (*TTI) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *TTI) GetValue() uint32 {
if m != nil {
return m.Value
}
return 0
}
// Uplink capacity, in MB.
type UplinkCapacity struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
@ -66,6 +80,13 @@ func (m *UplinkCapacity) String() string { return proto.CompactTextSt
func (*UplinkCapacity) ProtoMessage() {}
func (*UplinkCapacity) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *UplinkCapacity) GetValue() uint32 {
if m != nil {
return m.Value
}
return 0
}
// Downlink capacity, in MB.
type DownlinkCapacity struct {
Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
@ -76,6 +97,13 @@ func (m *DownlinkCapacity) String() string { return proto.CompactText
func (*DownlinkCapacity) ProtoMessage() {}
func (*DownlinkCapacity) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *DownlinkCapacity) GetValue() uint32 {
if m != nil {
return m.Value
}
return 0
}
type WriteBuffer struct {
// Buffer size in bytes.
Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"`
@ -86,6 +114,13 @@ func (m *WriteBuffer) String() string { return proto.CompactTextStrin
func (*WriteBuffer) ProtoMessage() {}
func (*WriteBuffer) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *WriteBuffer) GetSize() uint32 {
if m != nil {
return m.Size
}
return 0
}
type ReadBuffer struct {
// Buffer size in bytes.
Size uint32 `protobuf:"varint,1,opt,name=size" json:"size,omitempty"`
@ -96,6 +131,13 @@ func (m *ReadBuffer) String() string { return proto.CompactTextString
func (*ReadBuffer) ProtoMessage() {}
func (*ReadBuffer) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (m *ReadBuffer) GetSize() uint32 {
if m != nil {
return m.Size
}
return 0
}
type ConnectionReuse struct {
Enable bool `protobuf:"varint,1,opt,name=enable" json:"enable,omitempty"`
}
@ -105,6 +147,13 @@ func (m *ConnectionReuse) String() string { return proto.CompactTextS
func (*ConnectionReuse) ProtoMessage() {}
func (*ConnectionReuse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
func (m *ConnectionReuse) GetEnable() bool {
if m != nil {
return m.Enable
}
return false
}
type Config struct {
Mtu *MTU `protobuf:"bytes,1,opt,name=mtu" json:"mtu,omitempty"`
Tti *TTI `protobuf:"bytes,2,opt,name=tti" json:"tti,omitempty"`
@ -150,6 +199,13 @@ func (m *Config) GetDownlinkCapacity() *DownlinkCapacity {
return nil
}
func (m *Config) GetCongestion() bool {
if m != nil {
return m.Congestion
}
return false
}
func (m *Config) GetWriteBuffer() *WriteBuffer {
if m != nil {
return m.WriteBuffer

View File

@ -209,10 +209,10 @@ func NewConnection(conv uint16, sysConn SystemConnection, recycler internal.Conn
dataOutput: make(chan bool, 1),
Config: config,
output: NewSegmentWriter(sysConn),
mss: config.GetMtu().GetValue() - uint32(sysConn.Overhead()) - DataSegmentOverhead,
mss: config.GetMTUValue() - uint32(sysConn.Overhead()) - DataSegmentOverhead,
roundTrip: &RoundTripInfo{
rto: 100,
minRtt: config.Tti.GetValue(),
minRtt: config.GetTTIValue(),
},
}
sysConn.Reset(conn.Input)
@ -227,7 +227,7 @@ func NewConnection(conv uint16, sysConn SystemConnection, recycler internal.Conn
return conn.State() == StateTerminated
}
conn.dataUpdater = NewUpdater(
config.Tti.GetValue(),
config.GetTTIValue(),
predicate.Not(isTerminating).And(predicate.Any(conn.sendingWorker.UpdateNecessary, conn.receivingWorker.UpdateNecessary)),
isTerminating,
conn.updateTask)
@ -439,7 +439,7 @@ func (v *Connection) updateTask() {
}
func (v *Connection) Reusable() bool {
return v.Config.ConnectionReuse.IsEnabled() && v.reusable
return v.Config.IsConnectionReuse() && v.reusable
}
func (v *Connection) SetReusable(b bool) {
@ -456,7 +456,7 @@ func (v *Connection) Terminate() {
v.OnDataInput()
v.OnDataOutput()
if v.Config.ConnectionReuse.IsEnabled() && v.reusable {
if v.Config.IsConnectionReuse() && v.reusable {
v.connRecycler.Put(v.conn.Id(), v.conn)
} else {
v.conn.Close()

View File

@ -39,6 +39,13 @@ func (m *ConnectionReuse) String() string { return proto.CompactTextS
func (*ConnectionReuse) ProtoMessage() {}
func (*ConnectionReuse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *ConnectionReuse) GetEnable() bool {
if m != nil {
return m.Enable
}
return false
}
type Config struct {
ConnectionReuse *ConnectionReuse `protobuf:"bytes,1,opt,name=connection_reuse,json=connectionReuse" json:"connection_reuse,omitempty"`
HeaderSettings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,opt,name=header_settings,json=headerSettings" json:"header_settings,omitempty"`

View File

@ -41,6 +41,20 @@ func (m *Certificate) String() string { return proto.CompactTextStrin
func (*Certificate) ProtoMessage() {}
func (*Certificate) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Certificate) GetCertificate() []byte {
if m != nil {
return m.Certificate
}
return nil
}
func (m *Certificate) GetKey() []byte {
if m != nil {
return m.Key
}
return nil
}
type Config struct {
// Whether or not to allow self-signed certificates.
AllowInsecure bool `protobuf:"varint,1,opt,name=allow_insecure,json=allowInsecure" json:"allow_insecure,omitempty"`
@ -55,6 +69,13 @@ func (m *Config) String() string { return proto.CompactTextString(m)
func (*Config) ProtoMessage() {}
func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *Config) GetAllowInsecure() bool {
if m != nil {
return m.AllowInsecure
}
return false
}
func (m *Config) GetCertificate() []*Certificate {
if m != nil {
return m.Certificate
@ -62,6 +83,13 @@ func (m *Config) GetCertificate() []*Certificate {
return nil
}
func (m *Config) GetServerName() string {
if m != nil {
return m.ServerName
}
return ""
}
func init() {
proto.RegisterType((*Certificate)(nil), "v2ray.core.transport.internet.tls.Certificate")
proto.RegisterType((*Config)(nil), "v2ray.core.transport.internet.tls.Config")

View File

@ -38,6 +38,13 @@ func (m *ConnectionReuse) String() string { return proto.CompactTextS
func (*ConnectionReuse) ProtoMessage() {}
func (*ConnectionReuse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *ConnectionReuse) GetEnable() bool {
if m != nil {
return m.Enable
}
return false
}
type Config struct {
// Whether or not to reuse WebSocket connections.
ConnectionReuse *ConnectionReuse `protobuf:"bytes,1,opt,name=connection_reuse,json=connectionReuse" json:"connection_reuse,omitempty"`
@ -57,6 +64,13 @@ func (m *Config) GetConnectionReuse() *ConnectionReuse {
return nil
}
func (m *Config) GetPath() string {
if m != nil {
return m.Path
}
return ""
}
func init() {
proto.RegisterType((*ConnectionReuse)(nil), "v2ray.core.transport.internet.websocket.ConnectionReuse")
proto.RegisterType((*Config)(nil), "v2ray.core.transport.internet.websocket.Config")