Sfoglia il codice sorgente

merge sender and receiver to proxyman

Darien Raymond 8 anni fa
parent
commit
b8f01e0c03

+ 15 - 0
app/proxyman/config.go

@@ -0,0 +1,15 @@
+package proxyman
+
+func (s *AllocationStrategy) GetConcurrencyValue() uint32 {
+	if s == nil || s.Concurrency == nil {
+		return 3
+	}
+	return s.Concurrency.Value
+}
+
+func (s *AllocationStrategy) GetRefreshValue() uint32 {
+	if s == nil || s.Refresh == nil {
+		return 5
+	}
+	return s.Refresh.Value
+}

+ 262 - 12
app/proxyman/config.pb.go

@@ -3,6 +3,10 @@ package proxyman
 import proto "github.com/golang/protobuf/proto"
 import fmt "fmt"
 import math "math"
+import v2ray_core_common_serial "v2ray.com/core/common/serial"
+import v2ray_core_common_net "v2ray.com/core/common/net"
+import v2ray_core_common_net1 "v2ray.com/core/common/net"
+import v2ray_core_transport_internet "v2ray.com/core/transport/internet"
 
 // Reference imports to suppress errors if they are not otherwise used.
 var _ = proto.Marshal
@@ -15,6 +19,33 @@ var _ = math.Inf
 // proto package needs to be updated.
 const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
 
+type AllocationStrategy_Type int32
+
+const (
+	// Always allocate all connection handlers.
+	AllocationStrategy_Always AllocationStrategy_Type = 0
+	// Randomly allocate specific range of handlers.
+	AllocationStrategy_Random AllocationStrategy_Type = 1
+	// External. Not supported yet.
+	AllocationStrategy_External AllocationStrategy_Type = 2
+)
+
+var AllocationStrategy_Type_name = map[int32]string{
+	0: "Always",
+	1: "Random",
+	2: "External",
+}
+var AllocationStrategy_Type_value = map[string]int32{
+	"Always":   0,
+	"Random":   1,
+	"External": 2,
+}
+
+func (x AllocationStrategy_Type) String() string {
+	return proto.EnumName(AllocationStrategy_Type_name, int32(x))
+}
+func (AllocationStrategy_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{1, 0} }
+
 type InboundConfig struct {
 }
 
