From 6eff0acc0b3b523b315d0566a8bafbfa571f47af Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 16 Jan 2017 14:18:33 +0100 Subject: [PATCH] rename transportsettings to transportconfig --- testing/scenarios/transport_test.go | 135 ++++++++++++++++++++++++ tools/conf/transport.go | 6 +- tools/conf/transport_internet.go | 6 +- transport/config.pb.go | 20 ++-- transport/config.proto | 2 +- transport/internet/config.go | 6 +- transport/internet/config.pb.go | 72 ++++++------- transport/internet/config.proto | 4 +- transport/internet/kcp/kcp_test.go | 4 +- transport/internet/websocket/ws_test.go | 12 +-- 10 files changed, 201 insertions(+), 66 deletions(-) create mode 100644 testing/scenarios/transport_test.go diff --git a/testing/scenarios/transport_test.go b/testing/scenarios/transport_test.go new file mode 100644 index 000000000..2726fcac7 --- /dev/null +++ b/testing/scenarios/transport_test.go @@ -0,0 +1,135 @@ +package scenarios + +import ( + "net" + "testing" + "time" + + "v2ray.com/core" + v2net "v2ray.com/core/common/net" + "v2ray.com/core/common/protocol" + "v2ray.com/core/common/serial" + "v2ray.com/core/common/uuid" + "v2ray.com/core/proxy/dokodemo" + "v2ray.com/core/proxy/freedom" + "v2ray.com/core/proxy/vmess" + "v2ray.com/core/proxy/vmess/inbound" + "v2ray.com/core/proxy/vmess/outbound" + "v2ray.com/core/testing/assert" + "v2ray.com/core/testing/servers/tcp" + "v2ray.com/core/transport/internet" + "v2ray.com/core/transport/internet/headers/http" + tcptransport "v2ray.com/core/transport/internet/tcp" +) + +func TestNoOpConnectionHeader(t *testing.T) { + assert := assert.On(t) + + tcpServer := tcp.Server{ + MsgProcessor: xor, + } + dest, err := tcpServer.Start() + assert.Error(err).IsNil() + defer tcpServer.Close() + + userID := protocol.NewID(uuid.New()) + serverPort := pickPort() + serverConfig := &core.Config{ + Inbound: []*core.InboundConnectionConfig{ + { + PortRange: v2net.SinglePortRange(serverPort), + ListenOn: v2net.NewIPOrDomain(v2net.LocalHostIP), + Settings: serial.ToTypedMessage(&inbound.Config{ + User: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vmess.Account{ + Id: userID.String(), + }), + }, + }, + }), + StreamSettings: &internet.StreamConfig{ + TransportSettings: []*internet.TransportConfig{ + { + Protocol: internet.TransportProtocol_TCP, + Settings: serial.ToTypedMessage(&tcptransport.Config{ + HeaderSettings: serial.ToTypedMessage(&http.Config{}), + }), + }, + }, + }, + }, + }, + Outbound: []*core.OutboundConnectionConfig{ + { + Settings: serial.ToTypedMessage(&freedom.Config{}), + }, + }, + } + + clientPort := pickPort() + clientConfig := &core.Config{ + Inbound: []*core.InboundConnectionConfig{ + { + PortRange: v2net.SinglePortRange(clientPort), + ListenOn: v2net.NewIPOrDomain(v2net.LocalHostIP), + Settings: serial.ToTypedMessage(&dokodemo.Config{ + Address: v2net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + NetworkList: &v2net.NetworkList{ + Network: []v2net.Network{v2net.Network_TCP}, + }, + }), + }, + }, + Outbound: []*core.OutboundConnectionConfig{ + { + Settings: serial.ToTypedMessage(&outbound.Config{ + Receiver: []*protocol.ServerEndpoint{ + { + Address: v2net.NewIPOrDomain(v2net.LocalHostIP), + Port: uint32(serverPort), + User: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vmess.Account{ + Id: userID.String(), + }), + }, + }, + }, + }, + }), + StreamSettings: &internet.StreamConfig{ + TransportSettings: []*internet.TransportConfig{ + { + Protocol: internet.TransportProtocol_TCP, + Settings: serial.ToTypedMessage(&tcptransport.Config{ + HeaderSettings: serial.ToTypedMessage(&http.Config{}), + }), + }, + }, + }, + }, + }, + } + + assert.Error(InitializeServerConfig(serverConfig)).IsNil() + assert.Error(InitializeServerConfig(clientConfig)).IsNil() + + conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{ + IP: []byte{127, 0, 0, 1}, + Port: int(clientPort), + }) + assert.Error(err).IsNil() + + payload := "dokodemo request." + nBytes, err := conn.Write([]byte(payload)) + assert.Error(err).IsNil() + assert.Int(nBytes).Equals(len(payload)) + + response := readFrom(conn, time.Second*2, len(payload)) + assert.Bytes(response).Equals(xor([]byte(payload))) + assert.Error(conn.Close()).IsNil() + + CloseAllServers() +} diff --git a/tools/conf/transport.go b/tools/conf/transport.go index ad0387bf6..d2ca86e8d 100644 --- a/tools/conf/transport.go +++ b/tools/conf/transport.go @@ -20,7 +20,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) { if err != nil { return nil, errors.Base(err).Message("Failed to build TCP config.") } - config.TransportSettings = append(config.TransportSettings, &internet.TransportSettings{ + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ Protocol: internet.TransportProtocol_TCP, Settings: ts, }) @@ -31,7 +31,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) { if err != nil { return nil, errors.Base(err).Message("Failed to build mKCP config.") } - config.TransportSettings = append(config.TransportSettings, &internet.TransportSettings{ + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ Protocol: internet.TransportProtocol_MKCP, Settings: ts, }) @@ -42,7 +42,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) { if err != nil { return nil, errors.Base(err).Message("Failed to build WebSocket config.") } - config.TransportSettings = append(config.TransportSettings, &internet.TransportSettings{ + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ Protocol: internet.TransportProtocol_WebSocket, Settings: ts, }) diff --git a/tools/conf/transport_internet.go b/tools/conf/transport_internet.go index f18f53ca5..1f8e3c307 100644 --- a/tools/conf/transport_internet.go +++ b/tools/conf/transport_internet.go @@ -226,7 +226,7 @@ func (v *StreamConfig) Build() (*internet.StreamConfig, error) { if err != nil { return nil, errors.Base(err).Message("Failed to build TCP config.") } - config.TransportSettings = append(config.TransportSettings, &internet.TransportSettings{ + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ Protocol: internet.TransportProtocol_TCP, Settings: ts, }) @@ -236,7 +236,7 @@ func (v *StreamConfig) Build() (*internet.StreamConfig, error) { if err != nil { return nil, errors.Base(err).Message("Failed to build mKCP config.") } - config.TransportSettings = append(config.TransportSettings, &internet.TransportSettings{ + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ Protocol: internet.TransportProtocol_MKCP, Settings: ts, }) @@ -246,7 +246,7 @@ func (v *StreamConfig) Build() (*internet.StreamConfig, error) { if err != nil { return nil, errors.Base(err).Message("Failed to build WebSocket config.") } - config.TransportSettings = append(config.TransportSettings, &internet.TransportSettings{ + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ Protocol: internet.TransportProtocol_WebSocket, Settings: ts, }) diff --git a/transport/config.pb.go b/transport/config.pb.go index f99ea38f1..81f58dbfc 100644 --- a/transport/config.pb.go +++ b/transport/config.pb.go @@ -18,7 +18,7 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // Global transport settings. This affects all type of connections that go through V2Ray. type Config struct { - TransportSettings []*v2ray_core_transport_internet.TransportSettings `protobuf:"bytes,1,rep,name=transport_settings,json=transportSettings" json:"transport_settings,omitempty"` + TransportSettings []*v2ray_core_transport_internet.TransportConfig `protobuf:"bytes,1,rep,name=transport_settings,json=transportSettings" json:"transport_settings,omitempty"` } func (m *Config) Reset() { *m = Config{} } @@ -26,7 +26,7 @@ func (m *Config) String() string { return proto.CompactTextString(m) func (*Config) ProtoMessage() {} func (*Config) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (m *Config) GetTransportSettings() []*v2ray_core_transport_internet.TransportSettings { +func (m *Config) GetTransportSettings() []*v2ray_core_transport_internet.TransportConfig { if m != nil { return m.TransportSettings } @@ -40,16 +40,16 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/transport/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 174 bytes of a gzipped FileDescriptorProto + // 175 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x2d, 0x33, 0x2a, 0x4a, 0xac, 0xd4, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce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 0x83, 0xdb, 0x48, 0x4f, 0x0f, 0x9b, 0x65, 0x7a, 0x30, 0x23, 0xf5, 0x42, 0x60, 0x42, + 0x10, 0xb3, 0x82, 0x04, 0xe1, 0x6a, 0x82, 0xa1, 0x06, 0x39, 0x79, 0x72, 0x49, 0x24, 0xe7, 0xe7, + 0x62, 0x35, 0xc7, 0x89, 0x1b, 0xa2, 0x2d, 0x00, 0xe4, 0xa2, 0x28, 0x4e, 0xb8, 0xf8, 0x2a, 0x26, + 0x91, 0x30, 0xa3, 0xa0, 0xc4, 0x4a, 0x3d, 0x67, 0x90, 0x72, 0xb8, 0x1d, 0x49, 0x6c, 0x60, 0xa7, + 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x89, 0x64, 0xdc, 0xb9, 0x29, 0x01, 0x00, 0x00, } diff --git a/transport/config.proto b/transport/config.proto index 4ccaa06ac..174e74d67 100644 --- a/transport/config.proto +++ b/transport/config.proto @@ -10,5 +10,5 @@ import "v2ray.com/core/transport/internet/config.proto"; // Global transport settings. This affects all type of connections that go through V2Ray. message Config { - repeated v2ray.core.transport.internet.TransportSettings transport_settings = 1; + repeated v2ray.core.transport.internet.TransportConfig transport_settings = 1; } \ No newline at end of file diff --git a/transport/internet/config.go b/transport/internet/config.go index c97b3e2c9..e8807364d 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -9,7 +9,7 @@ type ConfigCreator func() interface{} var ( globalTransportConfigCreatorCache = make(map[TransportProtocol]ConfigCreator) - globalTransportSettings []*TransportSettings + globalTransportSettings []*TransportConfig ) func RegisterProtocolConfigCreator(protocol TransportProtocol, creator ConfigCreator) error { @@ -26,7 +26,7 @@ func CreateTransportConfig(protocol TransportProtocol) (interface{}, error) { return creator(), nil } -func (v *TransportSettings) GetTypedSettings() (interface{}, error) { +func (v *TransportConfig) GetTypedSettings() (interface{}, error) { return v.Settings.GetInstance() } @@ -69,7 +69,7 @@ func (v *StreamConfig) HasSecuritySettings() bool { return len(v.SecurityType) > 0 } -func ApplyGlobalTransportSettings(settings []*TransportSettings) error { +func ApplyGlobalTransportSettings(settings []*TransportConfig) error { globalTransportSettings = settings return nil } diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 0b5cd5063..10bb1488d 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -43,26 +43,26 @@ func (x TransportProtocol) String() string { } func (TransportProtocol) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -type TransportSettings struct { +type TransportConfig struct { // Type of network that this settings supports. Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,enum=v2ray.core.transport.internet.TransportProtocol" json:"protocol,omitempty"` // Specific settings. Settings *v2ray_core_common_serial.TypedMessage `protobuf:"bytes,2,opt,name=settings" json:"settings,omitempty"` } -func (m *TransportSettings) Reset() { *m = TransportSettings{} } -func (m *TransportSettings) String() string { return proto.CompactTextString(m) } -func (*TransportSettings) ProtoMessage() {} -func (*TransportSettings) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (m *TransportConfig) Reset() { *m = TransportConfig{} } +func (m *TransportConfig) String() string { return proto.CompactTextString(m) } +func (*TransportConfig) ProtoMessage() {} +func (*TransportConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } -func (m *TransportSettings) GetProtocol() TransportProtocol { +func (m *TransportConfig) GetProtocol() TransportProtocol { if m != nil { return m.Protocol } return TransportProtocol_TCP } -func (m *TransportSettings) GetSettings() *v2ray_core_common_serial.TypedMessage { +func (m *TransportConfig) GetSettings() *v2ray_core_common_serial.TypedMessage { if m != nil { return m.Settings } @@ -71,8 +71,8 @@ func (m *TransportSettings) GetSettings() *v2ray_core_common_serial.TypedMessage type StreamConfig struct { // Effective network. - Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,enum=v2ray.core.transport.internet.TransportProtocol" json:"protocol,omitempty"` - TransportSettings []*TransportSettings `protobuf:"bytes,2,rep,name=transport_settings,json=transportSettings" json:"transport_settings,omitempty"` + Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,enum=v2ray.core.transport.internet.TransportProtocol" json:"protocol,omitempty"` + TransportSettings []*TransportConfig `protobuf:"bytes,2,rep,name=transport_settings,json=transportSettings" json:"transport_settings,omitempty"` // Type of security. Must be a message name of the settings proto. SecurityType string `protobuf:"bytes,3,opt,name=security_type,json=securityType" json:"security_type,omitempty"` SecuritySettings []*v2ray_core_common_serial.TypedMessage `protobuf:"bytes,4,rep,name=security_settings,json=securitySettings" json:"security_settings,omitempty"` @@ -90,7 +90,7 @@ func (m *StreamConfig) GetProtocol() TransportProtocol { return TransportProtocol_TCP } -func (m *StreamConfig) GetTransportSettings() []*TransportSettings { +func (m *StreamConfig) GetTransportSettings() []*TransportConfig { if m != nil { return m.TransportSettings } @@ -128,7 +128,7 @@ func (m *ProxyConfig) GetTag() string { } func init() { - proto.RegisterType((*TransportSettings)(nil), "v2ray.core.transport.internet.TransportSettings") + proto.RegisterType((*TransportConfig)(nil), "v2ray.core.transport.internet.TransportConfig") proto.RegisterType((*StreamConfig)(nil), "v2ray.core.transport.internet.StreamConfig") proto.RegisterType((*ProxyConfig)(nil), "v2ray.core.transport.internet.ProxyConfig") proto.RegisterEnum("v2ray.core.transport.internet.TransportProtocol", TransportProtocol_name, TransportProtocol_value) @@ -137,29 +137,29 @@ func init() { func init() { proto.RegisterFile("v2ray.com/core/transport/internet/config.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 372 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x92, 0x4f, 0x4b, 0xf3, 0x40, - 0x10, 0xc6, 0xdf, 0x24, 0xe5, 0x35, 0x9d, 0xb6, 0x92, 0xee, 0xa9, 0x08, 0xc5, 0x5a, 0x41, 0x82, - 0x87, 0x4d, 0x89, 0x77, 0x0f, 0x8d, 0x17, 0xd1, 0x42, 0x48, 0xaa, 0x82, 0x97, 0x90, 0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b, 0xe3, 0x0b, 0x86, 0xe2, 0x57, 0xa2, 0xa7, 0x30, 0x28, 0x28, 0x79, - 0xe5, 0xa9, 0x28, 0xa3, 0xea, 0x0e, 0x23, 0x63, 0xa2, 0xd9, 0xdd, 0xa0, 0x2f, 0x3f, 0x56, 0xbf, - 0x8d, 0x42, 0x18, 0x2a, 0x91, 0x32, 0xd1, 0xa9, 0x4d, 0xec, 0x9b, 0x98, 0x25, 0x01, 0x72, 0xf3, - 0xf4, 0x18, 0x7a, 0x3e, 0x67, 0xef, 0x65, 0x9b, 0x9b, 0x05, 0x86, 0x88, 0x93, 0x3a, 0xb2, 0x6e, - 0x50, 0x95, 0xe7, 0x97, 0x5b, 0x2f, 0x40, 0x46, 0x83, 0x0e, 0xc0, 0x58, 0x7a, 0xbe, 0xf5, 0xaf, - 0x2a, 0xee, 0xae, 0x7c, 0x4b, 0x43, 0x26, 0x74, 0x16, 0x37, 0x9e, 0x6f, 0xe9, 0x68, 0x00, 0xdd, - 0x07, 0xba, 0x0a, 0x19, 0x79, 0xa1, 0xc2, 0x32, 0xe6, 0x0b, 0x38, 0x21, 0x2c, 0xdb, 0x1d, 0xd2, - 0xa3, 0x29, 0xab, 0x4f, 0x7d, 0x7c, 0xef, 0x06, 0x71, 0x89, 0xbd, 0x4a, 0xa9, 0x16, 0xe3, 0xeb, - 0xb6, 0xbf, 0xfa, 0x5f, 0x1f, 0xe5, 0xe2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xca, 0x28, 0x5d, 0x77, - 0x1b, 0x03, 0x00, 0x00, + // 371 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x91, 0x4f, 0x4b, 0xfb, 0x30, + 0x18, 0xc7, 0x7f, 0x6d, 0xc7, 0xcf, 0xee, 0xd9, 0xa6, 0x5d, 0x4e, 0x43, 0x18, 0xce, 0x09, 0x52, + 0x3c, 0xa4, 0xa3, 0x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, 0xc8, 0x1a, 0x76, 0xc7, 0xc5, + 0xbb, 0x72, 0x6b, 0xb3, 0xa0, 0xaf, 0x32, 0x61, 0x03, 0x42, 0x27, 0xd0, 0xcb, 0x29, 0x79, 0xe5, + 0x89, 0x28, 0x16, 0xe5, 0x1b, 0x0c, 0x8c, 0x91, 0x66, 0xb7, 0x83, 0xae, 0xfc, 0x58, 0xfe, 0x34, + 0x0a, 0xa1, 0xaf, 0x42, 0x4a, 0xa1, 0x55, 0x29, 0xec, 0xda, 0x97, 0x25, 0x01, 0x72, 0xf3, 0xf8, + 0x08, 0x3a, 0x3e, 0x67, 0xef, 0x45, 0xd3, 0x9a, 0x05, 0x86, 0x88, 0xe2, 0xaa, 0xb0, 0x76, 0x50, + 0x1e, 0xcf, 0x2e, 0xa0, 0xff, 0xab, 0x18, 0xb4, 0x07, 0xc6, 0xdc, 0xf3, 0xad, 0x7f, 0xe5, 0xe1, + 0xf6, 0xd2, 0xb7, 0x34, 0x64, 0x42, 0x6b, 0x76, 0xed, 0xf9, 0x96, 0x8e, 0x7a, 0xd0, 0xbe, 0xa7, + 0xcb, 0x90, 0x91, 0x17, 0x2a, 0x2c, 0x63, 0x3a, 0x83, 0x63, 0xc2, 0xd2, 0xed, 0x15, 0x3d, 0x98, + 0xf2, 0xf4, 0xa9, 0x0f, 0xef, 0xdc, 0x20, 0x2a, 0xb0, 0x57, 0x26, 0xd5, 0x62, 0x7c, 0xd5, 0xdc, + 0x2f, 0xff, 0x57, 0x4f, 0x72, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xc3, 0x2c, 0x5e, 0x17, + 0x03, 0x00, 0x00, } diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 229c20079..bb52f9ad9 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -14,7 +14,7 @@ enum TransportProtocol { WebSocket = 3; } -message TransportSettings { +message TransportConfig { // Type of network that this settings supports. TransportProtocol protocol = 1; @@ -26,7 +26,7 @@ message StreamConfig { // Effective network. TransportProtocol protocol = 1; - repeated TransportSettings transport_settings = 2; + repeated TransportConfig transport_settings = 2; // Type of security. Must be a message name of the settings proto. string security_type = 3; diff --git a/transport/internet/kcp/kcp_test.go b/transport/internet/kcp/kcp_test.go index eaceca2d7..c38107a8f 100644 --- a/transport/internet/kcp/kcp_test.go +++ b/transport/internet/kcp/kcp_test.go @@ -21,7 +21,7 @@ func TestDialAndListen(t *testing.T) { listerner, err := NewListener(v2net.LocalHostIP, v2net.Port(0), internet.ListenOptions{ Stream: &internet.StreamConfig{ Protocol: internet.TransportProtocol_MKCP, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_MKCP, Settings: serial.ToTypedMessage(&Config{}), @@ -60,7 +60,7 @@ func TestDialAndListen(t *testing.T) { clientConn, err := DialKCP(v2net.LocalHostIP, v2net.UDPDestination(v2net.LocalHostIP, port), internet.DialerOptions{ Stream: &internet.StreamConfig{ Protocol: internet.TransportProtocol_MKCP, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_MKCP, Settings: serial.ToTypedMessage(&Config{}), diff --git a/transport/internet/websocket/ws_test.go b/transport/internet/websocket/ws_test.go index 8572bd606..162eb93a8 100644 --- a/transport/internet/websocket/ws_test.go +++ b/transport/internet/websocket/ws_test.go @@ -20,7 +20,7 @@ func Test_listenWSAndDial(t *testing.T) { listen, err := ListenWS(v2net.DomainAddress("localhost"), 13146, internet.ListenOptions{ Stream: &internet.StreamConfig{ Protocol: internet.TransportProtocol_WebSocket, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_WebSocket, Settings: serial.ToTypedMessage(&Config{ @@ -57,7 +57,7 @@ func Test_listenWSAndDial(t *testing.T) { conn, err := Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13146), internet.DialerOptions{ Stream: &internet.StreamConfig{ Protocol: internet.TransportProtocol_WebSocket, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_WebSocket, Settings: serial.ToTypedMessage(&Config{ @@ -81,7 +81,7 @@ func Test_listenWSAndDial(t *testing.T) { conn, err = Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13146), internet.DialerOptions{ Stream: &internet.StreamConfig{ Protocol: internet.TransportProtocol_WebSocket, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_WebSocket, Settings: serial.ToTypedMessage(&Config{ @@ -102,7 +102,7 @@ func Test_listenWSAndDial(t *testing.T) { conn, err = Dial(v2net.AnyIP, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13146), internet.DialerOptions{ Stream: &internet.StreamConfig{ Protocol: internet.TransportProtocol_WebSocket, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_WebSocket, Settings: serial.ToTypedMessage(&Config{ @@ -137,7 +137,7 @@ func Test_listenWSAndDial_TLS(t *testing.T) { Certificate: []*v2tls.Certificate{tlsgen.GenerateCertificateForTest()}, })}, Protocol: internet.TransportProtocol_WebSocket, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_WebSocket, Settings: serial.ToTypedMessage(&Config{ @@ -164,7 +164,7 @@ func Test_listenWSAndDial_TLS(t *testing.T) { AllowInsecure: true, })}, Protocol: internet.TransportProtocol_WebSocket, - TransportSettings: []*internet.TransportSettings{ + TransportSettings: []*internet.TransportConfig{ { Protocol: internet.TransportProtocol_WebSocket, Settings: serial.ToTypedMessage(&Config{