Cleanups related to transport (#475)

* Remove DialUnauthenticated method
* Use more specific node transport enum
* Formatting
* Rename Provider.g -> Provider.grpc
* Fix naming in dialer
This commit is contained in:
Egon Elbre 2018-10-15 15:04:21 +03:00 committed by GitHub
parent 7849d7fa63
commit caecb2801d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 124 additions and 158 deletions

View File

@ -15,7 +15,7 @@ import (
// NewNodeStorageValue provides a convient way to create a node as a storage.Value for testing purposes
func NewNodeStorageValue(t *testing.T, address string) storage.Value {
na := &pb.Node{Id: "", Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: address}}
na := &pb.Node{Id: "", Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: address}}
d, err := proto.Marshal(na)
assert.NoError(t, err)
return d

View File

@ -28,7 +28,7 @@ var NodeErr = errs.Class("node error")
var BootstrapErr = errs.Class("bootstrap node error")
//TODO: shouldn't default to TCP but not sure what to do yet
var defaultTransport = pb.NodeTransport_TCP
var defaultTransport = pb.NodeTransport_TCP_TLS_GRPC
// NodeNotFound is returned when a lookup can not produce the requested node
var NodeNotFound = NodeErr.New("node not found")

View File

@ -133,7 +133,7 @@ var (
expectedTimesCalled: 1,
key: "foo",
expectedResponses: func() responses {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
return responses{
mock: na,
bolt: na,
@ -148,7 +148,7 @@ var (
data: []storage.ListItem{{
Key: storage.Key("foo"),
Value: func() storage.Value {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -161,7 +161,7 @@ var (
expectedTimesCalled: 1,
key: "error",
expectedResponses: func() responses {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
return responses{
mock: nil,
bolt: na,
@ -176,7 +176,7 @@ var (
data: []storage.ListItem{{
Key: storage.Key("error"),
Value: func() storage.Value {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -202,7 +202,7 @@ var (
data: []storage.ListItem{{
Key: storage.Key("foo"),
Value: func() storage.Value {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -224,7 +224,7 @@ var (
expectedTimesCalled: 1,
keys: []string{"key1"},
expectedResponses: func() responsesB {
n1 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
n1 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
ns := []*pb.Node{n1}
return responsesB{
mock: ns,
@ -241,7 +241,7 @@ var (
{
Key: storage.Key("key1"),
Value: func() storage.Value {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -255,8 +255,8 @@ var (
expectedTimesCalled: 1,
keys: []string{"key1", "key2"},
expectedResponses: func() responsesB {
n1 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
n2 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9998"}}
n1 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
n2 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9998"}}
ns := []*pb.Node{n1, n2}
return responsesB{
mock: ns,
@ -273,7 +273,7 @@ var (
{
Key: storage.Key("key1"),
Value: func() storage.Value {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -283,7 +283,7 @@ var (
}, {
Key: storage.Key("key2"),
Value: func() storage.Value {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9998"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9998"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -297,7 +297,7 @@ var (
expectedTimesCalled: 1,
keys: []string{"key1", "key3"},
expectedResponses: func() responsesB {
n1 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
n1 := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
ns := []*pb.Node{n1, nil}
return responsesB{
mock: ns,
@ -314,7 +314,7 @@ var (
{
Key: storage.Key("key1"),
Value: func() storage.Value {
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
na := &pb.Node{Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -370,7 +370,7 @@ var (
testID: "valid Put",
expectedTimesCalled: 1,
key: "foo",
value: pb.Node{Id: "foo", Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP, Address: "127.0.0.1:9999"}},
value: pb.Node{Id: "foo", Address: &pb.NodeAddress{Transport: pb.NodeTransport_TCP_TLS_GRPC, Address: "127.0.0.1:9999"}},
expectedErrors: errors{
mock: nil,
bolt: nil,

View File

@ -78,7 +78,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) error {
nodes = append(nodes, &pb.Node{
Id: id,
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP,
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: addr,
}})
}

View File

@ -35,7 +35,7 @@ func (m *MetaStreamInfo) Reset() { *m = MetaStreamInfo{} }
func (m *MetaStreamInfo) String() string { return proto.CompactTextString(m) }
func (*MetaStreamInfo) ProtoMessage() {}
func (*MetaStreamInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_3b5ea8fe65782bcc, []int{0}
return fileDescriptor_meta_026f5a060e38d7ef, []int{0}
}
func (m *MetaStreamInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_MetaStreamInfo.Unmarshal(m, b)
@ -108,9 +108,9 @@ func init() {
proto.RegisterType((*MetaStreamInfo)(nil), "streams.MetaStreamInfo")
}
func init() { proto.RegisterFile("meta.proto", fileDescriptor_3b5ea8fe65782bcc) }
func init() { proto.RegisterFile("meta.proto", fileDescriptor_meta_026f5a060e38d7ef) }
var fileDescriptor_3b5ea8fe65782bcc = []byte{
var fileDescriptor_meta_026f5a060e38d7ef = []byte{
// 250 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x4f, 0x4b, 0xc3, 0x40,
0x10, 0xc5, 0x49, 0xfa, 0x4f, 0x86, 0xda, 0xea, 0x8a, 0xb0, 0xe8, 0x25, 0xe8, 0xc1, 0x20, 0xe2,

View File

@ -28,23 +28,21 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type NodeTransport int32
const (
NodeTransport_TCP NodeTransport = 0
NodeTransport_TCP_TLS_GRPC NodeTransport = 0
)
var NodeTransport_name = map[int32]string{
0: "TCP",
0: "TCP_TLS_GRPC",
}
var NodeTransport_value = map[string]int32{
"TCP": 0,
"TCP_TLS_GRPC": 0,
}
func (x NodeTransport) String() string {
return proto.EnumName(NodeTransport_name, int32(x))
}
func (NodeTransport) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{0}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{0}
}
// NodeType is an enum of possible node types
@ -59,7 +57,6 @@ var NodeType_name = map[int32]string{
0: "ADMIN",
1: "STORAGE",
}
var NodeType_value = map[string]int32{
"ADMIN": 0,
"STORAGE": 1,
@ -68,9 +65,8 @@ var NodeType_value = map[string]int32{
func (x NodeType) String() string {
return proto.EnumName(NodeType_name, int32(x))
}
func (NodeType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{1}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{1}
}
type Restriction_Operator int32
@ -90,7 +86,6 @@ var Restriction_Operator_name = map[int32]string{
3: "LTE",
4: "GTE",
}
var Restriction_Operator_value = map[string]int32{
"LT": 0,
"EQ": 1,
@ -102,9 +97,8 @@ var Restriction_Operator_value = map[string]int32{
func (x Restriction_Operator) String() string {
return proto.EnumName(Restriction_Operator_name, int32(x))
}
func (Restriction_Operator) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{13, 0}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{13, 0}
}
type Restriction_Operand int32
@ -118,7 +112,6 @@ var Restriction_Operand_name = map[int32]string{
0: "freeBandwidth",
1: "freeDisk",
}
var Restriction_Operand_value = map[string]int32{
"freeBandwidth": 0,
"freeDisk": 1,
@ -127,9 +120,8 @@ var Restriction_Operand_value = map[string]int32{
func (x Restriction_Operand) String() string {
return proto.EnumName(Restriction_Operand_name, int32(x))
}
func (Restriction_Operand) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{13, 1}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{13, 1}
}
// LookupRequest is is request message for the lookup rpc call
@ -144,7 +136,7 @@ func (m *LookupRequest) Reset() { *m = LookupRequest{} }
func (m *LookupRequest) String() string { return proto.CompactTextString(m) }
func (*LookupRequest) ProtoMessage() {}
func (*LookupRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{0}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{0}
}
func (m *LookupRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LookupRequest.Unmarshal(m, b)
@ -183,7 +175,7 @@ func (m *LookupResponse) Reset() { *m = LookupResponse{} }
func (m *LookupResponse) String() string { return proto.CompactTextString(m) }
func (*LookupResponse) ProtoMessage() {}
func (*LookupResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{1}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{1}
}
func (m *LookupResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LookupResponse.Unmarshal(m, b)
@ -222,7 +214,7 @@ func (m *LookupRequests) Reset() { *m = LookupRequests{} }
func (m *LookupRequests) String() string { return proto.CompactTextString(m) }
func (*LookupRequests) ProtoMessage() {}
func (*LookupRequests) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{2}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{2}
}
func (m *LookupRequests) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LookupRequests.Unmarshal(m, b)
@ -261,7 +253,7 @@ func (m *LookupResponses) Reset() { *m = LookupResponses{} }
func (m *LookupResponses) String() string { return proto.CompactTextString(m) }
func (*LookupResponses) ProtoMessage() {}
func (*LookupResponses) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{3}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{3}
}
func (m *LookupResponses) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LookupResponses.Unmarshal(m, b)
@ -300,7 +292,7 @@ func (m *FindStorageNodesResponse) Reset() { *m = FindStorageNodesRespon
func (m *FindStorageNodesResponse) String() string { return proto.CompactTextString(m) }
func (*FindStorageNodesResponse) ProtoMessage() {}
func (*FindStorageNodesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{4}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{4}
}
func (m *FindStorageNodesResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FindStorageNodesResponse.Unmarshal(m, b)
@ -341,7 +333,7 @@ func (m *FindStorageNodesRequest) Reset() { *m = FindStorageNodesRequest
func (m *FindStorageNodesRequest) String() string { return proto.CompactTextString(m) }
func (*FindStorageNodesRequest) ProtoMessage() {}
func (*FindStorageNodesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{5}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{5}
}
func (m *FindStorageNodesRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FindStorageNodesRequest.Unmarshal(m, b)
@ -395,7 +387,7 @@ func (m *NodeAddress) Reset() { *m = NodeAddress{} }
func (m *NodeAddress) String() string { return proto.CompactTextString(m) }
func (*NodeAddress) ProtoMessage() {}
func (*NodeAddress) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{6}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{6}
}
func (m *NodeAddress) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NodeAddress.Unmarshal(m, b)
@ -419,7 +411,7 @@ func (m *NodeAddress) GetTransport() NodeTransport {
if m != nil {
return m.Transport
}
return NodeTransport_TCP
return NodeTransport_TCP_TLS_GRPC
}
func (m *NodeAddress) GetAddress() string {
@ -445,7 +437,7 @@ func (m *OverlayOptions) Reset() { *m = OverlayOptions{} }
func (m *OverlayOptions) String() string { return proto.CompactTextString(m) }
func (*OverlayOptions) ProtoMessage() {}
func (*OverlayOptions) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{7}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{7}
}
func (m *OverlayOptions) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_OverlayOptions.Unmarshal(m, b)
@ -511,7 +503,7 @@ func (m *NodeRep) Reset() { *m = NodeRep{} }
func (m *NodeRep) String() string { return proto.CompactTextString(m) }
func (*NodeRep) ProtoMessage() {}
func (*NodeRep) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{8}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{8}
}
func (m *NodeRep) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NodeRep.Unmarshal(m, b)
@ -544,7 +536,7 @@ func (m *NodeRestrictions) Reset() { *m = NodeRestrictions{} }
func (m *NodeRestrictions) String() string { return proto.CompactTextString(m) }
func (*NodeRestrictions) ProtoMessage() {}
func (*NodeRestrictions) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{9}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{9}
}
func (m *NodeRestrictions) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NodeRestrictions.Unmarshal(m, b)
@ -593,7 +585,7 @@ func (m *Node) Reset() { *m = Node{} }
func (m *Node) String() string { return proto.CompactTextString(m) }
func (*Node) ProtoMessage() {}
func (*Node) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{10}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{10}
}
func (m *Node) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Node.Unmarshal(m, b)
@ -655,7 +647,7 @@ func (m *QueryRequest) Reset() { *m = QueryRequest{} }
func (m *QueryRequest) String() string { return proto.CompactTextString(m) }
func (*QueryRequest) ProtoMessage() {}
func (*QueryRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{11}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{11}
}
func (m *QueryRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QueryRequest.Unmarshal(m, b)
@ -715,7 +707,7 @@ func (m *QueryResponse) Reset() { *m = QueryResponse{} }
func (m *QueryResponse) String() string { return proto.CompactTextString(m) }
func (*QueryResponse) ProtoMessage() {}
func (*QueryResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{12}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{12}
}
func (m *QueryResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QueryResponse.Unmarshal(m, b)
@ -762,7 +754,7 @@ func (m *Restriction) Reset() { *m = Restriction{} }
func (m *Restriction) String() string { return proto.CompactTextString(m) }
func (*Restriction) ProtoMessage() {}
func (*Restriction) Descriptor() ([]byte, []int) {
return fileDescriptor_61fc82527fbe24ad, []int{13}
return fileDescriptor_overlay_bd6c5c7d03cb2513, []int{13}
}
func (m *Restriction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Restriction.Unmarshal(m, b)
@ -1032,62 +1024,63 @@ var _Nodes_serviceDesc = grpc.ServiceDesc{
Metadata: "overlay.proto",
}
func init() { proto.RegisterFile("overlay.proto", fileDescriptor_61fc82527fbe24ad) }
func init() { proto.RegisterFile("overlay.proto", fileDescriptor_overlay_bd6c5c7d03cb2513) }
var fileDescriptor_61fc82527fbe24ad = []byte{
// 860 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x6d, 0x6f, 0x1b, 0x45,
0x10, 0xce, 0xf9, 0xdd, 0xe3, 0xd8, 0x5c, 0x47, 0x25, 0x39, 0x2c, 0xa8, 0xd2, 0x85, 0x8a, 0x12,
0x24, 0x57, 0x72, 0xab, 0x48, 0x91, 0x40, 0x51, 0x42, 0x42, 0x54, 0x61, 0x12, 0xba, 0xb1, 0x84,
0x84, 0xc4, 0x87, 0xb3, 0x6f, 0xeb, 0x1e, 0xb1, 0x6f, 0x8f, 0xdd, 0xbd, 0x82, 0xf9, 0x11, 0xfc,
0x0f, 0x24, 0x7e, 0x13, 0xbf, 0x83, 0x4f, 0x08, 0xed, 0xcb, 0x9d, 0x7d, 0x4e, 0x5c, 0xc1, 0xa7,
0xf3, 0xcc, 0x3c, 0x33, 0xfb, 0xec, 0x33, 0xb3, 0x63, 0xe8, 0xf2, 0xb7, 0x4c, 0xcc, 0xc3, 0xe5,
0x20, 0x15, 0x5c, 0x71, 0x6c, 0x3a, 0xb3, 0xff, 0x68, 0xc6, 0xf9, 0x6c, 0xce, 0x9e, 0x19, 0xf7,
0x24, 0x7b, 0xfd, 0x2c, 0xca, 0x44, 0xa8, 0x62, 0x9e, 0x58, 0x20, 0xf9, 0x14, 0xba, 0x23, 0xce,
0x6f, 0xb3, 0x94, 0xb2, 0x9f, 0x33, 0x26, 0x15, 0xee, 0x41, 0x23, 0xe1, 0x11, 0x7b, 0x79, 0x1e,
0x78, 0x07, 0xde, 0xd3, 0x36, 0x75, 0x16, 0x79, 0x0e, 0xbd, 0x1c, 0x28, 0x53, 0x9e, 0x48, 0x86,
0x8f, 0xa1, 0xa6, 0x63, 0x06, 0xd7, 0x19, 0x76, 0x07, 0x39, 0x83, 0x2b, 0x1e, 0x31, 0x6a, 0x42,
0xe4, 0x6a, 0x95, 0x64, 0xaa, 0x4b, 0xfc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
0x87, 0x04, 0x5a, 0xf9, 0x64, 0x61, 0x1b, 0xea, 0xa7, 0xe7, 0xdf, 0xbe, 0xbc, 0xf2, 0x77, 0xb0,
0x03, 0xcd, 0x9b, 0xf1, 0x35, 0x3d, 0xbd, 0xbc, 0xf0, 0xbd, 0xe1, 0x5f, 0x1e, 0x34, 0xdd, 0xf6,
0xc0, 0x63, 0x68, 0xd8, 0xbd, 0x8d, 0x5b, 0xfe, 0x1a, 0xfa, 0xdb, 0x16, 0x3c, 0x9e, 0x00, 0x9c,
0x65, 0xf3, 0x5b, 0x97, 0xbe, 0x7f, 0x7f, 0xba, 0xec, 0x07, 0x5b, 0xf2, 0x25, 0x7e, 0x0f, 0xfe,
0xe6, 0x3e, 0xc7, 0x83, 0x02, 0xbd, 0x65, 0xd5, 0xf7, 0x1f, 0xbf, 0x03, 0x61, 0x2b, 0x0f, 0x4f,
0xa0, 0x6e, 0xab, 0x1d, 0x41, 0xdd, 0x4c, 0x21, 0xbe, 0x5f, 0x24, 0xad, 0xbf, 0x92, 0xfe, 0xde,
0xa6, 0xdb, 0x16, 0x38, 0xab, 0xfd, 0x50, 0x49, 0x27, 0x93, 0x86, 0x59, 0x9b, 0xcf, 0xff, 0x0d,
0x00, 0x00, 0xff, 0xff, 0x34, 0x43, 0x8e, 0x71, 0xf4, 0x07, 0x00, 0x00,
var fileDescriptor_overlay_bd6c5c7d03cb2513 = []byte{
// 871 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xff, 0x6e, 0x1b, 0x45,
0x10, 0xce, 0xf9, 0xb7, 0xc7, 0x3f, 0xb8, 0x8e, 0x4a, 0x62, 0x2c, 0xa8, 0x92, 0x85, 0x8a, 0x12,
0x24, 0x57, 0x72, 0xab, 0x48, 0x91, 0x40, 0x51, 0xd2, 0x84, 0xa8, 0xc2, 0x24, 0xed, 0xfa, 0x24,
0x24, 0x24, 0x54, 0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fe, 0xb6, 0x4d, 0x8f, 0x27, 0x00, 0x67, 0xc9, 0xfc, 0xc6, 0xa6, 0xef,
0xdd, 0x9d, 0x2e, 0xfb, 0xbd, 0x2d, 0xf9, 0x12, 0xbf, 0x07, 0x77, 0x73, 0xb1, 0xe3, 0x7e, 0x8e,
0xde, 0xb2, 0xf3, 0xfb, 0x07, 0xf7, 0x20, 0x4c, 0xe5, 0xe1, 0x09, 0x54, 0x4d, 0xb5, 0x23, 0xa8,
0xea, 0x71, 0xc4, 0x0f, 0xf3, 0xa4, 0xf5, 0xe7, 0xd2, 0xdf, 0xdd, 0x74, 0x9b, 0x02, 0x67, 0x95,
0x1f, 0x4a, 0xf1, 0x64, 0x52, 0xd3, 0xfb, 0xf3, 0xd9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x55,
0x36, 0x3e, 0x6f, 0xfd, 0x07, 0x00, 0x00,
}

View File

@ -10,7 +10,7 @@ package overlay;
// NodeTransport is an enum of possible transports for the overlay network
enum NodeTransport {
TCP = 0;
TCP_TLS_GRPC = 0;
}
// Overlay defines the interface for communication with the overlay network

View File

@ -34,7 +34,7 @@ type Responsibility interface {
// Examples of providers are the heavy client, the storagenode, and the gateway.
type Provider struct {
lis net.Listener
g *grpc.Server
grpc *grpc.Server
next []Responsibility
identity *FullIdentity
}
@ -56,7 +56,7 @@ func NewProvider(identity *FullIdentity, lis net.Listener, interceptor grpc.Unar
return &Provider{
lis: lis,
g: grpc.NewServer(
grpc: grpc.NewServer(
grpc.StreamInterceptor(streamInterceptor),
grpc.UnaryInterceptor(unaryInterceptor),
ident,
@ -98,11 +98,11 @@ func SetupIdentity(ctx context.Context, c CASetupConfig, i IdentitySetupConfig)
func (p *Provider) Identity() *FullIdentity { return p.identity }
// GRPC returns the provider's gRPC server for registration purposes
func (p *Provider) GRPC() *grpc.Server { return p.g }
func (p *Provider) GRPC() *grpc.Server { return p.grpc }
// Close shuts down the provider
func (p *Provider) Close() error {
p.g.GracefulStop()
p.grpc.GracefulStop()
return nil
}
@ -118,11 +118,10 @@ func (p *Provider) Run(ctx context.Context) (err error) {
return next.Run(ctx, p)
}
return p.g.Serve(p.lis)
return p.grpc.Serve(p.lis)
}
func streamInterceptor(srv interface{}, ss grpc.ServerStream,
info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) {
func streamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error) {
err = handler(srv, ss)
if err != nil {
// no zap errors for canceled or wrong file downloads
@ -137,8 +136,7 @@ func streamInterceptor(srv interface{}, ss grpc.ServerStream,
return err
}
func unaryInterceptor(ctx context.Context, req interface{},
info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{},
func unaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{},
err error) {
resp, err = handler(ctx, req)
if err != nil {

View File

@ -38,19 +38,19 @@ type dialer interface {
}
type defaultDialer struct {
t transport.Client
identity *provider.FullIdentity
transport transport.Client
identity *provider.FullIdentity
}
func (d *defaultDialer) dial(ctx context.Context, node *pb.Node) (ps client.PSClient, err error) {
func (dialer *defaultDialer) dial(ctx context.Context, node *pb.Node) (ps client.PSClient, err error) {
defer mon.Task()(&ctx)(&err)
c, err := d.t.DialNode(ctx, node)
conn, err := dialer.transport.DialNode(ctx, node)
if err != nil {
return nil, err
}
return client.NewPSClient(c, 0, d.identity.Key)
return client.NewPSClient(conn, 0, dialer.identity.Key)
}
type ecClient struct {
@ -59,8 +59,8 @@ type ecClient struct {
}
// NewClient from the given TransportClient and max buffer memory
func NewClient(identity *provider.FullIdentity, t transport.Client, mbm int) Client {
d := defaultDialer{identity: identity, t: t}
func NewClient(identity *provider.FullIdentity, transport transport.Client, mbm int) Client {
d := defaultDialer{identity: identity, transport: transport}
return &ecClient{d: &d, mbm: mbm}
}

View File

@ -59,12 +59,12 @@ func TestNewECClient(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
tc := NewMockClient(ctrl)
transport := NewMockClient(ctrl)
mbm := 1234
privKey, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
identity := &provider.FullIdentity{Key: privKey}
ec := NewClient(identity, tc, mbm)
ec := NewClient(identity, transport, mbm)
assert.NotNil(t, ec)
ecc, ok := ec.(*ecClient)
@ -74,8 +74,8 @@ func TestNewECClient(t *testing.T) {
dd, ok := ecc.d.(*defaultDialer)
assert.True(t, ok)
assert.NotNil(t, dd.t)
assert.Equal(t, dd.t, tc)
assert.NotNil(t, dd.transport)
assert.Equal(t, dd.transport, transport)
}
func TestDefaultDialer(t *testing.T) {
@ -95,10 +95,10 @@ func TestDefaultDialer(t *testing.T) {
} {
errTag := fmt.Sprintf("Test case #%d", i)
tc := NewMockClient(ctrl)
tc.EXPECT().DialNode(gomock.Any(), node0).Return(nil, tt.err)
transport := NewMockClient(ctrl)
transport.EXPECT().DialNode(gomock.Any(), node0).Return(nil, tt.err)
dd := defaultDialer{t: tc, identity: identity}
dd := defaultDialer{transport: transport, identity: identity}
_, err := dd.dial(ctx, node0)
if tt.errString != "" {

View File

@ -51,16 +51,3 @@ func (m *MockClient) DialNode(arg0 context.Context, arg1 *pb.Node) (*grpc.Client
func (mr *MockClientMockRecorder) DialNode(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DialNode", reflect.TypeOf((*MockClient)(nil).DialNode), arg0, arg1)
}
// DialUnauthenticated mocks base method
func (m *MockClient) DialUnauthenticated(arg0 context.Context, arg1 pb.NodeAddress) (*grpc.ClientConn, error) {
ret := m.ctrl.Call(m, "DialUnauthenticated", arg0, arg1)
ret0, _ := ret[0].(*grpc.ClientConn)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DialUnauthenticated indicates an expected call of DialUnauthenticated
func (mr *MockClientMockRecorder) DialUnauthenticated(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DialUnauthenticated", reflect.TypeOf((*MockClient)(nil).DialUnauthenticated), arg0, arg1)
}

View File

@ -21,6 +21,5 @@ var (
// Client defines the interface to an transport client.
type Client interface {
DialUnauthenticated(ctx context.Context, addr pb.NodeAddress) (*grpc.ClientConn, error)
DialNode(ctx context.Context, node *pb.Node) (*grpc.ClientConn, error)
}

View File

@ -36,14 +36,3 @@ func (o *Transport) DialNode(ctx context.Context, node *pb.Node) (conn *grpc.Cli
}
return grpc.Dial(node.Address.Address, dialOpt)
}
// DialUnauthenticated using unauthenticated mode
func (o *Transport) DialUnauthenticated(ctx context.Context, addr pb.NodeAddress) (conn *grpc.ClientConn, err error) {
defer mon.Task()(&ctx)(&err)
if addr.Address == "" {
return nil, Error.New("no address")
}
return grpc.Dial(addr.Address, grpc.WithInsecure())
}

View File

@ -28,7 +28,7 @@ func TestDialNode(t *testing.T) {
node := pb.Node{
Id: "DUMMYID1",
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP,
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: "",
},
}
@ -49,7 +49,7 @@ func TestDialNode(t *testing.T) {
node = pb.Node{
Id: "DUMMYID3",
Address: &pb.NodeAddress{
Transport: pb.NodeTransport_TCP,
Transport: pb.NodeTransport_TCP_TLS_GRPC,
Address: "127.0.0.0:9000",
},
}