@@ -23,31 +54,250 @@ func (m *InboundConfig) String() string            { return proto.CompactTextStr
 func (*InboundConfig) ProtoMessage()               {}
 func (*InboundConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
 
+type AllocationStrategy struct {
+	Type AllocationStrategy_Type `protobuf:"varint,1,opt,name=type,enum=v2ray.core.app.proxyman.AllocationStrategy_Type" json:"type,omitempty"`
+	// Number of handlers (ports) running in parallel.
+	// Default value is 3 if unset.
+	Concurrency *AllocationStrategy_AllocationStrategyConcurrency `protobuf:"bytes,2,opt,name=concurrency" json:"concurrency,omitempty"`
+	// Number of minutes before a handler is regenerated.
+	// Default value is 5 if unset.
+	Refresh *AllocationStrategy_AllocationStrategyRefresh `protobuf:"bytes,3,opt,name=refresh" json:"refresh,omitempty"`
+}
+
+func (m *AllocationStrategy) Reset()                    { *m = AllocationStrategy{} }
+func (m *AllocationStrategy) String() string            { return proto.CompactTextString(m) }
+func (*AllocationStrategy) ProtoMessage()               {}
+func (*AllocationStrategy) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
+
+func (m *AllocationStrategy) GetType() AllocationStrategy_Type {
+	if m != nil {
+		return m.Type
+	}
+	return AllocationStrategy_Always
+}
+
+func (m *AllocationStrategy) GetConcurrency() *AllocationStrategy_AllocationStrategyConcurrency {
+	if m != nil {
+		return m.Concurrency
+	}
+	return nil
+}
+
+func (m *AllocationStrategy) GetRefresh() *AllocationStrategy_AllocationStrategyRefresh {
+	if m != nil {
+		return m.Refresh
+	}
+	return nil
+}
+
+type AllocationStrategy_AllocationStrategyConcurrency struct {
+	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
+}
+
+func (m *AllocationStrategy_AllocationStrategyConcurrency) Reset() {
+	*m = AllocationStrategy_AllocationStrategyConcurrency{}
+}
+func (m *AllocationStrategy_AllocationStrategyConcurrency) String() string {
+	return proto.CompactTextString(m)
+}
+func (*AllocationStrategy_AllocationStrategyConcurrency) ProtoMessage() {}
+func (*AllocationStrategy_AllocationStrategyConcurrency) Descriptor() ([]byte, []int) {
+	return fileDescriptor0, []int{1, 0}
+}
+
+func (m *AllocationStrategy_AllocationStrategyConcurrency) GetValue() uint32 {
+	if m != nil {
+		return m.Value
+	}
+	return 0
+}
+
+type AllocationStrategy_AllocationStrategyRefresh struct {
+	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
+}
+
+func (m *AllocationStrategy_AllocationStrategyRefresh) Reset() {
+	*m = AllocationStrategy_AllocationStrategyRefresh{}
+}
+func (m *AllocationStrategy_AllocationStrategyRefresh) String() string {
+	return proto.CompactTextString(m)
+}
+func (*AllocationStrategy_AllocationStrategyRefresh) ProtoMessage() {}
+func (*AllocationStrategy_AllocationStrategyRefresh) Descriptor() ([]byte, []int) {
+	return fileDescriptor0, []int{1, 1}
+}
+
+func (m *AllocationStrategy_AllocationStrategyRefresh) GetValue() uint32 {
+	if m != nil {
+		return m.Value
+	}
+	return 0
+}
+
+type StreamReceiverConfig struct {
+	PortRange          *v2ray_core_common_net1.PortRange           `protobuf:"bytes,1,opt,name=port_range,json=portRange" json:"port_range,omitempty"`
+	Listen             *v2ray_core_common_net.IPOrDomain           `protobuf:"bytes,2,opt,name=listen" json:"listen,omitempty"`
+	AllocationStrategy *AllocationStrategy                         `protobuf:"bytes,3,opt,name=allocation_strategy,json=allocationStrategy" json:"allocation_strategy,omitempty"`
+	StreamSettings     *v2ray_core_transport_internet.StreamConfig `protobuf:"bytes,4,opt,name=stream_settings,json=streamSettings" json:"stream_settings,omitempty"`
+}
+
+func (m *StreamReceiverConfig) Reset()                    { *m = StreamReceiverConfig{} }
+func (m *StreamReceiverConfig) String() string            { return proto.CompactTextString(m) }
+func (*StreamReceiverConfig) ProtoMessage()               {}
+func (*StreamReceiverConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
+
+func (m *StreamReceiverConfig) GetPortRange() *v2ray_core_common_net1.PortRange {
+	if m != nil {
+		return m.PortRange
+	}
+	return nil
+}
+
+func (m *StreamReceiverConfig) GetListen() *v2ray_core_common_net.IPOrDomain {
+	if m != nil {
+		return m.Listen
+	}
+	return nil
+}
+
+func (m *StreamReceiverConfig) GetAllocationStrategy() *AllocationStrategy {
+	if m != nil {
+		return m.AllocationStrategy
+	}
+	return nil
+}
+
+func (m *StreamReceiverConfig) GetStreamSettings() *v2ray_core_transport_internet.StreamConfig {
+	if m != nil {
+		return m.StreamSettings
+	}
+	return nil
+}
+
+type DatagramReceiverConfig struct {
+	PortRange          *v2ray_core_common_net1.PortRange `protobuf:"bytes,1,opt,name=port_range,json=portRange" json:"port_range,omitempty"`
+	Listen             *v2ray_core_common_net.IPOrDomain `protobuf:"bytes,2,opt,name=listen" json:"listen,omitempty"`
+	AllocationStrategy *AllocationStrategy               `protobuf:"bytes,3,opt,name=allocation_strategy,json=allocationStrategy" json:"allocation_strategy,omitempty"`
+}
+
+func (m *DatagramReceiverConfig) Reset()                    { *m = DatagramReceiverConfig{} }
+func (m *DatagramReceiverConfig) String() string            { return proto.CompactTextString(m) }
+func (*DatagramReceiverConfig) ProtoMessage()               {}
+func (*DatagramReceiverConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
+
+func (m *DatagramReceiverConfig) GetPortRange() *v2ray_core_common_net1.PortRange {
+	if m != nil {
+		return m.PortRange
+	}
+	return nil
+}
+
+func (m *DatagramReceiverConfig) GetListen() *v2ray_core_common_net.IPOrDomain {
+	if m != nil {
+		return m.Listen
+	}
+	return nil
+}
+
+func (m *DatagramReceiverConfig) GetAllocationStrategy() *AllocationStrategy {
+	if m != nil {
+		return m.AllocationStrategy
+	}
+	return nil
+}
+
+type InboundHandlerConfig struct {
+	Tag              string                                   `protobuf:"bytes,1,opt,name=tag" json:"tag,omitempty"`
+	ReceiverSettings []*v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,rep,name=receiver_settings,json=receiverSettings" json:"receiver_settings,omitempty"`
+	ProxySettings    *v2ray_core_common_serial.TypedMessage   `protobuf:"bytes,3,opt,name=proxy_settings,json=proxySettings" json:"proxy_settings,omitempty"`
+}
+
+func (m *InboundHandlerConfig) Reset()                    { *m = InboundHandlerConfig{} }
+func (m *InboundHandlerConfig) String() string            { return proto.CompactTextString(m) }
+func (*InboundHandlerConfig) ProtoMessage()               {}
+func (*InboundHandlerConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
+
+func (m *InboundHandlerConfig) GetTag() string {
+	if m != nil {
+		return m.Tag
+	}
+	return ""
+}
+
+func (m *InboundHandlerConfig) GetReceiverSettings() []*v2ray_core_common_serial.TypedMessage {
+	if m != nil {
+		return m.ReceiverSettings
+	}
+	return nil
+}
+
+func (m *InboundHandlerConfig) GetProxySettings() *v2ray_core_common_serial.TypedMessage {
+	if m != nil {
+		return m.ProxySettings
+	}
+	return nil
+}
+
 type OutboundConfig struct {
 }
 
 func (m *OutboundConfig) Reset()                    { *m = OutboundConfig{} }
 func (m *OutboundConfig) String() string            { return proto.CompactTextString(m) }
 func (*OutboundConfig) ProtoMessage()               {}
-func (*OutboundConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
+func (*OutboundConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
 
 func init() {
 	proto.RegisterType((*InboundConfig)(nil), "v2ray.core.app.proxyman.InboundConfig")
+	proto.RegisterType((*AllocationStrategy)(nil), "v2ray.core.app.proxyman.AllocationStrategy")
+	proto.RegisterType((*AllocationStrategy_AllocationStrategyConcurrency)(nil), "v2ray.core.app.proxyman.AllocationStrategy.AllocationStrategyConcurrency")
+	proto.RegisterType((*AllocationStrategy_AllocationStrategyRefresh)(nil), "v2ray.core.app.proxyman.AllocationStrategy.AllocationStrategyRefresh")
+	proto.RegisterType((*StreamReceiverConfig)(nil), "v2ray.core.app.proxyman.StreamReceiverConfig")
+	proto.RegisterType((*DatagramReceiverConfig)(nil), "v2ray.core.app.proxyman.DatagramReceiverConfig")
+	proto.RegisterType((*InboundHandlerConfig)(nil), "v2ray.core.app.proxyman.InboundHandlerConfig")
 	proto.RegisterType((*OutboundConfig)(nil), "v2ray.core.app.proxyman.OutboundConfig")
+	proto.RegisterEnum("v2ray.core.app.proxyman.AllocationStrategy_Type", AllocationStrategy_Type_name, AllocationStrategy_Type_value)
 }
 
 func init() { proto.RegisterFile("v2ray.com/core/app/proxyman/config.proto", fileDescriptor0) }
 
 var fileDescriptor0 = []byte{
-	// 148 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x33, 0x2a, 0x4a,
-	0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x4f, 0x2c, 0x28, 0xd0, 0x2f,
-	0x28, 0xca, 0xaf, 0xa8, 0xcc, 0x4d, 0xcc, 0xd3, 0x4f, 0xce, 0xcf, 0x4b, 0xcb, 0x4c, 0xd7, 0x2b,
-	0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x87, 0xa9, 0x2c, 0x4a, 0xd5, 0x4b, 0x2c, 0x28, 0xd0, 0x83,
-	0xa9, 0x52, 0xe2, 0xe7, 0xe2, 0xf5, 0xcc, 0x4b, 0xca, 0x2f, 0xcd, 0x4b, 0x71, 0x06, 0xab, 0x57,
-	0x12, 0xe0, 0xe2, 0xf3, 0x2f, 0x2d, 0x41, 0x12, 0x71, 0xf2, 0xe3, 0x92, 0x4e, 0xce, 0xcf, 0xd5,
-	0xc3, 0x61, 0x82, 0x13, 0x37, 0x44, 0x59, 0x00, 0xc8, 0x9e, 0x28, 0x0e, 0x98, 0xf0, 0x2a, 0x26,
-	0xf1, 0x30, 0xa3, 0xa0, 0xc4, 0x4a, 0x3d, 0x67, 0x90, 0x06, 0xc7, 0x82, 0x02, 0xbd, 0x00, 0xa8,
-	0x4c, 0x12, 0x1b, 0xd8, 0x49, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x59, 0xf9, 0x01,
-	0xbe, 0x00, 0x00, 0x00,
+	// 601 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe4, 0x54, 0x5f, 0x6f, 0xd3, 0x3e,
+	0x14, 0xfd, 0xb5, 0xdd, 0x6f, 0x6c, 0xb7, 0xac, 0x2b, 0x66, 0x62, 0xa5, 0x08, 0xa9, 0x54, 0x08,
+	0x2a, 0x81, 0x9c, 0x11, 0xc4, 0x03, 0x4f, 0x68, 0xff, 0x24, 0xf6, 0x30, 0x56, 0xb9, 0x13, 0x0f,
+	0x08, 0xa9, 0xba, 0x4b, 0xbc, 0x10, 0x91, 0xd8, 0x96, 0xed, 0x8e, 0xe5, 0x2b, 0xf1, 0x29, 0x78,
+	0xe2, 0x89, 0x4f, 0xc3, 0x27, 0x40, 0x89, 0x93, 0xae, 0x5a, 0x5b, 0xc4, 0xc4, 0x23, 0x6f, 0x8e,
+	0x73, 0xce, 0xb1, 0xcf, 0xb9, 0xd7, 0x17, 0x06, 0x17, 0xbe, 0xc6, 0x8c, 0x06, 0x32, 0xf5, 0x02,
+	0xa9, 0xb9, 0x87, 0x4a, 0x79, 0x4a, 0xcb, 0xcb, 0x2c, 0x45, 0xe1, 0x05, 0x52, 0x9c, 0xc7, 0x11,
+	0x55, 0x5a, 0x5a, 0x49, 0xb6, 0x2b, 0xa4, 0xe6, 0x14, 0x95, 0xa2, 0x15, 0xaa, 0xbb, 0x73, 0x4d,
+	0x22, 0x90, 0x69, 0x2a, 0x85, 0x67, 0xb8, 0x8e, 0x31, 0xf1, 0x6c, 0xa6, 0x78, 0x38, 0x4e, 0xb9,
+	0x31, 0x18, 0x71, 0x27, 0xd5, 0x7d, 0xba, 0x98, 0x21, 0xb8, 0xf5, 0x30, 0x0c, 0x35, 0x37, 0xa6,
+	0x04, 0x3e, 0x5e, 0x0e, 0x54, 0x52, 0xdb, 0x12, 0x45, 0xaf, 0xa1, 0xac, 0x46, 0x61, 0xf2, 0xff,
+	0x5e, 0x2c, 0x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, 0xd6, 0xb0, 0x0d, 0xad, 0x93, 0x89,
+	0x9d, 0x99, 0x70, 0x7b, 0xef, 0xe0, 0x41, 0x20, 0xd3, 0x65, 0x31, 0xed, 0x35, 0x1d, 0x6c, 0x98,
+	0x8f, 0xc7, 0x0f, 0x6b, 0xd5, 0xf6, 0xd7, 0xfa, 0xf6, 0x7b, 0x9f, 0x61, 0x46, 0xf7, 0x73, 0xc2,
+	0xae, 0x52, 0x74, 0x58, 0xfe, 0x39, 0x5b, 0x2d, 0x26, 0xe9, 0xcb, 0x5f, 0x01, 0x00, 0x00, 0xff,
+	0xff, 0x94, 0x72, 0xcb, 0xa7, 0x3f, 0x06, 0x00, 0x00,
 }

+ 74 - 1
app/proxyman/config.proto

@@ -9,6 +9,79 @@ option java_outer_classname = "ConfigProto";
 message InboundConfig {
 }
 
+import "v2ray.com/core/common/serial/typed_message.proto";
+import "v2ray.com/core/common/net/address.proto";
+import "v2ray.com/core/common/net/port.proto";
+import "v2ray.com/core/transport/internet/config.proto";
+
+message AllocationStrategy {
+  enum Type {
+    // Always allocate all connection handlers.
+    Always = 0;
+
+    // Randomly allocate specific range of handlers.
+    Random = 1;
+
+    // External. Not supported yet.
+    External = 2;
+  }
+
+  Type type = 1;
+
+  message AllocationStrategyConcurrency {
+    uint32 value = 1;
+  }
+
+  // Number of handlers (ports) running in parallel.
+  // Default value is 3 if unset.
+  AllocationStrategyConcurrency concurrency = 2;
+
+
+  message AllocationStrategyRefresh {
+    uint32 value = 1;
+  }
+
+  // Number of minutes before a handler is regenerated.
+  // Default value is 5 if unset.
+  AllocationStrategyRefresh refresh = 3;
+}
+
+message StreamReceiverConfig {
+  v2ray.core.common.net.PortRange port_range = 1;
+  v2ray.core.common.net.IPOrDomain listen = 2;
+  AllocationStrategy allocation_strategy = 3;
+  v2ray.core.transport.internet.StreamConfig stream_settings = 4;
+}
+
+message DatagramReceiverConfig {
+  v2ray.core.common.net.PortRange port_range = 1;
+  v2ray.core.common.net.IPOrDomain listen = 2;
+  AllocationStrategy allocation_strategy = 3;
+}
+
+message InboundHandlerConfig {
+  string tag = 1;
+  repeated v2ray.core.common.serial.TypedMessage receiver_settings = 2;
+  v2ray.core.common.serial.TypedMessage proxy_settings = 3;
+}
+
 message OutboundConfig {
   
-}
+}
+
+message StreamSenderConfig {
+  // Send traffic through the given IP. Only IP is allowed.
+  v2ray.core.common.net.IPOrDomain via = 1;
+  v2ray.core.transport.internet.StreamConfig stream_settings = 2;
+}
+
+message DatagramSenderConfig {
+  // Send traffic through the given IP. Only IP is allowed.
+  v2ray.core.common.net.IPOrDomain via = 1;
+}
+
+message OutboundHandlerConfig {
+  string tag = 1;
+  repeated v2ray.core.common.serial.TypedMessage sender_settings = 2;
+  v2ray.core.common.serial.TypedMessage proxy_settings = 3;
+}

+ 4 - 0
app/proxyman/proxyman.go

@@ -10,6 +10,10 @@ type InboundHandlerManager interface {
 	GetHandler(tag string) (proxy.InboundHandler, int)
 }
 
+type InboundHandler interface {
+	
+}
+
 type OutboundHandlerManager interface {
 	GetHandler(tag string) proxy.OutboundHandler
 	GetDefaultHandler() proxy.OutboundHandler

+ 0 - 15
app/receiver/config.go

@@ -1,15 +0,0 @@
-package receiver
-
-func (v *AllocationStrategy) GetConcurrencyValue() uint32 {
-	if v == nil || v.Concurrency == nil {
-		return 3
-	}
-	return v.Concurrency.Value
-}
-
-func (v *AllocationStrategy) GetRefreshValue() uint32 {
-	if v == nil || v.Refresh == nil {
-		return 5
-	}
-	return v.Refresh.Value
-}

+ 0 - 292
app/receiver/config.pb.go

@@ -1,292 +0,0 @@
-package receiver
-
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import v2ray_core_common_serial "v2ray.com/core/common/serial"
-import v2ray_core_common_net "v2ray.com/core/common/net"
-import v2ray_core_common_net1 "v2ray.com/core/common/net"
-import v2ray_core_transport_internet "v2ray.com/core/transport/internet"
-
-// 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 AllocationStrategy_Type int32
-
-const (
-	// Always allocate all connection handlers.
-	AllocationStrategy_Always AllocationStrategy_Type = 0
-	// Randomly allocate specific range of handlers.
-	AllocationStrategy_Random AllocationStrategy_Type = 1
-	// External. Not supported yet.
-	AllocationStrategy_External AllocationStrategy_Type = 2
-)
-
-var AllocationStrategy_Type_name = map[int32]string{
-	0: "Always",
-	1: "Random",
-	2: "External",
-}
-var AllocationStrategy_Type_value = map[string]int32{
-	"Always":   0,
-	"Random":   1,
-	"External": 2,
-}
-
-func (x AllocationStrategy_Type) String() string {
-	return proto.EnumName(AllocationStrategy_Type_name, int32(x))
-}
-func (AllocationStrategy_Type) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} }
-
-type AllocationStrategy struct {
-	Type AllocationStrategy_Type `protobuf:"varint,1,opt,name=type,enum=v2ray.core.app.receiver.AllocationStrategy_Type" json:"type,omitempty"`
-	// Number of handlers (ports) running in parallel.
-	// Default value is 3 if unset.
-	Concurrency *AllocationStrategy_AllocationStrategyConcurrency `protobuf:"bytes,2,opt,name=concurrency" json:"concurrency,omitempty"`
-	// Number of minutes before a handler is regenerated.
-	// Default value is 5 if unset.
-	Refresh *AllocationStrategy_AllocationStrategyRefresh `protobuf:"bytes,3,opt,name=refresh" json:"refresh,omitempty"`
-}
-
-func (m *AllocationStrategy) Reset()                    { *m = AllocationStrategy{} }
-func (m *AllocationStrategy) String() string            { return proto.CompactTextString(m) }
-func (*AllocationStrategy) ProtoMessage()               {}
-func (*AllocationStrategy) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
-
-func (m *AllocationStrategy) GetType() AllocationStrategy_Type {
-	if m != nil {
-		return m.Type
-	}
-	return AllocationStrategy_Always
-}
-
-func (m *AllocationStrategy) GetConcurrency() *AllocationStrategy_AllocationStrategyConcurrency {
-	if m != nil {
-		return m.Concurrency
-	}
-	return nil
-}
-
-func (m *AllocationStrategy) GetRefresh() *AllocationStrategy_AllocationStrategyRefresh {
-	if m != nil {
-		return m.Refresh
-	}
-	return nil
-}
-
-type AllocationStrategy_AllocationStrategyConcurrency struct {
-	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
-}
-
-func (m *AllocationStrategy_AllocationStrategyConcurrency) Reset() {
-	*m = AllocationStrategy_AllocationStrategyConcurrency{}
-}
-func (m *AllocationStrategy_AllocationStrategyConcurrency) String() string {
-	return proto.CompactTextString(m)
-}
-func (*AllocationStrategy_AllocationStrategyConcurrency) ProtoMessage() {}
-func (*AllocationStrategy_AllocationStrategyConcurrency) Descriptor() ([]byte, []int) {
-	return fileDescriptor0, []int{0, 0}
-}
-
-func (m *AllocationStrategy_AllocationStrategyConcurrency) GetValue() uint32 {
-	if m != nil {
-		return m.Value
-	}
-	return 0
-}
-
-type AllocationStrategy_AllocationStrategyRefresh struct {
-	Value uint32 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
-}
-
-func (m *AllocationStrategy_AllocationStrategyRefresh) Reset() {
-	*m = AllocationStrategy_AllocationStrategyRefresh{}
-}
-func (m *AllocationStrategy_AllocationStrategyRefresh) String() string {
-	return proto.CompactTextString(m)
-}
-func (*AllocationStrategy_AllocationStrategyRefresh) ProtoMessage() {}
-func (*AllocationStrategy_AllocationStrategyRefresh) Descriptor() ([]byte, []int) {
-	return fileDescriptor0, []int{0, 1}
-}
-
-func (m *AllocationStrategy_AllocationStrategyRefresh) GetValue() uint32 {
-	if m != nil {
-		return m.Value
-	}
-	return 0
-}
-
-type StreamReceiverConfig struct {
-	PortRange          *v2ray_core_common_net1.PortRange           `protobuf:"bytes,1,opt,name=port_range,json=portRange" json:"port_range,omitempty"`
-	Listen             *v2ray_core_common_net.IPOrDomain           `protobuf:"bytes,2,opt,name=listen" json:"listen,omitempty"`
-	AllocationStrategy *AllocationStrategy                         `protobuf:"bytes,3,opt,name=allocation_strategy,json=allocationStrategy" json:"allocation_strategy,omitempty"`
-	StreamSettings     *v2ray_core_transport_internet.StreamConfig `protobuf:"bytes,4,opt,name=stream_settings,json=streamSettings" json:"stream_settings,omitempty"`
-}
-
-func (m *StreamReceiverConfig) Reset()                    { *m = StreamReceiverConfig{} }
-func (m *StreamReceiverConfig) String() string            { return proto.CompactTextString(m) }
-func (*StreamReceiverConfig) ProtoMessage()               {}
-func (*StreamReceiverConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
-
-func (m *StreamReceiverConfig) GetPortRange() *v2ray_core_common_net1.PortRange {
-	if m != nil {
-		return m.PortRange
-	}
-	return nil
-}
-
-func (m *StreamReceiverConfig) GetListen() *v2ray_core_common_net.IPOrDomain {
-	if m != nil {
-		return m.Listen
-	}
-	return nil
-}
-
-func (m *StreamReceiverConfig) GetAllocationStrategy() *AllocationStrategy {
-	if m != nil {
-		return m.AllocationStrategy
-	}
-	return nil
-}
-
-func (m *StreamReceiverConfig) GetStreamSettings() *v2ray_core_transport_internet.StreamConfig {
-	if m != nil {
-		return m.StreamSettings
-	}
-	return nil
-}
-
-type DatagramReceiverConfig struct {
-	PortRange          *v2ray_core_common_net1.PortRange `protobuf:"bytes,1,opt,name=port_range,json=portRange" json:"port_range,omitempty"`
-	Listen             *v2ray_core_common_net.IPOrDomain `protobuf:"bytes,2,opt,name=listen" json:"listen,omitempty"`
-	AllocationStrategy *AllocationStrategy               `protobuf:"bytes,3,opt,name=allocation_strategy,json=allocationStrategy" json:"allocation_strategy,omitempty"`
-}
-
-func (m *DatagramReceiverConfig) Reset()                    { *m = DatagramReceiverConfig{} }
-func (m *DatagramReceiverConfig) String() string            { return proto.CompactTextString(m) }
-func (*DatagramReceiverConfig) ProtoMessage()               {}
-func (*DatagramReceiverConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
-
-func (m *DatagramReceiverConfig) GetPortRange() *v2ray_core_common_net1.PortRange {
-	if m != nil {
-		return m.PortRange
-	}
-	return nil
-}
-
-func (m *DatagramReceiverConfig) GetListen() *v2ray_core_common_net.IPOrDomain {
-	if m != nil {
-		return m.Listen
-	}
-	return nil
-}
-
-func (m *DatagramReceiverConfig) GetAllocationStrategy() *AllocationStrategy {
-	if m != nil {
-		return m.AllocationStrategy
-	}
-	return nil
-}
-
-type PerProxyConfig struct {
-	Tag      string                                   `protobuf:"bytes,1,opt,name=tag" json:"tag,omitempty"`
-	Settings []*v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,rep,name=settings" json:"settings,omitempty"`
-}
-
-func (m *PerProxyConfig) Reset()                    { *m = PerProxyConfig{} }
-func (m *PerProxyConfig) String() string            { return proto.CompactTextString(m) }
-func (*PerProxyConfig) ProtoMessage()               {}
-func (*PerProxyConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
-
-func (m *PerProxyConfig) GetTag() string {
-	if m != nil {
-		return m.Tag
-	}
-	return ""
-}
-
-func (m *PerProxyConfig) GetSettings() []*v2ray_core_common_serial.TypedMessage {
-	if m != nil {
-		return m.Settings
-	}
-	return nil
-}
-
-type Config struct {
-	Settings []*PerProxyConfig `protobuf:"bytes,1,rep,name=settings" json:"settings,omitempty"`
-}
-
-func (m *Config) Reset()                    { *m = Config{} }
-func (m *Config) String() string            { return proto.CompactTextString(m) }
-func (*Config) ProtoMessage()               {}
-func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
-
-func (m *Config) GetSettings() []*PerProxyConfig {
-	if m != nil {
-		return m.Settings
-	}
-	return nil
-}
-
-func init() {
-	proto.RegisterType((*AllocationStrategy)(nil), "v2ray.core.app.receiver.AllocationStrategy")
-	proto.RegisterType((*AllocationStrategy_AllocationStrategyConcurrency)(nil), "v2ray.core.app.receiver.AllocationStrategy.AllocationStrategyConcurrency")
-	proto.RegisterType((*AllocationStrategy_AllocationStrategyRefresh)(nil), "v2ray.core.app.receiver.AllocationStrategy.AllocationStrategyRefresh")
-	proto.RegisterType((*StreamReceiverConfig)(nil), "v2ray.core.app.receiver.StreamReceiverConfig")
-	proto.RegisterType((*DatagramReceiverConfig)(nil), "v2ray.core.app.receiver.DatagramReceiverConfig")
-	proto.RegisterType((*PerProxyConfig)(nil), "v2ray.core.app.receiver.PerProxyConfig")
-	proto.RegisterType((*Config)(nil), "v2ray.core.app.receiver.Config")
-	proto.RegisterEnum("v2ray.core.app.receiver.AllocationStrategy_Type", AllocationStrategy_Type_name, AllocationStrategy_Type_value)
-}
-
-func init() { proto.RegisterFile("v2ray.com/core/app/receiver/config.proto", fileDescriptor0) }
-
-var fileDescriptor0 = []byte{
-	// 572 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe4, 0x94, 0xd1, 0x6e, 0xd3, 0x3e,
-	0x14, 0xc6, 0xff, 0x69, 0xf7, 0x2f, 0xdb, 0x29, 0x8c, 0xca, 0x4c, 0xac, 0x14, 0x21, 0x95, 0x08,
-	0xb1, 0x4a, 0x20, 0x67, 0x04, 0x71, 0xc1, 0x15, 0xda, 0xda, 0x5d, 0xec, 0x62, 0x50, 0xb9, 0x13,
-	0x17, 0x08, 0xa9, 0x32, 0xa9, 0x1b, 0x22, 0x12, 0x3b, 0x3a, 0xf6, 0xca, 0xf2, 0x4a, 0x3c, 0x05,
-	0x57, 0x3c, 0x10, 0x4f, 0x80, 0x12, 0x27, 0x5d, 0x59, 0x1b, 0xa4, 0x89, 0x4b, 0xee, 0x5c, 0xf7,
-	0xfb, 0x7e, 0xf6, 0x77, 0x8e, 0x73, 0x60, 0xb0, 0xf0, 0x91, 0x67, 0x34, 0x50, 0x89, 0x17, 0x28,
-	0x14, 0x1e, 0x4f, 0x53, 0x0f, 0x45, 0x20, 0xa2, 0x85, 0x40, 0x2f, 0x50, 0x72, 0x1e, 0x85, 0x34,
-	0x45, 0x65, 0x14, 0xd9, 0xa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x96, 0x2f, 0xc9, 0x31, 0x6c, 0x2f,
-	0xeb, 0xdc, 0xe8, 0x37, 0x07, 0x6d, 0xff, 0xe9, 0x86, 0xeb, 0xdb, 0x21, 0x57, 0x7c, 0xff, 0xb3,
-	0x33, 0x3b, 0xe3, 0xd8, 0xd2, 0xe7, 0x9e, 0x41, 0xab, 0xe4, 0x0f, 0x57, 0x68, 0x4e, 0x41, 0x3b,
-	0xa8, 0x0d, 0xf1, 0xfb, 0xd5, 0xae, 0x70, 0xc7, 0x6f, 0xe1, 0x61, 0xa0, 0x92, 0x3a, 0xdf, 0x71,
-	0xdb, 0x1a, 0xc6, 0xf9, 0x8c, 0xfb, 0xb0, 0x5d, 0x6d, 0x7f, 0x6b, 0xec, 0xbf, 0xf7, 0x19, 0xcf,
-	0xe8, 0x30, 0x37, 0x1c, 0xa5, 0x29, 0xad, 0xda, 0xfc, 0xa9, 0x55, 0x8c, 0xc3, 0x97, 0xbf, 0x02,
-	0x00, 0x00, 0xff, 0xff, 0x3a, 0x23, 0xe2, 0x82, 0x04, 0x06, 0x00, 0x00,
-}

+ 0 - 66
app/receiver/config.proto

@@ -1,66 +0,0 @@
-syntax = "proto3";
-
-package v2ray.core.app.receiver;
-option csharp_namespace = "V2Ray.Core.App.Receiver";
-option go_package = "receiver";
-option java_package = "com.v2ray.core.app.receiver";
-option java_outer_classname = "ConfigProto";
-
-import "v2ray.com/core/common/serial/typed_message.proto";
-import "v2ray.com/core/common/net/address.proto";
-import "v2ray.com/core/common/net/port.proto";
-import "v2ray.com/core/transport/internet/config.proto";
-
-message AllocationStrategy {
-  enum Type {
-    // Always allocate all connection handlers.
-    Always = 0;
-
-    // Randomly allocate specific range of handlers.
-    Random = 1;
-
-    // External. Not supported yet.
-    External = 2;
-  }
-
-  Type type = 1;
-
-  message AllocationStrategyConcurrency {
-    uint32 value = 1;
-  }
-
-  // Number of handlers (ports) running in parallel.
-  // Default value is 3 if unset.
-  AllocationStrategyConcurrency concurrency = 2;
-
-
-  message AllocationStrategyRefresh {
-    uint32 value = 1;
-  }
-
-  // Number of minutes before a handler is regenerated.
-  // Default value is 5 if unset.
-  AllocationStrategyRefresh refresh = 3;
-}
-
-message StreamReceiverConfig {
-  v2ray.core.common.net.PortRange port_range = 1;
-  v2ray.core.common.net.IPOrDomain listen = 2;
-  AllocationStrategy allocation_strategy = 3;
-  v2ray.core.transport.internet.StreamConfig stream_settings = 4;
-}
-
-message DatagramReceiverConfig {
-  v2ray.core.common.net.PortRange port_range = 1;
-  v2ray.core.common.net.IPOrDomain listen = 2;
-  AllocationStrategy allocation_strategy = 3;
-}
-
-message PerProxyConfig {
-  string tag = 1;
-  repeated v2ray.core.common.serial.TypedMessage settings = 2;
-}
-
-message Config {
-  repeated PerProxyConfig settings = 1;
-}

+ 0 - 49
app/receiver/receiver.go

@@ -1,49 +0,0 @@
-package receiver
-
-import (
-	"net"
-	"time"
-
-	v2net "v2ray.com/core/common/net"
-	"v2ray.com/core/proxy"
-)
-
-type refresher struct {
-	strategy   *AllocationStrategy
-	portsInUse []v2net.Port
-}
-
-func (r *refresher) Refresh(s *StreamReceiver) {
-}
-
-func (r *refresher) Interval() time.Duration {
-	switch r.strategy.Type {
-	case AllocationStrategy_Random:
-		return time.Minute * time.Duration(r.strategy.GetRefreshValue())
-	default:
-		return 0
-	}
-}
-
-type StreamReceiver struct {
-	config *StreamReceiverConfig
-	proxy  *proxy.InboundHandler
-
-	listeners []net.Listener
-	refresher refresher
-}
-
-func (s *StreamReceiver) Start() {
-	s.refresher.Refresh(s)
-	interval := s.refresher.Interval()
-	if interval == 0 {
-		return
-	}
-
-	go func() {
-		for {
-			time.Sleep(s.refresher.Interval())
-			s.refresher.Refresh(s)
-		}
-	}()
-}

+ 0 - 144
app/sender/config.pb.go

@@ -1,144 +0,0 @@
-package sender
-
-import proto "github.com/golang/protobuf/proto"
-import fmt "fmt"
-import math "math"
-import v2ray_core_common_serial "v2ray.com/core/common/serial"
-import v2ray_core_common_net "v2ray.com/core/common/net"
-import v2ray_core_transport_internet "v2ray.com/core/transport/internet"
-
-// 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 StreamSenderConfig struct {
-	Via            *v2ray_core_common_net.IPOrDomain           `protobuf:"bytes,1,opt,name=via" json:"via,omitempty"`
-	StreamSettings *v2ray_core_transport_internet.StreamConfig `protobuf:"bytes,2,opt,name=stream_settings,json=streamSettings" json:"stream_settings,omitempty"`
-	ProxySettings  *v2ray_core_transport_internet.ProxyConfig  `protobuf:"bytes,3,opt,name=proxy_settings,json=proxySettings" json:"proxy_settings,omitempty"`
-}
-
-func (m *StreamSenderConfig) Reset()                    { *m = StreamSenderConfig{} }
-func (m *StreamSenderConfig) String() string            { return proto.CompactTextString(m) }
-func (*StreamSenderConfig) ProtoMessage()               {}
-func (*StreamSenderConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
-
-func (m *StreamSenderConfig) GetVia() *v2ray_core_common_net.IPOrDomain {
-	if m != nil {
-		return m.Via
-	}
-	return nil
-}
-
-func (m *StreamSenderConfig) GetStreamSettings() *v2ray_core_transport_internet.StreamConfig {
-	if m != nil {
-		return m.StreamSettings
-	}
-	return nil
-}
-
-func (m *StreamSenderConfig) GetProxySettings() *v2ray_core_transport_internet.ProxyConfig {
-	if m != nil {
-		return m.ProxySettings
-	}
-	return nil
-}
-
-type DatagramSenderConfig struct {
-	Via *v2ray_core_common_net.IPOrDomain `protobuf:"bytes,1,opt,name=via" json:"via,omitempty"`
-}
-
-func (m *DatagramSenderConfig) Reset()                    { *m = DatagramSenderConfig{} }
-func (m *DatagramSenderConfig) String() string            { return proto.CompactTextString(m) }
-func (*DatagramSenderConfig) ProtoMessage()               {}
-func (*DatagramSenderConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
-
-func (m *DatagramSenderConfig) GetVia() *v2ray_core_common_net.IPOrDomain {
-	if m != nil {
-		return m.Via
-	}
-	return nil
-}
-
-type PerProxyConfig struct {
-	Tag      string                                   `protobuf:"bytes,1,opt,name=tag" json:"tag,omitempty"`
-	Settings []*v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,rep,name=settings" json:"settings,omitempty"`
-}
-
-func (m *PerProxyConfig) Reset()                    { *m = PerProxyConfig{} }
-func (m *PerProxyConfig) String() string            { return proto.CompactTextString(m) }
-func (*PerProxyConfig) ProtoMessage()               {}
-func (*PerProxyConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
-
-func (m *PerProxyConfig) GetTag() string {
-	if m != nil {
-		return m.Tag
-	}
-	return ""
-}
-
-func (m *PerProxyConfig) GetSettings() []*v2ray_core_common_serial.TypedMessage {
-	if m != nil {
-		return m.Settings
-	}
-	return nil
-}
-
-type Config struct {
-	Settings []*PerProxyConfig `protobuf:"bytes,1,rep,name=settings" json:"settings,omitempty"`
-}
-
-func (m *Config) Reset()                    { *m = Config{} }
-func (m *Config) String() string            { return proto.CompactTextString(m) }
-func (*Config) ProtoMessage()               {}
-func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
-
-func (m *Config) GetSettings() []*PerProxyConfig {
-	if m != nil {
-		return m.Settings
-	}
-	return nil
-}
-
-func init() {
-	proto.RegisterType((*StreamSenderConfig)(nil), "v2ray.core.app.sender.StreamSenderConfig")
-	proto.RegisterType((*DatagramSenderConfig)(nil), "v2ray.core.app.sender.DatagramSenderConfig")
-	proto.RegisterType((*PerProxyConfig)(nil), "v2ray.core.app.sender.PerProxyConfig")
-	proto.RegisterType((*Config)(nil), "v2ray.core.app.sender.Config")
-}
-
-func init() { proto.RegisterFile("v2ray.com/core/app/sender/config.proto", fileDescriptor0) }
-
-var fileDescriptor0 = []byte{
-	// 377 bytes of a gzipped FileDescriptorProto
-	0x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, 0xdc, 0xd1, 0xf8, 0x2b, 0x00, 0x00, 0xff,
-	0xff, 0x20, 0x7f, 0xd1, 0x0a, 0x13, 0x03, 0x00, 0x00,
-}

+ 0 - 30
app/sender/config.proto

@@ -1,30 +0,0 @@
-syntax = "proto3";
-
-package v2ray.core.app.sender;
-option csharp_namespace = "V2Ray.Core.App.Sender";
-option go_package = "sender";
-option java_package = "com.v2ray.core.app.sender";
-option java_outer_classname = "ConfigProto";
-
-import "v2ray.com/core/common/serial/typed_message.proto";
-import "v2ray.com/core/common/net/address.proto";
-import "v2ray.com/core/transport/internet/config.proto";
-
-message StreamSenderConfig {
-  v2ray.core.common.net.IPOrDomain via = 1;
-  v2ray.core.transport.internet.StreamConfig stream_settings = 2;
-  v2ray.core.transport.internet.ProxyConfig proxy_settings = 3;
-}
-
-message DatagramSenderConfig {
-  v2ray.core.common.net.IPOrDomain via = 1;
-}
-
-message PerProxyConfig {
-  string tag = 1;
-  repeated v2ray.core.common.serial.TypedMessage settings = 2;
-}
-
-message Config {
-  repeated PerProxyConfig settings = 1;
-}

+ 0 - 39
app/sender/sender.go

@@ -1,39 +0,0 @@
-package sender
-
-import (
-	"context"
-
-	"v2ray.com/core/app"
-	"v2ray.com/core/common"
-	"v2ray.com/core/common/net"
-	"v2ray.com/core/transport/internet"
-)
-
-type Sender interface {
-	SendTo(net.Destination) (internet.Connection, error)
-}
-
-type SenderManager struct {
-}
-
-func New(ctx context.Context, config *Config) (*SenderManager, error) {
-	return &SenderManager{}, nil
-}
-
-func (SenderManager) Interface() interface{} {
-	return (*SenderManager)(nil)
-}
-
-func FromSpace(space app.Space) *SenderManager {
-	app := space.GetApplication((*SenderManager)(nil))
-	if app == nil {
-		return nil
-	}
-	return app.(*SenderManager)
-}
-
-func init() {
-	common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
-		return New(ctx, config.(*Config))
-	}))
-}

+ 0 - 25
app/sender/stream_sender.go

@@ -1,25 +0,0 @@
-package sender
-
-import (
-	"v2ray.com/core/app"
-	"v2ray.com/core/common/net"
-	"v2ray.com/core/transport/internet"
-)
-
-type StreamSender struct {
-	config *StreamSenderConfig
-}
-
-func NewStreamSender(config *StreamSenderConfig, space app.Space) *StreamSender {
-	return &StreamSender{
-		config: config,
-	}
-}
-
-func (s *StreamSender) SendTo(destination net.Destination) (internet.Connection, error) {
-	src := s.config.Via.AsAddress()
-	return internet.Dial(src, destination, internet.DialerOptions{
-		Stream: s.config.StreamSettings,
-		Proxy:  s.config.ProxySettings,
-	})
-}

+ 7 - 0
proxy/proxy.go

@@ -2,6 +2,8 @@
 package proxy
 
 import (
+	"context"
+
 	"v2ray.com/core/common/net"
 	"v2ray.com/core/common/protocol"
 	"v2ray.com/core/transport/internet"
@@ -59,3 +61,8 @@ type OutboundHandler interface {
 	// Dispatch sends one or more Packets to its destination.
 	Dispatch(destination net.Destination, ray ray.OutboundRay)
 }
+
+// Dialer is used by OutboundHandler for creating outbound connections.
+type Dialer interface {
+	Dial(ctx context.Context, destination net.Destination) (internet.Connection, error)
+}