Merge pull request #44 from mhchia/fix/dht-key-to-bytes

Change the type of `key` in `DHTRequest` from `string` to `bytes`
This commit is contained in:
vyzo 2018-12-09 12:20:04 +02:00 committed by GitHub
commit e88ccf22aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 137 deletions

12
dht.go
View File

@ -152,7 +152,8 @@ func (d *Daemon) doDHTGetClosestPeers(req *pb.DHTRequest) (*pb.Response, <-chan
ctx, cancel := d.dhtRequestContext(req) ctx, cancel := d.dhtRequestContext(req)
ch, err := d.dht.GetClosestPeers(ctx, *req.Key) keyString := string(req.Key)
ch, err := d.dht.GetClosestPeers(ctx, keyString)
if err != nil { if err != nil {
cancel() cancel()
return errorResponse(err), nil, nil return errorResponse(err), nil, nil
@ -207,7 +208,8 @@ func (d *Daemon) doDHTGetValue(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHT
ctx, cancel := d.dhtRequestContext(req) ctx, cancel := d.dhtRequestContext(req)
defer cancel() defer cancel()
val, err := d.dht.GetValue(ctx, *req.Key) keyString := string(req.Key)
val, err := d.dht.GetValue(ctx, keyString)
if err != nil { if err != nil {
return errorResponse(err), nil, nil return errorResponse(err), nil, nil
} }
@ -222,7 +224,8 @@ func (d *Daemon) doDHTSearchValue(req *pb.DHTRequest) (*pb.Response, <-chan *pb.
ctx, cancel := d.dhtRequestContext(req) ctx, cancel := d.dhtRequestContext(req)
ch, err := d.dht.SearchValue(ctx, *req.Key) keyString := string(req.Key)
ch, err := d.dht.SearchValue(ctx, keyString)
if err != nil { if err != nil {
cancel() cancel()
return errorResponse(err), nil, nil return errorResponse(err), nil, nil
@ -256,7 +259,8 @@ func (d *Daemon) doDHTPutValue(req *pb.DHTRequest) (*pb.Response, <-chan *pb.DHT
ctx, cancel := d.dhtRequestContext(req) ctx, cancel := d.dhtRequestContext(req)
defer cancel() defer cancel()
err := d.dht.PutValue(ctx, *req.Key, req.Value) keyString := string(req.Key)
err := d.dht.PutValue(ctx, keyString, req.Value)
if err != nil { if err != nil {
return errorResponse(err), nil, nil return errorResponse(err), nil, nil
} }

View File

@ -179,10 +179,10 @@ func (c *Client) GetPublicKey(peer peer.ID) (crypto.PubKey, error) {
} }
// GetValue queries the daemon for a value stored at a key. // GetValue queries the daemon for a value stored at a key.
func (c *Client) GetValue(key string) ([]byte, error) { func (c *Client) GetValue(key []byte) ([]byte, error) {
req := &pb.DHTRequest{ req := &pb.DHTRequest{
Type: pb.DHTRequest_GET_VALUE.Enum(), Type: pb.DHTRequest_GET_VALUE.Enum(),
Key: &key, Key: key,
} }
msg, err := c.doDHTNonNil(req) msg, err := c.doDHTNonNil(req)
@ -194,10 +194,10 @@ func (c *Client) GetValue(key string) ([]byte, error) {
} }
// PutValue sets the value stored at a given key in the DHT to a given value. // PutValue sets the value stored at a given key in the DHT to a given value.
func (c *Client) PutValue(key string, value []byte) error { func (c *Client) PutValue(key []byte, value []byte) error {
req := &pb.DHTRequest{ req := &pb.DHTRequest{
Type: pb.DHTRequest_PUT_VALUE.Enum(), Type: pb.DHTRequest_PUT_VALUE.Enum(),
Key: &key, Key: key,
Value: value, Value: value,
} }
@ -338,10 +338,10 @@ func (c *Client) FindProviders(ctx context.Context, cid cid.Cid) (<-chan PeerInf
// GetClosestPeers queries the DHT routing table for peers that are closest // GetClosestPeers queries the DHT routing table for peers that are closest
// to a provided key. // to a provided key.
func (c *Client) GetClosestPeers(ctx context.Context, key string) (<-chan peer.ID, error) { func (c *Client) GetClosestPeers(ctx context.Context, key []byte) (<-chan peer.ID, error) {
req := newDHTReq(&pb.DHTRequest{ req := newDHTReq(&pb.DHTRequest{
Type: pb.DHTRequest_GET_CLOSEST_PEERS.Enum(), Type: pb.DHTRequest_GET_CLOSEST_PEERS.Enum(),
Key: &key, Key: key,
}) })
return c.streamRequestPeerID(ctx, req) return c.streamRequestPeerID(ctx, req)
@ -349,10 +349,10 @@ func (c *Client) GetClosestPeers(ctx context.Context, key string) (<-chan peer.I
// SearchValue queries the DHT for the best/most valid value stored at a key. // SearchValue queries the DHT for the best/most valid value stored at a key.
// Later responses are better. // Later responses are better.
func (c *Client) SearchValue(ctx context.Context, key string) (<-chan []byte, error) { func (c *Client) SearchValue(ctx context.Context, key []byte) (<-chan []byte, error) {
req := newDHTReq(&pb.DHTRequest{ req := newDHTReq(&pb.DHTRequest{
Type: pb.DHTRequest_SEARCH_VALUE.Enum(), Type: pb.DHTRequest_SEARCH_VALUE.Enum(),
Key: &key, Key: key,
}) })
return c.streamRequestValue(ctx, req) return c.streamRequestValue(ctx, req)

View File

@ -76,7 +76,7 @@ func (x *Request_Type) UnmarshalJSON(data []byte) error {
return nil return nil
} }
func (Request_Type) EnumDescriptor() ([]byte, []int) { func (Request_Type) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{0, 0} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{0, 0}
} }
type Response_Type int32 type Response_Type int32
@ -112,7 +112,7 @@ func (x *Response_Type) UnmarshalJSON(data []byte) error {
return nil return nil
} }
func (Response_Type) EnumDescriptor() ([]byte, []int) { func (Response_Type) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{1, 0} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{1, 0}
} }
type DHTRequest_Type int32 type DHTRequest_Type int32
@ -169,7 +169,7 @@ func (x *DHTRequest_Type) UnmarshalJSON(data []byte) error {
return nil return nil
} }
func (DHTRequest_Type) EnumDescriptor() ([]byte, []int) { func (DHTRequest_Type) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{8, 0} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{8, 0}
} }
type DHTResponse_Type int32 type DHTResponse_Type int32
@ -208,7 +208,7 @@ func (x *DHTResponse_Type) UnmarshalJSON(data []byte) error {
return nil return nil
} }
func (DHTResponse_Type) EnumDescriptor() ([]byte, []int) { func (DHTResponse_Type) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{9, 0} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{9, 0}
} }
type ConnManagerRequest_Type int32 type ConnManagerRequest_Type int32
@ -247,7 +247,7 @@ func (x *ConnManagerRequest_Type) UnmarshalJSON(data []byte) error {
return nil return nil
} }
func (ConnManagerRequest_Type) EnumDescriptor() ([]byte, []int) { func (ConnManagerRequest_Type) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{11, 0} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{11, 0}
} }
type PSRequest_Type int32 type PSRequest_Type int32
@ -289,7 +289,7 @@ func (x *PSRequest_Type) UnmarshalJSON(data []byte) error {
return nil return nil
} }
func (PSRequest_Type) EnumDescriptor() ([]byte, []int) { func (PSRequest_Type) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{13, 0} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{13, 0}
} }
type Request struct { type Request struct {
@ -310,7 +310,7 @@ func (m *Request) Reset() { *m = Request{} }
func (m *Request) String() string { return proto.CompactTextString(m) } func (m *Request) String() string { return proto.CompactTextString(m) }
func (*Request) ProtoMessage() {} func (*Request) ProtoMessage() {}
func (*Request) Descriptor() ([]byte, []int) { func (*Request) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{0} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{0}
} }
func (m *Request) XXX_Unmarshal(b []byte) error { func (m *Request) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -412,7 +412,7 @@ func (m *Response) Reset() { *m = Response{} }
func (m *Response) String() string { return proto.CompactTextString(m) } func (m *Response) String() string { return proto.CompactTextString(m) }
func (*Response) ProtoMessage() {} func (*Response) ProtoMessage() {}
func (*Response) Descriptor() ([]byte, []int) { func (*Response) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{1} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{1}
} }
func (m *Response) XXX_Unmarshal(b []byte) error { func (m *Response) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -502,7 +502,7 @@ func (m *IdentifyResponse) Reset() { *m = IdentifyResponse{} }
func (m *IdentifyResponse) String() string { return proto.CompactTextString(m) } func (m *IdentifyResponse) String() string { return proto.CompactTextString(m) }
func (*IdentifyResponse) ProtoMessage() {} func (*IdentifyResponse) ProtoMessage() {}
func (*IdentifyResponse) Descriptor() ([]byte, []int) { func (*IdentifyResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{2} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{2}
} }
func (m *IdentifyResponse) XXX_Unmarshal(b []byte) error { func (m *IdentifyResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -558,7 +558,7 @@ func (m *ConnectRequest) Reset() { *m = ConnectRequest{} }
func (m *ConnectRequest) String() string { return proto.CompactTextString(m) } func (m *ConnectRequest) String() string { return proto.CompactTextString(m) }
func (*ConnectRequest) ProtoMessage() {} func (*ConnectRequest) ProtoMessage() {}
func (*ConnectRequest) Descriptor() ([]byte, []int) { func (*ConnectRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{3} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{3}
} }
func (m *ConnectRequest) XXX_Unmarshal(b []byte) error { func (m *ConnectRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -621,7 +621,7 @@ func (m *StreamOpenRequest) Reset() { *m = StreamOpenRequest{} }
func (m *StreamOpenRequest) String() string { return proto.CompactTextString(m) } func (m *StreamOpenRequest) String() string { return proto.CompactTextString(m) }
func (*StreamOpenRequest) ProtoMessage() {} func (*StreamOpenRequest) ProtoMessage() {}
func (*StreamOpenRequest) Descriptor() ([]byte, []int) { func (*StreamOpenRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{4} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{4}
} }
func (m *StreamOpenRequest) XXX_Unmarshal(b []byte) error { func (m *StreamOpenRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -683,7 +683,7 @@ func (m *StreamHandlerRequest) Reset() { *m = StreamHandlerRequest{} }
func (m *StreamHandlerRequest) String() string { return proto.CompactTextString(m) } func (m *StreamHandlerRequest) String() string { return proto.CompactTextString(m) }
func (*StreamHandlerRequest) ProtoMessage() {} func (*StreamHandlerRequest) ProtoMessage() {}
func (*StreamHandlerRequest) Descriptor() ([]byte, []int) { func (*StreamHandlerRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{5} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{5}
} }
func (m *StreamHandlerRequest) XXX_Unmarshal(b []byte) error { func (m *StreamHandlerRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -737,7 +737,7 @@ func (m *ErrorResponse) Reset() { *m = ErrorResponse{} }
func (m *ErrorResponse) String() string { return proto.CompactTextString(m) } func (m *ErrorResponse) String() string { return proto.CompactTextString(m) }
func (*ErrorResponse) ProtoMessage() {} func (*ErrorResponse) ProtoMessage() {}
func (*ErrorResponse) Descriptor() ([]byte, []int) { func (*ErrorResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{6} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{6}
} }
func (m *ErrorResponse) XXX_Unmarshal(b []byte) error { func (m *ErrorResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -786,7 +786,7 @@ func (m *StreamInfo) Reset() { *m = StreamInfo{} }
func (m *StreamInfo) String() string { return proto.CompactTextString(m) } func (m *StreamInfo) String() string { return proto.CompactTextString(m) }
func (*StreamInfo) ProtoMessage() {} func (*StreamInfo) ProtoMessage() {}
func (*StreamInfo) Descriptor() ([]byte, []int) { func (*StreamInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{7} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{7}
} }
func (m *StreamInfo) XXX_Unmarshal(b []byte) error { func (m *StreamInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -840,7 +840,7 @@ type DHTRequest struct {
Type *DHTRequest_Type `protobuf:"varint,1,req,name=type,enum=p2pd.pb.DHTRequest_Type" json:"type,omitempty"` Type *DHTRequest_Type `protobuf:"varint,1,req,name=type,enum=p2pd.pb.DHTRequest_Type" json:"type,omitempty"`
Peer []byte `protobuf:"bytes,2,opt,name=peer" json:"peer,omitempty"` Peer []byte `protobuf:"bytes,2,opt,name=peer" json:"peer,omitempty"`
Cid []byte `protobuf:"bytes,3,opt,name=cid" json:"cid,omitempty"` Cid []byte `protobuf:"bytes,3,opt,name=cid" json:"cid,omitempty"`
Key *string `protobuf:"bytes,4,opt,name=key" json:"key,omitempty"` Key []byte `protobuf:"bytes,4,opt,name=key" json:"key,omitempty"`
Value []byte `protobuf:"bytes,5,opt,name=value" json:"value,omitempty"` Value []byte `protobuf:"bytes,5,opt,name=value" json:"value,omitempty"`
Count *int32 `protobuf:"varint,6,opt,name=count" json:"count,omitempty"` Count *int32 `protobuf:"varint,6,opt,name=count" json:"count,omitempty"`
Timeout *int64 `protobuf:"varint,7,opt,name=timeout" json:"timeout,omitempty"` Timeout *int64 `protobuf:"varint,7,opt,name=timeout" json:"timeout,omitempty"`
@ -853,7 +853,7 @@ func (m *DHTRequest) Reset() { *m = DHTRequest{} }
func (m *DHTRequest) String() string { return proto.CompactTextString(m) } func (m *DHTRequest) String() string { return proto.CompactTextString(m) }
func (*DHTRequest) ProtoMessage() {} func (*DHTRequest) ProtoMessage() {}
func (*DHTRequest) Descriptor() ([]byte, []int) { func (*DHTRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{8} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{8}
} }
func (m *DHTRequest) XXX_Unmarshal(b []byte) error { func (m *DHTRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -903,11 +903,11 @@ func (m *DHTRequest) GetCid() []byte {
return nil return nil
} }
func (m *DHTRequest) GetKey() string { func (m *DHTRequest) GetKey() []byte {
if m != nil && m.Key != nil { if m != nil {
return *m.Key return m.Key
} }
return "" return nil
} }
func (m *DHTRequest) GetValue() []byte { func (m *DHTRequest) GetValue() []byte {
@ -944,7 +944,7 @@ func (m *DHTResponse) Reset() { *m = DHTResponse{} }
func (m *DHTResponse) String() string { return proto.CompactTextString(m) } func (m *DHTResponse) String() string { return proto.CompactTextString(m) }
func (*DHTResponse) ProtoMessage() {} func (*DHTResponse) ProtoMessage() {}
func (*DHTResponse) Descriptor() ([]byte, []int) { func (*DHTResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{9} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{9}
} }
func (m *DHTResponse) XXX_Unmarshal(b []byte) error { func (m *DHTResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -1006,7 +1006,7 @@ func (m *PeerInfo) Reset() { *m = PeerInfo{} }
func (m *PeerInfo) String() string { return proto.CompactTextString(m) } func (m *PeerInfo) String() string { return proto.CompactTextString(m) }
func (*PeerInfo) ProtoMessage() {} func (*PeerInfo) ProtoMessage() {}
func (*PeerInfo) Descriptor() ([]byte, []int) { func (*PeerInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{10} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{10}
} }
func (m *PeerInfo) XXX_Unmarshal(b []byte) error { func (m *PeerInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -1063,7 +1063,7 @@ func (m *ConnManagerRequest) Reset() { *m = ConnManagerRequest{} }
func (m *ConnManagerRequest) String() string { return proto.CompactTextString(m) } func (m *ConnManagerRequest) String() string { return proto.CompactTextString(m) }
func (*ConnManagerRequest) ProtoMessage() {} func (*ConnManagerRequest) ProtoMessage() {}
func (*ConnManagerRequest) Descriptor() ([]byte, []int) { func (*ConnManagerRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{11} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{11}
} }
func (m *ConnManagerRequest) XXX_Unmarshal(b []byte) error { func (m *ConnManagerRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -1131,7 +1131,7 @@ func (m *DisconnectRequest) Reset() { *m = DisconnectRequest{} }
func (m *DisconnectRequest) String() string { return proto.CompactTextString(m) } func (m *DisconnectRequest) String() string { return proto.CompactTextString(m) }
func (*DisconnectRequest) ProtoMessage() {} func (*DisconnectRequest) ProtoMessage() {}
func (*DisconnectRequest) Descriptor() ([]byte, []int) { func (*DisconnectRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{12} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{12}
} }
func (m *DisconnectRequest) XXX_Unmarshal(b []byte) error { func (m *DisconnectRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -1180,7 +1180,7 @@ func (m *PSRequest) Reset() { *m = PSRequest{} }
func (m *PSRequest) String() string { return proto.CompactTextString(m) } func (m *PSRequest) String() string { return proto.CompactTextString(m) }
func (*PSRequest) ProtoMessage() {} func (*PSRequest) ProtoMessage() {}
func (*PSRequest) Descriptor() ([]byte, []int) { func (*PSRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{13} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{13}
} }
func (m *PSRequest) XXX_Unmarshal(b []byte) error { func (m *PSRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -1246,7 +1246,7 @@ func (m *PSMessage) Reset() { *m = PSMessage{} }
func (m *PSMessage) String() string { return proto.CompactTextString(m) } func (m *PSMessage) String() string { return proto.CompactTextString(m) }
func (*PSMessage) ProtoMessage() {} func (*PSMessage) ProtoMessage() {}
func (*PSMessage) Descriptor() ([]byte, []int) { func (*PSMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{14} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{14}
} }
func (m *PSMessage) XXX_Unmarshal(b []byte) error { func (m *PSMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -1329,7 +1329,7 @@ func (m *PSResponse) Reset() { *m = PSResponse{} }
func (m *PSResponse) String() string { return proto.CompactTextString(m) } func (m *PSResponse) String() string { return proto.CompactTextString(m) }
func (*PSResponse) ProtoMessage() {} func (*PSResponse) ProtoMessage() {}
func (*PSResponse) Descriptor() ([]byte, []int) { func (*PSResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_p2pd_7f62241c2c6b13d6, []int{15} return fileDescriptor_p2pd_c0044816e48d3fb2, []int{15}
} }
func (m *PSResponse) XXX_Unmarshal(b []byte) error { func (m *PSResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -1867,8 +1867,8 @@ func (m *DHTRequest) MarshalTo(dAtA []byte) (int, error) {
if m.Key != nil { if m.Key != nil {
dAtA[i] = 0x22 dAtA[i] = 0x22
i++ i++
i = encodeVarintP2Pd(dAtA, i, uint64(len(*m.Key))) i = encodeVarintP2Pd(dAtA, i, uint64(len(m.Key)))
i += copy(dAtA[i:], *m.Key) i += copy(dAtA[i:], m.Key)
} }
if m.Value != nil { if m.Value != nil {
dAtA[i] = 0x2a dAtA[i] = 0x2a
@ -2442,7 +2442,7 @@ func (m *DHTRequest) Size() (n int) {
n += 1 + l + sovP2Pd(uint64(l)) n += 1 + l + sovP2Pd(uint64(l))
} }
if m.Key != nil { if m.Key != nil {
l = len(*m.Key) l = len(m.Key)
n += 1 + l + sovP2Pd(uint64(l)) n += 1 + l + sovP2Pd(uint64(l))
} }
if m.Value != nil { if m.Value != nil {
@ -4087,7 +4087,7 @@ func (m *DHTRequest) Unmarshal(dAtA []byte) error {
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
} }
var stringLen uint64 var byteLen int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
if shift >= 64 { if shift >= 64 {
return ErrIntOverflowP2Pd return ErrIntOverflowP2Pd
@ -4097,21 +4097,22 @@ func (m *DHTRequest) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
} }
intStringLen := int(stringLen) if byteLen < 0 {
if intStringLen < 0 {
return ErrInvalidLengthP2Pd return ErrInvalidLengthP2Pd
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + byteLen
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
s := string(dAtA[iNdEx:postIndex]) m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...)
m.Key = &s if m.Key == nil {
m.Key = []byte{}
}
iNdEx = postIndex iNdEx = postIndex
case 5: case 5:
if wireType != 2 { if wireType != 2 {
@ -5295,79 +5296,79 @@ var (
ErrIntOverflowP2Pd = fmt.Errorf("proto: integer overflow") ErrIntOverflowP2Pd = fmt.Errorf("proto: integer overflow")
) )
func init() { proto.RegisterFile("p2pd.proto", fileDescriptor_p2pd_7f62241c2c6b13d6) } func init() { proto.RegisterFile("p2pd.proto", fileDescriptor_p2pd_c0044816e48d3fb2) }
var fileDescriptor_p2pd_7f62241c2c6b13d6 = []byte{ var fileDescriptor_p2pd_c0044816e48d3fb2 = []byte{
// 1132 bytes of a gzipped FileDescriptorProto // 1129 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xcd, 0x6e, 0xdb, 0xc6, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4f, 0x6f, 0xe3, 0x44,
0x13, 0x37, 0x49, 0x7d, 0x8e, 0x64, 0xfd, 0xd7, 0x1b, 0x27, 0xa1, 0xf3, 0x4f, 0x0d, 0x95, 0x80, 0x14, 0xaf, 0xed, 0x24, 0x4e, 0x5e, 0xd2, 0x30, 0x9d, 0xed, 0xee, 0xba, 0xcb, 0x52, 0x05, 0x4b,
0x1b, 0x37, 0x49, 0x8d, 0xd6, 0x6d, 0x81, 0xa2, 0x40, 0x8b, 0xea, 0x83, 0xb1, 0xd8, 0xd8, 0x92, 0x65, 0xcb, 0xee, 0x52, 0x41, 0x01, 0x09, 0x21, 0x81, 0x48, 0x62, 0x6f, 0x63, 0xb6, 0x4d, 0xa2,
0xb0, 0xa4, 0x52, 0xe4, 0x24, 0xd0, 0xe6, 0x5a, 0x16, 0x12, 0x93, 0x0a, 0x49, 0xb5, 0xf0, 0x3b, 0xb1, 0xb3, 0x68, 0x4f, 0x91, 0x5b, 0x4f, 0xd3, 0x88, 0xad, 0x9d, 0xb5, 0x1d, 0x50, 0xbf, 0x03,
0xf4, 0xda, 0x7b, 0x4f, 0x7d, 0x81, 0x5e, 0xfa, 0x02, 0x05, 0x7a, 0xec, 0x23, 0x14, 0xbe, 0xf5, 0x57, 0xee, 0x9c, 0xf8, 0x02, 0x5c, 0xf8, 0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, 0x29, 0x31,
0x47, 0x4a, 0x4c, 0x8d, 0xc7, 0x95, 0x1a, 0x9b, 0x77, 0xd6, 0x6e, 0x96, 0x50, 0x50, 0x4c, 0xa9, 0x14, 0x1e, 0x57, 0x68, 0x6c, 0xde, 0x59, 0xbb, 0x59, 0xc2, 0x8c, 0x62, 0x52, 0xed, 0xb5, 0xfe,
0xdd, 0xe6, 0x1f, 0xd7, 0xbb, 0xda, 0x9f, 0xd7, 0xbb, 0xda, 0x5f, 0xd7, 0xbb, 0xda, 0xbf, 0x01, 0xbc, 0xde, 0x55, 0xfe, 0xba, 0xde, 0x55, 0xfe, 0xbe, 0xde, 0x55, 0xfe, 0x0b, 0x00, 0x00, 0xff,
0x00, 0x00, 0xff, 0xff, 0xf8, 0x8a, 0x93, 0x21, 0x1c, 0x0a, 0x00, 0x00, 0xff, 0x50, 0xfb, 0x0b, 0xfe, 0x1c, 0x0a, 0x00, 0x00,
} }

View File

@ -89,7 +89,7 @@ message DHTRequest {
required Type type = 1; required Type type = 1;
optional bytes peer = 2; optional bytes peer = 2;
optional bytes cid = 3; optional bytes cid = 3;
optional string key = 4; optional bytes key = 4;
optional bytes value = 5; optional bytes value = 5;
optional int32 count = 6; optional int32 count = 6;
optional int64 timeout = 7; optional int64 timeout = 7;

View File

@ -3,16 +3,16 @@ package test
import ( import (
"bytes" "bytes"
"context" "context"
"crypto/rand"
"fmt" "fmt"
"reflect" "reflect"
"testing" "testing"
"time" "time"
crypto "github.com/libp2p/go-libp2p-crypto" crypto "github.com/libp2p/go-libp2p-crypto"
peer "github.com/libp2p/go-libp2p-peer"
"github.com/libp2p/go-libp2p-daemon/p2pclient" "github.com/libp2p/go-libp2p-daemon/p2pclient"
pb "github.com/libp2p/go-libp2p-daemon/pb" pb "github.com/libp2p/go-libp2p-daemon/pb"
peer "github.com/libp2p/go-libp2p-peer"
) )
func clientRequestAsync(t *testing.T, client *p2pclient.Client, method string, arg interface{}) interface{} { func clientRequestAsync(t *testing.T, client *p2pclient.Client, method string, arg interface{}) interface{} {
@ -111,9 +111,8 @@ func TestDHTGetPublicKey(t *testing.T) {
func TestDHTGetValue(t *testing.T) { func TestDHTGetValue(t *testing.T) {
daemon, client, closer := createMockDaemonClientPair(t) daemon, client, closer := createMockDaemonClientPair(t)
defer closer() defer closer()
key := randString(t) key := randBytes(t)
value := make([]byte, 10) value := randBytes(t)
rand.Read(value)
valuec := clientRequestAsync(t, client, "GetValue", key).(chan []byte) valuec := clientRequestAsync(t, client, "GetValue", key).(chan []byte)
conn := daemon.ExpectConn(t) conn := daemon.ExpectConn(t)
@ -133,9 +132,8 @@ func TestDHTGetValue(t *testing.T) {
func TestDHTPutValue(t *testing.T) { func TestDHTPutValue(t *testing.T) {
daemon, client, closer := createMockDaemonClientPair(t) daemon, client, closer := createMockDaemonClientPair(t)
defer closer() defer closer()
key := randString(t) key := randBytes(t)
value := make([]byte, 10) value := randBytes(t)
rand.Read(value)
donec := make(chan struct{}) donec := make(chan struct{})
go func() { go func() {
@ -242,13 +240,13 @@ func TestDHTGetClosestPeers(t *testing.T) {
daemon, client, closer := createMockDaemonClientPair(t) daemon, client, closer := createMockDaemonClientPair(t)
defer closer() defer closer()
ids := randPeerIDs(t, 2) ids := randPeerIDs(t, 2)
key := randString(t) key := randBytes(t)
idc := clientRequestAsync(t, client, "GetClosestPeers", key).(chan peer.ID) idc := clientRequestAsync(t, client, "GetClosestPeers", key).(chan peer.ID)
conn := daemon.ExpectConn(t) conn := daemon.ExpectConn(t)
req := conn.ExpectDHTRequestType(t, pb.DHTRequest_GET_CLOSEST_PEERS) req := conn.ExpectDHTRequestType(t, pb.DHTRequest_GET_CLOSEST_PEERS)
if req.GetKey() != key { if !bytes.Equal(req.GetKey(), key) {
t.Fatal("request key didn't match expected key") t.Fatal("request key didn't match expected key")
} }
fmt.Println("we good") fmt.Println("we good")
@ -271,11 +269,10 @@ func TestDHTGetClosestPeers(t *testing.T) {
func TestDHTSearchValue(t *testing.T) { func TestDHTSearchValue(t *testing.T) {
daemon, client, closer := createMockDaemonClientPair(t) daemon, client, closer := createMockDaemonClientPair(t)
defer closer() defer closer()
key := randString(t) key := randBytes(t)
values := make([][]byte, 2) values := make([][]byte, 2)
for i := range values { for i := range values {
values[i] = make([]byte, 10) values[i] = randBytes(t)
rand.Read(values[i])
} }
valuec := clientRequestAsync(t, client, "SearchValue", key).(chan []byte) valuec := clientRequestAsync(t, client, "SearchValue", key).(chan []byte)

View File

@ -118,6 +118,12 @@ func randCids(t *testing.T, n int) []cid.Cid {
return ids return ids
} }
func randBytes(t *testing.T) []byte {
buf := make([]byte, 10)
rand.Read(buf)
return buf
}
func randString(t *testing.T) string { func randString(t *testing.T) string {
buf := make([]byte, 10) buf := make([]byte, 10)
rand.Read(buf) rand.Read(buf)