From ad6f064f265b20c47085d926b1bc7c2b29046e21 Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Mon, 29 Jul 2024 17:33:13 +0200 Subject: [PATCH 1/8] chore: remove gogo proto Signed-off-by: D4ryl00 --- buf.gen.yaml | 5 + client.go | 84 +- go.mod | 4 +- go.sum | 18 - pb/buf.yaml | 8 + pb/rendezvous.pb.go | 3885 +++++++++------------------------------- pb/rendezvous.proto | 2 + svc.go | 38 +- svc_test.go | 36 +- sync_inmem_client.go | 26 +- sync_inmem_provider.go | 52 +- 11 files changed, 1030 insertions(+), 3128 deletions(-) create mode 100644 buf.gen.yaml create mode 100644 pb/buf.yaml diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 0000000..e2e6410 --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,5 @@ +version: v1 +plugins: + - plugin: buf.build/protocolbuffers/go + out: ./pb + opt: module=github.com/berty/go-libp2p-rendezvous/pb diff --git a/client.go b/client.go index bb04bfa..6b83a6f 100644 --- a/client.go +++ b/client.go @@ -3,20 +3,19 @@ package rendezvous import ( "context" "fmt" + "io" "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" + "google.golang.org/protobuf/proto" pb "github.com/berty/go-libp2p-rendezvous/pb" ) -var ( - DiscoverAsyncInterval = 2 * time.Minute -) +var DiscoverAsyncInterval = 2 * time.Minute type RendezvousPoint interface { Register(ctx context.Context, ns string, ttl int) (time.Duration, error) @@ -76,8 +75,7 @@ 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) + buffer := make([]byte, inet.MessageSizeMax) addrs := rp.addrFactory(rp.host.Addrs()) if len(addrs) == 0 { @@ -86,13 +84,22 @@ 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) - err = w.WriteMsg(req) + reqBytes, err := proto.Marshal(req) + if err != nil { + return 0, err + } + _, err = s.Write(reqBytes) if err != nil { return 0, err } var res pb.Message - err = r.ReadMsg(&res) + n, err := s.Read(buffer) + if err != nil && err != io.EOF { + return 0, err + } + + err = proto.Unmarshal(buffer[:n], &res) if err != nil { return 0, err } @@ -163,9 +170,14 @@ func (rp *rendezvousPoint) Unregister(ctx context.Context, ns string) error { } defer s.Close() - w := ggio.NewDelimitedWriter(s) req := newUnregisterMessage(ns, rp.host.ID()) - return w.WriteMsg(req) + msgBytes, err := proto.Marshal(req) + if err != nil { + return err + } + + _, err = s.Write(msgBytes) + return err } func (rc *rendezvousClient) Unregister(ctx context.Context, ns string) error { @@ -179,27 +191,35 @@ 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) - - return discoverQuery(ns, limit, cookie, r, w) + return discoverQuery(ns, limit, cookie, s, s) } -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 io.Reader, w io.Writer) ([]Registration, []byte, error) { req := newDiscoverMessage(ns, limit, cookie) - err := w.WriteMsg(req) + reqBytes, err := proto.Marshal(req) + if err != nil { + return nil, nil, err + } + + _, err = w.Write(reqBytes) if err != nil { return nil, nil, err } var res pb.Message - err = r.ReadMsg(&res) + buffer := make([]byte, inet.MessageSizeMax) + n, err := r.Read(buffer) + if err != nil && err != io.EOF { + return nil, nil, err + } + + err = proto.Unmarshal(buffer[:n], &res) if err != nil { return nil, nil, err } 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() @@ -236,9 +256,6 @@ 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) - const batch = 200 var ( @@ -248,7 +265,7 @@ func discoverAsync(ctx context.Context, ns string, s inet.Stream, ch chan Regist ) for { - regs, cookie, err = discoverQuery(ns, batch, cookie, r, w) + regs, cookie, err = discoverQuery(ns, batch, cookie, s, s) if err != nil { // TODO robust error recovery // - handle closed streams with backoff + new stream, preserving the cookie @@ -343,10 +360,7 @@ func (rp *rendezvousPoint) DiscoverSubscribe(ctx context.Context, ns string, ser } defer s.Close() - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) - - subType, subDetails, err := discoverSubscribeQuery(ns, serviceTypes, r, w) + subType, subDetails, err := discoverSubscribeQuery(ns, serviceTypes, s, s) if err != nil { return nil, fmt.Errorf("discover subscribe error: %w", err) } @@ -386,22 +400,32 @@ func (rp *rendezvousPoint) DiscoverSubscribe(ctx context.Context, ns string, ser return ch, nil } -func discoverSubscribeQuery(ns string, serviceTypes []string, r ggio.Reader, w ggio.Writer) (subType string, subDetails string, err error) { +func discoverSubscribeQuery(ns string, serviceTypes []string, r io.Reader, w io.Writer) (subType string, subDetails string, err error) { req := &pb.Message{ Type: pb.Message_DISCOVER_SUBSCRIBE, DiscoverSubscribe: newDiscoverSubscribeMessage(ns, serviceTypes), } - err = w.WriteMsg(req) + reqBytes, err := proto.Marshal(req) + if err != nil { + return "", "", fmt.Errorf("marshal err: %w", err) + } + _, err = w.Write(reqBytes) if err != nil { return "", "", fmt.Errorf("write err: %w", err) } var res pb.Message - err = r.ReadMsg(&res) - if err != nil { + buffer := make([]byte, inet.MessageSizeMax) + n, err := r.Read(buffer) + if err != nil && err != io.EOF { return "", "", fmt.Errorf("read err: %w", err) } + err = proto.Unmarshal(buffer[:n], &res) + if err != nil { + return "", "", fmt.Errorf("unmarshal err: %w", err) + } + if res.GetType() != pb.Message_DISCOVER_SUBSCRIBE_RESPONSE { return "", "", fmt.Errorf("unexpected response: %s", res.GetType().String()) } diff --git a/go.mod b/go.mod index 843660a..d2a8e9a 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,6 @@ toolchain go1.22.5 require ( github.com/berty/go-libp2p-mock v1.0.2-0.20240719150538-d7088679a8a7 - github.com/gogo/protobuf v1.3.2 - github.com/golang/protobuf v1.5.3 github.com/google/uuid v1.4.0 github.com/ipfs/go-log/v2 v2.5.1 github.com/libp2p/go-libp2p v0.34.1 @@ -15,6 +13,7 @@ require ( github.com/multiformats/go-multiaddr v0.12.4 github.com/mutecomm/go-sqlcipher/v4 v4.4.2 github.com/stretchr/testify v1.9.0 + google.golang.org/protobuf v1.34.1 ) require ( @@ -91,7 +90,6 @@ require ( golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect golang.org/x/tools v0.21.0 // indirect - google.golang.org/protobuf v1.34.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index 33350a1..c92b9b9 100644 --- a/go.sum +++ b/go.sum @@ -66,12 +66,10 @@ github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= @@ -105,7 +103,6 @@ github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPw github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= @@ -322,8 +319,6 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= @@ -351,7 +346,6 @@ golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= @@ -371,8 +365,6 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -389,8 +381,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -414,8 +404,6 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -428,7 +416,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -482,8 +469,6 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= @@ -491,7 +476,6 @@ golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= @@ -509,8 +493,6 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pb/buf.yaml b/pb/buf.yaml new file mode 100644 index 0000000..7287355 --- /dev/null +++ b/pb/buf.yaml @@ -0,0 +1,8 @@ +version: v1 +name: buf.build/berty/go-libp2p-rendezvous +breaking: + use: + - FILE +lint: + use: + - DEFAULT diff --git a/pb/rendezvous.pb.go b/pb/rendezvous.pb.go index e9b3d3f..cf2c24f 100644 --- a/pb/rendezvous.pb.go +++ b/pb/rendezvous.pb.go @@ -1,27 +1,24 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: rendezvous.proto +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: pb/rendezvous.proto -package rendezvous_pb +package pb import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// 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 +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 @@ -35,32 +32,53 @@ const ( 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", -} +// 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", + 100: "DISCOVER_SUBSCRIBE", + 101: "DISCOVER_SUBSCRIBE_RESPONSE", + } + 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, + } +) -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) Enum() *Message_MessageType { + p := new(Message_MessageType) + *p = x + return p } func (x Message_MessageType) String() string { - return proto.EnumName(Message_MessageType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } +func (Message_MessageType) Descriptor() protoreflect.EnumDescriptor { + return file_pb_rendezvous_proto_enumTypes[0].Descriptor() +} + +func (Message_MessageType) Type() protoreflect.EnumType { + return &file_pb_rendezvous_proto_enumTypes[0] +} + +func (x Message_MessageType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Message_MessageType.Descriptor instead. func (Message_MessageType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 0} + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 0} } type Message_ResponseStatus int32 @@ -76,37 +94,62 @@ const ( 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", -} +// Enum value maps for Message_ResponseStatus. +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", + } + 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, + } +) -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) Enum() *Message_ResponseStatus { + p := new(Message_ResponseStatus) + *p = x + return p } func (x Message_ResponseStatus) String() string { - return proto.EnumName(Message_ResponseStatus_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Message_ResponseStatus) Descriptor() protoreflect.EnumDescriptor { + return file_pb_rendezvous_proto_enumTypes[1].Descriptor() +} + +func (Message_ResponseStatus) Type() protoreflect.EnumType { + return &file_pb_rendezvous_proto_enumTypes[1] +} + +func (x Message_ResponseStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } +// Deprecated: Use Message_ResponseStatus.Descriptor instead. func (Message_ResponseStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_ef0a1d5737df1c36, []int{0, 1} + return file_pb_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,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"` @@ -115,3220 +158,992 @@ type Message struct { 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 (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } } -func (m *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} -func (m *Message) XXX_Size() int { - return m.Size() + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_pb_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) } -var xxx_messageInfo_Message proto.InternalMessageInfo +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0} +} -func (m *Message) GetType() Message_MessageType { - if m != nil { - return m.Type +func (x *Message) GetType() Message_MessageType { + if x != nil { + return x.Type } return Message_REGISTER } -func (m *Message) GetRegister() *Message_Register { - if m != nil { - return m.Register +func (x *Message) GetRegister() *Message_Register { + if x != nil { + return x.Register } return nil } -func (m *Message) GetRegisterResponse() *Message_RegisterResponse { - if m != nil { - return m.RegisterResponse +func (x *Message) GetRegisterResponse() *Message_RegisterResponse { + if x != nil { + return x.RegisterResponse } return nil } -func (m *Message) GetUnregister() *Message_Unregister { - if m != nil { - return m.Unregister +func (x *Message) GetUnregister() *Message_Unregister { + if x != nil { + return x.Unregister } return nil } -func (m *Message) GetDiscover() *Message_Discover { - if m != nil { - return m.Discover +func (x *Message) GetDiscover() *Message_Discover { + if x != nil { + return x.Discover } return nil } -func (m *Message) GetDiscoverResponse() *Message_DiscoverResponse { - if m != nil { - return m.DiscoverResponse +func (x *Message) GetDiscoverResponse() *Message_DiscoverResponse { + if x != nil { + return x.DiscoverResponse } return nil } -func (m *Message) GetDiscoverSubscribe() *Message_DiscoverSubscribe { - if m != nil { - return m.DiscoverSubscribe +func (x *Message) GetDiscoverSubscribe() *Message_DiscoverSubscribe { + if x != nil { + return x.DiscoverSubscribe } return nil } -func (m *Message) GetDiscoverSubscribeResponse() *Message_DiscoverSubscribeResponse { - if m != nil { - return m.DiscoverSubscribeResponse +func (x *Message) GetDiscoverSubscribeResponse() *Message_DiscoverSubscribeResponse { + if x != nil { + return x.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:"-"` -} +type RegistrationRecord struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -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) + 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"` } -var xxx_messageInfo_Message_PeerInfo proto.InternalMessageInfo - -func (m *Message_PeerInfo) GetId() []byte { - if m != nil { - return m.Id +func (x *RegistrationRecord) Reset() { + *x = RegistrationRecord{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return nil } -func (m *Message_PeerInfo) GetAddrs() [][]byte { - if m != nil { - return m.Addrs - } - return nil +func (x *RegistrationRecord) String() string { + return protoimpl.X.MessageStringOf(x) } -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 (*RegistrationRecord) ProtoMessage() {} -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 +func (x *RegistrationRecord) ProtoReflect() protoreflect.Message { + mi := &file_pb_rendezvous_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } -} -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) + return mi.MessageOf(x) } -var xxx_messageInfo_Message_Register proto.InternalMessageInfo +// Deprecated: Use RegistrationRecord.ProtoReflect.Descriptor instead. +func (*RegistrationRecord) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{1} +} -func (m *Message_Register) GetNs() string { - if m != nil { - return m.Ns +func (x *RegistrationRecord) GetId() string { + if x != nil { + return x.Id } return "" } -func (m *Message_Register) GetPeer() *Message_PeerInfo { - if m != nil { - return m.Peer +func (x *RegistrationRecord) GetAddrs() [][]byte { + if x != nil { + return x.Addrs } return nil } -func (m *Message_Register) GetTtl() int64 { - if m != nil { - return m.Ttl +func (x *RegistrationRecord) GetNs() string { + if x != nil { + return x.Ns } - 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:"-"` + return "" } -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 (x *RegistrationRecord) GetTtl() int64 { + if x != nil { + return x.Ttl } -} -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) + return 0 } -var xxx_messageInfo_Message_RegisterResponse proto.InternalMessageInfo +type Message_PeerInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Message_RegisterResponse) GetStatus() Message_ResponseStatus { - if m != nil { - return m.Status - } - return Message_OK + Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Addrs [][]byte `protobuf:"bytes,2,rep,name=addrs,proto3" json:"addrs,omitempty"` } -func (m *Message_RegisterResponse) GetStatusText() string { - if m != nil { - return m.StatusText +func (x *Message_PeerInfo) Reset() { + *x = Message_PeerInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return "" } -func (m *Message_RegisterResponse) GetTtl() int64 { - if m != nil { - return m.Ttl - } - return 0 +func (x *Message_PeerInfo) String() string { + return protoimpl.X.MessageStringOf(x) } -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 (*Message_PeerInfo) ProtoMessage() {} -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 +func (x *Message_PeerInfo) ProtoReflect() protoreflect.Message { + mi := &file_pb_rendezvous_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } - return b[:n], nil + return ms } -} -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) + return mi.MessageOf(x) } -var xxx_messageInfo_Message_Unregister proto.InternalMessageInfo +// Deprecated: Use Message_PeerInfo.ProtoReflect.Descriptor instead. +func (*Message_PeerInfo) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 0} +} -func (m *Message_Unregister) GetNs() string { - if m != nil { - return m.Ns +func (x *Message_PeerInfo) GetId() []byte { + if x != nil { + return x.Id } - return "" + return nil } -func (m *Message_Unregister) GetId() []byte { - if m != nil { - return m.Id +func (x *Message_PeerInfo) GetAddrs() [][]byte { + if x != nil { + return x.Addrs } 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:"-"` +type Message_Register struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + 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"` // in seconds } -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 (x *Message_Register) Reset() { + *x = Message_Register{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } } -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) + +func (x *Message_Register) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Message_Discover proto.InternalMessageInfo +func (*Message_Register) ProtoMessage() {} -func (m *Message_Discover) GetNs() string { - if m != nil { - return m.Ns +func (x *Message_Register) ProtoReflect() protoreflect.Message { + mi := &file_pb_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 "" + return mi.MessageOf(x) +} + +// Deprecated: Use Message_Register.ProtoReflect.Descriptor instead. +func (*Message_Register) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 1} } -func (m *Message_Discover) GetLimit() int64 { - if m != nil { - return m.Limit +func (x *Message_Register) GetNs() string { + if x != nil { + return x.Ns } - return 0 + return "" } -func (m *Message_Discover) GetCookie() []byte { - if m != nil { - return m.Cookie +func (x *Message_Register) GetPeer() *Message_PeerInfo { + if x != nil { + return x.Peer } 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 (x *Message_Register) GetTtl() int64 { + if x != nil { + return x.Ttl } + return 0 } -func (m *Message_DiscoverResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message_DiscoverResponse.Merge(m, src) + +type Message_RegisterResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + 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"` } -func (m *Message_DiscoverResponse) XXX_Size() int { - return m.Size() + +func (x *Message_RegisterResponse) Reset() { + *x = Message_RegisterResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Message_DiscoverResponse) XXX_DiscardUnknown() { - xxx_messageInfo_Message_DiscoverResponse.DiscardUnknown(m) + +func (x *Message_RegisterResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Message_DiscoverResponse proto.InternalMessageInfo +func (*Message_RegisterResponse) ProtoMessage() {} -func (m *Message_DiscoverResponse) GetRegistrations() []*Message_Register { - if m != nil { - return m.Registrations +func (x *Message_RegisterResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_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 nil + return mi.MessageOf(x) } -func (m *Message_DiscoverResponse) GetCookie() []byte { - if m != nil { - return m.Cookie - } - return nil +// Deprecated: Use Message_RegisterResponse.ProtoReflect.Descriptor instead. +func (*Message_RegisterResponse) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 2} } -func (m *Message_DiscoverResponse) GetStatus() Message_ResponseStatus { - if m != nil { - return m.Status +func (x *Message_RegisterResponse) GetStatus() Message_ResponseStatus { + if x != nil { + return x.Status } return Message_OK } -func (m *Message_DiscoverResponse) GetStatusText() string { - if m != nil { - return m.StatusText +func (x *Message_RegisterResponse) GetStatusText() string { + if x != nil { + return x.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 (x *Message_RegisterResponse) GetTtl() int64 { + if x != nil { + return x.Ttl } -} -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) + return 0 } -var xxx_messageInfo_Message_DiscoverSubscribe proto.InternalMessageInfo +type Message_Unregister struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Message_DiscoverSubscribe) GetSupportedSubscriptionTypes() []string { - if m != nil { - return m.SupportedSubscriptionTypes - } - return nil + Ns string `protobuf:"bytes,1,opt,name=ns,proto3" json:"ns,omitempty"` + Id []byte `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` } -func (m *Message_DiscoverSubscribe) GetNs() string { - if m != nil { - return m.Ns +func (x *Message_Unregister) Reset() { + *x = Message_Unregister{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - 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) +func (x *Message_Unregister) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Message_DiscoverSubscribeResponse proto.InternalMessageInfo +func (*Message_Unregister) ProtoMessage() {} -func (m *Message_DiscoverSubscribeResponse) GetSubscriptionType() string { - if m != nil { - return m.SubscriptionType +func (x *Message_Unregister) ProtoReflect() protoreflect.Message { + mi := &file_pb_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 "" + return mi.MessageOf(x) +} + +// Deprecated: Use Message_Unregister.ProtoReflect.Descriptor instead. +func (*Message_Unregister) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 3} } -func (m *Message_DiscoverSubscribeResponse) GetSubscriptionDetails() string { - if m != nil { - return m.SubscriptionDetails +func (x *Message_Unregister) GetNs() string { + if x != nil { + return x.Ns } return "" } -func (m *Message_DiscoverSubscribeResponse) GetStatus() Message_ResponseStatus { - if m != nil { - return m.Status +func (x *Message_Unregister) GetId() []byte { + if x != nil { + return x.Id } - return Message_OK + return nil } -func (m *Message_DiscoverSubscribeResponse) GetStatusText() string { - if m != nil { - return m.StatusText - } - return "" +type Message_Discover struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + 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"` } -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 (x *Message_Discover) Reset() { + *x = Message_Discover{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } } -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) + +func (x *Message_Discover) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_RegistrationRecord proto.InternalMessageInfo +func (*Message_Discover) ProtoMessage() {} -func (m *RegistrationRecord) GetId() string { - if m != nil { - return m.Id +func (x *Message_Discover) ProtoReflect() protoreflect.Message { + mi := &file_pb_rendezvous_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return "" + return mi.MessageOf(x) } -func (m *RegistrationRecord) GetAddrs() [][]byte { - if m != nil { - return m.Addrs - } - return nil +// Deprecated: Use Message_Discover.ProtoReflect.Descriptor instead. +func (*Message_Discover) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 4} } -func (m *RegistrationRecord) GetNs() string { - if m != nil { - return m.Ns +func (x *Message_Discover) GetNs() string { + if x != nil { + return x.Ns } return "" } -func (m *RegistrationRecord) GetTtl() int64 { - if m != nil { - return m.Ttl +func (x *Message_Discover) GetLimit() int64 { + if x != nil { + return x.Limit } 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 +func (x *Message_Discover) GetCookie() []byte { + if x != nil { + return x.Cookie } - return dAtA[:n], nil + return nil } -func (m *Message) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} +type Message_DiscoverResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -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 + 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"` } -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 +func (x *Message_DiscoverResponse) Reset() { + *x = Message_DiscoverResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return dAtA[:n], nil } -func (m *Message_PeerInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_DiscoverResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -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 +func (*Message_DiscoverResponse) ProtoMessage() {} + +func (x *Message_DiscoverResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_rendezvous_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } + return ms } - 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 + return mi.MessageOf(x) } -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 +// Deprecated: Use Message_DiscoverResponse.ProtoReflect.Descriptor instead. +func (*Message_DiscoverResponse) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 5} } -func (m *Message_Register) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_DiscoverResponse) GetRegistrations() []*Message_Register { + if x != nil { + return x.Registrations + } + return nil } -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 +func (x *Message_DiscoverResponse) GetCookie() []byte { + if x != nil { + return x.Cookie } - 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 + return 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 +func (x *Message_DiscoverResponse) GetStatus() Message_ResponseStatus { + if x != nil { + return x.Status } - return dAtA[:n], nil + return Message_OK } -func (m *Message_RegisterResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_DiscoverResponse) GetStatusText() string { + if x != nil { + return x.StatusText + } + return "" } -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 +type Message_DiscoverSubscribe struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + 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"` } -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 +func (x *Message_DiscoverSubscribe) Reset() { + *x = Message_DiscoverSubscribe{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return dAtA[:n], nil } -func (m *Message_Unregister) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_DiscoverSubscribe) String() string { + return protoimpl.X.MessageStringOf(x) } -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 (*Message_DiscoverSubscribe) ProtoMessage() {} -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 +func (x *Message_DiscoverSubscribe) ProtoReflect() protoreflect.Message { + mi := &file_pb_rendezvous_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return dAtA[:n], nil + return mi.MessageOf(x) } -func (m *Message_Discover) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +// Deprecated: Use Message_DiscoverSubscribe.ProtoReflect.Descriptor instead. +func (*Message_DiscoverSubscribe) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 6} } -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 +func (x *Message_DiscoverSubscribe) GetSupportedSubscriptionTypes() []string { + if x != nil { + return x.SupportedSubscriptionTypes } - return len(dAtA) - i, nil + return 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 +func (x *Message_DiscoverSubscribe) GetNs() string { + if x != nil { + return x.Ns } - return dAtA[:n], nil + return "" } -func (m *Message_DiscoverResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} +type Message_DiscoverSubscribeResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -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 + 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"` } -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 +func (x *Message_DiscoverSubscribeResponse) Reset() { + *x = Message_DiscoverSubscribeResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_pb_rendezvous_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return dAtA[:n], nil } -func (m *Message_DiscoverSubscribe) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_DiscoverSubscribeResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -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 +func (*Message_DiscoverSubscribeResponse) ProtoMessage() {} + +func (x *Message_DiscoverSubscribeResponse) ProtoReflect() protoreflect.Message { + mi := &file_pb_rendezvous_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) } + return ms } - return len(dAtA) - i, nil + return mi.MessageOf(x) } -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 +// Deprecated: Use Message_DiscoverSubscribeResponse.ProtoReflect.Descriptor instead. +func (*Message_DiscoverSubscribeResponse) Descriptor() ([]byte, []int) { + return file_pb_rendezvous_proto_rawDescGZIP(), []int{0, 7} } -func (m *Message_DiscoverSubscribeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_DiscoverSubscribeResponse) GetSubscriptionType() string { + if x != nil { + return x.SubscriptionType + } + return "" } -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 +func (x *Message_DiscoverSubscribeResponse) GetSubscriptionDetails() string { + if x != nil { + return x.SubscriptionDetails } - 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 + return "" } -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 +func (x *Message_DiscoverSubscribeResponse) GetStatus() Message_ResponseStatus { + if x != nil { + return x.Status } - return dAtA[:n], nil + return Message_OK } -func (m *RegistrationRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (x *Message_DiscoverSubscribeResponse) GetStatusText() string { + if x != nil { + return x.StatusText + } + return "" } -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 +var File_pb_rendezvous_proto protoreflect.FileDescriptor + +var file_pb_rendezvous_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x70, 0x62, 0x2f, 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, 0xf5, 0x0e, 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, 0x12, + 0x56, 0x0a, 0x11, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x62, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 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, 0x53, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x62, 0x65, 0x52, 0x11, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x75, + 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x6e, 0x0a, 0x19, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x65, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 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, 0x53, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x19, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x30, 0x0a, 0x08, 0x50, 0x65, 0x65, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x1a, 0x61, 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, 0x33, 0x0a, 0x04, 0x70, 0x65, 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, 0x50, 0x65, 0x65, 0x72, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x74, + 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 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, 0x03, 0x52, 0x03, 0x74, + 0x74, 0x6c, 0x1a, 0x2c, 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, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, + 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, 0x03, 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, 0x1a, 0x65, 0x0a, + 0x11, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, + 0x62, 0x65, 0x12, 0x40, 0x0a, 0x1c, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x5f, + 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x1a, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, + 0x74, 0x65, 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x54, + 0x79, 0x70, 0x65, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x6e, 0x73, 0x1a, 0xda, 0x01, 0x0a, 0x19, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x31, 0x0a, 0x14, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x73, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x73, 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, 0xa0, 0x01, 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, 0x12, 0x16, 0x0a, 0x12, 0x44, + 0x49, 0x53, 0x43, 0x4f, 0x56, 0x45, 0x52, 0x5f, 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, 0x42, + 0x45, 0x10, 0x64, 0x12, 0x1f, 0x0a, 0x1b, 0x44, 0x49, 0x53, 0x43, 0x4f, 0x56, 0x45, 0x52, 0x5f, + 0x53, 0x55, 0x42, 0x53, 0x43, 0x52, 0x49, 0x42, 0x45, 0x5f, 0x52, 0x45, 0x53, 0x50, 0x4f, 0x4e, + 0x53, 0x45, 0x10, 0x65, 0x22, 0xb5, 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, 0x17, 0x0a, 0x13, 0x45, 0x5f, 0x49, 0x4e, + 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x50, 0x45, 0x45, 0x52, 0x5f, 0x49, 0x4e, 0x46, 0x4f, 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, 0x22, 0x5c, 0x0a, 0x12, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x63, 0x6f, + 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0c, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x6e, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x74, 0x6c, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x74, 0x74, 0x6c, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x65, 0x72, 0x74, 0x79, 0x2f, 0x67, + 0x6f, 0x2d, 0x6c, 0x69, 0x62, 0x70, 0x32, 0x70, 0x2d, 0x72, 0x65, 0x6e, 0x64, 0x65, 0x7a, 0x76, + 0x6f, 0x75, 0x73, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -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 +var ( + file_pb_rendezvous_proto_rawDescOnce sync.Once + file_pb_rendezvous_proto_rawDescData = file_pb_rendezvous_proto_rawDesc +) + +func file_pb_rendezvous_proto_rawDescGZIP() []byte { + file_pb_rendezvous_proto_rawDescOnce.Do(func() { + file_pb_rendezvous_proto_rawDescData = protoimpl.X.CompressGZIP(file_pb_rendezvous_proto_rawDescData) + }) + return file_pb_rendezvous_proto_rawDescData +} + +var file_pb_rendezvous_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_pb_rendezvous_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_pb_rendezvous_proto_goTypes = []any{ + (Message_MessageType)(0), // 0: rendezvous.pb.Message.MessageType + (Message_ResponseStatus)(0), // 1: rendezvous.pb.Message.ResponseStatus + (*Message)(nil), // 2: rendezvous.pb.Message + (*RegistrationRecord)(nil), // 3: rendezvous.pb.RegistrationRecord + (*Message_PeerInfo)(nil), // 4: rendezvous.pb.Message.PeerInfo + (*Message_Register)(nil), // 5: rendezvous.pb.Message.Register + (*Message_RegisterResponse)(nil), // 6: rendezvous.pb.Message.RegisterResponse + (*Message_Unregister)(nil), // 7: rendezvous.pb.Message.Unregister + (*Message_Discover)(nil), // 8: rendezvous.pb.Message.Discover + (*Message_DiscoverResponse)(nil), // 9: rendezvous.pb.Message.DiscoverResponse + (*Message_DiscoverSubscribe)(nil), // 10: rendezvous.pb.Message.DiscoverSubscribe + (*Message_DiscoverSubscribeResponse)(nil), // 11: rendezvous.pb.Message.DiscoverSubscribeResponse +} +var file_pb_rendezvous_proto_depIdxs = []int32{ + 0, // 0: rendezvous.pb.Message.type:type_name -> rendezvous.pb.Message.MessageType + 5, // 1: rendezvous.pb.Message.register:type_name -> rendezvous.pb.Message.Register + 6, // 2: rendezvous.pb.Message.registerResponse:type_name -> rendezvous.pb.Message.RegisterResponse + 7, // 3: rendezvous.pb.Message.unregister:type_name -> rendezvous.pb.Message.Unregister + 8, // 4: rendezvous.pb.Message.discover:type_name -> rendezvous.pb.Message.Discover + 9, // 5: rendezvous.pb.Message.discoverResponse:type_name -> rendezvous.pb.Message.DiscoverResponse + 10, // 6: rendezvous.pb.Message.discoverSubscribe:type_name -> rendezvous.pb.Message.DiscoverSubscribe + 11, // 7: rendezvous.pb.Message.discoverSubscribeResponse:type_name -> rendezvous.pb.Message.DiscoverSubscribeResponse + 4, // 8: rendezvous.pb.Message.Register.peer:type_name -> rendezvous.pb.Message.PeerInfo + 1, // 9: rendezvous.pb.Message.RegisterResponse.status:type_name -> rendezvous.pb.Message.ResponseStatus + 5, // 10: rendezvous.pb.Message.DiscoverResponse.registrations:type_name -> rendezvous.pb.Message.Register + 1, // 11: rendezvous.pb.Message.DiscoverResponse.status:type_name -> rendezvous.pb.Message.ResponseStatus + 1, // 12: rendezvous.pb.Message.DiscoverSubscribeResponse.status:type_name -> rendezvous.pb.Message.ResponseStatus + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name +} + +func init() { file_pb_rendezvous_proto_init() } +func file_pb_rendezvous_proto_init() { + if File_pb_rendezvous_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pb_rendezvous_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Message); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_rendezvous_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*RegistrationRecord); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_rendezvous_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*Message_PeerInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_rendezvous_proto_msgTypes[3].Exporter = func(v any, i int) any { + 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_pb_rendezvous_proto_msgTypes[4].Exporter = func(v any, i int) any { + 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_pb_rendezvous_proto_msgTypes[5].Exporter = func(v any, i int) any { + 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_pb_rendezvous_proto_msgTypes[6].Exporter = func(v any, i int) any { + 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_pb_rendezvous_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*Message_DiscoverResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_rendezvous_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*Message_DiscoverSubscribe); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pb_rendezvous_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*Message_DiscoverSubscribeResponse); 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_pb_rendezvous_proto_rawDesc, + NumEnums: 2, + NumMessages: 10, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_pb_rendezvous_proto_goTypes, + DependencyIndexes: file_pb_rendezvous_proto_depIdxs, + EnumInfos: file_pb_rendezvous_proto_enumTypes, + MessageInfos: file_pb_rendezvous_proto_msgTypes, + }.Build() + File_pb_rendezvous_proto = out.File + file_pb_rendezvous_proto_rawDesc = nil + file_pb_rendezvous_proto_goTypes = nil + file_pb_rendezvous_proto_depIdxs = nil } -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/pb/rendezvous.proto b/pb/rendezvous.proto index a1ec9d8..3c2e9d7 100644 --- a/pb/rendezvous.proto +++ b/pb/rendezvous.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package rendezvous.pb; +option go_package = "github.com/berty/go-libp2p-rendezvous/pb"; + message Message { enum MessageType { REGISTER = 0; diff --git a/svc.go b/svc.go index 79dfc3f..f0ea1b8 100644 --- a/svc.go +++ b/svc.go @@ -2,11 +2,12 @@ package rendezvous import ( "fmt" + "io" - 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" + "google.golang.org/protobuf/proto" db "github.com/berty/go-libp2p-rendezvous/db" pb "github.com/berty/go-libp2p-rendezvous/pb" @@ -34,18 +35,23 @@ func NewRendezvousService(host host.Host, db db.DB, rzs ...RendezvousSync) *Rend func (rz *RendezvousService) handleStream(s inet.Stream) { defer s.Reset() + buffer := make([]byte, inet.MessageSizeMax) + pid := s.Conn().RemotePeer() log.Debugf("New stream from %s", pid.String()) - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) - for { var req pb.Message var res pb.Message - err := r.ReadMsg(&req) + n, err := s.Read(buffer) + if err != nil && err != io.EOF { + return + } + + err = proto.Unmarshal(buffer[:n], &req) if err != nil { + log.Errorf("error unmarshalling request: %s", err.Error()) return } @@ -55,7 +61,13 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { r := rz.handleRegister(pid, req.GetRegister()) res.Type = pb.Message_REGISTER_RESPONSE res.RegisterResponse = r - err = w.WriteMsg(&res) + msgBytes, err := proto.Marshal(&res) + if err != nil { + log.Errorf("error marshalling response: %s", err.Error()) + return + } + + _, err = s.Write(msgBytes) if err != nil { log.Debugf("Error writing response: %s", err.Error()) return @@ -71,7 +83,12 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { r := rz.handleDiscover(pid, req.GetDiscover()) res.Type = pb.Message_DISCOVER_RESPONSE res.DiscoverResponse = r - err = w.WriteMsg(&res) + msgBytes, err := proto.Marshal(&res) + if err != nil { + log.Errorf("error marshalling response: %s", err.Error()) + return + } + _, err = s.Write(msgBytes) if err != nil { log.Debugf("Error writing response: %s", err.Error()) return @@ -81,7 +98,12 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { r := rz.handleDiscoverSubscribe(pid, req.GetDiscoverSubscribe()) res.Type = pb.Message_DISCOVER_SUBSCRIBE_RESPONSE res.DiscoverSubscribeResponse = r - err = w.WriteMsg(&res) + msgBytes, err := proto.Marshal(&res) + if err != nil { + log.Errorf("error marshalling response: %s", err.Error()) + return + } + _, err = s.Write(msgBytes) if err != nil { log.Debugf("Error writing response: %s", err.Error()) return diff --git a/svc_test.go b/svc_test.go index bc15365..606f639 100644 --- a/svc_test.go +++ b/svc_test.go @@ -3,16 +3,17 @@ package rendezvous import ( "context" "fmt" + "io" "math/rand" "testing" "time" mocknet "github.com/berty/go-libp2p-mock" - 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/stretchr/testify/require" + "google.golang.org/protobuf/proto" db "github.com/berty/go-libp2p-rendezvous/db/sqlite" pb "github.com/berty/go-libp2p-rendezvous/pb" @@ -140,14 +141,23 @@ func TestSVCErrors(t *testing.T) { require.NoError(t, err) defer svc.DB.Close() + const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + seededRand := rand.New(rand.NewSource(time.Now().UnixNano())) + generateRandomString := func(length int) string { + b := make([]byte, length) + for i := range b { + b[i] = charset[seededRand.Intn(len(charset))] + } + return string(b) + } + // testable registration errors res, err := doTestRequest(ctx, hosts[1], hosts[0].ID(), newRegisterMessage("", peer.AddrInfo{}, 0)) require.NoError(t, err) require.Equal(t, pb.Message_E_INVALID_NAMESPACE, res.GetRegisterResponse().GetStatus()) - badns := make([]byte, 2*MaxNamespaceLength) - rand.Read(badns) + badns := generateRandomString(2 * MaxNamespaceLength) res, err = doTestRequest(ctx, hosts[1], hosts[0].ID(), newRegisterMessage(string(badns), peer.AddrInfo{}, 0)) require.NoError(t, err) @@ -206,14 +216,14 @@ func TestSVCErrors(t *testing.T) { require.Equal(t, pb.Message_E_INVALID_NAMESPACE, res.GetDiscoverResponse().GetStatus()) badcookie := make([]byte, 10) - rand.Read(badcookie) + seededRand.Read(badcookie) res, err = doTestRequest(ctx, hosts[1], hosts[0].ID(), newDiscoverMessage("foo", 0, badcookie)) require.NoError(t, err) require.Equal(t, pb.Message_E_INVALID_COOKIE, res.GetDiscoverResponse().GetStatus()) badcookie = make([]byte, 40) - rand.Read(badcookie) + seededRand.Read(badcookie) res, err = doTestRequest(ctx, hosts[1], hosts[0].ID(), newDiscoverMessage("foo", 0, badcookie)) require.NoError(t, err) @@ -227,16 +237,22 @@ func doTestRequest(ctx context.Context, host host.Host, rp peer.ID, m *pb.Messag } defer s.Close() - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) - w := ggio.NewDelimitedWriter(s) - - err = w.WriteMsg(m) + mBytes, err := proto.Marshal(m) + if err != nil { + return nil, err + } + _, err = s.Write(mBytes) if err != nil { return nil, err } res := new(pb.Message) - err = r.ReadMsg(res) + buffer := make([]byte, inet.MessageSizeMax) + n, err := s.Read(buffer) + if err != nil && err != io.EOF { + return nil, err + } + err = proto.Unmarshal(buffer[:n], res) if err != nil { return nil, err } diff --git a/sync_inmem_client.go b/sync_inmem_client.go index d910ea5..487500d 100644 --- a/sync_inmem_client.go +++ b/sync_inmem_client.go @@ -4,14 +4,15 @@ import ( "context" "encoding/json" "fmt" + "io" "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" + "google.golang.org/protobuf/proto" pb "github.com/berty/go-libp2p-rendezvous/pb" ) @@ -57,16 +58,22 @@ func (c *client) getStreamToPeer(pidStr string) (inet.Stream, error) { } func (c *client) streamListener(s inet.Stream) { - r := ggio.NewDelimitedReader(s, inet.MessageSizeMax) record := &pb.RegistrationRecord{} for { - err := r.ReadMsg(record) - if err != nil { + buffer := make([]byte, inet.MessageSizeMax) + n, err := s.Read(buffer) + if err != nil && err != io.EOF { log.Errorf("unable to decode message: %s", err.Error()) return } + err = proto.Unmarshal(buffer[:n], record) + if err != nil { + log.Errorf("error unmarshalling request: %s", err.Error()) + return + } + pid, err := peer.Decode(record.Id) if err != nil { log.Warnf("invalid peer id: %s", err.Error()) @@ -118,13 +125,16 @@ func (c *client) Subscribe(ctx context.Context, syncDetails string) (<-chan *Reg return nil, fmt.Errorf("unable to get stream to peer: %w", err) } - w := ggio.NewDelimitedWriter(s) - - err = w.WriteMsg(&pb.Message{ + msbBytes, err := proto.Marshal(&pb.Message{ Type: pb.Message_DISCOVER_SUBSCRIBE, DiscoverSubscribe: &pb.Message_DiscoverSubscribe{ Ns: psDetails.ChannelName, - }}) + }, + }) + if err != nil { + return nil, fmt.Errorf("unable to marshal message: %w", err) + } + _, err = s.Write(msbBytes) if err != nil { return nil, fmt.Errorf("unable to query server") } diff --git a/sync_inmem_provider.go b/sync_inmem_provider.go index 970ed1d..bb5b3f9 100644 --- a/sync_inmem_provider.go +++ b/sync_inmem_provider.go @@ -3,15 +3,16 @@ package rendezvous import ( "encoding/json" "fmt" + "io" "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" + "google.golang.org/protobuf/proto" ) const ( @@ -27,7 +28,7 @@ type PubSub struct { type PubSubSubscribers struct { mu sync.RWMutex - subscribers map[peer.ID]ggio.Writer + subscribers map[peer.ID]io.Writer lastAnnouncement *pb.RegistrationRecord } @@ -52,7 +53,6 @@ func (ps *PubSub) Subscribe(ns string) (syncDetails string, err error) { PeerID: ps.host.ID().String(), ChannelName: ns, }) - if err != nil { return "", fmt.Errorf("unable to marshal subscription details: %w", err) } @@ -73,7 +73,7 @@ func (ps *PubSub) getOrCreateTopic(ns string) *PubSubSubscribers { } ps.topics[ns] = &PubSubSubscribers{ - subscribers: map[peer.ID]ggio.Writer{}, + subscribers: map[peer.ID]io.Writer{}, lastAnnouncement: nil, } return ps.topics[ns] @@ -81,18 +81,23 @@ func (ps *PubSub) getOrCreateTopic(ns string) *PubSubSubscribers { func (ps *PubSub) Register(pid peer.ID, ns string, addrs [][]byte, ttlAsSeconds int, counter uint64) { topic := ps.getOrCreateTopic(ns) - dataToSend := &pb.RegistrationRecord{ + data := &pb.RegistrationRecord{ Id: pid.String(), Addrs: addrs, Ns: ns, Ttl: time.Now().Add(time.Duration(ttlAsSeconds) * time.Second).UnixMilli(), } + dataBytes, err := proto.Marshal(data) + if err != nil { + log.Errorf("unable to marshal registration record: %s", err.Error()) + return + } topic.mu.Lock() - topic.lastAnnouncement = dataToSend + topic.lastAnnouncement = data toNotify := topic.subscribers for _, stream := range toNotify { - if err := stream.WriteMsg(dataToSend); err != nil { + if _, err := stream.Write(dataBytes); err != nil { log.Errorf("unable to notify rendezvous data update: %s", err.Error()) } } @@ -110,22 +115,30 @@ func (ps *PubSub) Listen() { 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 + buffer := make([]byte, inet.MessageSizeMax) - err := r.ReadMsg(&req) - if err != nil { + defer func() { for ns := range subscribedTopics { topic := ps.getOrCreateTopic(ns) topic.mu.Lock() delete(topic.subscribers, s.Conn().RemotePeer()) topic.mu.Unlock() } + }() + + n, err := s.Read(buffer) + if err != nil && err != io.EOF { + log.Errorf("unable to read from stream: %s", err.Error()) + return + } + + err = proto.Unmarshal(buffer[:n], &req) + if err != nil { + log.Errorf("error unmarshalling request: %s", err.Error()) return } @@ -140,11 +153,16 @@ func (ps *PubSub) handleStream(s inet.Stream) { continue } - topic.subscribers[s.Conn().RemotePeer()] = w + topic.subscribers[s.Conn().RemotePeer()] = s subscribedTopics[req.DiscoverSubscribe.Ns] = struct{}{} lastAnnouncement := topic.lastAnnouncement if lastAnnouncement != nil { - if err := w.WriteMsg(lastAnnouncement); err != nil { + msgBytes, err := proto.Marshal(lastAnnouncement) + if err != nil { + log.Errorf("error marshalling response: %s", err.Error()) + continue + } + if _, err := s.Write(msgBytes); err != nil { log.Errorf("unable to write announcement: %s", err.Error()) } } @@ -152,5 +170,7 @@ func (ps *PubSub) handleStream(s inet.Stream) { } } -var _ RendezvousSync = (*PubSub)(nil) -var _ RendezvousSyncSubscribable = (*PubSub)(nil) +var ( + _ RendezvousSync = (*PubSub)(nil) + _ RendezvousSyncSubscribable = (*PubSub)(nil) +) From f770cd76e5a052d17adc253a97ba6bc5d6acf052 Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Thu, 1 Aug 2024 12:19:40 +0200 Subject: [PATCH 2/8] chore: use libp2p mocknet Signed-off-by: D4ryl00 --- client_test.go | 2 +- discovery_test.go | 2 +- go.mod | 1 - go.sum | 6 ++++-- svc_test.go | 2 +- sync_inmem_test.go | 2 +- test_utils/svc.go | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/client_test.go b/client_test.go index 8520480..92840d8 100644 --- a/client_test.go +++ b/client_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - mocknet "github.com/berty/go-libp2p-mock" "github.com/libp2p/go-libp2p/core/peer" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/berty/go-libp2p-rendezvous/test_utils" "github.com/libp2p/go-libp2p/core/host" diff --git a/discovery_test.go b/discovery_test.go index f5e36c5..4c6c3ab 100644 --- a/discovery_test.go +++ b/discovery_test.go @@ -6,10 +6,10 @@ import ( "testing" "time" - mocknet "github.com/berty/go-libp2p-mock" "github.com/libp2p/go-libp2p/core/discovery" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" ) func getRendezvousDiscovery(hosts []host.Host) []discovery.Discovery { diff --git a/go.mod b/go.mod index d2a8e9a..41f32b2 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.22 toolchain go1.22.5 require ( - github.com/berty/go-libp2p-mock v1.0.2-0.20240719150538-d7088679a8a7 github.com/google/uuid v1.4.0 github.com/ipfs/go-log/v2 v2.5.1 github.com/libp2p/go-libp2p v0.34.1 diff --git a/go.sum b/go.sum index c92b9b9..5bf8fc8 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,6 @@ github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 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-mock v1.0.2-0.20240719150538-d7088679a8a7 h1:PDDJoHz7nIpeLhoNNRCO1pKqtwl8q4dEJAT0f+fEqH0= -github.com/berty/go-libp2p-mock v1.0.2-0.20240719150538-d7088679a8a7/go.mod h1:EFApuF26i3EW00yju+Gu0+yM3ozxrZQmnWi5R5AdsNM= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= @@ -94,12 +92,16 @@ github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= +github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= +github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= +github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= diff --git a/svc_test.go b/svc_test.go index 606f639..98febed 100644 --- a/svc_test.go +++ b/svc_test.go @@ -8,10 +8,10 @@ import ( "testing" "time" - mocknet "github.com/berty/go-libp2p-mock" "github.com/libp2p/go-libp2p/core/host" inet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" diff --git a/sync_inmem_test.go b/sync_inmem_test.go index 91f2064..583972d 100644 --- a/sync_inmem_test.go +++ b/sync_inmem_test.go @@ -7,11 +7,11 @@ import ( "testing" "time" - mocknet "github.com/berty/go-libp2p-mock" rendezvous "github.com/berty/go-libp2p-rendezvous" db "github.com/berty/go-libp2p-rendezvous/db/sqlite" "github.com/berty/go-libp2p-rendezvous/test_utils" "github.com/libp2p/go-libp2p/core/host" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" ) func makeRendezvousService(ctx context.Context, host host.Host, path string, rzs ...rendezvous.RendezvousSync) (*rendezvous.RendezvousService, error) { diff --git a/test_utils/svc.go b/test_utils/svc.go index 13b4f31..375b09f 100644 --- a/test_utils/svc.go +++ b/test_utils/svc.go @@ -4,9 +4,9 @@ import ( "context" "testing" - mocknet "github.com/berty/go-libp2p-mock" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" + mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/stretchr/testify/require" ) From 7cfbd32ab6f5c3853efa93cb0f76711061a69912 Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Thu, 1 Aug 2024 18:14:32 +0200 Subject: [PATCH 3/8] chore: import ggio into protoio Signed-off-by: D4ryl00 --- client.go | 78 ++++++++--------------- protoio/full.go | 103 ++++++++++++++++++++++++++++++ protoio/io.go | 71 +++++++++++++++++++++ protoio/uint32.go | 138 +++++++++++++++++++++++++++++++++++++++++ protoio/varint.go | 134 +++++++++++++++++++++++++++++++++++++++ svc.go | 38 +++--------- svc_test.go | 19 ++---- sync_inmem_client.go | 23 +++---- sync_inmem_provider.go | 41 ++++-------- 9 files changed, 505 insertions(+), 140 deletions(-) create mode 100644 protoio/full.go create mode 100644 protoio/io.go create mode 100644 protoio/uint32.go create mode 100644 protoio/varint.go diff --git a/client.go b/client.go index 6b83a6f..60522b5 100644 --- a/client.go +++ b/client.go @@ -3,16 +3,15 @@ package rendezvous import ( "context" "fmt" - "io" "math/rand" "time" "github.com/libp2p/go-libp2p/core/host" inet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" - "google.golang.org/protobuf/proto" pb "github.com/berty/go-libp2p-rendezvous/pb" + protoio "github.com/berty/go-libp2p-rendezvous/protoio" ) var DiscoverAsyncInterval = 2 * time.Minute @@ -75,7 +74,8 @@ func (rp *rendezvousPoint) Register(ctx context.Context, ns string, ttl int) (ti } defer s.Reset() - buffer := make([]byte, inet.MessageSizeMax) + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) addrs := rp.addrFactory(rp.host.Addrs()) if len(addrs) == 0 { @@ -84,23 +84,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) - reqBytes, err := proto.Marshal(req) - if err != nil { - return 0, err - } - _, err = s.Write(reqBytes) + err = w.WriteMsg(req) if err != nil { return 0, err } var res pb.Message - n, err := s.Read(buffer) - if err != nil && err != io.EOF { - return 0, err - } - - err = proto.Unmarshal(buffer[:n], &res) - if err != nil { + if err := r.ReadMsg(&res); err != nil { return 0, err } @@ -170,14 +160,9 @@ func (rp *rendezvousPoint) Unregister(ctx context.Context, ns string) error { } defer s.Close() + w := protoio.NewDelimitedWriter(s) req := newUnregisterMessage(ns, rp.host.ID()) - msgBytes, err := proto.Marshal(req) - if err != nil { - return err - } - - _, err = s.Write(msgBytes) - return err + return w.WriteMsg(req) } func (rc *rendezvousClient) Unregister(ctx context.Context, ns string) error { @@ -191,29 +176,20 @@ func (rp *rendezvousPoint) Discover(ctx context.Context, ns string, limit int, c } defer s.Reset() - return discoverQuery(ns, limit, cookie, s, s) + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) + return discoverQuery(ns, limit, cookie, r, w) } -func discoverQuery(ns string, limit int, cookie []byte, r io.Reader, w io.Writer) ([]Registration, []byte, error) { +func discoverQuery(ns string, limit int, cookie []byte, r protoio.Reader, w protoio.Writer) ([]Registration, []byte, error) { req := newDiscoverMessage(ns, limit, cookie) - reqBytes, err := proto.Marshal(req) - if err != nil { - return nil, nil, err - } - - _, err = w.Write(reqBytes) + err := w.WriteMsg(req) if err != nil { return nil, nil, err } var res pb.Message - buffer := make([]byte, inet.MessageSizeMax) - n, err := r.Read(buffer) - if err != nil && err != io.EOF { - return nil, nil, err - } - - err = proto.Unmarshal(buffer[:n], &res) + err = r.ReadMsg(&res) if err != nil { return nil, nil, err } @@ -256,6 +232,9 @@ func discoverAsync(ctx context.Context, ns string, s inet.Stream, ch chan Regist defer s.Reset() defer close(ch) + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) + const batch = 200 var ( @@ -265,7 +244,7 @@ func discoverAsync(ctx context.Context, ns string, s inet.Stream, ch chan Regist ) for { - regs, cookie, err = discoverQuery(ns, batch, cookie, s, s) + regs, cookie, err = discoverQuery(ns, batch, cookie, r, w) if err != nil { // TODO robust error recovery // - handle closed streams with backoff + new stream, preserving the cookie @@ -360,7 +339,10 @@ func (rp *rendezvousPoint) DiscoverSubscribe(ctx context.Context, ns string, ser } defer s.Close() - subType, subDetails, err := discoverSubscribeQuery(ns, serviceTypes, s, s) + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) + + subType, subDetails, err := discoverSubscribeQuery(ns, serviceTypes, r, w) if err != nil { return nil, fmt.Errorf("discover subscribe error: %w", err) } @@ -400,30 +382,20 @@ func (rp *rendezvousPoint) DiscoverSubscribe(ctx context.Context, ns string, ser return ch, nil } -func discoverSubscribeQuery(ns string, serviceTypes []string, r io.Reader, w io.Writer) (subType string, subDetails string, err error) { +func discoverSubscribeQuery(ns string, serviceTypes []string, r protoio.Reader, w protoio.Writer) (subType string, subDetails string, err error) { req := &pb.Message{ Type: pb.Message_DISCOVER_SUBSCRIBE, DiscoverSubscribe: newDiscoverSubscribeMessage(ns, serviceTypes), } - reqBytes, err := proto.Marshal(req) - if err != nil { - return "", "", fmt.Errorf("marshal err: %w", err) - } - _, err = w.Write(reqBytes) + err = w.WriteMsg(req) if err != nil { return "", "", fmt.Errorf("write err: %w", err) } var res pb.Message - buffer := make([]byte, inet.MessageSizeMax) - n, err := r.Read(buffer) - if err != nil && err != io.EOF { - return "", "", fmt.Errorf("read err: %w", err) - } - - err = proto.Unmarshal(buffer[:n], &res) + err = r.ReadMsg(&res) if err != nil { - return "", "", fmt.Errorf("unmarshal err: %w", err) + return "", "", fmt.Errorf("read err: %w", err) } if res.GetType() != pb.Message_DISCOVER_SUBSCRIBE_RESPONSE { diff --git a/protoio/full.go b/protoio/full.go new file mode 100644 index 0000000..d3d038a --- /dev/null +++ b/protoio/full.go @@ -0,0 +1,103 @@ +// 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 protoio + +import ( + "io" + + "google.golang.org/protobuf/proto" +) + +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/protoio/io.go b/protoio/io.go new file mode 100644 index 0000000..4bf8042 --- /dev/null +++ b/protoio/io.go @@ -0,0 +1,71 @@ +// 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 protoio + +import ( + "io" + + "google.golang.org/protobuf/proto" +) + +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/protoio/uint32.go b/protoio/uint32.go new file mode 100644 index 0000000..160dcdf --- /dev/null +++ b/protoio/uint32.go @@ -0,0 +1,138 @@ +// 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 protoio + +import ( + "encoding/binary" + "io" + + "google.golang.org/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/protoio/varint.go b/protoio/varint.go new file mode 100644 index 0000000..1e2a3b8 --- /dev/null +++ b/protoio/varint.go @@ -0,0 +1,134 @@ +// 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 protoio + +import ( + "bufio" + "encoding/binary" + "errors" + "io" + + "google.golang.org/protobuf/proto" +) + +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/svc.go b/svc.go index f0ea1b8..e34cc33 100644 --- a/svc.go +++ b/svc.go @@ -2,15 +2,14 @@ package rendezvous import ( "fmt" - "io" "github.com/libp2p/go-libp2p/core/host" inet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" - "google.golang.org/protobuf/proto" db "github.com/berty/go-libp2p-rendezvous/db" pb "github.com/berty/go-libp2p-rendezvous/pb" + protoio "github.com/berty/go-libp2p-rendezvous/protoio" ) const ( @@ -35,23 +34,17 @@ func NewRendezvousService(host host.Host, db db.DB, rzs ...RendezvousSync) *Rend func (rz *RendezvousService) handleStream(s inet.Stream) { defer s.Reset() - buffer := make([]byte, inet.MessageSizeMax) - pid := s.Conn().RemotePeer() log.Debugf("New stream from %s", pid.String()) + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) + for { var req pb.Message var res pb.Message - n, err := s.Read(buffer) - if err != nil && err != io.EOF { - return - } - - err = proto.Unmarshal(buffer[:n], &req) - if err != nil { - log.Errorf("error unmarshalling request: %s", err.Error()) + if err := r.ReadMsg(&req); err != nil { return } @@ -61,13 +54,8 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { r := rz.handleRegister(pid, req.GetRegister()) res.Type = pb.Message_REGISTER_RESPONSE res.RegisterResponse = r - msgBytes, err := proto.Marshal(&res) - if err != nil { - log.Errorf("error marshalling response: %s", err.Error()) - return - } - _, err = s.Write(msgBytes) + err := w.WriteMsg(&res) if err != nil { log.Debugf("Error writing response: %s", err.Error()) return @@ -83,12 +71,7 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { r := rz.handleDiscover(pid, req.GetDiscover()) res.Type = pb.Message_DISCOVER_RESPONSE res.DiscoverResponse = r - msgBytes, err := proto.Marshal(&res) - if err != nil { - log.Errorf("error marshalling response: %s", err.Error()) - return - } - _, err = s.Write(msgBytes) + err := w.WriteMsg(&res) if err != nil { log.Debugf("Error writing response: %s", err.Error()) return @@ -98,12 +81,7 @@ func (rz *RendezvousService) handleStream(s inet.Stream) { r := rz.handleDiscoverSubscribe(pid, req.GetDiscoverSubscribe()) res.Type = pb.Message_DISCOVER_SUBSCRIBE_RESPONSE res.DiscoverSubscribeResponse = r - msgBytes, err := proto.Marshal(&res) - if err != nil { - log.Errorf("error marshalling response: %s", err.Error()) - return - } - _, err = s.Write(msgBytes) + err := w.WriteMsg(&res) if err != nil { log.Debugf("Error writing response: %s", err.Error()) return diff --git a/svc_test.go b/svc_test.go index 98febed..de1f52e 100644 --- a/svc_test.go +++ b/svc_test.go @@ -3,7 +3,6 @@ package rendezvous import ( "context" "fmt" - "io" "math/rand" "testing" "time" @@ -13,10 +12,10 @@ import ( "github.com/libp2p/go-libp2p/core/peer" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/proto" db "github.com/berty/go-libp2p-rendezvous/db/sqlite" pb "github.com/berty/go-libp2p-rendezvous/pb" + protoio "github.com/berty/go-libp2p-rendezvous/protoio" "github.com/berty/go-libp2p-rendezvous/test_utils" ) @@ -237,22 +236,16 @@ func doTestRequest(ctx context.Context, host host.Host, rp peer.ID, m *pb.Messag } defer s.Close() - mBytes, err := proto.Marshal(m) - if err != nil { - return nil, err - } - _, err = s.Write(mBytes) + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) + + err = w.WriteMsg(m) if err != nil { return nil, err } res := new(pb.Message) - buffer := make([]byte, inet.MessageSizeMax) - n, err := s.Read(buffer) - if err != nil && err != io.EOF { - return nil, err - } - err = proto.Unmarshal(buffer[:n], res) + err = r.ReadMsg(res) if err != nil { return nil, err } diff --git a/sync_inmem_client.go b/sync_inmem_client.go index 487500d..eb4a320 100644 --- a/sync_inmem_client.go +++ b/sync_inmem_client.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io" "sync" "github.com/google/uuid" @@ -12,9 +11,9 @@ import ( inet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/multiformats/go-multiaddr" - "google.golang.org/protobuf/proto" pb "github.com/berty/go-libp2p-rendezvous/pb" + protoio "github.com/berty/go-libp2p-rendezvous/protoio" ) type client struct { @@ -58,19 +57,13 @@ func (c *client) getStreamToPeer(pidStr string) (inet.Stream, error) { } func (c *client) streamListener(s inet.Stream) { + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) record := &pb.RegistrationRecord{} for { - buffer := make([]byte, inet.MessageSizeMax) - n, err := s.Read(buffer) - if err != nil && err != io.EOF { - log.Errorf("unable to decode message: %s", err.Error()) - return - } - - err = proto.Unmarshal(buffer[:n], record) + err := r.ReadMsg(record) if err != nil { - log.Errorf("error unmarshalling request: %s", err.Error()) + log.Errorf("unable to decode message: %s", err.Error()) return } @@ -125,16 +118,14 @@ func (c *client) Subscribe(ctx context.Context, syncDetails string) (<-chan *Reg return nil, fmt.Errorf("unable to get stream to peer: %w", err) } - msbBytes, err := proto.Marshal(&pb.Message{ + w := protoio.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 marshal message: %w", err) - } - _, err = s.Write(msbBytes) if err != nil { return nil, fmt.Errorf("unable to query server") } diff --git a/sync_inmem_provider.go b/sync_inmem_provider.go index bb5b3f9..fa60e46 100644 --- a/sync_inmem_provider.go +++ b/sync_inmem_provider.go @@ -3,16 +3,15 @@ package rendezvous import ( "encoding/json" "fmt" - "io" "sync" "time" pb "github.com/berty/go-libp2p-rendezvous/pb" + protoio "github.com/berty/go-libp2p-rendezvous/protoio" "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" - "google.golang.org/protobuf/proto" ) const ( @@ -28,7 +27,7 @@ type PubSub struct { type PubSubSubscribers struct { mu sync.RWMutex - subscribers map[peer.ID]io.Writer + subscribers map[peer.ID]protoio.Writer lastAnnouncement *pb.RegistrationRecord } @@ -73,7 +72,7 @@ func (ps *PubSub) getOrCreateTopic(ns string) *PubSubSubscribers { } ps.topics[ns] = &PubSubSubscribers{ - subscribers: map[peer.ID]io.Writer{}, + subscribers: map[peer.ID]protoio.Writer{}, lastAnnouncement: nil, } return ps.topics[ns] @@ -81,23 +80,18 @@ func (ps *PubSub) getOrCreateTopic(ns string) *PubSubSubscribers { func (ps *PubSub) Register(pid peer.ID, ns string, addrs [][]byte, ttlAsSeconds int, counter uint64) { topic := ps.getOrCreateTopic(ns) - data := &pb.RegistrationRecord{ + dataToSend := &pb.RegistrationRecord{ Id: pid.String(), Addrs: addrs, Ns: ns, Ttl: time.Now().Add(time.Duration(ttlAsSeconds) * time.Second).UnixMilli(), } - dataBytes, err := proto.Marshal(data) - if err != nil { - log.Errorf("unable to marshal registration record: %s", err.Error()) - return - } topic.mu.Lock() - topic.lastAnnouncement = data + topic.lastAnnouncement = dataToSend toNotify := topic.subscribers for _, stream := range toNotify { - if _, err := stream.Write(dataBytes); err != nil { + if err := stream.WriteMsg(dataToSend); err != nil { log.Errorf("unable to notify rendezvous data update: %s", err.Error()) } } @@ -115,11 +109,13 @@ func (ps *PubSub) Listen() { func (ps *PubSub) handleStream(s inet.Stream) { defer s.Reset() + r := protoio.NewDelimitedReader(s, inet.MessageSizeMax) + w := protoio.NewDelimitedWriter(s) + subscribedTopics := map[string]struct{}{} for { var req pb.Message - buffer := make([]byte, inet.MessageSizeMax) defer func() { for ns := range subscribedTopics { @@ -130,15 +126,9 @@ func (ps *PubSub) handleStream(s inet.Stream) { } }() - n, err := s.Read(buffer) - if err != nil && err != io.EOF { - log.Errorf("unable to read from stream: %s", err.Error()) - return - } - - err = proto.Unmarshal(buffer[:n], &req) + err := r.ReadMsg(&req) if err != nil { - log.Errorf("error unmarshalling request: %s", err.Error()) + log.Errorf("unable to read from stream: %s", err.Error()) return } @@ -153,16 +143,11 @@ func (ps *PubSub) handleStream(s inet.Stream) { continue } - topic.subscribers[s.Conn().RemotePeer()] = s + topic.subscribers[s.Conn().RemotePeer()] = w subscribedTopics[req.DiscoverSubscribe.Ns] = struct{}{} lastAnnouncement := topic.lastAnnouncement if lastAnnouncement != nil { - msgBytes, err := proto.Marshal(lastAnnouncement) - if err != nil { - log.Errorf("error marshalling response: %s", err.Error()) - continue - } - if _, err := s.Write(msgBytes); err != nil { + if err := w.WriteMsg(lastAnnouncement); err != nil { log.Errorf("unable to write announcement: %s", err.Error()) } } From d3037f9880b214f0dfa1523f3781d01e0ba81147 Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Mon, 5 Aug 2024 16:30:43 +0200 Subject: [PATCH 4/8] chore: restore previous state Signed-off-by: D4ryl00 --- sync_inmem_provider.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sync_inmem_provider.go b/sync_inmem_provider.go index fa60e46..da8376b 100644 --- a/sync_inmem_provider.go +++ b/sync_inmem_provider.go @@ -117,18 +117,14 @@ func (ps *PubSub) handleStream(s inet.Stream) { for { var req pb.Message - defer func() { + 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() } - }() - - err := r.ReadMsg(&req) - if err != nil { - log.Errorf("unable to read from stream: %s", err.Error()) return } From 5cc5f457c722c416083d35fed579f38c5afc865f Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Mon, 5 Aug 2024 16:35:53 +0200 Subject: [PATCH 5/8] chore: update CI go version Signed-off-by: D4ryl00 --- .github/workflows/go.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2918899..3b686b9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: golang: - - 1.19.x + - 1.21.x steps: - uses: actions/checkout@v3 - name: Set up Go @@ -32,8 +32,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - golang: ['1.19', '1.20'] - os: ['ubuntu-latest', 'macos-latest'] + golang: ["1.21", "1.22"] + os: ["ubuntu-latest", "macos-latest"] env: OS: ${{ matrix.os }} GOLANG: ${{ matrix.golang }} From 9b01c0dbdf809e2e2c856eb3317c095f63af0be0 Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Mon, 5 Aug 2024 16:53:59 +0200 Subject: [PATCH 6/8] fix: CI Signed-off-by: D4ryl00 --- .github/workflows/go.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3b686b9..31a9c7d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,8 +24,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.3.0 with: - go-version: ${{ matrix.golang }} - version: v1.50.1 + version: v1.55.2 args: --timeout=10m go-tests: From 056fadc53ae768dd83307fbd85533b8a2dfa3c9f Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Mon, 5 Aug 2024 16:58:40 +0200 Subject: [PATCH 7/8] fix: test for CI Signed-off-by: D4ryl00 --- db/sqlcipher/db_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/sqlcipher/db_test.go b/db/sqlcipher/db_test.go index b07d9f3..a230bf6 100644 --- a/db/sqlcipher/db_test.go +++ b/db/sqlcipher/db_test.go @@ -93,7 +93,7 @@ func TestOpenCloseFSDB(t *testing.T) { nonce1 := db.nonce // let the flush goroutine run its cleanup act - time.Sleep(1 * time.Second) + time.Sleep(2 * time.Second) err = db.Close() if err != nil { @@ -108,7 +108,7 @@ func TestOpenCloseFSDB(t *testing.T) { nonce2 := db.nonce // let the flush goroutine run its cleanup act - time.Sleep(1 * time.Second) + time.Sleep(2 * time.Second) err = db.Close() if err != nil { From 7f659ebc97374bbe6574836693dad12470697a37 Mon Sep 17 00:00:00 2001 From: D4ryl00 Date: Mon, 5 Aug 2024 17:05:31 +0200 Subject: [PATCH 8/8] fix: test for CI Signed-off-by: D4ryl00 --- .github/workflows/go.yml | 2 +- protoio/full.go | 2 +- protoio/varint.go | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 31a9c7d..e8107b7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -24,7 +24,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3.3.0 with: - version: v1.55.2 + version: v1.59.1 args: --timeout=10m go-tests: diff --git a/protoio/full.go b/protoio/full.go index d3d038a..05c2619 100644 --- a/protoio/full.go +++ b/protoio/full.go @@ -48,7 +48,7 @@ func (this *fullWriter) WriteMsg(msg proto.Message) (err error) { if m, ok := msg.(marshaler); ok { n, ok := getSize(m) if !ok { - data, err = proto.Marshal(msg) + _, err = proto.Marshal(msg) if err != nil { return err } diff --git a/protoio/varint.go b/protoio/varint.go index 1e2a3b8..63e8512 100644 --- a/protoio/varint.go +++ b/protoio/varint.go @@ -31,17 +31,11 @@ package protoio import ( "bufio" "encoding/binary" - "errors" "io" "google.golang.org/protobuf/proto" ) -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} }