diff --git a/VERSION b/VERSION index 96bbc366d..a95410b17 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.156.1 +0.157.0 diff --git a/go.mod b/go.mod index 496627da1..626cd306b 100644 --- a/go.mod +++ b/go.mod @@ -82,7 +82,7 @@ require ( github.com/mutecomm/go-sqlcipher/v4 v4.4.2 github.com/schollz/peerdiscovery v1.7.0 github.com/siphiuel/lc-proxy-wrapper v0.0.0-20230516150924-246507cee8c7 - github.com/waku-org/go-waku v0.6.1-0.20230526151800-10c2e20910bf + github.com/waku-org/go-waku v0.6.1-0.20230605200314-b0c094b0b663 github.com/yeqown/go-qrcode/v2 v2.2.1 github.com/yeqown/go-qrcode/writer/standard v1.2.1 go.uber.org/multierr v1.11.0 @@ -116,7 +116,6 @@ require ( github.com/benbjohnson/clock v1.3.0 // indirect github.com/benbjohnson/immutable v0.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/berty/go-libp2p-rendezvous v0.4.1 // indirect github.com/bits-and-blooms/bitset v1.2.0 // indirect github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect github.com/btcsuite/btcd v0.22.1 // indirect @@ -233,7 +232,7 @@ require ( github.com/raulk/go-watchdog v1.3.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/rivo/uniseg v0.2.0 // indirect - github.com/rjeczalik/notify v0.9.2 // indirect + github.com/rjeczalik/notify v0.9.3 // indirect github.com/rs/cors v1.7.0 // indirect github.com/rs/dnscache v0.0.0-20210201191234-295bba877686 // indirect github.com/russolsen/ohyeah v0.0.0-20160324131710-f4938c005315 // indirect @@ -249,6 +248,7 @@ require ( github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/urfave/cli/v2 v2.24.4 // indirect github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 // indirect + github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230601172541-0fad5ff68671 // indirect github.com/waku-org/go-zerokit-rln v0.1.12 // indirect github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 // indirect github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d // indirect diff --git a/go.sum b/go.sum index a832e0090..9d5bf4509 100644 --- a/go.sum +++ b/go.sum @@ -398,8 +398,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/berty/go-libp2p-rendezvous v0.4.1 h1:+yXsKocTxfKt+Sl3JkcPbv1J31QKjYoYSyIpMWGb/Wc= -github.com/berty/go-libp2p-rendezvous v0.4.1/go.mod h1:Kc2dtCckvFN44/eCiWXT5YbwVbR7WA5iPhDZIKNkQG0= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= @@ -1869,8 +1867,9 @@ github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1 github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= -github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8= github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM= +github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY= +github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc= github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= @@ -2111,8 +2110,10 @@ github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1 github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98 h1:xwY0kW5XZFimdqfZb9cZwT1S3VJP9j3AE6bdNd9boXM= github.com/waku-org/go-discover v0.0.0-20221209174356-61c833f34d98/go.mod h1:eBHgM6T4EG0RZzxpxKy+rGz/6Dw2Nd8DWxS0lm9ESDw= -github.com/waku-org/go-waku v0.6.1-0.20230526151800-10c2e20910bf h1:9+3yMLVo/O7QX7s98gZ+nqLwl7UX/XGKBZ9PHVufkkY= -github.com/waku-org/go-waku v0.6.1-0.20230526151800-10c2e20910bf/go.mod h1:dcGbxOa6+J+RxFP43QDJaiVrsXKGbK8v3suUabWbvOs= +github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230601172541-0fad5ff68671 h1:iOCDabjZ11Zk0ejdWBR54OEFA/rRZdQgIrX6Rv4U7AM= +github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230601172541-0fad5ff68671/go.mod h1:/1YwD6sx3xsbrSkVa4++e8AUDcUjC035bgKwDsZo+0Q= +github.com/waku-org/go-waku v0.6.1-0.20230605200314-b0c094b0b663 h1:BBRrzCEy0p+TEdspf+gAvl6uc3FR27oHL0t4BgrLaDk= +github.com/waku-org/go-waku v0.6.1-0.20230605200314-b0c094b0b663/go.mod h1:qz1a/J+lTA+hJy61aVgGP9E85SnAQ2gldRgU97aUB/U= github.com/waku-org/go-zerokit-rln v0.1.12 h1:66+tU6sTlmUpuUlEv7kCFOGZ37MwZYFJBXHcm8QquwU= github.com/waku-org/go-zerokit-rln v0.1.12/go.mod h1:MUW+wB6Yj7UBMdZrhko7oHfUZeY2wchggXYjpUiMoac= github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 h1:Q5XQqo+PEmvrybT8D7BEsKCwIYDi80s+00Q49cfm9Gs= diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/generate.go b/vendor/github.com/berty/go-libp2p-rendezvous/generate.go deleted file mode 100644 index 2726dcdbf..000000000 --- a/vendor/github.com/berty/go-libp2p-rendezvous/generate.go +++ /dev/null @@ -1,2 +0,0 @@ -//go:generate protoc --proto_path=pb/ --gofast_opt="Mrendezvous.proto=.;rendezvous_pb" --gofast_out=./pb ./pb/rendezvous.proto -package rendezvous diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/pb/rendezvous.pb.go b/vendor/github.com/berty/go-libp2p-rendezvous/pb/rendezvous.pb.go deleted file mode 100644 index e9b3d3f33..000000000 --- a/vendor/github.com/berty/go-libp2p-rendezvous/pb/rendezvous.pb.go +++ /dev/null @@ -1,3334 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: rendezvous.proto - -package rendezvous_pb - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/golang/protobuf/proto" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type Message_MessageType int32 - -const ( - Message_REGISTER Message_MessageType = 0 - Message_REGISTER_RESPONSE Message_MessageType = 1 - Message_UNREGISTER Message_MessageType = 2 - Message_DISCOVER Message_MessageType = 3 - Message_DISCOVER_RESPONSE Message_MessageType = 4 - Message_DISCOVER_SUBSCRIBE Message_MessageType = 100 - Message_DISCOVER_SUBSCRIBE_RESPONSE Message_MessageType = 101 -) - -var Message_MessageType_name = map[int32]string{ - 0: "REGISTER", - 1: "REGISTER_RESPONSE", - 2: "UNREGISTER", - 3: "DISCOVER", - 4: "DISCOVER_RESPONSE", - 100: "DISCOVER_SUBSCRIBE", - 101: "DISCOVER_SUBSCRIBE_RESPONSE", -} - -var Message_MessageType_value = map[string]int32{ - "REGISTER": 0, - "REGISTER_RESPONSE": 1, - "UNREGISTER": 2, - "DISCOVER": 3, - "DISCOVER_RESPONSE": 4, - "DISCOVER_SUBSCRIBE": 100, - "DISCOVER_SUBSCRIBE_RESPONSE": 101, -} - -func (x Message_MessageType) String() string { - return proto.EnumName(Message_MessageType_name, int32(x)) -} - -func (Message_MessageType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 0} -} - -type Message_ResponseStatus int32 - -const ( - Message_OK Message_ResponseStatus = 0 - Message_E_INVALID_NAMESPACE Message_ResponseStatus = 100 - Message_E_INVALID_PEER_INFO Message_ResponseStatus = 101 - Message_E_INVALID_TTL Message_ResponseStatus = 102 - Message_E_INVALID_COOKIE Message_ResponseStatus = 103 - Message_E_NOT_AUTHORIZED Message_ResponseStatus = 200 - Message_E_INTERNAL_ERROR Message_ResponseStatus = 300 - Message_E_UNAVAILABLE Message_ResponseStatus = 400 -) - -var Message_ResponseStatus_name = map[int32]string{ - 0: "OK", - 100: "E_INVALID_NAMESPACE", - 101: "E_INVALID_PEER_INFO", - 102: "E_INVALID_TTL", - 103: "E_INVALID_COOKIE", - 200: "E_NOT_AUTHORIZED", - 300: "E_INTERNAL_ERROR", - 400: "E_UNAVAILABLE", -} - -var Message_ResponseStatus_value = map[string]int32{ - "OK": 0, - "E_INVALID_NAMESPACE": 100, - "E_INVALID_PEER_INFO": 101, - "E_INVALID_TTL": 102, - "E_INVALID_COOKIE": 103, - "E_NOT_AUTHORIZED": 200, - "E_INTERNAL_ERROR": 300, - "E_UNAVAILABLE": 400, -} - -func (x Message_ResponseStatus) String() string { - return proto.EnumName(Message_ResponseStatus_name, int32(x)) -} - -func (Message_ResponseStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 1} -} - -type Message struct { - Type Message_MessageType `protobuf:"varint,1,opt,name=type,proto3,enum=rendezvous.pb.Message_MessageType" json:"type,omitempty"` - Register *Message_Register `protobuf:"bytes,2,opt,name=register,proto3" json:"register,omitempty"` - RegisterResponse *Message_RegisterResponse `protobuf:"bytes,3,opt,name=registerResponse,proto3" json:"registerResponse,omitempty"` - Unregister *Message_Unregister `protobuf:"bytes,4,opt,name=unregister,proto3" json:"unregister,omitempty"` - Discover *Message_Discover `protobuf:"bytes,5,opt,name=discover,proto3" json:"discover,omitempty"` - DiscoverResponse *Message_DiscoverResponse `protobuf:"bytes,6,opt,name=discoverResponse,proto3" json:"discoverResponse,omitempty"` - DiscoverSubscribe *Message_DiscoverSubscribe `protobuf:"bytes,100,opt,name=discoverSubscribe,proto3" json:"discoverSubscribe,omitempty"` - DiscoverSubscribeResponse *Message_DiscoverSubscribeResponse `protobuf:"bytes,101,opt,name=discoverSubscribeResponse,proto3" json:"discoverSubscribeResponse,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0} -} -func (m *Message) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} -func (m *Message) XXX_Size() int { - return m.Size() -} -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) -} - -var xxx_messageInfo_Message proto.InternalMessageInfo - -func (m *Message) GetType() Message_MessageType { - if m != nil { - return m.Type - } - return Message_REGISTER -} - -func (m *Message) GetRegister() *Message_Register { - if m != nil { - return m.Register - } - return nil -} - -func (m *Message) GetRegisterResponse() *Message_RegisterResponse { - if m != nil { - return m.RegisterResponse - } - return nil -} - -func (m *Message) GetUnregister() *Message_Unregister { - if m != nil { - return m.Unregister - } - return nil -} - -func (m *Message) GetDiscover() *Message_Discover { - if m != nil { - return m.Discover - } - return nil -} - -func (m *Message) GetDiscoverResponse() *Message_DiscoverResponse { - if m != nil { - return m.DiscoverResponse - } - return nil -} - -func (m *Message) GetDiscoverSubscribe() *Message_DiscoverSubscribe { - if m != nil { - return m.DiscoverSubscribe - } - return nil -} - -func (m *Message) GetDiscoverSubscribeResponse() *Message_DiscoverSubscribeResponse { - if m != nil { - return m.DiscoverSubscribeResponse - } - return nil -} - -type Message_PeerInfo struct { - Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Addrs [][]byte `protobuf:"bytes,2,rep,name=addrs,proto3" json:"addrs,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_PeerInfo) Reset() { *m = Message_PeerInfo{} } -func (m *Message_PeerInfo) String() string { return proto.CompactTextString(m) } -func (*Message_PeerInfo) ProtoMessage() {} -func (*Message_PeerInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 0} -} -func (m *Message_PeerInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_PeerInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_PeerInfo.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_PeerInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_PeerInfo.Merge(m, src) -} -func (m *Message_PeerInfo) XXX_Size() int { - return m.Size() -} -func (m *Message_PeerInfo) XXX_DiscardUnknown() { - xxx_messageInfo_Message_PeerInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_PeerInfo proto.InternalMessageInfo - -func (m *Message_PeerInfo) GetId() []byte { - if m != nil { - return m.Id - } - return nil -} - -func (m *Message_PeerInfo) GetAddrs() [][]byte { - if m != nil { - return m.Addrs - } - return nil -} - -type Message_Register struct { - Ns string `protobuf:"bytes,1,opt,name=ns,proto3" json:"ns,omitempty"` - Peer *Message_PeerInfo `protobuf:"bytes,2,opt,name=peer,proto3" json:"peer,omitempty"` - Ttl int64 `protobuf:"varint,3,opt,name=ttl,proto3" json:"ttl,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_Register) Reset() { *m = Message_Register{} } -func (m *Message_Register) String() string { return proto.CompactTextString(m) } -func (*Message_Register) ProtoMessage() {} -func (*Message_Register) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 1} -} -func (m *Message_Register) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_Register) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Register.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_Register) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Register.Merge(m, src) -} -func (m *Message_Register) XXX_Size() int { - return m.Size() -} -func (m *Message_Register) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Register.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_Register proto.InternalMessageInfo - -func (m *Message_Register) GetNs() string { - if m != nil { - return m.Ns - } - return "" -} - -func (m *Message_Register) GetPeer() *Message_PeerInfo { - if m != nil { - return m.Peer - } - return nil -} - -func (m *Message_Register) GetTtl() int64 { - if m != nil { - return m.Ttl - } - return 0 -} - -type Message_RegisterResponse struct { - Status Message_ResponseStatus `protobuf:"varint,1,opt,name=status,proto3,enum=rendezvous.pb.Message_ResponseStatus" json:"status,omitempty"` - StatusText string `protobuf:"bytes,2,opt,name=statusText,proto3" json:"statusText,omitempty"` - Ttl int64 `protobuf:"varint,3,opt,name=ttl,proto3" json:"ttl,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_RegisterResponse) Reset() { *m = Message_RegisterResponse{} } -func (m *Message_RegisterResponse) String() string { return proto.CompactTextString(m) } -func (*Message_RegisterResponse) ProtoMessage() {} -func (*Message_RegisterResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 2} -} -func (m *Message_RegisterResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_RegisterResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_RegisterResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_RegisterResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_RegisterResponse.Merge(m, src) -} -func (m *Message_RegisterResponse) XXX_Size() int { - return m.Size() -} -func (m *Message_RegisterResponse) XXX_DiscardUnknown() { - xxx_messageInfo_Message_RegisterResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_RegisterResponse proto.InternalMessageInfo - -func (m *Message_RegisterResponse) GetStatus() Message_ResponseStatus { - if m != nil { - return m.Status - } - return Message_OK -} - -func (m *Message_RegisterResponse) GetStatusText() string { - if m != nil { - return m.StatusText - } - return "" -} - -func (m *Message_RegisterResponse) GetTtl() int64 { - if m != nil { - return m.Ttl - } - return 0 -} - -type Message_Unregister struct { - Ns string `protobuf:"bytes,1,opt,name=ns,proto3" json:"ns,omitempty"` - Id []byte `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_Unregister) Reset() { *m = Message_Unregister{} } -func (m *Message_Unregister) String() string { return proto.CompactTextString(m) } -func (*Message_Unregister) ProtoMessage() {} -func (*Message_Unregister) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 3} -} -func (m *Message_Unregister) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_Unregister) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Unregister.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_Unregister) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Unregister.Merge(m, src) -} -func (m *Message_Unregister) XXX_Size() int { - return m.Size() -} -func (m *Message_Unregister) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Unregister.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_Unregister proto.InternalMessageInfo - -func (m *Message_Unregister) GetNs() string { - if m != nil { - return m.Ns - } - return "" -} - -func (m *Message_Unregister) GetId() []byte { - if m != nil { - return m.Id - } - return nil -} - -type Message_Discover struct { - Ns string `protobuf:"bytes,1,opt,name=ns,proto3" json:"ns,omitempty"` - Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` - Cookie []byte `protobuf:"bytes,3,opt,name=cookie,proto3" json:"cookie,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_Discover) Reset() { *m = Message_Discover{} } -func (m *Message_Discover) String() string { return proto.CompactTextString(m) } -func (*Message_Discover) ProtoMessage() {} -func (*Message_Discover) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 4} -} -func (m *Message_Discover) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_Discover) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_Discover.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_Discover) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_Discover.Merge(m, src) -} -func (m *Message_Discover) XXX_Size() int { - return m.Size() -} -func (m *Message_Discover) XXX_DiscardUnknown() { - xxx_messageInfo_Message_Discover.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_Discover proto.InternalMessageInfo - -func (m *Message_Discover) GetNs() string { - if m != nil { - return m.Ns - } - return "" -} - -func (m *Message_Discover) GetLimit() int64 { - if m != nil { - return m.Limit - } - return 0 -} - -func (m *Message_Discover) GetCookie() []byte { - if m != nil { - return m.Cookie - } - return nil -} - -type Message_DiscoverResponse struct { - Registrations []*Message_Register `protobuf:"bytes,1,rep,name=registrations,proto3" json:"registrations,omitempty"` - Cookie []byte `protobuf:"bytes,2,opt,name=cookie,proto3" json:"cookie,omitempty"` - Status Message_ResponseStatus `protobuf:"varint,3,opt,name=status,proto3,enum=rendezvous.pb.Message_ResponseStatus" json:"status,omitempty"` - StatusText string `protobuf:"bytes,4,opt,name=statusText,proto3" json:"statusText,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_DiscoverResponse) Reset() { *m = Message_DiscoverResponse{} } -func (m *Message_DiscoverResponse) String() string { return proto.CompactTextString(m) } -func (*Message_DiscoverResponse) ProtoMessage() {} -func (*Message_DiscoverResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 5} -} -func (m *Message_DiscoverResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_DiscoverResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_DiscoverResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_DiscoverResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_DiscoverResponse.Merge(m, src) -} -func (m *Message_DiscoverResponse) XXX_Size() int { - return m.Size() -} -func (m *Message_DiscoverResponse) XXX_DiscardUnknown() { - xxx_messageInfo_Message_DiscoverResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_DiscoverResponse proto.InternalMessageInfo - -func (m *Message_DiscoverResponse) GetRegistrations() []*Message_Register { - if m != nil { - return m.Registrations - } - return nil -} - -func (m *Message_DiscoverResponse) GetCookie() []byte { - if m != nil { - return m.Cookie - } - return nil -} - -func (m *Message_DiscoverResponse) GetStatus() Message_ResponseStatus { - if m != nil { - return m.Status - } - return Message_OK -} - -func (m *Message_DiscoverResponse) GetStatusText() string { - if m != nil { - return m.StatusText - } - return "" -} - -type Message_DiscoverSubscribe struct { - SupportedSubscriptionTypes []string `protobuf:"bytes,1,rep,name=supported_subscription_types,json=supportedSubscriptionTypes,proto3" json:"supported_subscription_types,omitempty"` - Ns string `protobuf:"bytes,2,opt,name=ns,proto3" json:"ns,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_DiscoverSubscribe) Reset() { *m = Message_DiscoverSubscribe{} } -func (m *Message_DiscoverSubscribe) String() string { return proto.CompactTextString(m) } -func (*Message_DiscoverSubscribe) ProtoMessage() {} -func (*Message_DiscoverSubscribe) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 6} -} -func (m *Message_DiscoverSubscribe) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_DiscoverSubscribe) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_DiscoverSubscribe.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_DiscoverSubscribe) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_DiscoverSubscribe.Merge(m, src) -} -func (m *Message_DiscoverSubscribe) XXX_Size() int { - return m.Size() -} -func (m *Message_DiscoverSubscribe) XXX_DiscardUnknown() { - xxx_messageInfo_Message_DiscoverSubscribe.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_DiscoverSubscribe proto.InternalMessageInfo - -func (m *Message_DiscoverSubscribe) GetSupportedSubscriptionTypes() []string { - if m != nil { - return m.SupportedSubscriptionTypes - } - return nil -} - -func (m *Message_DiscoverSubscribe) GetNs() string { - if m != nil { - return m.Ns - } - return "" -} - -type Message_DiscoverSubscribeResponse struct { - SubscriptionType string `protobuf:"bytes,1,opt,name=subscription_type,json=subscriptionType,proto3" json:"subscription_type,omitempty"` - SubscriptionDetails string `protobuf:"bytes,2,opt,name=subscription_details,json=subscriptionDetails,proto3" json:"subscription_details,omitempty"` - Status Message_ResponseStatus `protobuf:"varint,3,opt,name=status,proto3,enum=rendezvous.pb.Message_ResponseStatus" json:"status,omitempty"` - StatusText string `protobuf:"bytes,4,opt,name=statusText,proto3" json:"statusText,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Message_DiscoverSubscribeResponse) Reset() { *m = Message_DiscoverSubscribeResponse{} } -func (m *Message_DiscoverSubscribeResponse) String() string { return proto.CompactTextString(m) } -func (*Message_DiscoverSubscribeResponse) ProtoMessage() {} -func (*Message_DiscoverSubscribeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 7} -} -func (m *Message_DiscoverSubscribeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message_DiscoverSubscribeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message_DiscoverSubscribeResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Message_DiscoverSubscribeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_DiscoverSubscribeResponse.Merge(m, src) -} -func (m *Message_DiscoverSubscribeResponse) XXX_Size() int { - return m.Size() -} -func (m *Message_DiscoverSubscribeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_Message_DiscoverSubscribeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_Message_DiscoverSubscribeResponse proto.InternalMessageInfo - -func (m *Message_DiscoverSubscribeResponse) GetSubscriptionType() string { - if m != nil { - return m.SubscriptionType - } - return "" -} - -func (m *Message_DiscoverSubscribeResponse) GetSubscriptionDetails() string { - if m != nil { - return m.SubscriptionDetails - } - return "" -} - -func (m *Message_DiscoverSubscribeResponse) GetStatus() Message_ResponseStatus { - if m != nil { - return m.Status - } - return Message_OK -} - -func (m *Message_DiscoverSubscribeResponse) GetStatusText() string { - if m != nil { - return m.StatusText - } - return "" -} - -type RegistrationRecord struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Addrs [][]byte `protobuf:"bytes,2,rep,name=addrs,proto3" json:"addrs,omitempty"` - Ns string `protobuf:"bytes,3,opt,name=ns,proto3" json:"ns,omitempty"` - Ttl int64 `protobuf:"varint,4,opt,name=ttl,proto3" json:"ttl,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RegistrationRecord) Reset() { *m = RegistrationRecord{} } -func (m *RegistrationRecord) String() string { return proto.CompactTextString(m) } -func (*RegistrationRecord) ProtoMessage() {} -func (*RegistrationRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{1} -} -func (m *RegistrationRecord) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RegistrationRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RegistrationRecord.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RegistrationRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_RegistrationRecord.Merge(m, src) -} -func (m *RegistrationRecord) XXX_Size() int { - return m.Size() -} -func (m *RegistrationRecord) XXX_DiscardUnknown() { - xxx_messageInfo_RegistrationRecord.DiscardUnknown(m) -} - -var xxx_messageInfo_RegistrationRecord proto.InternalMessageInfo - -func (m *RegistrationRecord) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *RegistrationRecord) GetAddrs() [][]byte { - if m != nil { - return m.Addrs - } - return nil -} - -func (m *RegistrationRecord) GetNs() string { - if m != nil { - return m.Ns - } - return "" -} - -func (m *RegistrationRecord) GetTtl() int64 { - if m != nil { - return m.Ttl - } - return 0 -} - -func init() { - proto.RegisterEnum("rendezvous.pb.Message_MessageType", Message_MessageType_name, Message_MessageType_value) - proto.RegisterEnum("rendezvous.pb.Message_ResponseStatus", Message_ResponseStatus_name, Message_ResponseStatus_value) - proto.RegisterType((*Message)(nil), "rendezvous.pb.Message") - proto.RegisterType((*Message_PeerInfo)(nil), "rendezvous.pb.Message.PeerInfo") - proto.RegisterType((*Message_Register)(nil), "rendezvous.pb.Message.Register") - proto.RegisterType((*Message_RegisterResponse)(nil), "rendezvous.pb.Message.RegisterResponse") - proto.RegisterType((*Message_Unregister)(nil), "rendezvous.pb.Message.Unregister") - proto.RegisterType((*Message_Discover)(nil), "rendezvous.pb.Message.Discover") - proto.RegisterType((*Message_DiscoverResponse)(nil), "rendezvous.pb.Message.DiscoverResponse") - proto.RegisterType((*Message_DiscoverSubscribe)(nil), "rendezvous.pb.Message.DiscoverSubscribe") - proto.RegisterType((*Message_DiscoverSubscribeResponse)(nil), "rendezvous.pb.Message.DiscoverSubscribeResponse") - proto.RegisterType((*RegistrationRecord)(nil), "rendezvous.pb.RegistrationRecord") -} - -func init() { proto.RegisterFile("rendezvous.proto", fileDescriptor_ef0a1d5737df1c36) } - -var fileDescriptor_ef0a1d5737df1c36 = []byte{ - // 795 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x8e, 0xdb, 0x54, - 0x14, 0x1e, 0xdb, 0x99, 0x90, 0x9c, 0x66, 0xa2, 0x9b, 0xd3, 0xb4, 0xa4, 0x06, 0xa5, 0x43, 0x24, - 0x44, 0x24, 0xd0, 0xa8, 0xb4, 0x12, 0x1b, 0x84, 0x84, 0x93, 0x5c, 0xa8, 0xd5, 0xd4, 0x8e, 0xae, - 0x9d, 0x2c, 0x10, 0x92, 0x95, 0xc4, 0xb7, 0x23, 0x8b, 0x21, 0xb6, 0x7c, 0x9d, 0x8a, 0xb2, 0xe5, - 0x05, 0x58, 0xb2, 0xe4, 0x01, 0xd8, 0xf2, 0x0e, 0x5d, 0x76, 0xcd, 0x0a, 0x0d, 0xcf, 0xc0, 0x1e, - 0xf9, 0x37, 0x4e, 0x4c, 0x3a, 0x23, 0x21, 0x56, 0xf1, 0x3d, 0xf7, 0xfb, 0xbe, 0xf3, 0x73, 0xcf, - 0x39, 0x01, 0x12, 0xf2, 0x8d, 0xcb, 0x7f, 0x7c, 0xe9, 0x6f, 0xc5, 0x45, 0x10, 0xfa, 0x91, 0x8f, - 0x67, 0x65, 0xcb, 0x6a, 0xf0, 0x77, 0x1b, 0xde, 0x79, 0xce, 0x85, 0x58, 0x5e, 0x72, 0xfc, 0x0c, - 0x6a, 0xd1, 0xab, 0x80, 0xf7, 0xa4, 0x73, 0x69, 0xd8, 0x7e, 0x3c, 0xb8, 0xd8, 0x43, 0x5e, 0x64, - 0xa8, 0xfc, 0xd7, 0x7e, 0x15, 0x70, 0x96, 0xe0, 0xf1, 0x73, 0x68, 0x84, 0xfc, 0xd2, 0x13, 0x11, - 0x0f, 0x7b, 0xf2, 0xb9, 0x34, 0xbc, 0xf3, 0xf8, 0xe1, 0x11, 0x2e, 0xcb, 0x60, 0xac, 0x20, 0xa0, - 0x15, 0xc7, 0x98, 0x59, 0xb9, 0x08, 0xfc, 0x8d, 0xe0, 0x3d, 0x25, 0x11, 0xf9, 0xe8, 0x26, 0x91, - 0x0c, 0xce, 0x2a, 0x02, 0xa8, 0x01, 0x6c, 0x37, 0x45, 0x4c, 0xb5, 0x44, 0xee, 0x83, 0x23, 0x72, - 0xf3, 0x02, 0xc8, 0x4a, 0xa4, 0x38, 0x29, 0xd7, 0x13, 0x6b, 0xff, 0x25, 0x0f, 0x7b, 0xa7, 0x6f, - 0x4d, 0x6a, 0x92, 0xc1, 0x58, 0x41, 0x88, 0x93, 0xca, 0xbf, 0x8b, 0xa4, 0xea, 0x6f, 0x4d, 0x6a, - 0x72, 0x00, 0x67, 0x15, 0x01, 0x5c, 0x40, 0x27, 0xb7, 0x59, 0xdb, 0x95, 0x58, 0x87, 0xde, 0x8a, - 0xf7, 0xdc, 0x44, 0x75, 0x78, 0x83, 0x6a, 0x81, 0x67, 0x55, 0x09, 0xdc, 0xc0, 0x83, 0x8a, 0xb1, - 0x88, 0x9a, 0x27, 0xfa, 0x8f, 0x6e, 0xad, 0x9f, 0x87, 0x7f, 0x5c, 0x52, 0x7d, 0x04, 0x8d, 0x19, - 0xe7, 0xa1, 0xbe, 0x79, 0xe1, 0x63, 0x1b, 0x64, 0xcf, 0x4d, 0x1a, 0xae, 0xc5, 0x64, 0xcf, 0xc5, - 0x2e, 0x9c, 0x2e, 0x5d, 0x37, 0x14, 0x3d, 0xf9, 0x5c, 0x19, 0xb6, 0x58, 0x7a, 0x50, 0x97, 0xd0, - 0xc8, 0x1f, 0x3d, 0x66, 0x6c, 0x44, 0xc2, 0x68, 0x32, 0x79, 0x23, 0xf0, 0x09, 0xd4, 0x02, 0x7e, - 0x63, 0xe3, 0xe5, 0x0e, 0x59, 0x02, 0x46, 0x02, 0x4a, 0x14, 0x5d, 0x25, 0x7d, 0xa6, 0xb0, 0xf8, - 0x53, 0xfd, 0x49, 0x02, 0x72, 0xd8, 0x58, 0xf8, 0x05, 0xd4, 0x45, 0xb4, 0x8c, 0xb6, 0x22, 0x1b, - 0x89, 0x0f, 0x8f, 0x76, 0x64, 0x4a, 0xb0, 0x12, 0x30, 0xcb, 0x48, 0xd8, 0x07, 0x48, 0xbf, 0x6c, - 0xfe, 0x43, 0x94, 0x04, 0xd8, 0x64, 0x25, 0xcb, 0xbf, 0x44, 0xf1, 0x09, 0xc0, 0xae, 0x1d, 0x2b, - 0xa9, 0xa6, 0xc5, 0x92, 0xf3, 0x62, 0xa9, 0x4f, 0xa1, 0x91, 0x3f, 0x40, 0x05, 0xdb, 0x85, 0xd3, - 0x2b, 0xef, 0x7b, 0x2f, 0x75, 0xab, 0xb0, 0xf4, 0x80, 0xf7, 0xa1, 0xbe, 0xf6, 0xfd, 0xef, 0xbc, - 0x74, 0xc4, 0x5a, 0x2c, 0x3b, 0xa9, 0x6f, 0x24, 0x20, 0x87, 0x1d, 0x88, 0x14, 0xce, 0xd2, 0x50, - 0xc2, 0x65, 0xe4, 0xf9, 0x89, 0xba, 0x72, 0x9b, 0xd9, 0xde, 0x67, 0x95, 0x7c, 0xca, 0x65, 0x9f, - 0xa5, 0xe2, 0x2a, 0xff, 0xbd, 0xb8, 0xb5, 0xc3, 0xe2, 0xaa, 0x1c, 0x3a, 0x95, 0xee, 0xc4, 0x2f, - 0xe1, 0x7d, 0xb1, 0x0d, 0x02, 0x3f, 0x8c, 0xb8, 0xeb, 0x88, 0xd4, 0x1c, 0xc4, 0x61, 0x3a, 0xf1, - 0x22, 0x4b, 0x33, 0x6c, 0x32, 0xb5, 0xc0, 0x58, 0x25, 0x48, 0xbc, 0xf0, 0x44, 0x56, 0x67, 0x39, - 0xaf, 0xb3, 0xfa, 0x87, 0x04, 0x0f, 0x8e, 0x4e, 0x01, 0x7e, 0x0c, 0x9d, 0x8a, 0x97, 0xec, 0x91, - 0x88, 0x38, 0xd0, 0xc6, 0x4f, 0xa1, 0xbb, 0x07, 0x76, 0x79, 0xb4, 0xf4, 0xae, 0x72, 0x67, 0x77, - 0xcb, 0x77, 0x93, 0xf4, 0xea, 0x7f, 0xae, 0xe1, 0xe0, 0x57, 0x09, 0xee, 0x94, 0xd6, 0x3d, 0xb6, - 0xa0, 0xc1, 0xe8, 0xd7, 0xba, 0x65, 0x53, 0x46, 0x4e, 0xf0, 0x1e, 0x74, 0xf2, 0x93, 0xc3, 0xa8, - 0x35, 0x33, 0x0d, 0x8b, 0x12, 0x09, 0xdb, 0x00, 0x73, 0xa3, 0x80, 0xc9, 0x31, 0x69, 0xa2, 0x5b, - 0x63, 0x73, 0x41, 0x19, 0x51, 0x62, 0x52, 0x7e, 0xda, 0x91, 0x6a, 0x78, 0x1f, 0xb0, 0x30, 0x5b, - 0xf3, 0x91, 0x35, 0x66, 0xfa, 0x88, 0x12, 0x17, 0x1f, 0xc2, 0x7b, 0x55, 0xfb, 0x8e, 0xc8, 0x07, - 0xbf, 0x4b, 0xd0, 0xde, 0xcf, 0x0e, 0xeb, 0x20, 0x9b, 0xcf, 0xc8, 0x09, 0xbe, 0x0b, 0x77, 0xa9, - 0xa3, 0x1b, 0x0b, 0x6d, 0xaa, 0x4f, 0x1c, 0x43, 0x7b, 0x4e, 0xad, 0x99, 0x36, 0x8e, 0x45, 0xf7, - 0x2e, 0x66, 0x94, 0x32, 0x47, 0x37, 0xbe, 0x32, 0x09, 0xc7, 0x0e, 0x9c, 0xed, 0x2e, 0x6c, 0x7b, - 0x4a, 0x5e, 0x60, 0x17, 0xc8, 0xce, 0x34, 0x36, 0xcd, 0x67, 0x3a, 0x25, 0x97, 0x78, 0x2f, 0xb6, - 0x1a, 0xa6, 0xed, 0x68, 0x73, 0xfb, 0xa9, 0xc9, 0xf4, 0x6f, 0xe8, 0x84, 0xbc, 0x96, 0x52, 0xb3, - 0x6e, 0xd8, 0x94, 0x19, 0xda, 0xd4, 0xa1, 0x8c, 0x99, 0x8c, 0xfc, 0x26, 0x23, 0xc6, 0xb2, 0x73, - 0x43, 0x5b, 0x68, 0xfa, 0x54, 0x1b, 0x4d, 0x29, 0xf9, 0x59, 0x19, 0x7c, 0x0b, 0xc8, 0x4a, 0x63, - 0xc2, 0xf8, 0xda, 0x0f, 0xdd, 0xd2, 0x3a, 0x6c, 0x1e, 0x5f, 0x87, 0x59, 0x0f, 0x2a, 0xc5, 0xac, - 0x67, 0x7b, 0xa4, 0x56, 0xec, 0x91, 0x11, 0x79, 0x7d, 0xdd, 0x97, 0xde, 0x5c, 0xf7, 0xa5, 0x3f, - 0xaf, 0xfb, 0xd2, 0x2f, 0x7f, 0xf5, 0x4f, 0x56, 0xf5, 0xe4, 0xdf, 0xff, 0xc9, 0x3f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x91, 0x28, 0x17, 0x04, 0x11, 0x08, 0x00, 0x00, -} - -func (m *Message) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.DiscoverSubscribeResponse != nil { - { - size, err := m.DiscoverSubscribeResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0xaa - } - if m.DiscoverSubscribe != nil { - { - size, err := m.DiscoverSubscribe.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6 - i-- - dAtA[i] = 0xa2 - } - if m.DiscoverResponse != nil { - { - size, err := m.DiscoverResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - if m.Discover != nil { - { - size, err := m.Discover.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if m.Unregister != nil { - { - size, err := m.Unregister.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.RegisterResponse != nil { - { - size, err := m.RegisterResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.Register != nil { - { - size, err := m.Register.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.Type != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Message_PeerInfo) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_PeerInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_PeerInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Addrs) > 0 { - for iNdEx := len(m.Addrs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Addrs[iNdEx]) - copy(dAtA[i:], m.Addrs[iNdEx]) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Addrs[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Message_Register) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_Register) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_Register) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Ttl != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Ttl)) - i-- - dAtA[i] = 0x18 - } - if m.Peer != nil { - { - size, err := m.Peer.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Ns) > 0 { - i -= len(m.Ns) - copy(dAtA[i:], m.Ns) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Ns))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Message_RegisterResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_RegisterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_RegisterResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Ttl != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Ttl)) - i-- - dAtA[i] = 0x18 - } - if len(m.StatusText) > 0 { - i -= len(m.StatusText) - copy(dAtA[i:], m.StatusText) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.StatusText))) - i-- - dAtA[i] = 0x12 - } - if m.Status != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Message_Unregister) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_Unregister) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_Unregister) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x12 - } - if len(m.Ns) > 0 { - i -= len(m.Ns) - copy(dAtA[i:], m.Ns) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Ns))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Message_Discover) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_Discover) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_Discover) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Cookie) > 0 { - i -= len(m.Cookie) - copy(dAtA[i:], m.Cookie) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Cookie))) - i-- - dAtA[i] = 0x1a - } - if m.Limit != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Limit)) - i-- - dAtA[i] = 0x10 - } - if len(m.Ns) > 0 { - i -= len(m.Ns) - copy(dAtA[i:], m.Ns) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Ns))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Message_DiscoverResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_DiscoverResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_DiscoverResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.StatusText) > 0 { - i -= len(m.StatusText) - copy(dAtA[i:], m.StatusText) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.StatusText))) - i-- - dAtA[i] = 0x22 - } - if m.Status != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x18 - } - if len(m.Cookie) > 0 { - i -= len(m.Cookie) - copy(dAtA[i:], m.Cookie) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Cookie))) - i-- - dAtA[i] = 0x12 - } - if len(m.Registrations) > 0 { - for iNdEx := len(m.Registrations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Registrations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintRendezvous(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Message_DiscoverSubscribe) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_DiscoverSubscribe) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_DiscoverSubscribe) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Ns) > 0 { - i -= len(m.Ns) - copy(dAtA[i:], m.Ns) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Ns))) - i-- - dAtA[i] = 0x12 - } - if len(m.SupportedSubscriptionTypes) > 0 { - for iNdEx := len(m.SupportedSubscriptionTypes) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.SupportedSubscriptionTypes[iNdEx]) - copy(dAtA[i:], m.SupportedSubscriptionTypes[iNdEx]) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.SupportedSubscriptionTypes[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Message_DiscoverSubscribeResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Message_DiscoverSubscribeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message_DiscoverSubscribeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.StatusText) > 0 { - i -= len(m.StatusText) - copy(dAtA[i:], m.StatusText) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.StatusText))) - i-- - dAtA[i] = 0x22 - } - if m.Status != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x18 - } - if len(m.SubscriptionDetails) > 0 { - i -= len(m.SubscriptionDetails) - copy(dAtA[i:], m.SubscriptionDetails) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.SubscriptionDetails))) - i-- - dAtA[i] = 0x12 - } - if len(m.SubscriptionType) > 0 { - i -= len(m.SubscriptionType) - copy(dAtA[i:], m.SubscriptionType) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.SubscriptionType))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RegistrationRecord) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RegistrationRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RegistrationRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Ttl != 0 { - i = encodeVarintRendezvous(dAtA, i, uint64(m.Ttl)) - i-- - dAtA[i] = 0x20 - } - if len(m.Ns) > 0 { - i -= len(m.Ns) - copy(dAtA[i:], m.Ns) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Ns))) - i-- - dAtA[i] = 0x1a - } - if len(m.Addrs) > 0 { - for iNdEx := len(m.Addrs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Addrs[iNdEx]) - copy(dAtA[i:], m.Addrs[iNdEx]) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Addrs[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintRendezvous(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintRendezvous(dAtA []byte, offset int, v uint64) int { - offset -= sovRendezvous(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Message) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Type != 0 { - n += 1 + sovRendezvous(uint64(m.Type)) - } - if m.Register != nil { - l = m.Register.Size() - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.RegisterResponse != nil { - l = m.RegisterResponse.Size() - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Unregister != nil { - l = m.Unregister.Size() - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Discover != nil { - l = m.Discover.Size() - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.DiscoverResponse != nil { - l = m.DiscoverResponse.Size() - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.DiscoverSubscribe != nil { - l = m.DiscoverSubscribe.Size() - n += 2 + l + sovRendezvous(uint64(l)) - } - if m.DiscoverSubscribeResponse != nil { - l = m.DiscoverSubscribeResponse.Size() - n += 2 + l + sovRendezvous(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_PeerInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if len(m.Addrs) > 0 { - for _, b := range m.Addrs { - l = len(b) - n += 1 + l + sovRendezvous(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_Register) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Ns) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Peer != nil { - l = m.Peer.Size() - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Ttl != 0 { - n += 1 + sovRendezvous(uint64(m.Ttl)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_RegisterResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Status != 0 { - n += 1 + sovRendezvous(uint64(m.Status)) - } - l = len(m.StatusText) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Ttl != 0 { - n += 1 + sovRendezvous(uint64(m.Ttl)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_Unregister) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Ns) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - l = len(m.Id) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_Discover) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Ns) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Limit != 0 { - n += 1 + sovRendezvous(uint64(m.Limit)) - } - l = len(m.Cookie) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_DiscoverResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Registrations) > 0 { - for _, e := range m.Registrations { - l = e.Size() - n += 1 + l + sovRendezvous(uint64(l)) - } - } - l = len(m.Cookie) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Status != 0 { - n += 1 + sovRendezvous(uint64(m.Status)) - } - l = len(m.StatusText) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_DiscoverSubscribe) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.SupportedSubscriptionTypes) > 0 { - for _, s := range m.SupportedSubscriptionTypes { - l = len(s) - n += 1 + l + sovRendezvous(uint64(l)) - } - } - l = len(m.Ns) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Message_DiscoverSubscribeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SubscriptionType) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - l = len(m.SubscriptionDetails) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Status != 0 { - n += 1 + sovRendezvous(uint64(m.Status)) - } - l = len(m.StatusText) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RegistrationRecord) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if len(m.Addrs) > 0 { - for _, b := range m.Addrs { - l = len(b) - n += 1 + l + sovRendezvous(uint64(l)) - } - } - l = len(m.Ns) - if l > 0 { - n += 1 + l + sovRendezvous(uint64(l)) - } - if m.Ttl != 0 { - n += 1 + sovRendezvous(uint64(m.Ttl)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovRendezvous(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozRendezvous(x uint64) (n int) { - return sovRendezvous(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Message) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= Message_MessageType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Register", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Register == nil { - m.Register = &Message_Register{} - } - if err := m.Register.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RegisterResponse", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RegisterResponse == nil { - m.RegisterResponse = &Message_RegisterResponse{} - } - if err := m.RegisterResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Unregister", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Unregister == nil { - m.Unregister = &Message_Unregister{} - } - if err := m.Unregister.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Discover", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Discover == nil { - m.Discover = &Message_Discover{} - } - if err := m.Discover.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DiscoverResponse", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DiscoverResponse == nil { - m.DiscoverResponse = &Message_DiscoverResponse{} - } - if err := m.DiscoverResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 100: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DiscoverSubscribe", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DiscoverSubscribe == nil { - m.DiscoverSubscribe = &Message_DiscoverSubscribe{} - } - if err := m.DiscoverSubscribe.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 101: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DiscoverSubscribeResponse", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DiscoverSubscribeResponse == nil { - m.DiscoverSubscribeResponse = &Message_DiscoverSubscribeResponse{} - } - if err := m.DiscoverSubscribeResponse.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_PeerInfo) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PeerInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PeerInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...) - if m.Id == nil { - m.Id = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addrs", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addrs = append(m.Addrs, make([]byte, postIndex-iNdEx)) - copy(m.Addrs[len(m.Addrs)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_Register) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Register: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Register: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ns = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Peer", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Peer == nil { - m.Peer = &Message_PeerInfo{} - } - if err := m.Peer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Ttl", wireType) - } - m.Ttl = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Ttl |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_RegisterResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RegisterResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RegisterResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= Message_ResponseStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StatusText", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StatusText = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Ttl", wireType) - } - m.Ttl = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Ttl |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_Unregister) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Unregister: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Unregister: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ns = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...) - if m.Id == nil { - m.Id = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_Discover) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Discover: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Discover: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ns = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) - } - m.Limit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Limit |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cookie", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Cookie = append(m.Cookie[:0], dAtA[iNdEx:postIndex]...) - if m.Cookie == nil { - m.Cookie = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_DiscoverResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DiscoverResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DiscoverResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Registrations", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Registrations = append(m.Registrations, &Message_Register{}) - if err := m.Registrations[len(m.Registrations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cookie", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Cookie = append(m.Cookie[:0], dAtA[iNdEx:postIndex]...) - if m.Cookie == nil { - m.Cookie = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= Message_ResponseStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StatusText", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StatusText = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_DiscoverSubscribe) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DiscoverSubscribe: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DiscoverSubscribe: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SupportedSubscriptionTypes", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SupportedSubscriptionTypes = append(m.SupportedSubscriptionTypes, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ns = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Message_DiscoverSubscribeResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DiscoverSubscribeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DiscoverSubscribeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SubscriptionType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SubscriptionDetails", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SubscriptionDetails = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= Message_ResponseStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StatusText", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StatusText = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RegistrationRecord) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RegistrationRecord: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RegistrationRecord: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addrs", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addrs = append(m.Addrs, make([]byte, postIndex-iNdEx)) - copy(m.Addrs[len(m.Addrs)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ns", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthRendezvous - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRendezvous - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ns = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Ttl", wireType) - } - m.Ttl = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRendezvous - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Ttl |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipRendezvous(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthRendezvous - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipRendezvous(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRendezvous - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRendezvous - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowRendezvous - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthRendezvous - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupRendezvous - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthRendezvous - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthRendezvous = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowRendezvous = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupRendezvous = fmt.Errorf("proto: unexpected end of group") -) diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/pb/rendezvous.proto b/vendor/github.com/berty/go-libp2p-rendezvous/pb/rendezvous.proto deleted file mode 100644 index a1ec9d826..000000000 --- a/vendor/github.com/berty/go-libp2p-rendezvous/pb/rendezvous.proto +++ /dev/null @@ -1,91 +0,0 @@ -syntax = "proto3"; - -package rendezvous.pb; - -message Message { - enum MessageType { - REGISTER = 0; - REGISTER_RESPONSE = 1; - UNREGISTER = 2; - DISCOVER = 3; - DISCOVER_RESPONSE = 4; - - DISCOVER_SUBSCRIBE = 100; - DISCOVER_SUBSCRIBE_RESPONSE = 101; - } - - enum ResponseStatus { - OK = 0; - E_INVALID_NAMESPACE = 100; - E_INVALID_PEER_INFO = 101; - E_INVALID_TTL = 102; - E_INVALID_COOKIE = 103; - E_NOT_AUTHORIZED = 200; - E_INTERNAL_ERROR = 300; - E_UNAVAILABLE = 400; - } - - message PeerInfo { - bytes id = 1; - repeated bytes addrs = 2; - } - - message Register { - string ns = 1; - PeerInfo peer = 2; - int64 ttl = 3; // in seconds - } - - message RegisterResponse { - ResponseStatus status = 1; - string statusText = 2; - int64 ttl = 3; - } - - message Unregister { - string ns = 1; - bytes id = 2; - } - - message Discover { - string ns = 1; - int64 limit = 2; - bytes cookie = 3; - } - - message DiscoverResponse { - repeated Register registrations = 1; - bytes cookie = 2; - ResponseStatus status = 3; - string statusText = 4; - } - - message DiscoverSubscribe { - repeated string supported_subscription_types = 1; - string ns = 2; - } - - message DiscoverSubscribeResponse { - string subscription_type = 1; - string subscription_details = 2; - ResponseStatus status = 3; - string statusText = 4; - } - - MessageType type = 1; - Register register = 2; - RegisterResponse registerResponse = 3; - Unregister unregister = 4; - Discover discover = 5; - DiscoverResponse discoverResponse = 6; - - DiscoverSubscribe discoverSubscribe = 100; - DiscoverSubscribeResponse discoverSubscribeResponse = 101; -} - -message RegistrationRecord{ - string id = 1; - repeated bytes addrs = 2; - string ns = 3; - int64 ttl = 4; -} diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/proto.go b/vendor/github.com/berty/go-libp2p-rendezvous/proto.go deleted file mode 100644 index c8b5b7890..000000000 --- a/vendor/github.com/berty/go-libp2p-rendezvous/proto.go +++ /dev/null @@ -1,178 +0,0 @@ -package rendezvous - -import ( - "errors" - "fmt" - - db "github.com/berty/go-libp2p-rendezvous/db" - pb "github.com/berty/go-libp2p-rendezvous/pb" - - logging "github.com/ipfs/go-log/v2" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/core/protocol" - ma "github.com/multiformats/go-multiaddr" -) - -var log = logging.Logger("rendezvous") - -const ( - RendezvousProto = protocol.ID("/rendezvous/1.0.0") - - DefaultTTL = 2 * 3600 // 2hr -) - -type RendezvousError struct { - Status pb.Message_ResponseStatus - Text string -} - -func (e RendezvousError) Error() string { - return fmt.Sprintf("Rendezvous error: %s (%s)", e.Text, e.Status.String()) -} - -func NewRegisterMessage(ns string, pi peer.AddrInfo, ttl int) *pb.Message { - return newRegisterMessage(ns, pi, ttl) -} - -func newRegisterMessage(ns string, pi peer.AddrInfo, ttl int) *pb.Message { - msg := new(pb.Message) - msg.Type = pb.Message_REGISTER - msg.Register = new(pb.Message_Register) - if ns != "" { - msg.Register.Ns = ns - } - if ttl > 0 { - ttl64 := int64(ttl) - msg.Register.Ttl = ttl64 - } - msg.Register.Peer = new(pb.Message_PeerInfo) - msg.Register.Peer.Id = []byte(pi.ID) - msg.Register.Peer.Addrs = make([][]byte, len(pi.Addrs)) - for i, addr := range pi.Addrs { - msg.Register.Peer.Addrs[i] = addr.Bytes() - } - return msg -} - -func newUnregisterMessage(ns string, pid peer.ID) *pb.Message { - msg := new(pb.Message) - msg.Type = pb.Message_UNREGISTER - msg.Unregister = new(pb.Message_Unregister) - if ns != "" { - msg.Unregister.Ns = ns - } - msg.Unregister.Id = []byte(pid) - return msg -} - -func NewDiscoverMessage(ns string, limit int, cookie []byte) *pb.Message { - return newDiscoverMessage(ns, limit, cookie) -} - -func newDiscoverMessage(ns string, limit int, cookie []byte) *pb.Message { - msg := new(pb.Message) - msg.Type = pb.Message_DISCOVER - msg.Discover = new(pb.Message_Discover) - if ns != "" { - msg.Discover.Ns = ns - } - if limit > 0 { - limit64 := int64(limit) - msg.Discover.Limit = limit64 - } - if cookie != nil { - msg.Discover.Cookie = cookie - } - return msg -} - -func pbToPeerInfo(p *pb.Message_PeerInfo) (peer.AddrInfo, error) { - if p == nil { - return peer.AddrInfo{}, errors.New("missing peer info") - } - - id, err := peer.IDFromBytes(p.Id) - if err != nil { - return peer.AddrInfo{}, err - } - addrs := make([]ma.Multiaddr, 0, len(p.Addrs)) - for _, bs := range p.Addrs { - addr, err := ma.NewMultiaddrBytes(bs) - if err != nil { - log.Errorf("Error parsing multiaddr: %s", err.Error()) - continue - } - addrs = append(addrs, addr) - } - - return peer.AddrInfo{ID: id, Addrs: addrs}, nil -} - -func newRegisterResponse(ttl int) *pb.Message_RegisterResponse { - ttl64 := int64(ttl) - r := new(pb.Message_RegisterResponse) - r.Status = pb.Message_OK - r.Ttl = ttl64 - return r -} - -func newRegisterResponseError(status pb.Message_ResponseStatus, text string) *pb.Message_RegisterResponse { - r := new(pb.Message_RegisterResponse) - r.Status = status - r.StatusText = text - return r -} - -func newDiscoverResponse(regs []db.RegistrationRecord, cookie []byte) *pb.Message_DiscoverResponse { - r := new(pb.Message_DiscoverResponse) - r.Status = pb.Message_OK - - rregs := make([]*pb.Message_Register, len(regs)) - for i, reg := range regs { - rreg := new(pb.Message_Register) - rns := reg.Ns - rreg.Ns = rns - rreg.Peer = new(pb.Message_PeerInfo) - rreg.Peer.Id = []byte(reg.Id) - rreg.Peer.Addrs = reg.Addrs - rttl := int64(reg.Ttl) - rreg.Ttl = rttl - rregs[i] = rreg - } - - r.Registrations = rregs - r.Cookie = cookie - - return r -} - -func newDiscoverResponseError(status pb.Message_ResponseStatus, text string) *pb.Message_DiscoverResponse { - r := new(pb.Message_DiscoverResponse) - r.Status = status - r.StatusText = text - return r -} - -func newDiscoverSubscribeResponse(subscriptionType string, subscriptionDetails string) *pb.Message_DiscoverSubscribeResponse { - r := new(pb.Message_DiscoverSubscribeResponse) - r.Status = pb.Message_OK - - r.SubscriptionDetails = subscriptionDetails - r.SubscriptionType = subscriptionType - - return r -} - -func newDiscoverSubscribeResponseError(status pb.Message_ResponseStatus, text string) *pb.Message_DiscoverSubscribeResponse { - r := new(pb.Message_DiscoverSubscribeResponse) - r.Status = status - r.StatusText = text - return r -} - -func newDiscoverSubscribeMessage(ns string, supportedSubscriptionTypes []string) *pb.Message_DiscoverSubscribe { - r := new(pb.Message_DiscoverSubscribe) - r.Ns = ns - r.SupportedSubscriptionTypes = supportedSubscriptionTypes - return r -} diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/sync_iface.go b/vendor/github.com/berty/go-libp2p-rendezvous/sync_iface.go deleted file mode 100644 index d92e23b24..000000000 --- a/vendor/github.com/berty/go-libp2p-rendezvous/sync_iface.go +++ /dev/null @@ -1,22 +0,0 @@ -package rendezvous - -import ( - "context" - - "github.com/libp2p/go-libp2p/core/peer" -) - -type RendezvousSync interface { - Register(p peer.ID, ns string, addrs [][]byte, ttl int, counter uint64) - Unregister(p peer.ID, ns string) -} - -type RendezvousSyncSubscribable interface { - Subscribe(ns string) (syncDetails string, err error) - GetServiceType() string -} - -type RendezvousSyncClient interface { - Subscribe(ctx context.Context, syncDetails string) (<-chan *Registration, error) - GetServiceType() string -} diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/sync_inmem_client.go b/vendor/github.com/berty/go-libp2p-rendezvous/sync_inmem_client.go deleted file mode 100644 index d910ea5fc..000000000 --- a/vendor/github.com/berty/go-libp2p-rendezvous/sync_inmem_client.go +++ /dev/null @@ -1,156 +0,0 @@ -package rendezvous - -import ( - "context" - "encoding/json" - "fmt" - "sync" - - ggio "github.com/gogo/protobuf/io" - "github.com/google/uuid" - "github.com/libp2p/go-libp2p/core/host" - inet "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/multiformats/go-multiaddr" - - pb "github.com/berty/go-libp2p-rendezvous/pb" -) - -type client struct { - ctx context.Context - host host.Host - mu sync.Mutex - streams map[string]inet.Stream - subscriptions map[string]map[string]chan *Registration -} - -func NewSyncInMemClient(ctx context.Context, h host.Host) *client { - return &client{ - ctx: ctx, - host: h, - streams: map[string]inet.Stream{}, - subscriptions: map[string]map[string]chan *Registration{}, - } -} - -func (c *client) getStreamToPeer(pidStr string) (inet.Stream, error) { - c.mu.Lock() - defer c.mu.Unlock() - - if stream, ok := c.streams[pidStr]; ok { - return stream, nil - } - - pid, err := peer.Decode(pidStr) - if err != nil { - return nil, fmt.Errorf("unable to decode peer id: %w", err) - } - - stream, err := c.host.NewStream(c.ctx, pid, ServiceProto) - if err != nil { - return nil, fmt.Errorf("unable to connect to peer: %w", err) - } - - go c.streamListener(stream) - - return stream, nil -} - -func (c *client) streamListener(s inet.Stream) { - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - record := &pb.RegistrationRecord{} - - for { - err := r.ReadMsg(record) - if err != nil { - log.Errorf("unable to decode message: %s", err.Error()) - return - } - - pid, err := peer.Decode(record.Id) - if err != nil { - log.Warnf("invalid peer id: %s", err.Error()) - continue - } - - maddrs := make([]multiaddr.Multiaddr, len(record.Addrs)) - for i, addrBytes := range record.Addrs { - maddrs[i], err = multiaddr.NewMultiaddrBytes(addrBytes) - if err != nil { - log.Warnf("invalid multiaddr: %s", err.Error()) - continue - } - } - - c.mu.Lock() - subscriptions, ok := c.subscriptions[record.Ns] - if ok { - for _, subscription := range subscriptions { - subscription <- &Registration{ - Peer: peer.AddrInfo{ - ID: pid, - Addrs: maddrs, - }, - Ns: record.Ns, - Ttl: int(record.Ttl), - } - } - } - c.mu.Unlock() - } -} - -func (c *client) Subscribe(ctx context.Context, syncDetails string) (<-chan *Registration, error) { - ctxUUID, err := uuid.NewRandom() - if err != nil { - return nil, fmt.Errorf("unable to generate uuid: %w", err) - } - - psDetails := &PubSubSubscriptionDetails{} - - err = json.Unmarshal([]byte(syncDetails), psDetails) - if err != nil { - return nil, fmt.Errorf("unable to decode json: %w", err) - } - - s, err := c.getStreamToPeer(psDetails.PeerID) - if err != nil { - return nil, fmt.Errorf("unable to get stream to peer: %w", err) - } - - w := ggio.NewDelimitedWriter(s) - - err = w.WriteMsg(&pb.Message{ - Type: pb.Message_DISCOVER_SUBSCRIBE, - DiscoverSubscribe: &pb.Message_DiscoverSubscribe{ - Ns: psDetails.ChannelName, - }}) - if err != nil { - return nil, fmt.Errorf("unable to query server") - } - - ch := make(chan *Registration) - c.mu.Lock() - if _, ok := c.subscriptions[psDetails.ChannelName]; !ok { - c.subscriptions[psDetails.ChannelName] = map[string]chan *Registration{} - } - - c.subscriptions[psDetails.ChannelName][ctxUUID.String()] = ch - c.mu.Unlock() - - go func() { - <-ctx.Done() - c.mu.Lock() - delete(c.subscriptions[psDetails.ChannelName], ctxUUID.String()) - c.mu.Unlock() - close(ch) - }() - - return ch, nil -} - -func (c *client) GetServiceType() string { - return ServiceType -} - -var _ RendezvousSyncClient = (*client)(nil) diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/sync_inmem_provider.go b/vendor/github.com/berty/go-libp2p-rendezvous/sync_inmem_provider.go deleted file mode 100644 index 970ed1dc5..000000000 --- a/vendor/github.com/berty/go-libp2p-rendezvous/sync_inmem_provider.go +++ /dev/null @@ -1,156 +0,0 @@ -package rendezvous - -import ( - "encoding/json" - "fmt" - "sync" - "time" - - pb "github.com/berty/go-libp2p-rendezvous/pb" - ggio "github.com/gogo/protobuf/io" - "github.com/libp2p/go-libp2p/core/host" - inet "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/core/protocol" -) - -const ( - ServiceType = "inmem" - ServiceProto = protocol.ID("/rendezvous/sync/inmem/1.0.0") -) - -type PubSub struct { - mu sync.RWMutex - host host.Host - topics map[string]*PubSubSubscribers -} - -type PubSubSubscribers struct { - mu sync.RWMutex - subscribers map[peer.ID]ggio.Writer - lastAnnouncement *pb.RegistrationRecord -} - -type PubSubSubscriptionDetails struct { - PeerID string - ChannelName string -} - -func NewSyncInMemProvider(host host.Host) (*PubSub, error) { - ps := &PubSub{ - host: host, - topics: map[string]*PubSubSubscribers{}, - } - - ps.Listen() - - return ps, nil -} - -func (ps *PubSub) Subscribe(ns string) (syncDetails string, err error) { - details, err := json.Marshal(&PubSubSubscriptionDetails{ - PeerID: ps.host.ID().String(), - ChannelName: ns, - }) - - if err != nil { - return "", fmt.Errorf("unable to marshal subscription details: %w", err) - } - - return string(details), nil -} - -func (ps *PubSub) GetServiceType() string { - return ServiceType -} - -func (ps *PubSub) getOrCreateTopic(ns string) *PubSubSubscribers { - ps.mu.Lock() - defer ps.mu.Unlock() - - if subscribers, ok := ps.topics[ns]; ok { - return subscribers - } - - ps.topics[ns] = &PubSubSubscribers{ - subscribers: map[peer.ID]ggio.Writer{}, - lastAnnouncement: nil, - } - return ps.topics[ns] -} - -func (ps *PubSub) Register(pid peer.ID, ns string, addrs [][]byte, ttlAsSeconds int, counter uint64) { - topic := ps.getOrCreateTopic(ns) - dataToSend := &pb.RegistrationRecord{ - Id: pid.String(), - Addrs: addrs, - Ns: ns, - Ttl: time.Now().Add(time.Duration(ttlAsSeconds) * time.Second).UnixMilli(), - } - - topic.mu.Lock() - topic.lastAnnouncement = dataToSend - toNotify := topic.subscribers - for _, stream := range toNotify { - if err := stream.WriteMsg(dataToSend); err != nil { - log.Errorf("unable to notify rendezvous data update: %s", err.Error()) - } - } - topic.mu.Unlock() -} - -func (ps *PubSub) Unregister(p peer.ID, ns string) { - // TODO: unsupported -} - -func (ps *PubSub) Listen() { - ps.host.SetStreamHandler(ServiceProto, ps.handleStream) -} - -func (ps *PubSub) handleStream(s inet.Stream) { - defer s.Reset() - - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) - - subscribedTopics := map[string]struct{}{} - - for { - var req pb.Message - - err := r.ReadMsg(&req) - if err != nil { - for ns := range subscribedTopics { - topic := ps.getOrCreateTopic(ns) - topic.mu.Lock() - delete(topic.subscribers, s.Conn().RemotePeer()) - topic.mu.Unlock() - } - return - } - - if req.Type != pb.Message_DISCOVER_SUBSCRIBE { - continue - } - - topic := ps.getOrCreateTopic(req.DiscoverSubscribe.Ns) - topic.mu.Lock() - if _, ok := topic.subscribers[s.Conn().RemotePeer()]; ok { - topic.mu.Unlock() - continue - } - - topic.subscribers[s.Conn().RemotePeer()] = w - subscribedTopics[req.DiscoverSubscribe.Ns] = struct{}{} - lastAnnouncement := topic.lastAnnouncement - if lastAnnouncement != nil { - if err := w.WriteMsg(lastAnnouncement); err != nil { - log.Errorf("unable to write announcement: %s", err.Error()) - } - } - topic.mu.Unlock() - } -} - -var _ RendezvousSync = (*PubSub)(nil) -var _ RendezvousSyncSubscribable = (*PubSub)(nil) diff --git a/vendor/github.com/gogo/protobuf/io/full.go b/vendor/github.com/gogo/protobuf/io/full.go deleted file mode 100644 index 550726a32..000000000 --- a/vendor/github.com/gogo/protobuf/io/full.go +++ /dev/null @@ -1,102 +0,0 @@ -// Protocol Buffers for Go with Gadgets -// -// Copyright (c) 2013, The GoGo Authors. All rights reserved. -// http://github.com/gogo/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package io - -import ( - "github.com/gogo/protobuf/proto" - "io" -) - -func NewFullWriter(w io.Writer) WriteCloser { - return &fullWriter{w, nil} -} - -type fullWriter struct { - w io.Writer - buffer []byte -} - -func (this *fullWriter) WriteMsg(msg proto.Message) (err error) { - var data []byte - if m, ok := msg.(marshaler); ok { - n, ok := getSize(m) - if !ok { - data, err = proto.Marshal(msg) - if err != nil { - return err - } - } - if n >= len(this.buffer) { - this.buffer = make([]byte, n) - } - _, err = m.MarshalTo(this.buffer) - if err != nil { - return err - } - data = this.buffer[:n] - } else { - data, err = proto.Marshal(msg) - if err != nil { - return err - } - } - _, err = this.w.Write(data) - return err -} - -func (this *fullWriter) Close() error { - if closer, ok := this.w.(io.Closer); ok { - return closer.Close() - } - return nil -} - -type fullReader struct { - r io.Reader - buf []byte -} - -func NewFullReader(r io.Reader, maxSize int) ReadCloser { - return &fullReader{r, make([]byte, maxSize)} -} - -func (this *fullReader) ReadMsg(msg proto.Message) error { - length, err := this.r.Read(this.buf) - if err != nil { - return err - } - return proto.Unmarshal(this.buf[:length], msg) -} - -func (this *fullReader) Close() error { - if closer, ok := this.r.(io.Closer); ok { - return closer.Close() - } - return nil -} diff --git a/vendor/github.com/gogo/protobuf/io/io.go b/vendor/github.com/gogo/protobuf/io/io.go deleted file mode 100644 index 6dca519a1..000000000 --- a/vendor/github.com/gogo/protobuf/io/io.go +++ /dev/null @@ -1,70 +0,0 @@ -// Protocol Buffers for Go with Gadgets -// -// Copyright (c) 2013, The GoGo Authors. All rights reserved. -// http://github.com/gogo/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package io - -import ( - "github.com/gogo/protobuf/proto" - "io" -) - -type Writer interface { - WriteMsg(proto.Message) error -} - -type WriteCloser interface { - Writer - io.Closer -} - -type Reader interface { - ReadMsg(msg proto.Message) error -} - -type ReadCloser interface { - Reader - io.Closer -} - -type marshaler interface { - MarshalTo(data []byte) (n int, err error) -} - -func getSize(v interface{}) (int, bool) { - if sz, ok := v.(interface { - Size() (n int) - }); ok { - return sz.Size(), true - } else if sz, ok := v.(interface { - ProtoSize() (n int) - }); ok { - return sz.ProtoSize(), true - } else { - return 0, false - } -} diff --git a/vendor/github.com/gogo/protobuf/io/uint32.go b/vendor/github.com/gogo/protobuf/io/uint32.go deleted file mode 100644 index 233b90924..000000000 --- a/vendor/github.com/gogo/protobuf/io/uint32.go +++ /dev/null @@ -1,138 +0,0 @@ -// Protocol Buffers for Go with Gadgets -// -// Copyright (c) 2013, The GoGo Authors. All rights reserved. -// http://github.com/gogo/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package io - -import ( - "encoding/binary" - "io" - - "github.com/gogo/protobuf/proto" -) - -const uint32BinaryLen = 4 - -func NewUint32DelimitedWriter(w io.Writer, byteOrder binary.ByteOrder) WriteCloser { - return &uint32Writer{w, byteOrder, nil, make([]byte, uint32BinaryLen)} -} - -func NewSizeUint32DelimitedWriter(w io.Writer, byteOrder binary.ByteOrder, size int) WriteCloser { - return &uint32Writer{w, byteOrder, make([]byte, size), make([]byte, uint32BinaryLen)} -} - -type uint32Writer struct { - w io.Writer - byteOrder binary.ByteOrder - buffer []byte - lenBuf []byte -} - -func (this *uint32Writer) writeFallback(msg proto.Message) error { - data, err := proto.Marshal(msg) - if err != nil { - return err - } - - length := uint32(len(data)) - this.byteOrder.PutUint32(this.lenBuf, length) - if _, err = this.w.Write(this.lenBuf); err != nil { - return err - } - _, err = this.w.Write(data) - return err -} - -func (this *uint32Writer) WriteMsg(msg proto.Message) error { - m, ok := msg.(marshaler) - if !ok { - return this.writeFallback(msg) - } - - n, ok := getSize(m) - if !ok { - return this.writeFallback(msg) - } - - size := n + uint32BinaryLen - if size > len(this.buffer) { - this.buffer = make([]byte, size) - } - - this.byteOrder.PutUint32(this.buffer, uint32(n)) - if _, err := m.MarshalTo(this.buffer[uint32BinaryLen:]); err != nil { - return err - } - - _, err := this.w.Write(this.buffer[:size]) - return err -} - -func (this *uint32Writer) Close() error { - if closer, ok := this.w.(io.Closer); ok { - return closer.Close() - } - return nil -} - -type uint32Reader struct { - r io.Reader - byteOrder binary.ByteOrder - lenBuf []byte - buf []byte - maxSize int -} - -func NewUint32DelimitedReader(r io.Reader, byteOrder binary.ByteOrder, maxSize int) ReadCloser { - return &uint32Reader{r, byteOrder, make([]byte, 4), nil, maxSize} -} - -func (this *uint32Reader) ReadMsg(msg proto.Message) error { - if _, err := io.ReadFull(this.r, this.lenBuf); err != nil { - return err - } - length32 := this.byteOrder.Uint32(this.lenBuf) - length := int(length32) - if length < 0 || length > this.maxSize { - return io.ErrShortBuffer - } - if length > len(this.buf) { - this.buf = make([]byte, length) - } - _, err := io.ReadFull(this.r, this.buf[:length]) - if err != nil { - return err - } - return proto.Unmarshal(this.buf[:length], msg) -} - -func (this *uint32Reader) Close() error { - if closer, ok := this.r.(io.Closer); ok { - return closer.Close() - } - return nil -} diff --git a/vendor/github.com/gogo/protobuf/io/varint.go b/vendor/github.com/gogo/protobuf/io/varint.go deleted file mode 100644 index e81e296e4..000000000 --- a/vendor/github.com/gogo/protobuf/io/varint.go +++ /dev/null @@ -1,133 +0,0 @@ -// Protocol Buffers for Go with Gadgets -// -// Copyright (c) 2013, The GoGo Authors. All rights reserved. -// http://github.com/gogo/protobuf -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -package io - -import ( - "bufio" - "encoding/binary" - "errors" - "github.com/gogo/protobuf/proto" - "io" -) - -var ( - errSmallBuffer = errors.New("Buffer Too Small") - errLargeValue = errors.New("Value is Larger than 64 bits") -) - -func NewDelimitedWriter(w io.Writer) WriteCloser { - return &varintWriter{w, make([]byte, binary.MaxVarintLen64), nil} -} - -type varintWriter struct { - w io.Writer - lenBuf []byte - buffer []byte -} - -func (this *varintWriter) WriteMsg(msg proto.Message) (err error) { - var data []byte - if m, ok := msg.(marshaler); ok { - n, ok := getSize(m) - if ok { - if n+binary.MaxVarintLen64 >= len(this.buffer) { - this.buffer = make([]byte, n+binary.MaxVarintLen64) - } - lenOff := binary.PutUvarint(this.buffer, uint64(n)) - _, err = m.MarshalTo(this.buffer[lenOff:]) - if err != nil { - return err - } - _, err = this.w.Write(this.buffer[:lenOff+n]) - return err - } - } - - // fallback - data, err = proto.Marshal(msg) - if err != nil { - return err - } - length := uint64(len(data)) - n := binary.PutUvarint(this.lenBuf, length) - _, err = this.w.Write(this.lenBuf[:n]) - if err != nil { - return err - } - _, err = this.w.Write(data) - return err -} - -func (this *varintWriter) Close() error { - if closer, ok := this.w.(io.Closer); ok { - return closer.Close() - } - return nil -} - -func NewDelimitedReader(r io.Reader, maxSize int) ReadCloser { - var closer io.Closer - if c, ok := r.(io.Closer); ok { - closer = c - } - return &varintReader{bufio.NewReader(r), nil, maxSize, closer} -} - -type varintReader struct { - r *bufio.Reader - buf []byte - maxSize int - closer io.Closer -} - -func (this *varintReader) ReadMsg(msg proto.Message) error { - length64, err := binary.ReadUvarint(this.r) - if err != nil { - return err - } - length := int(length64) - if length < 0 || length > this.maxSize { - return io.ErrShortBuffer - } - if len(this.buf) < length { - this.buf = make([]byte, length) - } - buf := this.buf[:length] - if _, err := io.ReadFull(this.r, buf); err != nil { - return err - } - return proto.Unmarshal(buf, msg) -} - -func (this *varintReader) Close() error { - if this.closer != nil { - return this.closer.Close() - } - return nil -} diff --git a/vendor/github.com/rjeczalik/notify/.travis.yml b/vendor/github.com/rjeczalik/notify/.travis.yml index 9fbeef655..720f6613c 100644 --- a/vendor/github.com/rjeczalik/notify/.travis.yml +++ b/vendor/github.com/rjeczalik/notify/.travis.yml @@ -2,7 +2,8 @@ language: go go: - 1.10.x - - tip + - 1.11.x + - master os: - linux diff --git a/vendor/github.com/rjeczalik/notify/README.md b/vendor/github.com/rjeczalik/notify/README.md index ad743b2a2..0ff880e36 100644 --- a/vendor/github.com/rjeczalik/notify/README.md +++ b/vendor/github.com/rjeczalik/notify/README.md @@ -18,5 +18,6 @@ Filesystem event notification library on steroids. (under active development) - [github.com/rjeczalik/cmd/notify](https://godoc.org/github.com/rjeczalik/cmd/notify) - [github.com/cortesi/devd](https://github.com/cortesi/devd) - [github.com/cortesi/modd](https://github.com/cortesi/modd) -- [github.com/syncthing/syncthing-inotify](https://github.com/syncthing/syncthing-inotify) +- [github.com/syncthing/syncthing](https://github.com/syncthing/syncthing) - [github.com/OrlovEvgeny/TinyJPG](https://github.com/OrlovEvgeny/TinyJPG) +- [github.com/mitranim/gow](https://github.com/mitranim/gow) diff --git a/vendor/github.com/rjeczalik/notify/debug_debug.go b/vendor/github.com/rjeczalik/notify/debug_debug.go index 9d234cedd..e64128975 100644 --- a/vendor/github.com/rjeczalik/notify/debug_debug.go +++ b/vendor/github.com/rjeczalik/notify/debug_debug.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build debug // +build debug package notify diff --git a/vendor/github.com/rjeczalik/notify/debug_nodebug.go b/vendor/github.com/rjeczalik/notify/debug_nodebug.go index 9ebf880d8..724fe7aa9 100644 --- a/vendor/github.com/rjeczalik/notify/debug_nodebug.go +++ b/vendor/github.com/rjeczalik/notify/debug_nodebug.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build !debug // +build !debug package notify diff --git a/vendor/github.com/rjeczalik/notify/event.go b/vendor/github.com/rjeczalik/notify/event.go index c12884197..4b4b10220 100644 --- a/vendor/github.com/rjeczalik/notify/event.go +++ b/vendor/github.com/rjeczalik/notify/event.go @@ -57,54 +57,54 @@ func (e Event) String() string { // // The value of Sys if system-dependent and can be nil. // -// Sys +// # Sys // // Under Darwin (FSEvents) Sys() always returns a non-nil *notify.FSEvent value, // which is defined as: // -// type FSEvent struct { -// Path string // real path of the file or directory -// ID uint64 // ID of the event (FSEventStreamEventId) -// Flags uint32 // joint FSEvents* flags (FSEventStreamEventFlags) -// } +// type FSEvent struct { +// Path string // real path of the file or directory +// ID uint64 // ID of the event (FSEventStreamEventId) +// Flags uint32 // joint FSEvents* flags (FSEventStreamEventFlags) +// } // // For possible values of Flags see Darwin godoc for notify or FSEvents // documentation for FSEventStreamEventFlags constants: // -// https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/index.html#//apple_ref/doc/constant_group/FSEventStreamEventFlags +// https://developer.apple.com/library/mac/documentation/Darwin/Reference/FSEvents_Ref/index.html#//apple_ref/doc/constant_group/FSEventStreamEventFlags // // Under Linux (inotify) Sys() always returns a non-nil *unix.InotifyEvent // value, defined as: // -// type InotifyEvent struct { -// Wd int32 // Watch descriptor -// Mask uint32 // Mask describing event -// Cookie uint32 // Unique cookie associating related events (for rename(2)) -// Len uint32 // Size of name field -// Name [0]uint8 // Optional null-terminated name -// } +// type InotifyEvent struct { +// Wd int32 // Watch descriptor +// Mask uint32 // Mask describing event +// Cookie uint32 // Unique cookie associating related events (for rename(2)) +// Len uint32 // Size of name field +// Name [0]uint8 // Optional null-terminated name +// } // // More information about inotify masks and the usage of inotify_event structure // can be found at: // -// http://man7.org/linux/man-pages/man7/inotify.7.html +// http://man7.org/linux/man-pages/man7/inotify.7.html // // Under Darwin, DragonFlyBSD, FreeBSD, NetBSD, OpenBSD (kqueue) Sys() always // returns a non-nil *notify.Kevent value, which is defined as: // -// type Kevent struct { -// Kevent *syscall.Kevent_t // Kevent is a kqueue specific structure -// FI os.FileInfo // FI describes file/dir -// } +// type Kevent struct { +// Kevent *syscall.Kevent_t // Kevent is a kqueue specific structure +// FI os.FileInfo // FI describes file/dir +// } // // More information about syscall.Kevent_t can be found at: // -// https://www.freebsd.org/cgi/man.cgi?query=kqueue +// https://www.freebsd.org/cgi/man.cgi?query=kqueue // // Under Windows (ReadDirectoryChangesW) Sys() always returns nil. The documentation // of watcher's WinAPI function can be found at: // -// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465%28v=vs.85%29.aspx +// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465%28v=vs.85%29.aspx type EventInfo interface { Event() Event // event value for the filesystem action Path() string // real path of the file or directory diff --git a/vendor/github.com/rjeczalik/notify/event_fen.go b/vendor/github.com/rjeczalik/notify/event_fen.go index 767f04fa8..1be3922d5 100644 --- a/vendor/github.com/rjeczalik/notify/event_fen.go +++ b/vendor/github.com/rjeczalik/notify/event_fen.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build solaris +//go:build solaris || illumos +// +build solaris illumos package notify diff --git a/vendor/github.com/rjeczalik/notify/event_fsevents.go b/vendor/github.com/rjeczalik/notify/event_fsevents.go index 6ded80b2c..c3edfec8d 100644 --- a/vendor/github.com/rjeczalik/notify/event_fsevents.go +++ b/vendor/github.com/rjeczalik/notify/event_fsevents.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build darwin,!kqueue +//go:build darwin && !kqueue && cgo +// +build darwin,!kqueue,cgo package notify diff --git a/vendor/github.com/rjeczalik/notify/event_inotify.go b/vendor/github.com/rjeczalik/notify/event_inotify.go index 1f32bb73e..cea42ecb3 100644 --- a/vendor/github.com/rjeczalik/notify/event_inotify.go +++ b/vendor/github.com/rjeczalik/notify/event_inotify.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build linux // +build linux package notify diff --git a/vendor/github.com/rjeczalik/notify/event_kqueue.go b/vendor/github.com/rjeczalik/notify/event_kqueue.go index 422ac87f6..866118538 100644 --- a/vendor/github.com/rjeczalik/notify/event_kqueue.go +++ b/vendor/github.com/rjeczalik/notify/event_kqueue.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build darwin,kqueue dragonfly freebsd netbsd openbsd +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd +// +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd package notify diff --git a/vendor/github.com/rjeczalik/notify/event_readdcw.go b/vendor/github.com/rjeczalik/notify/event_readdcw.go index f7b82de0c..4ae3a063f 100644 --- a/vendor/github.com/rjeczalik/notify/event_readdcw.go +++ b/vendor/github.com/rjeczalik/notify/event_readdcw.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify diff --git a/vendor/github.com/rjeczalik/notify/event_stub.go b/vendor/github.com/rjeczalik/notify/event_stub.go index faac7c7cb..68edc7e2a 100644 --- a/vendor/github.com/rjeczalik/notify/event_stub.go +++ b/vendor/github.com/rjeczalik/notify/event_stub.go @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows -// +build !kqueue,!solaris +//go:build !darwin && !linux && !freebsd && !dragonfly && !netbsd && !openbsd && !windows && !kqueue && !solaris && !illumos +// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows,!kqueue,!solaris,!illumos package notify diff --git a/vendor/github.com/rjeczalik/notify/event_trigger.go b/vendor/github.com/rjeczalik/notify/event_trigger.go index 94470fd37..6d8cd1c3e 100644 --- a/vendor/github.com/rjeczalik/notify/event_trigger.go +++ b/vendor/github.com/rjeczalik/notify/event_trigger.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build darwin,kqueue dragonfly freebsd netbsd openbsd solaris +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd || solaris || illumos +// +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd solaris illumos package notify diff --git a/vendor/github.com/rjeczalik/notify/node.go b/vendor/github.com/rjeczalik/notify/node.go index aced8b9c4..ad7d04f25 100644 --- a/vendor/github.com/rjeczalik/notify/node.go +++ b/vendor/github.com/rjeczalik/notify/node.go @@ -6,7 +6,7 @@ package notify import ( "errors" - "io/ioutil" + "io/fs" "os" "path/filepath" ) @@ -49,7 +49,7 @@ func (nd node) addchild(name, base string) node { } func (nd node) Add(name string) node { - i := indexbase(nd.Name, name) + i := indexrel(nd.Name, name) if i == -1 { return node{} } @@ -78,12 +78,12 @@ Traverse: } // TODO(rjeczalik): tolerate open failures - add failed names to // AddDirError and notify users which names are not added to the tree. - fi, err := ioutil.ReadDir(nd.Name) + fi, err := os.ReadDir(nd.Name) if err != nil { return err } for _, fi := range fi { - if fi.Mode()&(os.ModeSymlink|os.ModeDir) == os.ModeDir { + if fi.Type()&(fs.ModeSymlink|fs.ModeDir) == fs.ModeDir { name := filepath.Join(nd.Name, fi.Name()) stack = append(stack, nd.addchild(name, name[len(nd.Name)+1:])) } @@ -93,7 +93,7 @@ Traverse: } func (nd node) Get(name string) (node, error) { - i := indexbase(nd.Name, name) + i := indexrel(nd.Name, name) if i == -1 { return node{}, errnotexist(name) } @@ -111,7 +111,7 @@ func (nd node) Get(name string) (node, error) { } func (nd node) Del(name string) error { - i := indexbase(nd.Name, name) + i := indexrel(nd.Name, name) if i == -1 { return errnotexist(name) } @@ -122,13 +122,13 @@ func (nd node) Del(name string) error { return errnotexist(name[:i+j]) } stack = append(stack, nd) + i += j + 1 } - if nd, ok = nd.Child[name[i:]]; !ok { + if _, ok = nd.Child[name[i:]]; !ok { return errnotexist(name) } - nd.Child = nil - nd.Watch = nil - for name, i = base(nd.Name), len(stack); i != 0; name, i = base(nd.Name), i-1 { + delete(nd.Child, name[i:]) + for name, i = name[i:], len(stack); i != 0; name, i = base(nd.Name), i-1 { nd = stack[i-1] if nd := nd.Child[name]; len(nd.Watch) > 1 || len(nd.Child) != 0 { break @@ -167,7 +167,7 @@ Traverse: } func (nd node) WalkPath(name string, fn walkPathFunc) error { - i := indexbase(nd.Name, name) + i := indexrel(nd.Name, name) if i == -1 { return errnotexist(name) } diff --git a/vendor/github.com/rjeczalik/notify/notify.go b/vendor/github.com/rjeczalik/notify/notify.go index 7d2eec3a2..aa57660b9 100644 --- a/vendor/github.com/rjeczalik/notify/notify.go +++ b/vendor/github.com/rjeczalik/notify/notify.go @@ -40,20 +40,20 @@ var defaultTree = newTree() // watchpoint expands its event set. The only way to shrink it, is to call // Stop on its channel. // -// Calling Watch with empty event list does expand nor shrink watchpoint's event -// set. If c is the first channel to listen for events on the given path, Watch -// will seamlessly create a watch on the filesystem. +// Calling Watch with empty event list does not expand nor shrink watchpoint's +// event set. If c is the first channel to listen for events on the given path, +// Watch will seamlessly create a watch on the filesystem. // // Notify dispatches copies of single filesystem event to all channels registered // for each path. If a single filesystem event contains multiple coalesced events, // each of them is dispatched separately. E.g. the following filesystem change: // -// ~ $ echo Hello > Notify.txt +// ~ $ echo Hello > Notify.txt // // dispatches two events - notify.Create and notify.Write. However, it may depend // on the underlying watcher implementation whether OS reports both of them. // -// Windows and recursive watches +// # Windows and recursive watches // // If a directory which path was used to create recursive watch under Windows // gets deleted, the OS will not report such event. It is advised to keep in diff --git a/vendor/github.com/rjeczalik/notify/tree_nonrecursive.go b/vendor/github.com/rjeczalik/notify/tree_nonrecursive.go index dfa72d1d2..6e233408a 100644 --- a/vendor/github.com/rjeczalik/notify/tree_nonrecursive.go +++ b/vendor/github.com/rjeczalik/notify/tree_nonrecursive.go @@ -65,7 +65,7 @@ func (t *nonrecursiveTree) dispatch(c <-chan EventInfo) { } t.rw.RUnlock() // If the event describes newly leaf directory created within - if !isrec || ei.Event() != Create { + if !isrec || ei.Event()&(Create|Remove) == 0 { return } if ok, err := ei.(isDirer).isDir(); !ok || err != nil { @@ -79,9 +79,23 @@ func (t *nonrecursiveTree) dispatch(c <-chan EventInfo) { // internal TODO(rjeczalik) func (t *nonrecursiveTree) internal(rec <-chan EventInfo) { for ei := range rec { + t.rw.Lock() + if ei.Event() == Remove { + nd, err := t.root.Get(ei.Path()) + if err != nil { + t.rw.Unlock() + continue + } + t.walkWatchpoint(nd, func(_ Event, nd node) error { + t.w.Unwatch(nd.Name) + return nil + }) + t.root.Del(ei.Path()) + t.rw.Unlock() + continue + } var nd node var eset = internal - t.rw.Lock() t.root.WalkPath(ei.Path(), func(it node, _ bool) error { if e := it.Watch[t.rec]; e != 0 && e > eset { eset = e @@ -93,7 +107,10 @@ func (t *nonrecursiveTree) internal(rec <-chan EventInfo) { t.rw.Unlock() continue } - err := nd.Add(ei.Path()).AddDir(t.recFunc(eset)) + if ei.Path() != nd.Name { + nd = nd.Add(ei.Path()) + } + err := nd.AddDir(t.recFunc(eset)) t.rw.Unlock() if err != nil { dbgprintf("internal(%p) error: %v", rec, err) diff --git a/vendor/github.com/rjeczalik/notify/util.go b/vendor/github.com/rjeczalik/notify/util.go index 67e01fbbd..7b50b0c01 100644 --- a/vendor/github.com/rjeczalik/notify/util.go +++ b/vendor/github.com/rjeczalik/notify/util.go @@ -123,10 +123,12 @@ func base(s string) string { return s } -func indexbase(root, name string) int { - if n, m := len(root), len(name); m >= n && name[:n] == root && - (n == m || name[n] == os.PathSeparator) { - return min(n+1, m) +// indexrel returns the index of the first char of name that is +// below/relative to root. It returns -1 if name is not a child of root. +func indexrel(root, name string) int { + if n, m := len(root), len(name); m > n && name[:n] == root && + name[n] == os.PathSeparator { + return n + 1 } return -1 } diff --git a/vendor/github.com/rjeczalik/notify/watcher_fen.go b/vendor/github.com/rjeczalik/notify/watcher_fen.go index dfe77f2f1..114ec7f75 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_fen.go +++ b/vendor/github.com/rjeczalik/notify/watcher_fen.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build solaris +//go:build solaris || illumos +// +build solaris illumos package notify diff --git a/vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go b/vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go index 8ec8ead34..50f289dea 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go +++ b/vendor/github.com/rjeczalik/notify/watcher_fen_cgo.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build solaris +//go:build solaris || illumos +// +build solaris illumos package notify diff --git a/vendor/github.com/rjeczalik/notify/watcher_fsevents.go b/vendor/github.com/rjeczalik/notify/watcher_fsevents.go index 7d9b97b65..dab5286ef 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_fsevents.go +++ b/vendor/github.com/rjeczalik/notify/watcher_fsevents.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build darwin,!kqueue +//go:build darwin && !kqueue && cgo +// +build darwin,!kqueue,cgo package notify @@ -55,35 +56,34 @@ type watch struct { // Example format: // -// ~ $ (trigger command) # (event set) -> (effective event set) +// ~ $ (trigger command) # (event set) -> (effective event set) // // Heuristics: // // 1. Create event is removed when it was present in previous event set. // Example: // -// ~ $ echo > file # Create|Write -> Create|Write -// ~ $ echo > file # Create|Write|InodeMetaMod -> Write|InodeMetaMod +// ~ $ echo > file # Create|Write -> Create|Write +// ~ $ echo > file # Create|Write|InodeMetaMod -> Write|InodeMetaMod // // 2. Remove event is removed if it was present in previouse event set. // Example: // -// ~ $ touch file # Create -> Create -// ~ $ rm file # Create|Remove -> Remove -// ~ $ touch file # Create|Remove -> Create +// ~ $ touch file # Create -> Create +// ~ $ rm file # Create|Remove -> Remove +// ~ $ touch file # Create|Remove -> Create // // 3. Write event is removed if not followed by InodeMetaMod on existing // file. Example: // -// ~ $ echo > file # Create|Write -> Create|Write -// ~ $ chmod +x file # Create|Write|ChangeOwner -> ChangeOwner +// ~ $ echo > file # Create|Write -> Create|Write +// ~ $ chmod +x file # Create|Write|ChangeOwner -> ChangeOwner // // 4. Write&InodeMetaMod is removed when effective event set contain Remove event. // Example: // -// ~ $ echo > file # Write|InodeMetaMod -> Write|InodeMetaMod -// ~ $ rm file # Remove|Write|InodeMetaMod -> Remove -// +// ~ $ echo > file # Write|InodeMetaMod -> Write|InodeMetaMod +// ~ $ rm file # Remove|Write|InodeMetaMod -> Remove func (w *watch) strip(base string, set uint32) uint32 { const ( write = FSEventsModified | FSEventsInodeMetaMod @@ -129,7 +129,7 @@ func (w *watch) Dispatch(ev []FSEvent) { } dbgprintf("%v (0x%x) (%s, i=%d, ID=%d, len=%d)\n", Event(ev[i].Flags), ev[i].Flags, ev[i].Path, i, ev[i].ID, len(ev)) - if ev[i].Flags&failure != 0 { + if ev[i].Flags&failure != 0 && failure&events == 0 { // TODO(rjeczalik): missing error handling continue } @@ -258,13 +258,13 @@ func (fse *fsevents) RecursiveUnwatch(path string) error { return fse.unwatch(path) } -// RecrusiveRewatch implements RecursiveWatcher interface. It fails: +// RecursiveRewatch implements RecursiveWatcher interface. It fails: // -// * with errNotWatched when the given path is not being watched -// * with errInvalidEventSet when oldevent does not match the current event set -// * with errAlreadyWatched when watch-point given by the oldpath was meant to +// - with errNotWatched when the given path is not being watched +// - with errInvalidEventSet when oldevent does not match the current event set +// - with errAlreadyWatched when watch-point given by the oldpath was meant to // be relocated to newpath, but the newpath is already watched -// * a non-nil error when setting the watch-point with FSEvents fails +// - a non-nil error when setting the watch-point with FSEvents fails // // TODO(rjeczalik): Improve handling of watch-point relocation? See two TODOs // that follows. diff --git a/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go b/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go index cf0416c37..7cf7d71a9 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go +++ b/vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go @@ -2,16 +2,15 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build darwin,!kqueue +//go:build darwin && !kqueue && cgo +// +build darwin,!kqueue,cgo package notify /* #include +#include -typedef void (*CFRunLoopPerformCallBack)(void*); - -void gosource(void *); void gostream(uintptr_t, uintptr_t, size_t, uintptr_t, uintptr_t, uintptr_t); static FSEventStreamRef EventStreamCreate(FSEventStreamContext * context, uintptr_t info, CFArrayRef paths, FSEventStreamEventId since, CFTimeInterval latency, FSEventStreamCreateFlags flags) { @@ -26,7 +25,6 @@ import "C" import ( "errors" "os" - "runtime" "sync" "sync/atomic" "unsafe" @@ -41,16 +39,11 @@ var ( since = uint64(C.FSEventsGetCurrentEventId()) ) -var runloop C.CFRunLoopRef // global runloop which all streams are registered with -var wg sync.WaitGroup // used to wait until the runloop starts - -// source is used for synchronization purposes - it signals when runloop has -// started and is ready via the wg. It also serves purpose of a dummy source, -// thanks to it the runloop does not return as it also has at least one source -// registered. -var source = C.CFRunLoopSourceCreate(C.kCFAllocatorDefault, 0, &C.CFRunLoopSourceContext{ - perform: (C.CFRunLoopPerformCallBack)(C.gosource), -}) +// global dispatch queue which all streams are registered with +var q C.dispatch_queue_t = C.dispatch_queue_create( + C.CString("com.github.rjeczalik.notify"), + (C.dispatch_queue_attr_t)(C.DISPATCH_QUEUE_SERIAL), +) // Errors returned when FSEvents functions fail. var ( @@ -58,28 +51,6 @@ var ( errStart = os.NewSyscallError("FSEventStreamStart", errors.New("false")) ) -// initializes the global runloop and ensures any created stream awaits its -// readiness. -func init() { - wg.Add(1) - go func() { - // There is exactly one run loop per thread. Lock this goroutine to its - // thread to ensure that it's not rescheduled on a different thread while - // setting up the run loop. - runtime.LockOSThread() - runloop = C.CFRunLoopGetCurrent() - C.CFRunLoopAddSource(runloop, source, C.kCFRunLoopDefaultMode) - C.CFRunLoopRun() - panic("runloop has just unexpectedly stopped") - }() - C.CFRunLoopSourceSignal(source) -} - -//export gosource -func gosource(unsafe.Pointer) { - wg.Done() -} - //export gostream func gostream(_, info uintptr, n C.size_t, paths, flags, ids uintptr) { const ( @@ -142,8 +113,7 @@ func (r *streamFuncRegistry) delete(id uintptr) { delete(r.m, id) } -// Stream represents single watch-point which listens for events scheduled by -// the global runloop. +// Stream represents a single watch-point which listens for events scheduled on the global dispatch queue. type stream struct { path string ref C.FSEventStreamRef @@ -159,13 +129,12 @@ func newStream(path string, fn streamFunc) *stream { } } -// Start creates a FSEventStream for the given path and schedules it with -// global runloop. It's a nop if the stream was already started. +// Start creates a FSEventStream for the given path and schedules on the global dispatch queue. +// It's a nop if the stream was already started. func (s *stream) Start() error { if s.ref != nilstream { return nil } - wg.Wait() p := C.CFStringCreateWithCStringNoCopy(C.kCFAllocatorDefault, C.CString(s.path), C.kCFStringEncodingUTF8, C.kCFAllocatorDefault) path := C.CFArrayCreate(C.kCFAllocatorDefault, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil) ctx := C.FSEventStreamContext{} @@ -173,25 +142,22 @@ func (s *stream) Start() error { if ref == nilstream { return errCreate } - C.FSEventStreamScheduleWithRunLoop(ref, runloop, C.kCFRunLoopDefaultMode) + C.FSEventStreamSetDispatchQueue(ref, q) if C.FSEventStreamStart(ref) == C.Boolean(0) { C.FSEventStreamInvalidate(ref) return errStart } - C.CFRunLoopWakeUp(runloop) s.ref = ref return nil } -// Stop stops underlying FSEventStream and unregisters it from global runloop. +// Stop stops underlying FSEventStream and unregisters it from the global dispatch queue. func (s *stream) Stop() { if s.ref == nilstream { return } - wg.Wait() C.FSEventStreamStop(s.ref) C.FSEventStreamInvalidate(s.ref) - C.CFRunLoopWakeUp(runloop) s.ref = nilstream streamFuncs.delete(s.info) } diff --git a/vendor/github.com/rjeczalik/notify/watcher_inotify.go b/vendor/github.com/rjeczalik/notify/watcher_inotify.go index d082baca0..02b432844 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_inotify.go +++ b/vendor/github.com/rjeczalik/notify/watcher_inotify.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build linux // +build linux package notify @@ -93,20 +94,14 @@ func (i *inotify) watch(path string, e Event) (err error) { if err != nil { return } - i.RLock() - wd := i.m[int32(iwd)] - i.RUnlock() - if wd == nil { - i.Lock() - if i.m[int32(iwd)] == nil { - i.m[int32(iwd)] = &watched{path: path, mask: uint32(e)} - } - i.Unlock() + i.Lock() + if wd, ok := i.m[int32(iwd)]; !ok { + i.m[int32(iwd)] = &watched{path: path, mask: uint32(e)} } else { - i.Lock() + wd.path = path wd.mask = uint32(e) - i.Unlock() } + i.Unlock() return nil } diff --git a/vendor/github.com/rjeczalik/notify/watcher_kqueue.go b/vendor/github.com/rjeczalik/notify/watcher_kqueue.go index 22e3c2c4a..715edfb25 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_kqueue.go +++ b/vendor/github.com/rjeczalik/notify/watcher_kqueue.go @@ -2,11 +2,13 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build darwin,kqueue dragonfly freebsd netbsd openbsd +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd +// +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd package notify import ( + "errors" "fmt" "os" "syscall" @@ -57,6 +59,17 @@ func (k *kq) Close() error { func (*kq) NewWatched(p string, fi os.FileInfo) (*watched, error) { fd, err := syscall.Open(p, syscall.O_NONBLOCK|syscall.O_RDONLY, 0) if err != nil { + // BSDs can't open symlinks and return an error if the symlink + // cannot be followed - ignore it instead of failing. See e.g. + // https://github.com/libinotify-kqueue/libinotify-kqueue/blob/a822c8f1d75404fe3132f695a898dcd42fe8afbc/patches/freebsd11-O_SYMLINK.patch + if os.IsNotExist(err) && fi.Mode()&os.ModeSymlink == os.ModeSymlink { + return nil, errSkip + } + // FreeBSD can't open unix domain sockets and returns "operation not supported" error. + // Ignore it instead of failing. + if errors.Is(err, syscall.ENOTSUP) && fi.Mode()&os.ModeSocket == os.ModeSocket { + return nil, errSkip + } return nil, err } return &watched{ diff --git a/vendor/github.com/rjeczalik/notify/watcher_notimplemented.go b/vendor/github.com/rjeczalik/notify/watcher_notimplemented.go index bb0672fd8..9e5176692 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_notimplemented.go +++ b/vendor/github.com/rjeczalik/notify/watcher_notimplemented.go @@ -2,8 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows -// +build !kqueue,!solaris +//go:build !darwin && !linux && !freebsd && !dragonfly && !netbsd && !openbsd && !windows && !kqueue && !solaris && !illumos +// +build !darwin,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!windows,!kqueue,!solaris,!illumos package notify diff --git a/vendor/github.com/rjeczalik/notify/watcher_readdcw.go b/vendor/github.com/rjeczalik/notify/watcher_readdcw.go index b69811a69..b0dee4126 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_readdcw.go +++ b/vendor/github.com/rjeczalik/notify/watcher_readdcw.go @@ -1,7 +1,8 @@ -// Copyright (c) 2014-2018 The Notify Authors. All rights reserved. +// Copyright (c) 2014-2020 The Notify Authors. All rights reserved. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify @@ -32,10 +33,11 @@ const ( ) // Filter used in current implementation was split into four segments: -// - bits 0-11 store ReadDirectoryChangesW filters, -// - bits 12-19 store File notify actions, -// - bits 20-27 store notify specific events and flags, -// - bits 28-31 store states which are used in loop's FSM. +// - bits 0-11 store ReadDirectoryChangesW filters, +// - bits 12-19 store File notify actions, +// - bits 20-27 store notify specific events and flags, +// - bits 28-31 store states which are used in loop's FSM. +// // Constants below are used as masks to retrieve only specific filter parts. const ( onlyNotifyChanges uint32 = 0x00000FFF @@ -358,11 +360,14 @@ func (r *readdcw) loop() { continue } overEx := (*overlappedEx)(unsafe.Pointer(overlapped)) - if n != 0 { + if overEx == nil || overEx.parent == nil { + dbgprintf("incomplete completion status transferred=%d, overlapped=%#v, key=%#b", n, overEx, key) + continue + } else if n != 0 { r.loopevent(n, overEx) - if err = overEx.parent.readDirChanges(); err != nil { - // TODO: error handling - } + } + if err = overEx.parent.readDirChanges(); err != nil { + // TODO: error handling } r.loopstate(overEx) } @@ -584,7 +589,9 @@ func decode(filter, action uint32) (Event, Event) { case syscall.FILE_ACTION_RENAMED_NEW_NAME: return gensys(filter, Rename, FileActionRenamedNewName) } - panic(`notify: cannot decode internal mask`) + dbgprintf("cannot decode internal mask: %d", action) + + return 0, 0 } // gensys decides whether the Windows action, system-independent event or both diff --git a/vendor/github.com/rjeczalik/notify/watcher_trigger.go b/vendor/github.com/rjeczalik/notify/watcher_trigger.go index 1ebe04829..7cd0824e3 100644 --- a/vendor/github.com/rjeczalik/notify/watcher_trigger.go +++ b/vendor/github.com/rjeczalik/notify/watcher_trigger.go @@ -2,7 +2,8 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -// +build darwin,kqueue dragonfly freebsd netbsd openbsd solaris +//go:build (darwin && kqueue) || (darwin && !cgo) || dragonfly || freebsd || netbsd || openbsd || solaris || illumos +// +build darwin,kqueue darwin,!cgo dragonfly freebsd netbsd openbsd solaris illumos // watcher_trigger is used for FEN and kqueue which behave similarly: // only files and dirs can be watched directly, but not files inside dirs. @@ -151,6 +152,9 @@ func (t *trg) singlewatch(p string, e Event, direct mode, fi os.FileInfo) (err e w, ok := t.pthLkp[p] if !ok { if w, err = t.t.NewWatched(p, fi); err != nil { + if err == errSkip { + err = nil + } return } } diff --git a/vendor/github.com/rjeczalik/notify/watchpoint_other.go b/vendor/github.com/rjeczalik/notify/watchpoint_other.go index 9bb381db7..d4269994e 100644 --- a/vendor/github.com/rjeczalik/notify/watchpoint_other.go +++ b/vendor/github.com/rjeczalik/notify/watchpoint_other.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build !windows // +build !windows package notify diff --git a/vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go b/vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go index 9fd1e1df3..49a9b9c87 100644 --- a/vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go +++ b/vendor/github.com/rjeczalik/notify/watchpoint_readdcw.go @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +//go:build windows // +build windows package notify diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/.gitattributes b/vendor/github.com/waku-org/go-libp2p-rendezvous/.gitattributes similarity index 100% rename from vendor/github.com/berty/go-libp2p-rendezvous/.gitattributes rename to vendor/github.com/waku-org/go-libp2p-rendezvous/.gitattributes diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/.gitignore b/vendor/github.com/waku-org/go-libp2p-rendezvous/.gitignore similarity index 100% rename from vendor/github.com/berty/go-libp2p-rendezvous/.gitignore rename to vendor/github.com/waku-org/go-libp2p-rendezvous/.gitignore diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/.golangci.yml b/vendor/github.com/waku-org/go-libp2p-rendezvous/.golangci.yml similarity index 100% rename from vendor/github.com/berty/go-libp2p-rendezvous/.golangci.yml rename to vendor/github.com/waku-org/go-libp2p-rendezvous/.golangci.yml diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/.releaserc b/vendor/github.com/waku-org/go-libp2p-rendezvous/.releaserc similarity index 100% rename from vendor/github.com/berty/go-libp2p-rendezvous/.releaserc rename to vendor/github.com/waku-org/go-libp2p-rendezvous/.releaserc diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/LICENSE b/vendor/github.com/waku-org/go-libp2p-rendezvous/LICENSE similarity index 100% rename from vendor/github.com/berty/go-libp2p-rendezvous/LICENSE rename to vendor/github.com/waku-org/go-libp2p-rendezvous/LICENSE diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/client.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/client.go similarity index 64% rename from vendor/github.com/berty/go-libp2p-rendezvous/client.go rename to vendor/github.com/waku-org/go-libp2p-rendezvous/client.go index bb04bfa6a..fe36cbd10 100644 --- a/vendor/github.com/berty/go-libp2p-rendezvous/client.go +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/client.go @@ -6,12 +6,12 @@ import ( "math/rand" "time" - ggio "github.com/gogo/protobuf/io" "github.com/libp2p/go-libp2p/core/host" inet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-msgio/pbio" - pb "github.com/berty/go-libp2p-rendezvous/pb" + pb "github.com/waku-org/go-libp2p-rendezvous/pb" ) var ( @@ -23,7 +23,6 @@ type RendezvousPoint interface { Unregister(ctx context.Context, ns string) error Discover(ctx context.Context, ns string, limit int, cookie []byte) ([]Registration, []byte, error) DiscoverAsync(ctx context.Context, ns string) (<-chan Registration, error) - DiscoverSubscribe(ctx context.Context, ns string, serviceTypes []RendezvousSyncClient) (<-chan peer.AddrInfo, error) } type Registration struct { @@ -37,7 +36,6 @@ type RendezvousClient interface { Unregister(ctx context.Context, ns string) error Discover(ctx context.Context, ns string, limit int, cookie []byte) ([]peer.AddrInfo, []byte, error) DiscoverAsync(ctx context.Context, ns string) (<-chan peer.AddrInfo, error) - DiscoverSubscribe(ctx context.Context, ns string) (<-chan peer.AddrInfo, error) } func NewRendezvousPoint(host host.Host, p peer.ID, opts ...RendezvousPointOption) RendezvousPoint { @@ -56,17 +54,16 @@ type rendezvousPoint struct { p peer.ID } -func NewRendezvousClient(host host.Host, rp peer.ID, sync ...RendezvousSyncClient) RendezvousClient { - return NewRendezvousClientWithPoint(NewRendezvousPoint(host, rp), sync...) +func NewRendezvousClient(host host.Host, rp peer.ID) RendezvousClient { + return NewRendezvousClientWithPoint(NewRendezvousPoint(host, rp)) } -func NewRendezvousClientWithPoint(rp RendezvousPoint, syncClientList ...RendezvousSyncClient) RendezvousClient { - return &rendezvousClient{rp: rp, syncClients: syncClientList} +func NewRendezvousClientWithPoint(rp RendezvousPoint) RendezvousClient { + return &rendezvousClient{rp: rp} } type rendezvousClient struct { - rp RendezvousPoint - syncClients []RendezvousSyncClient + rp RendezvousPoint } func (rp *rendezvousPoint) Register(ctx context.Context, ns string, ttl int) (time.Duration, error) { @@ -76,8 +73,8 @@ func (rp *rendezvousPoint) Register(ctx context.Context, ns string, ttl int) (ti } defer s.Reset() - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) + r := pbio.NewDelimitedReader(s, inet.MessageSizeMax) + w := pbio.NewDelimitedWriter(s) addrs := rp.addrFactory(rp.host.Addrs()) if len(addrs) == 0 { @@ -85,7 +82,13 @@ func (rp *rendezvousPoint) Register(ctx context.Context, ns string, ttl int) (ti } log.Debugf("advertising on `%s` with: %v", ns, addrs) - req := newRegisterMessage(ns, peer.AddrInfo{ID: rp.host.ID(), Addrs: addrs}, ttl) + + privKey := rp.host.Peerstore().PrivKey(rp.host.ID()) + req, err := newRegisterMessage(privKey, ns, peer.AddrInfo{ID: rp.host.ID(), Addrs: addrs}, ttl) + if err != nil { + return 0, err + } + err = w.WriteMsg(req) if err != nil { return 0, err @@ -107,7 +110,12 @@ func (rp *rendezvousPoint) Register(ctx context.Context, ns string, ttl int) (ti return 0, RendezvousError{Status: status, Text: res.GetRegisterResponse().GetStatusText()} } - return time.Duration(response.Ttl) * time.Second, nil + responseTTL := int64(0) + if response.Ttl != nil { + responseTTL = int64(*response.Ttl) + } + + return time.Duration(responseTTL) * time.Second, nil } func (rc *rendezvousClient) Register(ctx context.Context, ns string, ttl int) (time.Duration, error) { @@ -163,7 +171,7 @@ func (rp *rendezvousPoint) Unregister(ctx context.Context, ns string) error { } defer s.Close() - w := ggio.NewDelimitedWriter(s) + w := pbio.NewDelimitedWriter(s) req := newUnregisterMessage(ns, rp.host.ID()) return w.WriteMsg(req) } @@ -179,13 +187,13 @@ func (rp *rendezvousPoint) Discover(ctx context.Context, ns string, limit int, c } defer s.Reset() - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) + r := pbio.NewDelimitedReader(s, inet.MessageSizeMax) + w := pbio.NewDelimitedWriter(s) return discoverQuery(ns, limit, cookie, r, w) } -func discoverQuery(ns string, limit int, cookie []byte, r ggio.Reader, w ggio.Writer) ([]Registration, []byte, error) { +func discoverQuery(ns string, limit int, cookie []byte, r pbio.Reader, w pbio.Writer) ([]Registration, []byte, error) { req := newDiscoverMessage(ns, limit, cookie) err := w.WriteMsg(req) if err != nil { @@ -199,7 +207,7 @@ func discoverQuery(ns string, limit int, cookie []byte, r ggio.Reader, w ggio.Wr } if res.GetType() != pb.Message_DISCOVER_RESPONSE { - return nil, nil, fmt.Errorf("Unexpected response: %s", res.GetType().String()) + return nil, nil, fmt.Errorf("unexpected response: %s", res.GetType().String()) } status := res.GetDiscoverResponse().GetStatus() @@ -210,7 +218,7 @@ func discoverQuery(ns string, limit int, cookie []byte, r ggio.Reader, w ggio.Wr regs := res.GetDiscoverResponse().GetRegistrations() result := make([]Registration, 0, len(regs)) for _, reg := range regs { - pi, err := pbToPeerInfo(reg.GetPeer()) + pi, err := pbToPeerRecord(reg.SignedPeerRecord) if err != nil { log.Errorf("Invalid peer info: %s", err.Error()) continue @@ -236,8 +244,8 @@ func discoverAsync(ctx context.Context, ns string, s inet.Stream, ch chan Regist defer s.Reset() defer close(ch) - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) + r := pbio.NewDelimitedReader(s, inet.MessageSizeMax) + w := pbio.NewDelimitedWriter(s) const batch = 200 @@ -320,99 +328,3 @@ func discoverPeersAsync(ctx context.Context, rch <-chan Registration, ch chan pe } } } - -func (rc *rendezvousClient) DiscoverSubscribe(ctx context.Context, ns string) (<-chan peer.AddrInfo, error) { - return rc.rp.DiscoverSubscribe(ctx, ns, rc.syncClients) -} - -func subscribeServiceTypes(serviceTypeClients []RendezvousSyncClient) []string { - serviceTypes := []string(nil) - for _, serviceType := range serviceTypeClients { - serviceTypes = append(serviceTypes, serviceType.GetServiceType()) - } - - return serviceTypes -} - -func (rp *rendezvousPoint) DiscoverSubscribe(ctx context.Context, ns string, serviceTypeClients []RendezvousSyncClient) (<-chan peer.AddrInfo, error) { - serviceTypes := subscribeServiceTypes(serviceTypeClients) - - s, err := rp.host.NewStream(ctx, rp.p, RendezvousProto) - if err != nil { - return nil, err - } - defer s.Close() - - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) - - subType, subDetails, err := discoverSubscribeQuery(ns, serviceTypes, r, w) - if err != nil { - return nil, fmt.Errorf("discover subscribe error: %w", err) - } - - subClient := RendezvousSyncClient(nil) - for _, subClient = range serviceTypeClients { - if subClient.GetServiceType() == subType { - break - } - } - if subClient == nil { - return nil, fmt.Errorf("unrecognized client type") - } - - regCh, err := subClient.Subscribe(ctx, subDetails) - if err != nil { - return nil, fmt.Errorf("unable to subscribe to updates: %w", err) - } - - ch := make(chan peer.AddrInfo) - go func() { - defer close(ch) - - for { - select { - case result, ok := <-regCh: - if !ok { - return - } - ch <- result.Peer - case <-ctx.Done(): - return - } - } - }() - - return ch, nil -} - -func discoverSubscribeQuery(ns string, serviceTypes []string, r ggio.Reader, w ggio.Writer) (subType string, subDetails string, err error) { - req := &pb.Message{ - Type: pb.Message_DISCOVER_SUBSCRIBE, - DiscoverSubscribe: newDiscoverSubscribeMessage(ns, serviceTypes), - } - err = w.WriteMsg(req) - if err != nil { - return "", "", fmt.Errorf("write err: %w", err) - } - - var res pb.Message - err = r.ReadMsg(&res) - if err != nil { - return "", "", fmt.Errorf("read err: %w", err) - } - - if res.GetType() != pb.Message_DISCOVER_SUBSCRIBE_RESPONSE { - return "", "", fmt.Errorf("unexpected response: %s", res.GetType().String()) - } - - status := res.GetDiscoverSubscribeResponse().GetStatus() - if status != pb.Message_OK { - return "", "", RendezvousError{Status: status, Text: res.GetDiscoverSubscribeResponse().GetStatusText()} - } - - subType = res.GetDiscoverSubscribeResponse().GetSubscriptionType() - subDetails = res.GetDiscoverSubscribeResponse().GetSubscriptionDetails() - - return subType, subDetails, nil -} diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/db/dbi.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/db/dbi.go similarity index 66% rename from vendor/github.com/berty/go-libp2p-rendezvous/db/dbi.go rename to vendor/github.com/waku-org/go-libp2p-rendezvous/db/dbi.go index 1f9e0bed0..e6ac6b7dd 100644 --- a/vendor/github.com/berty/go-libp2p-rendezvous/db/dbi.go +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/db/dbi.go @@ -5,15 +5,15 @@ import ( ) type RegistrationRecord struct { - Id peer.ID - Addrs [][]byte - Ns string - Ttl int + Id peer.ID + SignedPeerRecord []byte + Ns string + Ttl int } type DB interface { Close() error - Register(p peer.ID, ns string, addrs [][]byte, ttl int) (uint64, error) + Register(p peer.ID, ns string, signedPeerRecord []byte, ttl int) (uint64, error) Unregister(p peer.ID, ns string) error CountRegistrations(p peer.ID) (int, error) Discover(ns string, cookie []byte, limit int) ([]RegistrationRecord, []byte, error) diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/discovery.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/discovery.go similarity index 94% rename from vendor/github.com/berty/go-libp2p-rendezvous/discovery.go rename to vendor/github.com/waku-org/go-libp2p-rendezvous/discovery.go index 99a4fbac9..a5b603074 100644 --- a/vendor/github.com/berty/go-libp2p-rendezvous/discovery.go +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/discovery.go @@ -21,12 +21,12 @@ type rendezvousDiscovery struct { } type discoveryCache struct { - recs map[peer.ID]*record + recs map[peer.ID]*peerRecord cookie []byte mux sync.Mutex } -type record struct { +type peerRecord struct { peer peer.AddrInfo expire int64 } @@ -84,7 +84,7 @@ func (c *rendezvousDiscovery) FindPeers(ctx context.Context, ns string, opts ... c.peerCacheMux.Lock() cache, ok = c.peerCache[ns] if !ok { - cache = &discoveryCache{recs: make(map[peer.ID]*record)} + cache = &discoveryCache{recs: make(map[peer.ID]*peerRecord)} c.peerCache[ns] = cache } c.peerCacheMux.Unlock() @@ -114,7 +114,7 @@ func (c *rendezvousDiscovery) FindPeers(ctx context.Context, ns string, opts ... var newCookie []byte if regs, newCookie, err = c.rp.Discover(ctx, ns, limit, cookie); err == nil { for _, reg := range regs { - rec := &record{peer: reg.Peer, expire: int64(reg.Ttl) + currentTime} + rec := &peerRecord{peer: reg.Peer, expire: int64(reg.Ttl) + currentTime} cache.recs[rec.peer.ID] = rec } cache.cookie = newCookie diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/options.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/options.go similarity index 100% rename from vendor/github.com/berty/go-libp2p-rendezvous/options.go rename to vendor/github.com/waku-org/go-libp2p-rendezvous/options.go diff --git a/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/generate.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/generate.go new file mode 100644 index 000000000..621785ef1 --- /dev/null +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/generate.go @@ -0,0 +1,3 @@ +package rendezvous_pb + +//go:generate protoc -I. --proto_path=./ --go_opt=paths=source_relative --go_opt=Mrendezvous.proto=github.com/waku-org/go-libp2p-rendezvous/rendezvous_pb --go_out=. ./rendezvous.proto diff --git a/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/rendezvous.pb.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/rendezvous.pb.go new file mode 100644 index 000000000..b580edc9c --- /dev/null +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/rendezvous.pb.go @@ -0,0 +1,782 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.21.12 +// source: rendezvous.proto + +package rendezvous_pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Message_MessageType int32 + +const ( + Message_REGISTER Message_MessageType = 0 + Message_REGISTER_RESPONSE Message_MessageType = 1 + Message_UNREGISTER Message_MessageType = 2 + Message_DISCOVER Message_MessageType = 3 + Message_DISCOVER_RESPONSE Message_MessageType = 4 +) + +// Enum value maps for Message_MessageType. +var ( + Message_MessageType_name = map[int32]string{ + 0: "REGISTER", + 1: "REGISTER_RESPONSE", + 2: "UNREGISTER", + 3: "DISCOVER", + 4: "DISCOVER_RESPONSE", + } + Message_MessageType_value = map[string]int32{ + "REGISTER": 0, + "REGISTER_RESPONSE": 1, + "UNREGISTER": 2, + "DISCOVER": 3, + "DISCOVER_RESPONSE": 4, + } +) + +func (x Message_MessageType) Enum() *Message_MessageType { + p := new(Message_MessageType) + *p = x + return p +} + +func (x Message_MessageType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Message_MessageType) Descriptor() protoreflect.EnumDescriptor { + return file_rendezvous_proto_enumTypes[0].Descriptor() +} + +func (Message_MessageType) Type() protoreflect.EnumType { + return &file_rendezvous_proto_enumTypes[0] +} + +func (x Message_MessageType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Message_MessageType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = Message_MessageType(num) + return nil +} + +// Deprecated: Use Message_MessageType.Descriptor instead. +func (Message_MessageType) EnumDescriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0, 0} +} + +type Message_ResponseStatus int32 + +const ( + Message_OK Message_ResponseStatus = 0 + Message_E_INVALID_NAMESPACE Message_ResponseStatus = 100 + Message_E_INVALID_SIGNED_PEER_RECORD Message_ResponseStatus = 101 + Message_E_INVALID_TTL Message_ResponseStatus = 102 + Message_E_INVALID_COOKIE Message_ResponseStatus = 103 + Message_E_NOT_AUTHORIZED Message_ResponseStatus = 200 + Message_E_INTERNAL_ERROR Message_ResponseStatus = 300 + Message_E_UNAVAILABLE Message_ResponseStatus = 400 +) + +// Enum value maps for Message_ResponseStatus. +var ( + Message_ResponseStatus_name = map[int32]string{ + 0: "OK", + 100: "E_INVALID_NAMESPACE", + 101: "E_INVALID_SIGNED_PEER_RECORD", + 102: "E_INVALID_TTL", + 103: "E_INVALID_COOKIE", + 200: "E_NOT_AUTHORIZED", + 300: "E_INTERNAL_ERROR", + 400: "E_UNAVAILABLE", + } + Message_ResponseStatus_value = map[string]int32{ + "OK": 0, + "E_INVALID_NAMESPACE": 100, + "E_INVALID_SIGNED_PEER_RECORD": 101, + "E_INVALID_TTL": 102, + "E_INVALID_COOKIE": 103, + "E_NOT_AUTHORIZED": 200, + "E_INTERNAL_ERROR": 300, + "E_UNAVAILABLE": 400, + } +) + +func (x Message_ResponseStatus) Enum() *Message_ResponseStatus { + p := new(Message_ResponseStatus) + *p = x + return p +} + +func (x Message_ResponseStatus) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Message_ResponseStatus) Descriptor() protoreflect.EnumDescriptor { + return file_rendezvous_proto_enumTypes[1].Descriptor() +} + +func (Message_ResponseStatus) Type() protoreflect.EnumType { + return &file_rendezvous_proto_enumTypes[1] +} + +func (x Message_ResponseStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Message_ResponseStatus) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) + if err != nil { + return err + } + *x = Message_ResponseStatus(num) + return nil +} + +// Deprecated: Use Message_ResponseStatus.Descriptor instead. +func (Message_ResponseStatus) EnumDescriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0, 1} +} + +type Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Message_MessageType `protobuf:"varint,1,opt,name=type,enum=rendezvous.pb.Message_MessageType" json:"type,omitempty"` + Register *Message_Register `protobuf:"bytes,2,opt,name=register" json:"register,omitempty"` + RegisterResponse *Message_RegisterResponse `protobuf:"bytes,3,opt,name=registerResponse" json:"registerResponse,omitempty"` + Unregister *Message_Unregister `protobuf:"bytes,4,opt,name=unregister" json:"unregister,omitempty"` + Discover *Message_Discover `protobuf:"bytes,5,opt,name=discover" json:"discover,omitempty"` + DiscoverResponse *Message_DiscoverResponse `protobuf:"bytes,6,opt,name=discoverResponse" json:"discoverResponse,omitempty"` +} + +func (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_rendezvous_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_rendezvous_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0} +} + +func (x *Message) GetType() Message_MessageType { + if x != nil && x.Type != nil { + return *x.Type + } + return Message_REGISTER +} + +func (x *Message) GetRegister() *Message_Register { + if x != nil { + return x.Register + } + return nil +} + +func (x *Message) GetRegisterResponse() *Message_RegisterResponse { + if x != nil { + return x.RegisterResponse + } + return nil +} + +func (x *Message) GetUnregister() *Message_Unregister { + if x != nil { + return x.Unregister + } + return nil +} + +func (x *Message) GetDiscover() *Message_Discover { + if x != nil { + return x.Discover + } + return nil +} + +func (x *Message) GetDiscoverResponse() *Message_DiscoverResponse { + if x != nil { + return x.DiscoverResponse + } + return nil +} + +type Message_Register struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ns *string `protobuf:"bytes,1,opt,name=ns" json:"ns,omitempty"` + SignedPeerRecord []byte `protobuf:"bytes,2,opt,name=signedPeerRecord" json:"signedPeerRecord,omitempty"` + Ttl *uint64 `protobuf:"varint,3,opt,name=ttl" json:"ttl,omitempty"` // in seconds +} + +func (x *Message_Register) Reset() { + *x = Message_Register{} + if protoimpl.UnsafeEnabled { + mi := &file_rendezvous_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message_Register) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message_Register) ProtoMessage() {} + +func (x *Message_Register) ProtoReflect() protoreflect.Message { + mi := &file_rendezvous_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message_Register.ProtoReflect.Descriptor instead. +func (*Message_Register) Descriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *Message_Register) GetNs() string { + if x != nil && x.Ns != nil { + return *x.Ns + } + return "" +} + +func (x *Message_Register) GetSignedPeerRecord() []byte { + if x != nil { + return x.SignedPeerRecord + } + return nil +} + +func (x *Message_Register) GetTtl() uint64 { + if x != nil && x.Ttl != nil { + return *x.Ttl + } + return 0 +} + +type Message_RegisterResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Status *Message_ResponseStatus `protobuf:"varint,1,opt,name=status,enum=rendezvous.pb.Message_ResponseStatus" json:"status,omitempty"` + StatusText *string `protobuf:"bytes,2,opt,name=statusText" json:"statusText,omitempty"` + Ttl *uint64 `protobuf:"varint,3,opt,name=ttl" json:"ttl,omitempty"` // in seconds +} + +func (x *Message_RegisterResponse) Reset() { + *x = Message_RegisterResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rendezvous_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message_RegisterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message_RegisterResponse) ProtoMessage() {} + +func (x *Message_RegisterResponse) ProtoReflect() protoreflect.Message { + mi := &file_rendezvous_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message_RegisterResponse.ProtoReflect.Descriptor instead. +func (*Message_RegisterResponse) Descriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0, 1} +} + +func (x *Message_RegisterResponse) GetStatus() Message_ResponseStatus { + if x != nil && x.Status != nil { + return *x.Status + } + return Message_OK +} + +func (x *Message_RegisterResponse) GetStatusText() string { + if x != nil && x.StatusText != nil { + return *x.StatusText + } + return "" +} + +func (x *Message_RegisterResponse) GetTtl() uint64 { + if x != nil && x.Ttl != nil { + return *x.Ttl + } + return 0 +} + +type Message_Unregister struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ns *string `protobuf:"bytes,1,opt,name=ns" json:"ns,omitempty"` // optional bytes id = 2; deprecated as per https://github.com/libp2p/specs/issues/335 +} + +func (x *Message_Unregister) Reset() { + *x = Message_Unregister{} + if protoimpl.UnsafeEnabled { + mi := &file_rendezvous_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message_Unregister) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message_Unregister) ProtoMessage() {} + +func (x *Message_Unregister) ProtoReflect() protoreflect.Message { + mi := &file_rendezvous_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message_Unregister.ProtoReflect.Descriptor instead. +func (*Message_Unregister) Descriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0, 2} +} + +func (x *Message_Unregister) GetNs() string { + if x != nil && x.Ns != nil { + return *x.Ns + } + return "" +} + +type Message_Discover struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ns *string `protobuf:"bytes,1,opt,name=ns" json:"ns,omitempty"` + Limit *uint64 `protobuf:"varint,2,opt,name=limit" json:"limit,omitempty"` + Cookie []byte `protobuf:"bytes,3,opt,name=cookie" json:"cookie,omitempty"` +} + +func (x *Message_Discover) Reset() { + *x = Message_Discover{} + if protoimpl.UnsafeEnabled { + mi := &file_rendezvous_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message_Discover) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message_Discover) ProtoMessage() {} + +func (x *Message_Discover) ProtoReflect() protoreflect.Message { + mi := &file_rendezvous_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message_Discover.ProtoReflect.Descriptor instead. +func (*Message_Discover) Descriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0, 3} +} + +func (x *Message_Discover) GetNs() string { + if x != nil && x.Ns != nil { + return *x.Ns + } + return "" +} + +func (x *Message_Discover) GetLimit() uint64 { + if x != nil && x.Limit != nil { + return *x.Limit + } + return 0 +} + +func (x *Message_Discover) GetCookie() []byte { + if x != nil { + return x.Cookie + } + return nil +} + +type Message_DiscoverResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Registrations []*Message_Register `protobuf:"bytes,1,rep,name=registrations" json:"registrations,omitempty"` + Cookie []byte `protobuf:"bytes,2,opt,name=cookie" json:"cookie,omitempty"` + Status *Message_ResponseStatus `protobuf:"varint,3,opt,name=status,enum=rendezvous.pb.Message_ResponseStatus" json:"status,omitempty"` + StatusText *string `protobuf:"bytes,4,opt,name=statusText" json:"statusText,omitempty"` +} + +func (x *Message_DiscoverResponse) Reset() { + *x = Message_DiscoverResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_rendezvous_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message_DiscoverResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message_DiscoverResponse) ProtoMessage() {} + +func (x *Message_DiscoverResponse) ProtoReflect() protoreflect.Message { + mi := &file_rendezvous_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message_DiscoverResponse.ProtoReflect.Descriptor instead. +func (*Message_DiscoverResponse) Descriptor() ([]byte, []int) { + return file_rendezvous_proto_rawDescGZIP(), []int{0, 4} +} + +func (x *Message_DiscoverResponse) GetRegistrations() []*Message_Register { + if x != nil { + return x.Registrations + } + return nil +} + +func (x *Message_DiscoverResponse) GetCookie() []byte { + if x != nil { + return x.Cookie + } + return nil +} + +func (x *Message_DiscoverResponse) GetStatus() Message_ResponseStatus { + if x != nil && x.Status != nil { + return *x.Status + } + return Message_OK +} + +func (x *Message_DiscoverResponse) GetStatusText() string { + if x != nil && x.StatusText != nil { + return *x.StatusText + } + return "" +} + +var File_rendezvous_proto protoreflect.FileDescriptor + +var file_rendezvous_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0d, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, + 0x62, 0x22, 0xed, 0x09, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e, 0x72, 0x65, + 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x7a, + 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x12, 0x53, 0x0a, 0x10, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x72, + 0x65, 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x10, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x0a, 0x75, 0x6e, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x72, 0x65, + 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0a, + 0x75, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x3b, 0x0a, 0x08, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x72, + 0x65, 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x08, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x53, 0x0a, 0x10, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x27, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, + 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x10, 0x64, 0x69, 0x73, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x58, 0x0a, 0x08, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x6e, 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x10, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, + 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x1a, 0x83, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x72, 0x65, + 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x54, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x54, 0x65, 0x78, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x74, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x1a, 0x1c, 0x0a, 0x0a, + 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x6e, 0x73, 0x1a, 0x48, 0x0a, 0x08, 0x44, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x63, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x63, 0x6f, + 0x6f, 0x6b, 0x69, 0x65, 0x1a, 0xd0, 0x01, 0x0a, 0x10, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a, 0x0d, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, + 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, + 0x72, 0x52, 0x0d, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x63, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x12, 0x3d, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x72, 0x65, 0x6e, 0x64, 0x65, + 0x7a, 0x76, 0x6f, 0x75, 0x73, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x54, 0x65, 0x78, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x54, 0x65, 0x78, 0x74, 0x22, 0x67, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, + 0x45, 0x52, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, + 0x5f, 0x52, 0x45, 0x53, 0x50, 0x4f, 0x4e, 0x53, 0x45, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x55, + 0x4e, 0x52, 0x45, 0x47, 0x49, 0x53, 0x54, 0x45, 0x52, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x44, + 0x49, 0x53, 0x43, 0x4f, 0x56, 0x45, 0x52, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x44, 0x49, 0x53, + 0x43, 0x4f, 0x56, 0x45, 0x52, 0x5f, 0x52, 0x45, 0x53, 0x50, 0x4f, 0x4e, 0x53, 0x45, 0x10, 0x04, + 0x22, 0xbe, 0x01, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x45, + 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, + 0x43, 0x45, 0x10, 0x64, 0x12, 0x20, 0x0a, 0x1c, 0x45, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, + 0x44, 0x5f, 0x53, 0x49, 0x47, 0x4e, 0x45, 0x44, 0x5f, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x52, 0x45, + 0x43, 0x4f, 0x52, 0x44, 0x10, 0x65, 0x12, 0x11, 0x0a, 0x0d, 0x45, 0x5f, 0x49, 0x4e, 0x56, 0x41, + 0x4c, 0x49, 0x44, 0x5f, 0x54, 0x54, 0x4c, 0x10, 0x66, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x5f, 0x49, + 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x43, 0x4f, 0x4f, 0x4b, 0x49, 0x45, 0x10, 0x67, 0x12, + 0x15, 0x0a, 0x10, 0x45, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, + 0x5a, 0x45, 0x44, 0x10, 0xc8, 0x01, 0x12, 0x15, 0x0a, 0x10, 0x45, 0x5f, 0x49, 0x4e, 0x54, 0x45, + 0x52, 0x4e, 0x41, 0x4c, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0xac, 0x02, 0x12, 0x12, 0x0a, + 0x0d, 0x45, 0x5f, 0x55, 0x4e, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x90, + 0x03, +} + +var ( + file_rendezvous_proto_rawDescOnce sync.Once + file_rendezvous_proto_rawDescData = file_rendezvous_proto_rawDesc +) + +func file_rendezvous_proto_rawDescGZIP() []byte { + file_rendezvous_proto_rawDescOnce.Do(func() { + file_rendezvous_proto_rawDescData = protoimpl.X.CompressGZIP(file_rendezvous_proto_rawDescData) + }) + return file_rendezvous_proto_rawDescData +} + +var file_rendezvous_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_rendezvous_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_rendezvous_proto_goTypes = []interface{}{ + (Message_MessageType)(0), // 0: rendezvous.pb.Message.MessageType + (Message_ResponseStatus)(0), // 1: rendezvous.pb.Message.ResponseStatus + (*Message)(nil), // 2: rendezvous.pb.Message + (*Message_Register)(nil), // 3: rendezvous.pb.Message.Register + (*Message_RegisterResponse)(nil), // 4: rendezvous.pb.Message.RegisterResponse + (*Message_Unregister)(nil), // 5: rendezvous.pb.Message.Unregister + (*Message_Discover)(nil), // 6: rendezvous.pb.Message.Discover + (*Message_DiscoverResponse)(nil), // 7: rendezvous.pb.Message.DiscoverResponse +} +var file_rendezvous_proto_depIdxs = []int32{ + 0, // 0: rendezvous.pb.Message.type:type_name -> rendezvous.pb.Message.MessageType + 3, // 1: rendezvous.pb.Message.register:type_name -> rendezvous.pb.Message.Register + 4, // 2: rendezvous.pb.Message.registerResponse:type_name -> rendezvous.pb.Message.RegisterResponse + 5, // 3: rendezvous.pb.Message.unregister:type_name -> rendezvous.pb.Message.Unregister + 6, // 4: rendezvous.pb.Message.discover:type_name -> rendezvous.pb.Message.Discover + 7, // 5: rendezvous.pb.Message.discoverResponse:type_name -> rendezvous.pb.Message.DiscoverResponse + 1, // 6: rendezvous.pb.Message.RegisterResponse.status:type_name -> rendezvous.pb.Message.ResponseStatus + 3, // 7: rendezvous.pb.Message.DiscoverResponse.registrations:type_name -> rendezvous.pb.Message.Register + 1, // 8: rendezvous.pb.Message.DiscoverResponse.status:type_name -> rendezvous.pb.Message.ResponseStatus + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_rendezvous_proto_init() } +func file_rendezvous_proto_init() { + if File_rendezvous_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_rendezvous_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rendezvous_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_Register); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rendezvous_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_RegisterResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rendezvous_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_Unregister); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rendezvous_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_Discover); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rendezvous_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Message_DiscoverResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rendezvous_proto_rawDesc, + NumEnums: 2, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_rendezvous_proto_goTypes, + DependencyIndexes: file_rendezvous_proto_depIdxs, + EnumInfos: file_rendezvous_proto_enumTypes, + MessageInfos: file_rendezvous_proto_msgTypes, + }.Build() + File_rendezvous_proto = out.File + file_rendezvous_proto_rawDesc = nil + file_rendezvous_proto_goTypes = nil + file_rendezvous_proto_depIdxs = nil +} diff --git a/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/rendezvous.proto b/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/rendezvous.proto new file mode 100644 index 000000000..c9614c13b --- /dev/null +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/pb/rendezvous.proto @@ -0,0 +1,61 @@ +syntax = "proto2"; + +package rendezvous.pb; + +message Message { + enum MessageType { + REGISTER = 0; + REGISTER_RESPONSE = 1; + UNREGISTER = 2; + DISCOVER = 3; + DISCOVER_RESPONSE = 4; + } + + enum ResponseStatus { + OK = 0; + E_INVALID_NAMESPACE = 100; + E_INVALID_SIGNED_PEER_RECORD = 101; + E_INVALID_TTL = 102; + E_INVALID_COOKIE = 103; + E_NOT_AUTHORIZED = 200; + E_INTERNAL_ERROR = 300; + E_UNAVAILABLE = 400; + } + + message Register { + optional string ns = 1; + optional bytes signedPeerRecord = 2; + optional uint64 ttl = 3; // in seconds + } + + message RegisterResponse { + optional ResponseStatus status = 1; + optional string statusText = 2; + optional uint64 ttl = 3; // in seconds + } + + message Unregister { + optional string ns = 1; + // optional bytes id = 2; deprecated as per https://github.com/libp2p/specs/issues/335 + } + + message Discover { + optional string ns = 1; + optional uint64 limit = 2; + optional bytes cookie = 3; + } + + message DiscoverResponse { + repeated Register registrations = 1; + optional bytes cookie = 2; + optional ResponseStatus status = 3; + optional string statusText = 4; + } + + optional MessageType type = 1; + optional Register register = 2; + optional RegisterResponse registerResponse = 3; + optional Unregister unregister = 4; + optional Discover discover = 5; + optional DiscoverResponse discoverResponse = 6; +} \ No newline at end of file diff --git a/vendor/github.com/waku-org/go-libp2p-rendezvous/proto.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/proto.go new file mode 100644 index 000000000..f530f1622 --- /dev/null +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/proto.go @@ -0,0 +1,160 @@ +package rendezvous + +import ( + "errors" + "fmt" + "time" + + db "github.com/waku-org/go-libp2p-rendezvous/db" + pb "github.com/waku-org/go-libp2p-rendezvous/pb" + + logging "github.com/ipfs/go-log/v2" + crypto "github.com/libp2p/go-libp2p/core/crypto" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/protocol" + "github.com/libp2p/go-libp2p/core/record" +) + +var log = logging.Logger("rendezvous") + +const ( + RendezvousProto = protocol.ID("/rendezvous/1.0.0") + + DefaultTTL = 2 * 3600 // 2hr +) + +type RendezvousError struct { + Status pb.Message_ResponseStatus + Text string +} + +func (e RendezvousError) Error() string { + return fmt.Sprintf("Rendezvous error: %s (%s)", e.Text, e.Status.String()) +} + +func NewRegisterMessage(privKey crypto.PrivKey, ns string, pi peer.AddrInfo, ttl int) (*pb.Message, error) { + return newRegisterMessage(privKey, ns, pi, ttl) +} + +func newRegisterMessage(privKey crypto.PrivKey, ns string, pi peer.AddrInfo, ttl int) (*pb.Message, error) { + msg := new(pb.Message) + msg.Type = pb.Message_REGISTER.Enum() + msg.Register = new(pb.Message_Register) + if ns != "" { + msg.Register.Ns = &ns + } + if ttl > 0 { + ttlu64 := uint64(ttl) + msg.Register.Ttl = &ttlu64 + } + + peerInfo := &peer.PeerRecord{ + PeerID: pi.ID, + Addrs: pi.Addrs, + Seq: uint64(time.Now().Unix()), + } + + envelope, err := record.Seal(peerInfo, privKey) + if err != nil { + return nil, err + } + + envPayload, err := envelope.Marshal() + if err != nil { + return nil, err + } + + msg.Register.SignedPeerRecord = envPayload + + return msg, nil +} + +func newUnregisterMessage(ns string, pid peer.ID) *pb.Message { + msg := new(pb.Message) + msg.Type = pb.Message_UNREGISTER.Enum() + msg.Unregister = new(pb.Message_Unregister) + if ns != "" { + msg.Unregister.Ns = &ns + } + return msg +} + +func NewDiscoverMessage(ns string, limit int, cookie []byte) *pb.Message { + return newDiscoverMessage(ns, limit, cookie) +} + +func newDiscoverMessage(ns string, limit int, cookie []byte) *pb.Message { + msg := new(pb.Message) + msg.Type = pb.Message_DISCOVER.Enum() + msg.Discover = new(pb.Message_Discover) + if ns != "" { + msg.Discover.Ns = &ns + } + if limit > 0 { + limitu64 := uint64(limit) + msg.Discover.Limit = &limitu64 + } + if cookie != nil { + msg.Discover.Cookie = cookie + } + return msg +} +func pbToPeerRecord(envelopeBytes []byte) (peer.AddrInfo, error) { + envelope, rec, err := record.ConsumeEnvelope(envelopeBytes, peer.PeerRecordEnvelopeDomain) + if err != nil { + return peer.AddrInfo{}, err + } + + peerRec, ok := rec.(*peer.PeerRecord) + if !ok { + return peer.AddrInfo{}, errors.New("invalid peer record") + } + + if !peerRec.PeerID.MatchesPublicKey(envelope.PublicKey) { + return peer.AddrInfo{}, errors.New("signing key does not match peer record") + } + + return peer.AddrInfo{ID: peerRec.PeerID, Addrs: peerRec.Addrs}, nil +} + +func newRegisterResponse(ttl int) *pb.Message_RegisterResponse { + ttlu64 := uint64(ttl) + r := new(pb.Message_RegisterResponse) + r.Status = pb.Message_OK.Enum() + r.Ttl = &ttlu64 + return r +} + +func newRegisterResponseError(status pb.Message_ResponseStatus, text string) *pb.Message_RegisterResponse { + r := new(pb.Message_RegisterResponse) + r.Status = status.Enum() + r.StatusText = &text + return r +} + +func newDiscoverResponse(regs []db.RegistrationRecord, cookie []byte) *pb.Message_DiscoverResponse { + r := new(pb.Message_DiscoverResponse) + r.Status = pb.Message_OK.Enum() + + rregs := make([]*pb.Message_Register, len(regs)) + for i, reg := range regs { + rreg := new(pb.Message_Register) + rreg.Ns = ®.Ns + rreg.SignedPeerRecord = reg.SignedPeerRecord + rttl := uint64(reg.Ttl) + rreg.Ttl = &rttl + rregs[i] = rreg + } + + r.Registrations = rregs + r.Cookie = cookie + + return r +} + +func newDiscoverResponseError(status pb.Message_ResponseStatus, text string) *pb.Message_DiscoverResponse { + r := new(pb.Message_DiscoverResponse) + r.Status = status.Enum() + r.StatusText = &text + return r +} diff --git a/vendor/github.com/berty/go-libp2p-rendezvous/svc.go b/vendor/github.com/waku-org/go-libp2p-rendezvous/svc.go similarity index 60% rename from vendor/github.com/berty/go-libp2p-rendezvous/svc.go rename to vendor/github.com/waku-org/go-libp2p-rendezvous/svc.go index 453479de7..f2dfa9457 100644 --- a/vendor/github.com/berty/go-libp2p-rendezvous/svc.go +++ b/vendor/github.com/waku-org/go-libp2p-rendezvous/svc.go @@ -1,15 +1,13 @@ package rendezvous import ( - "fmt" - - ggio "github.com/gogo/protobuf/io" "github.com/libp2p/go-libp2p/core/host" inet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-msgio/pbio" - db "github.com/berty/go-libp2p-rendezvous/db" - pb "github.com/berty/go-libp2p-rendezvous/pb" + db "github.com/waku-org/go-libp2p-rendezvous/db" + pb "github.com/waku-org/go-libp2p-rendezvous/pb" ) const ( @@ -21,12 +19,11 @@ const ( ) type RendezvousService struct { - DB db.DB - rzs []RendezvousSync + DB db.DB } -func NewRendezvousService(host host.Host, db db.DB, rzs ...RendezvousSync) *RendezvousService { - rz := &RendezvousService{DB: db, rzs: rzs} +func NewRendezvousService(host host.Host, db db.DB) *RendezvousService { + rz := &RendezvousService{DB: db} host.SetStreamHandler(RendezvousProto, rz.handleStream) return rz } @@ -37,8 +34,8 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { pid := s.Conn().RemotePeer() log.Debugf("New stream from %s", pid.Pretty()) - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) + r := pbio.NewDelimitedReader(s, inet.MessageSizeMax) + w := pbio.NewDelimitedWriter(s) for { var req pb.Message @@ -53,7 +50,7 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { switch t { case pb.Message_REGISTER: r := rz.handleRegister(pid, req.GetRegister()) - res.Type = pb.Message_REGISTER_RESPONSE + res.Type = pb.Message_REGISTER_RESPONSE.Enum() res.RegisterResponse = r err = w.WriteMsg(&res) if err != nil { @@ -69,7 +66,7 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { case pb.Message_DISCOVER: r := rz.handleDiscover(pid, req.GetDiscover()) - res.Type = pb.Message_DISCOVER_RESPONSE + res.Type = pb.Message_DISCOVER_RESPONSE.Enum() res.DiscoverResponse = r err = w.WriteMsg(&res) if err != nil { @@ -77,16 +74,6 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { return } - case pb.Message_DISCOVER_SUBSCRIBE: - r := rz.handleDiscoverSubscribe(pid, req.GetDiscoverSubscribe()) - res.Type = pb.Message_DISCOVER_SUBSCRIBE_RESPONSE - res.DiscoverSubscribeResponse = r - err = w.WriteMsg(&res) - if err != nil { - log.Debugf("Error writing response: %s", err.Error()) - return - } - default: log.Debugf("Unexpected message: %s", t.String()) return @@ -104,34 +91,30 @@ func (rz *RendezvousService) handleRegister(p peer.ID, m *pb.Message_Register) * return newRegisterResponseError(pb.Message_E_INVALID_NAMESPACE, "namespace too long") } - mpi := m.GetPeer() - if mpi == nil { - return newRegisterResponseError(pb.Message_E_INVALID_PEER_INFO, "missing peer info") + signedPeerRecord := m.GetSignedPeerRecord() + if signedPeerRecord == nil { + return newRegisterResponseError(pb.Message_E_INVALID_SIGNED_PEER_RECORD, "missing signed peer record") } - mpid := mpi.GetId() - if mpid != nil { - mp, err := peer.IDFromBytes(mpid) - if err != nil { - return newRegisterResponseError(pb.Message_E_INVALID_PEER_INFO, "bad peer id") - } - - if mp != p { - return newRegisterResponseError(pb.Message_E_INVALID_PEER_INFO, "peer id mismatch") - } + peerRecord, err := pbToPeerRecord(signedPeerRecord) + if err != nil { + return newRegisterResponseError(pb.Message_E_INVALID_SIGNED_PEER_RECORD, "invalid peer record") } - maddrs := mpi.GetAddrs() - if len(maddrs) == 0 { - return newRegisterResponseError(pb.Message_E_INVALID_PEER_INFO, "missing peer addresses") + if peerRecord.ID != p { + return newRegisterResponseError(pb.Message_E_INVALID_SIGNED_PEER_RECORD, "peer id mismatch") + } + + if len(peerRecord.Addrs) == 0 { + return newRegisterResponseError(pb.Message_E_INVALID_SIGNED_PEER_RECORD, "missing peer addresses") } mlen := 0 - for _, maddr := range maddrs { - mlen += len(maddr) + for _, maddr := range peerRecord.Addrs { + mlen += len(maddr.Bytes()) } if mlen > MaxPeerAddressLength { - return newRegisterResponseError(pb.Message_E_INVALID_PEER_INFO, "peer info too long") + return newRegisterResponseError(pb.Message_E_INVALID_SIGNED_PEER_RECORD, "peer info too long") } // Note: @@ -139,7 +122,7 @@ func (rz *RendezvousService) handleRegister(p peer.ID, m *pb.Message_Register) * // Perhaps we should though. mttl := m.GetTtl() - if mttl < 0 || mttl > MaxTTL { + if mttl > MaxTTL { return newRegisterResponseError(pb.Message_E_INVALID_TTL, "bad ttl") } @@ -163,7 +146,7 @@ func (rz *RendezvousService) handleRegister(p peer.ID, m *pb.Message_Register) * } // ok, seems like we can register - counter, err := rz.DB.Register(p, ns, maddrs, ttl) + _, err = rz.DB.Register(p, ns, signedPeerRecord, ttl) if err != nil { log.Errorf("Error registering: %s", err.Error()) return newRegisterResponseError(pb.Message_E_INTERNAL_ERROR, "database error") @@ -171,28 +154,12 @@ func (rz *RendezvousService) handleRegister(p peer.ID, m *pb.Message_Register) * log.Infof("registered peer %s %s (%d)", p, ns, ttl) - for _, rzs := range rz.rzs { - rzs.Register(p, ns, maddrs, ttl, counter) - } - return newRegisterResponse(ttl) } func (rz *RendezvousService) handleUnregister(p peer.ID, m *pb.Message_Unregister) error { ns := m.GetNs() - mpid := m.GetId() - if mpid != nil { - mp, err := peer.IDFromBytes(mpid) - if err != nil { - return err - } - - if mp != p { - return fmt.Errorf("peer id mismatch: %s asked to unregister %s", p.Pretty(), mp.Pretty()) - } - } - err := rz.DB.Unregister(p, ns) if err != nil { return err @@ -200,10 +167,6 @@ func (rz *RendezvousService) handleUnregister(p peer.ID, m *pb.Message_Unregiste log.Infof("unregistered peer %s %s", p, ns) - for _, rzs := range rz.rzs { - rzs.Unregister(p, ns) - } - return nil } @@ -216,7 +179,7 @@ func (rz *RendezvousService) handleDiscover(p peer.ID, m *pb.Message_Discover) * limit := MaxDiscoverLimit mlimit := m.GetLimit() - if mlimit > 0 && mlimit < int64(limit) { + if mlimit > 0 && mlimit < uint64(limit) { limit = int(mlimit) } @@ -231,31 +194,7 @@ func (rz *RendezvousService) handleDiscover(p peer.ID, m *pb.Message_Discover) * return newDiscoverResponseError(pb.Message_E_INTERNAL_ERROR, "database error") } - log.Infof("discover query: %s %s -> %d", p, ns, len(regs)) + log.Debugf("discover query: %s %s -> %d", p, ns, len(regs)) return newDiscoverResponse(regs, cookie) } - -func (rz *RendezvousService) handleDiscoverSubscribe(_ peer.ID, m *pb.Message_DiscoverSubscribe) *pb.Message_DiscoverSubscribeResponse { - ns := m.GetNs() - - for _, s := range rz.rzs { - rzSub, ok := s.(RendezvousSyncSubscribable) - if !ok { - continue - } - - for _, supportedSubType := range m.GetSupportedSubscriptionTypes() { - if rzSub.GetServiceType() == supportedSubType { - sub, err := rzSub.Subscribe(ns) - if err != nil { - return newDiscoverSubscribeResponseError(pb.Message_E_INTERNAL_ERROR, "error while subscribing") - } - - return newDiscoverSubscribeResponse(supportedSubType, sub) - } - } - } - - return newDiscoverSubscribeResponseError(pb.Message_E_INTERNAL_ERROR, "subscription type not found") -} diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/node/wakuoptions.go b/vendor/github.com/waku-org/go-waku/waku/v2/node/wakuoptions.go index 1ca086fca..333e73a24 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/node/wakuoptions.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/node/wakuoptions.go @@ -230,12 +230,12 @@ func WithExternalIP(ip net.IP) WakuNodeOption { params.addressFactory = func(inputAddr []multiaddr.Multiaddr) (addresses []multiaddr.Multiaddr) { addresses = append(addresses, inputAddr...) - component := "/ip4/" - if ip.To4() == nil && ip.To16() != nil { - component = "/ip6/" + ipType := "/ip4/" + if utils.IsIPv6(ip.String()) { + ipType = "/ip6/" } - hostAddrMA, err := multiaddr.NewMultiaddr(component + ip.String()) + hostAddrMA, err := multiaddr.NewMultiaddr(ipType + ip.String()) if err != nil { panic("Could not build external IP") } diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/enr.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/enr.go index 9d6bec32e..df22d2c04 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/enr.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/enr.go @@ -57,7 +57,18 @@ func enodeToMultiAddr(node *enode.Node) (multiaddr.Multiaddr, error) { return nil, err } - return multiaddr.NewMultiaddr(fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", node.IP(), node.TCP(), peerID)) + ipType := "ip4" + portNumber := node.TCP() + if utils.IsIPv6(node.IP().String()) { + ipType = "ip6" + var port enr.TCP6 + if err := node.Record().Load(&port); err != nil { + return nil, err + } + portNumber = int(port) + } + + return multiaddr.NewMultiaddr(fmt.Sprintf("/%s/%s/tcp/%d/p2p/%s", ipType, node.IP(), portNumber, peerID)) } // Multiaddress is used to extract all the multiaddresses that are part of a ENR record diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/shards.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/shards.go index bec90b7a3..d5f47b648 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/shards.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/enr/shards.go @@ -1,6 +1,8 @@ package enr import ( + "errors" + "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/enr" "github.com/waku-org/go-waku/waku/v2/protocol" @@ -24,7 +26,7 @@ func WithWakuRelayShardingBitVector(rs protocol.RelayShards) ENROption { } } -func WithtWakuRelaySharding(rs protocol.RelayShards) ENROption { +func WithWakuRelaySharding(rs protocol.RelayShards) ENROption { return func(localnode *enode.LocalNode) error { if len(rs.Indices) >= 64 { return WithWakuRelayShardingBitVector(rs)(localnode) @@ -34,6 +36,21 @@ func WithtWakuRelaySharding(rs protocol.RelayShards) ENROption { } } +func WithWakuRelayShardingTopics(topics ...string) ENROption { + return func(localnode *enode.LocalNode) error { + rs, err := protocol.TopicsToRelayShards(topics...) + if err != nil { + return err + } + + if len(rs) != 1 { + return errors.New("expected a single RelayShards") + } + + return WithWakuRelaySharding(rs[0])(localnode) + } +} + // ENR record accessors func RelayShardingIndicesList(localnode *enode.LocalNode) (*protocol.RelayShards, error) { diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/client.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/client.go index 15922d108..24b7b8b68 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/client.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/client.go @@ -154,14 +154,7 @@ func (wf *WakuFilterLightnode) notify(remotePeerID peer.ID, pubsubTopic string, } func (wf *WakuFilterLightnode) request(ctx context.Context, params *FilterSubscribeParameters, reqType pb.FilterSubscribeRequest_FilterSubscribeType, contentFilter ContentFilter) error { - err := wf.h.Connect(ctx, wf.h.Peerstore().PeerInfo(params.selectedPeer)) - if err != nil { - metrics.RecordFilterError(ctx, "dial_failure") - return err - } - - var conn network.Stream - conn, err = wf.h.NewStream(ctx, params.selectedPeer, FilterSubscribeID_v20beta1) + conn, err := wf.h.NewStream(ctx, params.selectedPeer, FilterSubscribeID_v20beta1) if err != nil { metrics.RecordFilterError(ctx, "dial_failure") return err diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/server.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/server.go index 9181f3b2d..1e8fd50f8 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/server.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/filter/server.go @@ -285,19 +285,6 @@ func (wf *WakuFilterFullNode) pushMessage(ctx context.Context, peerID peer.ID, e ctx, cancel := context.WithTimeout(ctx, MessagePushTimeout) defer cancel() - // We connect first so dns4 addresses are resolved (NewStream does not do it) - err := wf.h.Connect(ctx, wf.h.Peerstore().PeerInfo(peerID)) - if err != nil { - wf.subscriptions.FlagAsFailure(peerID) - if errors.Is(context.DeadlineExceeded, err) { - metrics.RecordFilterError(ctx, "push_timeout_failure") - } else { - metrics.RecordFilterError(ctx, "dial_failure") - } - logger.Error("connecting to peer", zap.Error(err)) - return err - } - conn, err := wf.h.NewStream(ctx, peerID, FilterPushID_v20beta1) if err != nil { wf.subscriptions.FlagAsFailure(peerID) diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/legacy_filter/waku_filter.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/legacy_filter/waku_filter.go index 9ca46b4d6..85f9c8c21 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/legacy_filter/waku_filter.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/legacy_filter/waku_filter.go @@ -171,15 +171,6 @@ func (wf *WakuFilter) pushMessage(ctx context.Context, subscriber Subscriber, ms pushRPC := &pb.FilterRPC{RequestId: subscriber.requestId, Push: &pb.MessagePush{Messages: []*wpb.WakuMessage{msg}}} logger := wf.log.With(logging.HostID("peer", subscriber.peer)) - // We connect first so dns4 addresses are resolved (NewStream does not do it) - err := wf.h.Connect(ctx, wf.h.Peerstore().PeerInfo(subscriber.peer)) - if err != nil { - wf.subscribers.FlagAsFailure(subscriber.peer) - logger.Error("connecting to peer", zap.Error(err)) - metrics.RecordLegacyFilterError(ctx, "dial_failure") - return err - } - conn, err := wf.h.NewStream(ctx, subscriber.peer, FilterID_v20beta1) if err != nil { wf.subscribers.FlagAsFailure(subscriber.peer) @@ -269,13 +260,6 @@ func (wf *WakuFilter) requestSubscription(ctx context.Context, filter ContentFil contentFilters = append(contentFilters, &pb.FilterRequest_ContentFilter{ContentTopic: ct}) } - // We connect first so dns4 addresses are resolved (NewStream does not do it) - err = wf.h.Connect(ctx, wf.h.Peerstore().PeerInfo(params.selectedPeer)) - if err != nil { - metrics.RecordLegacyFilterError(ctx, "dial_failure") - return - } - request := &pb.FilterRequest{ Subscribe: true, Topic: filter.Topic, @@ -313,12 +297,6 @@ func (wf *WakuFilter) requestSubscription(ctx context.Context, filter ContentFil // Unsubscribe is used to stop receiving messages from a peer that match a content filter func (wf *WakuFilter) Unsubscribe(ctx context.Context, contentFilter ContentFilter, peer peer.ID) error { - // We connect first so dns4 addresses are resolved (NewStream does not do it) - err := wf.h.Connect(ctx, wf.h.Peerstore().PeerInfo(peer)) - if err != nil { - metrics.RecordLegacyFilterError(ctx, "dial_failure") - return err - } conn, err := wf.h.NewStream(ctx, peer, FilterID_v20beta1) if err != nil { diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/lightpush/waku_lightpush.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/lightpush/waku_lightpush.go index 385e34e1d..85af5d40a 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/lightpush/waku_lightpush.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/lightpush/waku_lightpush.go @@ -157,13 +157,6 @@ func (wakuLP *WakuLightPush) request(ctx context.Context, req *pb.PushRequest, o } logger := wakuLP.log.With(logging.HostID("peer", params.selectedPeer)) - // We connect first so dns4 addresses are resolved (NewStream does not do it) - err := wakuLP.h.Connect(ctx, wakuLP.h.Peerstore().PeerInfo(params.selectedPeer)) - if err != nil { - metrics.RecordLightpushError(ctx, "dial_failure") - logger.Error("connecting peer", zap.Error(err)) - return nil, err - } connOpt, err := wakuLP.h.NewStream(ctx, params.selectedPeer, LightPushID_v20beta1) if err != nil { diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/peer_exchange/client.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/peer_exchange/client.go index 9f151c978..d5bf9d06a 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/peer_exchange/client.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/peer_exchange/client.go @@ -38,12 +38,6 @@ func (wakuPX *WakuPeerExchange) Request(ctx context.Context, numPeers int, opts }, } - // We connect first so dns4 addresses are resolved (NewStream does not do it) - err := wakuPX.h.Connect(ctx, wakuPX.h.Peerstore().PeerInfo(params.selectedPeer)) - if err != nil { - return err - } - connOpt, err := wakuPX.h.NewStream(ctx, params.selectedPeer, PeerExchangeID_v20alpha1) if err != nil { return err diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/shard.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/shard.go index fec1ccb11..184817b8d 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/shard.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/shard.go @@ -72,6 +72,42 @@ func (rs RelayShards) ContainsNamespacedTopic(topic NamespacedPubsubTopic) bool return rs.Contains(shardedTopic.Cluster(), shardedTopic.Shard()) } +func TopicsToRelayShards(topic ...string) ([]RelayShards, error) { + result := make([]RelayShards, 0) + dict := make(map[uint16]map[uint16]struct{}) + for _, t := range topic { + var ps StaticShardingPubsubTopic + err := ps.Parse(t) + if err != nil { + return nil, err + } + + indices, ok := dict[ps.cluster] + if !ok { + indices = make(map[uint16]struct{}) + } + + indices[ps.shard] = struct{}{} + dict[ps.cluster] = indices + } + + for cluster, indices := range dict { + idx := make([]uint16, 0, len(indices)) + for index := range indices { + idx = append(idx, index) + } + + rs, err := NewRelayShards(cluster, idx...) + if err != nil { + return nil, err + } + + result = append(result, rs) + } + + return result, nil +} + func (rs RelayShards) ContainsTopic(topic string) bool { nsTopic, err := ToShardedPubsubTopic(topic) if err != nil { diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/store/waku_store_client.go b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/store/waku_store_client.go index 47357b984..d2c957b46 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/protocol/store/waku_store_client.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/protocol/store/waku_store_client.go @@ -176,14 +176,6 @@ func (store *WakuStore) queryFrom(ctx context.Context, q *pb.HistoryQuery, selec logger := store.log.With(logging.HostID("peer", selectedPeer)) logger.Info("querying message history") - // We connect first so dns4 addresses are resolved (NewStream does not do it) - err := store.h.Connect(ctx, store.h.Peerstore().PeerInfo(selectedPeer)) - if err != nil { - logger.Error("connecting to peer", zap.Error(err)) - metrics.RecordStoreError(store.ctx, "dial_failure") - return nil, err - } - connOpt, err := store.h.NewStream(ctx, selectedPeer, StoreID_v20beta4) if err != nil { logger.Error("creating stream to peer", zap.Error(err)) diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/db.go b/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/db.go index 4152a84ca..c4e1f5c7a 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/db.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/db.go @@ -11,8 +11,8 @@ import ( "fmt" "time" - dbi "github.com/berty/go-libp2p-rendezvous/db" "github.com/libp2p/go-libp2p/core/peer" + dbi "github.com/waku-org/go-libp2p-rendezvous/db" "go.uber.org/zap" ) @@ -164,9 +164,8 @@ func (db *DB) prepareStmts() error { return nil } -func (db *DB) Register(p peer.ID, ns string, addrs [][]byte, ttl int) (uint64, error) { +func (db *DB) Register(p peer.ID, ns string, signedPeerRecord []byte, ttl int) (uint64, error) { pid := p.Pretty() - maddrs := packAddrs(addrs) expire := time.Now().Unix() + int64(ttl) tx, err := db.db.Begin() @@ -184,7 +183,7 @@ func (db *DB) Register(p peer.ID, ns string, addrs [][]byte, ttl int) (uint64, e return 0, err } - _, err = insertNew.Exec(pid, ns, expire, maddrs) + _, err = insertNew.Exec(pid, ns, expire, signedPeerRecord) if err != nil { _ = tx.Rollback() return 0, err @@ -268,16 +267,15 @@ func (db *DB) Discover(ns string, cookie []byte, limit int) ([]dbi.RegistrationR regs := make([]dbi.RegistrationRecord, 0, limit) for rows.Next() { var ( - reg dbi.RegistrationRecord - rid string - rns string - expire int64 - raddrs []byte - addrs [][]byte - p peer.ID + reg dbi.RegistrationRecord + rid string + rns string + expire int64 + signedPeerRecord []byte + p peer.ID ) - err = rows.Scan(&counter, &rid, &rns, &expire, &raddrs) + err = rows.Scan(&counter, &rid, &rns, &expire, &signedPeerRecord) if err != nil { db.logger.Error("row scan error", zap.Error(err)) return nil, nil, err @@ -289,14 +287,8 @@ func (db *DB) Discover(ns string, cookie []byte, limit int) ([]dbi.RegistrationR continue } - addrs, err := unpackAddrs(raddrs) - if err != nil { - db.logger.Error("error unpacking address", zap.Error(err)) - continue - } - reg.Id = p - reg.Addrs = addrs + reg.SignedPeerRecord = signedPeerRecord reg.Ttl = int(expire - now) if ns == "" { @@ -342,47 +334,6 @@ func (db *DB) cleanupExpired() { } } -func packAddrs(addrs [][]byte) []byte { - packlen := 0 - for _, addr := range addrs { - packlen = packlen + 2 + len(addr) - } - - packed := make([]byte, packlen) - buf := packed - for _, addr := range addrs { - binary.BigEndian.PutUint16(buf, uint16(len(addr))) - buf = buf[2:] - copy(buf, addr) - buf = buf[len(addr):] - } - - return packed -} - -func unpackAddrs(packed []byte) ([][]byte, error) { - var addrs [][]byte - - buf := packed - for len(buf) > 1 { - l := binary.BigEndian.Uint16(buf) - buf = buf[2:] - if len(buf) < int(l) { - return nil, fmt.Errorf("bad packed address: not enough bytes %v %v", packed, buf) - } - addr := make([]byte, l) - copy(addr, buf[:l]) - buf = buf[l:] - addrs = append(addrs, addr) - } - - if len(buf) > 0 { - return nil, fmt.Errorf("bad packed address: unprocessed bytes: %v %v", packed, buf) - } - - return addrs, nil -} - // cookie: counter:SHA256(nonce + ns + counter) func packCookie(counter int64, ns string, nonce []byte) []byte { cbits := make([]byte, 8) diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/rendezvous.go b/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/rendezvous.go index d0adea479..d45da75d6 100644 --- a/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/rendezvous.go +++ b/vendor/github.com/waku-org/go-waku/waku/v2/rendezvous/rendezvous.go @@ -7,9 +7,9 @@ import ( "sync" "time" - rvs "github.com/berty/go-libp2p-rendezvous" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" + rvs "github.com/waku-org/go-libp2p-rendezvous" "github.com/waku-org/go-waku/waku/v2/protocol/relay" "go.uber.org/zap" ) @@ -116,6 +116,8 @@ func (r *Rendezvous) discover(ctx context.Context) { if err != nil { r.log.Error("could not discover new peers", zap.Error(err)) cookie = nil + // TODO: add backoff strategy + // continue } if len(addrInfo) != 0 { @@ -133,7 +135,7 @@ func (r *Rendezvous) discover(ctx context.Context) { } else { // TODO: change log level to DEBUG in go-libp2p-rendezvous@v0.4.1/svc.go:234 discover query // TODO: improve this by adding an exponential backoff? - time.Sleep(2 * time.Second) + time.Sleep(5 * time.Second) } } } diff --git a/vendor/github.com/waku-org/go-waku/waku/v2/utils/ip.go b/vendor/github.com/waku-org/go-waku/waku/v2/utils/ip.go new file mode 100644 index 000000000..d74473e87 --- /dev/null +++ b/vendor/github.com/waku-org/go-waku/waku/v2/utils/ip.go @@ -0,0 +1,16 @@ +package utils + +import ( + "net" + "strings" +) + +func IsIPv4(str string) bool { + ip := net.ParseIP(str) + return ip != nil && !strings.Contains(str, ":") +} + +func IsIPv6(str string) bool { + ip := net.ParseIP(str) + return ip != nil && strings.Contains(str, ":") +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 20238d0e3..85a138f75 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -128,11 +128,6 @@ github.com/benbjohnson/immutable # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile -# github.com/berty/go-libp2p-rendezvous v0.4.1 -## explicit; go 1.18 -github.com/berty/go-libp2p-rendezvous -github.com/berty/go-libp2p-rendezvous/db -github.com/berty/go-libp2p-rendezvous/pb # github.com/bits-and-blooms/bitset v1.2.0 ## explicit; go 1.14 github.com/bits-and-blooms/bitset @@ -317,7 +312,6 @@ github.com/godbus/dbus/v5 # github.com/gogo/protobuf v1.3.2 ## explicit; go 1.15 github.com/gogo/protobuf/gogoproto -github.com/gogo/protobuf/io github.com/gogo/protobuf/proto github.com/gogo/protobuf/protoc-gen-gogo/descriptor # github.com/golang-jwt/jwt/v4 v4.3.0 @@ -856,8 +850,8 @@ github.com/remyoudompheng/bigfft # github.com/rivo/uniseg v0.2.0 ## explicit; go 1.12 github.com/rivo/uniseg -# github.com/rjeczalik/notify v0.9.2 -## explicit +# github.com/rjeczalik/notify v0.9.3 +## explicit; go 1.11 github.com/rjeczalik/notify # github.com/rs/cors v1.7.0 ## explicit @@ -987,7 +981,12 @@ github.com/vacp2p/mvds/transport github.com/waku-org/go-discover/discover github.com/waku-org/go-discover/discover/v4wire github.com/waku-org/go-discover/discover/v5wire -# github.com/waku-org/go-waku v0.6.1-0.20230526151800-10c2e20910bf +# github.com/waku-org/go-libp2p-rendezvous v0.0.0-20230601172541-0fad5ff68671 +## explicit; go 1.19 +github.com/waku-org/go-libp2p-rendezvous +github.com/waku-org/go-libp2p-rendezvous/db +github.com/waku-org/go-libp2p-rendezvous/pb +# github.com/waku-org/go-waku v0.6.1-0.20230605200314-b0c094b0b663 ## explicit; go 1.19 github.com/waku-org/go-waku/logging github.com/waku-org/go-waku/waku/persistence