1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-18 05:25:23 +00:00

migrate NetworkList to []Network

This commit is contained in:
Darien Raymond 2018-11-20 16:58:26 +01:00
parent 7b80322b60
commit 769f770cf7
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
18 changed files with 167 additions and 153 deletions

View File

@ -89,7 +89,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
}
for port := pr.From; port <= pr.To; port++ {
if nl.HasNetwork(net.Network_TCP) {
if net.HasNetwork(nl, net.Network_TCP) {
newError("creating stream worker on ", address, ":", port).AtDebug().WriteToLog()
worker := &tcpWorker{
@ -107,7 +107,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
h.workers = append(h.workers, worker)
}
if nl.HasNetwork(net.Network_UDP) {
if net.HasNetwork(nl, net.Network_UDP) {
worker := &udpWorker{
tag: tag,
proxy: p,

View File

@ -122,7 +122,7 @@ func (h *DynamicInboundHandler) refresh() error {
}
p := rawProxy.(proxy.Inbound)
nl := p.Network()
if nl.HasNetwork(net.Network_TCP) {
if net.HasNetwork(nl, net.Network_TCP) {
worker := &tcpWorker{
tag: h.tag,
address: address,
@ -142,7 +142,7 @@ func (h *DynamicInboundHandler) refresh() error {
workers = append(workers, worker)
}
if nl.HasNetwork(net.Network_UDP) {
if net.HasNetwork(nl, net.Network_UDP) {
worker := &udpWorker{
tag: h.tag,
proxy: p,

View File

@ -85,7 +85,9 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) {
conds.Add(NewPortMatcher(*rr.PortRange))
}
if rr.NetworkList != nil {
if len(rr.Networks) > 0 {
conds.Add(NewNetworkMatcher(rr.Networks))
} else if rr.NetworkList != nil {
conds.Add(NewNetworkMatcher(rr.NetworkList.Network))
}

View File

@ -374,9 +374,12 @@ type RoutingRule struct {
// List of GeoIPs for target IP address matching. If this entry exists, the cidr above will have no effect.
// GeoIP fields with the same country code are supposed to contain exactly same content. They will be merged during runtime.
// For customized GeoIPs, please leave country code empty.
Geoip []*GeoIP `protobuf:"bytes,10,rep,name=geoip,proto3" json:"geoip,omitempty"`
PortRange *net.PortRange `protobuf:"bytes,4,opt,name=port_range,json=portRange,proto3" json:"port_range,omitempty"`
NetworkList *net.NetworkList `protobuf:"bytes,5,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"`
Geoip []*GeoIP `protobuf:"bytes,10,rep,name=geoip,proto3" json:"geoip,omitempty"`
PortRange *net.PortRange `protobuf:"bytes,4,opt,name=port_range,json=portRange,proto3" json:"port_range,omitempty"`
// List of networks. Deprecated. Use networks.
NetworkList *net.NetworkList `protobuf:"bytes,5,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` // Deprecated: Do not use.
// List of networks for matching.
Networks []net.Network `protobuf:"varint,13,rep,packed,name=networks,proto3,enum=v2ray.core.common.net.Network" json:"networks,omitempty"`
// List of CIDRs for source IP address matching.
SourceCidr []*CIDR `protobuf:"bytes,6,rep,name=source_cidr,json=sourceCidr,proto3" json:"source_cidr,omitempty"` // Deprecated: Do not use.
// List of GeoIPs for source IP address matching. If this entry exists, the source_cidr above will have no effect.
@ -480,6 +483,7 @@ func (m *RoutingRule) GetPortRange() *net.PortRange {
return nil
}
// Deprecated: Do not use.
func (m *RoutingRule) GetNetworkList() *net.NetworkList {
if m != nil {
return m.NetworkList
@ -487,6 +491,13 @@ func (m *RoutingRule) GetNetworkList() *net.NetworkList {
return nil
}
func (m *RoutingRule) GetNetworks() []net.Network {
if m != nil {
return m.Networks
}
return nil
}
// Deprecated: Do not use.
func (m *RoutingRule) GetSourceCidr() []*CIDR {
if m != nil {
@ -710,54 +721,55 @@ func init() {
}
var fileDescriptor_6b1608360690c5fc = []byte{
// 776 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xdd, 0x6e, 0xeb, 0x44,
0x10, 0x3e, 0x76, 0x7e, 0x4e, 0x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6d, 0x3d, 0xfe, 0x27, 0x00, 0x00, 0xff, 0xff,
0x7c, 0x01, 0x52, 0xfa, 0xba, 0x06, 0x00, 0x00,
// 799 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x6d, 0x6f, 0xe3, 0x44,
0x10, 0x3e, 0x3b, 0x2f, 0x57, 0x8f, 0xdd, 0x60, 0x56, 0x1c, 0x32, 0x85, 0x83, 0x60, 0x1d, 0x10,
0x09, 0xe4, 0x48, 0x39, 0xe0, 0x03, 0x12, 0x2a, 0xd7, 0x14, 0x82, 0x05, 0x94, 0x68, 0x7b, 0xc7,
0x07, 0xf8, 0x10, 0x6d, 0x9d, 0xad, 0xb1, 0x70, 0x76, 0x57, 0xeb, 0xf5, 0x71, 0xf9, 0x0b, 0xfc,
0x07, 0xfe, 0x00, 0x12, 0xff, 0x11, 0xed, 0x4b, 0xda, 0x06, 0xce, 0x10, 0xf1, 0x6d, 0x67, 0xe6,
0x99, 0x99, 0x67, 0xe7, 0x0d, 0xde, 0x7f, 0x3e, 0x93, 0x64, 0x9b, 0x15, 0x7c, 0x33, 0x2d, 0xb8,
0xa4, 0x53, 0x22, 0xc4, 0x54, 0xf2, 0x56, 0x51, 0x39, 0x2d, 0x38, 0xbb, 0xae, 0xca, 0x4c, 0x48,
0xae, 0x38, 0x7a, 0xb0, 0xc3, 0x49, 0x9a, 0x11, 0x21, 0x32, 0x8b, 0x39, 0x79, 0xf4, 0x37, 0xf7,
0x82, 0x6f, 0x36, 0x9c, 0x4d, 0x19, 0x55, 0x53, 0xc1, 0xa5, 0xb2, 0xce, 0x27, 0x1f, 0x74, 0xa3,
0x18, 0x55, 0xbf, 0x72, 0xf9, 0x8b, 0x05, 0xa6, 0xbf, 0x79, 0x30, 0x3c, 0xe7, 0x1b, 0x52, 0x31,
0xf4, 0x29, 0xf4, 0xd5, 0x56, 0xd0, 0xc4, 0x1b, 0x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f, 0x35,
0x34, 0x17, 0xb1, 0x87, 0x62, 0x88, 0x72, 0x91, 0x5f, 0x5f, 0x70, 0xf6, 0x1d, 0x51, 0xc5, 0xcf,
0xb1, 0x8f, 0x46, 0x00, 0xb9, 0xf8, 0x9e, 0x9d, 0xd3, 0x0d, 0x61, 0xeb, 0xb8, 0x77, 0xf6, 0x39,
0xbc, 0x51, 0xf0, 0xcd, 0xcb, 0x29, 0x2c, 0xbd, 0x1f, 0x87, 0xf6, 0xf5, 0x87, 0xff, 0xe0, 0x87,
0x19, 0x26, 0xdb, 0x6c, 0xae, 0x11, 0x4f, 0x84, 0x30, 0xff, 0xa3, 0xf2, 0x6a, 0x68, 0xda, 0xfa,
0xf8, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x46, 0xbc, 0x52, 0xfa, 0x06, 0x00, 0x00,
}

View File

@ -80,7 +80,12 @@ message RoutingRule {
repeated GeoIP geoip = 10;
v2ray.core.common.net.PortRange port_range = 4;
v2ray.core.common.net.NetworkList network_list = 5;
// List of networks. Deprecated. Use networks.
v2ray.core.common.net.NetworkList network_list = 5 [deprecated = true];
// List of networks for matching.
repeated v2ray.core.common.net.Network networks = 13;
// List of CIDRs for source IP address matching.
repeated CIDR source_cidr = 6 [deprecated = true];

View File

@ -24,9 +24,7 @@ func TestSimpleRouter(t *testing.T) {
TargetTag: &RoutingRule_Tag{
Tag: "test",
},
NetworkList: &net.NetworkList{
Network: []net.Network{net.Network_TCP},
},
Networks: []net.Network{net.Network_TCP},
},
},
}
@ -59,9 +57,7 @@ func TestSimpleBalancer(t *testing.T) {
TargetTag: &RoutingRule_BalancingTag{
BalancingTag: "balance",
},
NetworkList: &net.NetworkList{
Network: []net.Network{net.Network_TCP},
},
Networks: []net.Network{net.Network_TCP},
},
},
BalancingRule: []*BalancingRule{

View File

@ -1,11 +1,5 @@
package net
func (n Network) AsList() *NetworkList {
return &NetworkList{
Network: []Network{n},
}
}
func (n Network) SystemString() string {
switch n {
case Network_TCP:
@ -19,7 +13,7 @@ func (n Network) SystemString() string {
func HasNetwork(list []Network, network Network) bool {
for _, value := range list {
if string(value) == string(network) {
if value == network {
return true
}
}
@ -36,10 +30,6 @@ func (l NetworkList) HasNetwork(network Network) bool {
return false
}
func (l NetworkList) Get(idx int) Network {
return l.Network[idx]
}
// Size returns the number of networks in this network list.
func (l NetworkList) Size() int {
return len(l.Network)

View File

@ -19,15 +19,19 @@ var _ = math.Inf
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type Config struct {
Address *net.IPOrDomain `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
NetworkList *net.NetworkList `protobuf:"bytes,3,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"`
Timeout uint32 `protobuf:"varint,4,opt,name=timeout,proto3" json:"timeout,omitempty"` // Deprecated: Do not use.
FollowRedirect bool `protobuf:"varint,5,opt,name=follow_redirect,json=followRedirect,proto3" json:"follow_redirect,omitempty"`
UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Address *net.IPOrDomain `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
// List of networks that the Dokodemo accepts.
// Deprecated. Use networks.
NetworkList *net.NetworkList `protobuf:"bytes,3,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` // Deprecated: Do not use.
// List of networks that the Dokodemo accepts.
Networks []net.Network `protobuf:"varint,7,rep,packed,name=networks,proto3,enum=v2ray.core.common.net.Network" json:"networks,omitempty"`
Timeout uint32 `protobuf:"varint,4,opt,name=timeout,proto3" json:"timeout,omitempty"` // Deprecated: Do not use.
FollowRedirect bool `protobuf:"varint,5,opt,name=follow_redirect,json=followRedirect,proto3" json:"follow_redirect,omitempty"`
UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Config) Reset() { *m = Config{} }
@ -69,6 +73,7 @@ func (m *Config) GetPort() uint32 {
return 0
}
// Deprecated: Do not use.
func (m *Config) GetNetworkList() *net.NetworkList {
if m != nil {
return m.NetworkList
@ -76,6 +81,13 @@ func (m *Config) GetNetworkList() *net.NetworkList {
return nil
}
func (m *Config) GetNetworks() []net.Network {
if m != nil {
return m.Networks
}
return nil
}
// Deprecated: Do not use.
func (m *Config) GetTimeout() uint32 {
if m != nil {
@ -107,25 +119,26 @@ func init() {
}
var fileDescriptor_de04411d7254f312 = []byte{
// 310 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xcf, 0x4e, 0xc2, 0x40,
0x10, 0x87, 0xd3, 0x8a, 0x80, 0x8b, 0x7f, 0x92, 0x3d, 0x2d, 0x46, 0x12, 0xe4, 0x02, 0xf1, 0xb0,
0x4d, 0xf0, 0xe8, 0x0d, 0x30, 0xc6, 0x84, 0x28, 0xd9, 0x83, 0x07, 0x2f, 0xa4, 0xb6, 0x83, 0x69,
0xe8, 0xee, 0x90, 0xe9, 0x02, 0xf6, 0x05, 0x7c, 0x18, 0x9f, 0xd2, 0x74, 0xdb, 0x46, 0x63, 0x82,
0xb7, 0xd9, 0xdf, 0x7e, 0xf3, 0xcd, 0x64, 0xd8, 0xcd, 0x6e, 0x4c, 0x61, 0x2e, 0x23, 0xd4, 0x41,
0x84, 0x04, 0xc1, 0x86, 0xf0, 0x23, 0x0f, 0x62, 0x5c, 0x63, 0x0c, 0x1a, 0x83, 0x08, 0xcd, 0x2a,
0x79, 0x97, 0x1b, 0x42, 0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 0xb7, 0x70,
0xdc, 0xac, 0xfa, 0x7b, 0x6b, 0xba, 0xc3, 0xde, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x33, 0x8e,
0x70, 0xce, 0xf3, 0x01, 0x00, 0x00,
// 331 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0x41, 0x4f, 0xea, 0x40,
0x10, 0xc7, 0xd3, 0xc2, 0x03, 0xde, 0xf2, 0x1e, 0x26, 0x7b, 0x5a, 0x8c, 0x98, 0xca, 0x85, 0xc6,
0xc3, 0x36, 0xa9, 0x37, 0xbd, 0x01, 0x89, 0x21, 0x21, 0x4a, 0xf6, 0xe0, 0xc1, 0x0b, 0xa9, 0xed,
0x60, 0x1a, 0xba, 0x3b, 0x64, 0xbb, 0x80, 0x7c, 0x25, 0x3f, 0x88, 0x9f, 0xcb, 0x74, 0xdb, 0xaa,
0x31, 0x81, 0xdb, 0xec, 0x7f, 0x7f, 0xfb, 0x9b, 0xd9, 0x0c, 0xb9, 0xde, 0x85, 0x3a, 0x3a, 0xf0,
0x18, 0x65, 0x10, 0xa3, 0x86, 0x60, 0xa3, 0xf1, 0xed, 0x10, 0x24, 0xb8, 0xc6, 0x04, 0x24, 0x06,
0x31, 0xaa, 0x55, 0xfa, 0xca, 0x37, 0x1a, 0x0d, 0xd2, 0x7e, 0xcd, 0x6a, 0xe0, 0x96, 0xe3, 0x35,
0x77, 0x3e, 0xfa, 0xa5, 0x89, 0x51, 0x4a, 0x54, 0x81, 0x02, 0x13, 0x44, 0x49, 0xa2, 0x21, 0xcf,
0x4b, 0xc7, 0x29, 0x50, 0x81, 0xd9, 0xa3, 0x5e, 0x97, 0xe0, 0xf0, 0xc3, 0x25, 0xad, 0x89, 0xed,
0x4e, 0xef, 0x48, 0xbb, 0x92, 0x30, 0xc7, 0x73, 0xfc, 0x6e, 0x78, 0xc5, 0x7f, 0x4c, 0x52, 0x1a,
0xb8, 0x02, 0xc3, 0x67, 0x8b, 0x47, 0x3d, 0x45, 0x19, 0xa5, 0x4a, 0xd4, 0x2f, 0x28, 0x25, 0xcd,
0x0d, 0x6a, 0xc3, 0x5c, 0xcf, 0xf1, 0xff, 0x0b, 0x5b, 0xd3, 0x19, 0xf9, 0x57, 0x35, 0x5b, 0x66,
0x69, 0x6e, 0x58, 0xc3, 0x5a, 0x87, 0x47, 0xac, 0x0f, 0x25, 0x3a, 0x4f, 0x73, 0x33, 0x76, 0x99,
0x23, 0xba, 0xea, 0x3b, 0xa0, 0xb7, 0xa4, 0x53, 0x1d, 0x73, 0xd6, 0xf6, 0x1a, 0x7e, 0x2f, 0xbc,
0x3c, 0xad, 0x11, 0x5f, 0x3c, 0xbd, 0x20, 0x6d, 0x93, 0x4a, 0xc0, 0xad, 0x61, 0xcd, 0x62, 0x3a,
0x6b, 0xaf, 0x23, 0x3a, 0x22, 0x67, 0x2b, 0xcc, 0x32, 0xdc, 0x2f, 0x35, 0x24, 0xa9, 0x86, 0xd8,
0xb0, 0x3f, 0x9e, 0xe3, 0x77, 0x44, 0xaf, 0x8c, 0x45, 0x95, 0xd2, 0x01, 0x21, 0xdb, 0x1c, 0xf4,
0x32, 0x83, 0x1d, 0x64, 0xac, 0x65, 0xff, 0xf9, 0xb7, 0x48, 0xe6, 0x45, 0x30, 0xbe, 0x27, 0x83,
0x18, 0x25, 0x3f, 0xba, 0xbb, 0x85, 0xf3, 0xdc, 0xa9, 0xeb, 0x77, 0xb7, 0xff, 0x14, 0x8a, 0xe8,
0xc0, 0x27, 0x05, 0xb7, 0xb0, 0xdc, 0xb4, 0xba, 0x7b, 0x69, 0xd9, 0xc5, 0xdc, 0x7c, 0x06, 0x00,
0x00, 0xff, 0xff, 0xec, 0xf1, 0xbb, 0x96, 0x33, 0x02, 0x00, 0x00,
}

View File

@ -12,7 +12,13 @@ import "v2ray.com/core/common/net/network.proto";
message Config {
v2ray.core.common.net.IPOrDomain address = 1;
uint32 port = 2;
v2ray.core.common.net.NetworkList network_list = 3;
// List of networks that the Dokodemo accepts.
// Deprecated. Use networks.
v2ray.core.common.net.NetworkList network_list = 3 [deprecated = true];
// List of networks that the Dokodemo accepts.
repeated v2ray.core.common.net.Network networks = 7;
uint32 timeout = 4 [deprecated = true];
bool follow_redirect = 5;
uint32 user_level = 6;

View File

@ -38,7 +38,7 @@ type DokodemoDoor struct {
// Init initializes the DokodemoDoor instance with necessary parameters.
func (d *DokodemoDoor) Init(config *Config, pm policy.Manager) error {
if config.NetworkList == nil || config.NetworkList.Size() == 0 {
if (config.NetworkList == nil || config.NetworkList.Size() == 0) && len(config.Networks) == 0 {
return newError("no network specified")
}
d.config = config
@ -49,8 +49,13 @@ func (d *DokodemoDoor) Init(config *Config, pm policy.Manager) error {
return nil
}
func (d *DokodemoDoor) Network() net.NetworkList {
return *(d.config.NetworkList)
// Network implements proxy.Inbound.
func (d *DokodemoDoor) Network() []net.Network {
if len(d.config.Networks) > 0 {
return d.config.Networks
}
return d.config.NetworkList.Network
}
func (d *DokodemoDoor) policy() policy.Session {
@ -66,6 +71,7 @@ type hasHandshakeAddress interface {
HandshakeAddress() net.Address
}
// Process implements proxy.Inbound.
func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher routing.Dispatcher) error {
newError("processing connection from: ", conn.RemoteAddr()).AtDebug().WriteToLog(session.ExportIDToError(ctx))
dest := net.Destination{

View File

@ -52,10 +52,8 @@ func (s *Server) policy() policy.Session {
return p
}
func (*Server) Network() net.NetworkList {
return net.NetworkList{
Network: []net.Network{net.Network_TCP},
}
func (*Server) Network() []net.Network {
return []net.Network{net.Network_TCP}
}
func parseHost(rawHost string, defaultPort net.Port) (net.Destination, error) {

View File

@ -60,10 +60,8 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
}, nil
}
func (s *Server) Network() net.NetworkList {
return net.NetworkList{
Network: []net.Network{net.Network_TCP},
}
func (s *Server) Network() []net.Network {
return []net.Network{net.Network_TCP}
}
func isValidConnectionType(c [4]byte) bool {

View File

@ -17,8 +17,8 @@ import (
// An Inbound processes inbound connections.
type Inbound interface {
// Network returns a list of network that this inbound supports. Connections with not-supported networks will not be passed into Process().
Network() net.NetworkList
// Network returns a list of networks that this inbound supports. Connections with not-supported networks will not be passed into Process().
Network() []net.Network
// Process processes a connection of given network. If necessary, the Inbound can dispatch the connection to an Outbound.
Process(context.Context, net.Network, internet.Connection, routing.Dispatcher) error

View File

@ -47,15 +47,13 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) {
return s, nil
}
func (s *Server) Network() net.NetworkList {
list := net.NetworkList{
Network: s.config.Network,
}
if len(list.Network) == 0 {
list.Network = append(list.Network, net.Network_TCP)
func (s *Server) Network() []net.Network {
list := s.config.Network
if len(list) == 0 {
list = append(list, net.Network_TCP)
}
if s.config.UdpEnabled {
list.Network = append(list.Network, net.Network_UDP)
list = append(list, net.Network_UDP)
}
return list
}

View File

@ -51,12 +51,10 @@ func (s *Server) policy() policy.Session {
}
// Network implements proxy.Inbound.
func (s *Server) Network() net.NetworkList {
list := net.NetworkList{
Network: []net.Network{net.Network_TCP},
}
func (s *Server) Network() []net.Network {
list := []net.Network{net.Network_TCP}
if s.config.UdpEnabled {
list.Network = append(list.Network, net.Network_UDP)
list = append(list, net.Network_UDP)
}
return list
}

View File

@ -145,10 +145,8 @@ func (h *Handler) Close() error {
}
// Network implements proxy.Inbound.Network().
func (*Handler) Network() net.NetworkList {
return net.NetworkList{
Network: []net.Network{net.Network_TCP},
}
func (*Handler) Network() []net.Network {
return []net.Network{net.Network_TCP}
}
func (h *Handler) GetUser(email string) *protocol.MemoryUser {

View File

@ -38,9 +38,9 @@ func (m *ProxyInbound) EXPECT() *ProxyInboundMockRecorder {
}
// Network mocks base method
func (m *ProxyInbound) Network() net.NetworkList {
func (m *ProxyInbound) Network() []net.Network {
ret := m.ctrl.Call(m, "Network")
ret0, _ := ret[0].(net.NetworkList)
ret0, _ := ret[0].([]net.Network)
return ret0
}

View File

@ -71,11 +71,9 @@ func TestCommanderRemoveHandler(t *testing.T) {
Listen: net.NewIPOrDomain(net.LocalHostIP),
}),
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
Address: net.NewIPOrDomain(dest.Address),
Port: uint32(dest.Port),
NetworkList: &net.NetworkList{
Network: []net.Network{net.Network_TCP},
},
Address: net.NewIPOrDomain(dest.Address),
Port: uint32(dest.Port),
Networks: []net.Network{net.Network_TCP},
}),
},
{
@ -85,11 +83,9 @@ func TestCommanderRemoveHandler(t *testing.T) {
Listen: net.NewIPOrDomain(net.LocalHostIP),
}),
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
Address: net.NewIPOrDomain(dest.Address),
Port: uint32(dest.Port),
NetworkList: &net.NetworkList{
Network: []net.Network{net.Network_TCP},
},
Address: net.NewIPOrDomain(dest.Address),
Port: uint32(dest.Port),
Networks: []net.Network{net.Network_TCP},
}),
},
},
@ -218,11 +214,9 @@ func TestCommanderAddRemoveUser(t *testing.T) {
Listen: net.NewIPOrDomain(net.LocalHostIP),
}),
ProxySettings: serial.ToTypedMessage(&dokodemo.Config{
Address: net.NewIPOrDomain(dest.Address),
Port: uint32(dest.Port),
NetworkList: &net.NetworkList{
Network: []net.Network{net.Network_TCP},
},
Address: net.NewIPOrDomain(dest.Address),
Port: uint32(dest.Port),
Networks: []net.Network{net.Network_TCP},
}),
},
},