From 5bddfb044d286eb14ecdf76ac8970fbaf48bb259 Mon Sep 17 00:00:00 2001 From: sukun Date: Mon, 21 Aug 2023 18:44:46 +0530 Subject: [PATCH] rename proto package to pb --- p2p/protocol/autonatv2/autonat.go | 7 +- p2p/protocol/autonatv2/autonat_test.go | 110 +++---- p2p/protocol/autonatv2/client.go | 40 +-- .../autonat.pb.go => pb/autonatv2.pb.go} | 269 +++++++++--------- .../autonat.proto => pb/autonatv2.proto} | 2 +- p2p/protocol/autonatv2/server.go | 54 ++-- p2p/protocol/autonatv2/server_test.go | 8 +- 7 files changed, 245 insertions(+), 245 deletions(-) rename p2p/protocol/autonatv2/{pbv2/autonat.pb.go => pb/autonatv2.pb.go} (58%) rename p2p/protocol/autonatv2/{pbv2/autonat.proto => pb/autonatv2.proto} (97%) diff --git a/p2p/protocol/autonatv2/autonat.go b/p2p/protocol/autonatv2/autonat.go index f220950d86..0cc9c8f56f 100644 --- a/p2p/protocol/autonatv2/autonat.go +++ b/p2p/protocol/autonatv2/autonat.go @@ -12,7 +12,7 @@ import ( "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pbv2" + "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pb" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" "golang.org/x/exp/rand" @@ -28,6 +28,9 @@ const ( streamTimeout = time.Minute dialBackStreamTimeout = 5 * time.Second dialBackDialTimeout = 30 * time.Second + maxHandshakeSizeBytes = 100_000 + minHandshakeSizeBytes = 30_000 + maxPeerAddresses = 50 ) var ( @@ -142,7 +145,7 @@ type Result struct { // Reachability of the dialed address Reachability network.Reachability // Status is the outcome of the dialback - Status pbv2.DialStatus + Status pb.DialStatus } // CheckReachability makes a single dial request for checking reachability. For highPriorityAddrs dial charge is paid diff --git a/p2p/protocol/autonatv2/autonat_test.go b/p2p/protocol/autonatv2/autonat_test.go index 7972c78ba2..9ccd79701d 100644 --- a/p2p/protocol/autonatv2/autonat_test.go +++ b/p2p/protocol/autonatv2/autonat_test.go @@ -15,7 +15,7 @@ import ( bhost "github.com/libp2p/go-libp2p/p2p/host/blank" "github.com/libp2p/go-libp2p/p2p/host/eventbus" swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing" - "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pbv2" + "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pb" "github.com/libp2p/go-msgio/pbio" ma "github.com/multiformats/go-multiaddr" @@ -38,7 +38,7 @@ func newAutoNAT(t *testing.T, dialer host.Host, opts ...AutoNATOption) *AutoNAT return an } -func parseAddrs(t *testing.T, msg *pbv2.Message) []ma.Multiaddr { +func parseAddrs(t *testing.T, msg *pb.Message) []ma.Multiaddr { t.Helper() req := msg.GetDialRequest() addrs := make([]ma.Multiaddr, 0) @@ -93,7 +93,7 @@ func TestClientRequest(t *testing.T) { p.SetStreamHandler(DialProtocol, func(s network.Stream) { gotReq.Store(true) r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message if err := r.ReadMsg(&msg); err != nil { t.Error(err) return @@ -139,12 +139,12 @@ func TestClientServerError(t *testing.T) { }}, {handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) w := pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialRequest{ - DialRequest: &pbv2.DialRequest{ + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialRequest{ + DialRequest: &pb.DialRequest{ Addrs: [][]byte{}, Nonce: 0, }, @@ -182,12 +182,12 @@ func TestClientDataRequest(t *testing.T) { }{ {handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) w := pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialDataRequest{ - DialDataRequest: &pbv2.DialDataRequest{ + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialDataRequest{ + DialDataRequest: &pb.DialDataRequest{ AddrIdx: 0, NumBytes: 10000, }, @@ -210,12 +210,12 @@ func TestClientDataRequest(t *testing.T) { }}, {handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) w := pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialDataRequest{ - DialDataRequest: &pbv2.DialDataRequest{ + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialDataRequest{ + DialDataRequest: &pb.DialDataRequest{ AddrIdx: 1, NumBytes: 10000, }, @@ -229,12 +229,12 @@ func TestClientDataRequest(t *testing.T) { }}, {handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) w := pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialDataRequest{ - DialDataRequest: &pbv2.DialDataRequest{ + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialDataRequest{ + DialDataRequest: &pb.DialDataRequest{ AddrIdx: 0, NumBytes: 1000_000, }, @@ -275,18 +275,18 @@ func TestClientDialBacks(t *testing.T) { { handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message if err := r.ReadMsg(&msg); err != nil { t.Error(err) } - resp := &pbv2.DialResponse{ - Status: pbv2.DialResponse_ResponseStatus_OK, - DialStatus: pbv2.DialStatus_OK, + resp := &pb.DialResponse{ + Status: pb.DialResponse_ResponseStatus_OK, + DialStatus: pb.DialStatus_OK, AddrIdx: 0, } w := pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialResponse{ DialResponse: resp, }, }) @@ -297,7 +297,7 @@ func TestClientDialBacks(t *testing.T) { { handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) req := msg.GetDialRequest() addrs := parseAddrs(t, &msg) @@ -311,15 +311,15 @@ func TestClientDialBacks(t *testing.T) { return } w := pbio.NewDelimitedWriter(as) - w.WriteMsg(&pbv2.DialBack{Nonce: req.Nonce}) + w.WriteMsg(&pb.DialBack{Nonce: req.Nonce}) as.CloseWrite() w = pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ - DialResponse: &pbv2.DialResponse{ - Status: pbv2.DialResponse_ResponseStatus_OK, - DialStatus: pbv2.DialStatus_OK, + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialResponse{ + DialResponse: &pb.DialResponse{ + Status: pb.DialResponse_ResponseStatus_OK, + DialStatus: pb.DialStatus_OK, AddrIdx: 0, }, }, @@ -331,7 +331,7 @@ func TestClientDialBacks(t *testing.T) { { handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) req := msg.GetDialRequest() addrs := parseAddrs(t, &msg) @@ -346,7 +346,7 @@ func TestClientDialBacks(t *testing.T) { return } ww := pbio.NewDelimitedWriter(as) - if err := ww.WriteMsg(&pbv2.DialBack{Nonce: req.Nonce - 1}); err != nil { + if err := ww.WriteMsg(&pb.DialBack{Nonce: req.Nonce - 1}); err != nil { s.Reset() as.Reset() return @@ -359,11 +359,11 @@ func TestClientDialBacks(t *testing.T) { }() w := pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ - DialResponse: &pbv2.DialResponse{ - Status: pbv2.DialResponse_ResponseStatus_OK, - DialStatus: pbv2.DialStatus_OK, + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialResponse{ + DialResponse: &pb.DialResponse{ + Status: pb.DialResponse_ResponseStatus_OK, + DialStatus: pb.DialStatus_OK, AddrIdx: 0, }, }, @@ -375,7 +375,7 @@ func TestClientDialBacks(t *testing.T) { { handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) req := msg.GetDialRequest() addrs := parseAddrs(t, &msg) @@ -391,7 +391,7 @@ func TestClientDialBacks(t *testing.T) { } w := pbio.NewDelimitedWriter(as) - if err := w.WriteMsg(&pbv2.DialBack{Nonce: req.Nonce}); err != nil { + if err := w.WriteMsg(&pb.DialBack{Nonce: req.Nonce}); err != nil { t.Error("failed to write nonce", err) s.Reset() as.Reset() @@ -406,11 +406,11 @@ func TestClientDialBacks(t *testing.T) { w = pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ - DialResponse: &pbv2.DialResponse{ - Status: pbv2.DialResponse_ResponseStatus_OK, - DialStatus: pbv2.DialStatus_OK, + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialResponse{ + DialResponse: &pb.DialResponse{ + Status: pb.DialResponse_ResponseStatus_OK, + DialStatus: pb.DialStatus_OK, AddrIdx: 1, }, }, @@ -422,7 +422,7 @@ func TestClientDialBacks(t *testing.T) { { handler: func(s network.Stream) { r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message r.ReadMsg(&msg) req := msg.GetDialRequest() addrs := parseAddrs(t, &msg) @@ -438,7 +438,7 @@ func TestClientDialBacks(t *testing.T) { } w := pbio.NewDelimitedWriter(as) - if err := w.WriteMsg(&pbv2.DialBack{Nonce: req.Nonce}); err != nil { + if err := w.WriteMsg(&pb.DialBack{Nonce: req.Nonce}); err != nil { t.Error("failed to write nonce", err) s.Reset() as.Reset() @@ -453,11 +453,11 @@ func TestClientDialBacks(t *testing.T) { w = pbio.NewDelimitedWriter(s) - w.WriteMsg(&pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ - DialResponse: &pbv2.DialResponse{ - Status: pbv2.DialResponse_ResponseStatus_OK, - DialStatus: pbv2.DialStatus_OK, + w.WriteMsg(&pb.Message{ + Msg: &pb.Message_DialResponse{ + DialResponse: &pb.DialResponse{ + Status: pb.DialResponse_ResponseStatus_OK, + DialStatus: pb.DialStatus_OK, AddrIdx: 10, }, }, @@ -480,12 +480,12 @@ func TestClientDialBacks(t *testing.T) { } else { require.NoError(t, err) require.Equal(t, res.Reachability, network.ReachabilityUnknown) - require.NotEqual(t, res.Status, pbv2.DialStatus_OK, "got: %d", res.Status) + require.NotEqual(t, res.Status, pb.DialStatus_OK, "got: %d", res.Status) } } else { require.NoError(t, err) require.Equal(t, res.Reachability, network.ReachabilityPublic) - require.Equal(t, res.Status, pbv2.DialStatus_OK) + require.Equal(t, res.Status, pb.DialStatus_OK) } }) } diff --git a/p2p/protocol/autonatv2/client.go b/p2p/protocol/autonatv2/client.go index 92c4f6d29f..e75d11e16d 100644 --- a/p2p/protocol/autonatv2/client.go +++ b/p2p/protocol/autonatv2/client.go @@ -9,14 +9,14 @@ import ( "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pbv2" + "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pb" "github.com/libp2p/go-msgio/pbio" ma "github.com/multiformats/go-multiaddr" "golang.org/x/exp/rand" "golang.org/x/exp/slices" ) -//go:generate protoc --go_out=. --go_opt=Mpbv2/autonat.proto=./pbv2 pbv2/autonat.proto +//go:generate protoc --go_out=. --go_opt=Mpb/autonatv2.proto=./pb pb/autonatv2.proto // Client implements the client for making dial requests for AutoNAT v2. It verifies successful // dials and provides an option to send data for dial requests. @@ -113,20 +113,20 @@ func (ac *Client) CheckReachability(ctx context.Context, p peer.ID, highPriority } resp := msg.GetDialResponse() - if resp.GetStatus() != pbv2.DialResponse_ResponseStatus_OK { + if resp.GetStatus() != pb.DialResponse_ResponseStatus_OK { // server couldn't dial any requested address - if resp.GetStatus() == pbv2.DialResponse_E_DIAL_REFUSED { + if resp.GetStatus() == pb.DialResponse_E_DIAL_REFUSED { return Result{}, fmt.Errorf("dial request: %w", ErrDialRefused) } return Result{}, fmt.Errorf("dial request: status %d %s", resp.GetStatus(), - pbv2.DialStatus_name[int32(resp.GetStatus())]) + pb.DialStatus_name[int32(resp.GetStatus())]) } - if resp.GetDialStatus() == pbv2.DialStatus_UNUSED { + if resp.GetDialStatus() == pb.DialStatus_UNUSED { return Result{}, fmt.Errorf("dial request failed: received invalid dial status 0") } var dialBackAddr ma.Multiaddr - if resp.GetDialStatus() == pbv2.DialStatus_OK && int(resp.AddrIdx) < len(highPriorityAddrs)+len(lowPriorityAddrs) { + if resp.GetDialStatus() == pb.DialStatus_OK && int(resp.AddrIdx) < len(highPriorityAddrs)+len(lowPriorityAddrs) { timer := time.NewTimer(dialBackStreamTimeout) select { case at := <-ch: @@ -139,7 +139,7 @@ func (ac *Client) CheckReachability(ctx context.Context, p peer.ID, highPriority return ac.newResults(resp, highPriorityAddrs, lowPriorityAddrs, dialBackAddr) } -func (ac *Client) newResults(resp *pbv2.DialResponse, highPriorityAddrs []ma.Multiaddr, lowPriorityAddrs []ma.Multiaddr, dialBackAddr ma.Multiaddr) (Result, error) { +func (ac *Client) newResults(resp *pb.DialResponse, highPriorityAddrs []ma.Multiaddr, lowPriorityAddrs []ma.Multiaddr, dialBackAddr ma.Multiaddr) (Result, error) { if int(resp.AddrIdx) >= len(highPriorityAddrs)+len(lowPriorityAddrs) { return Result{}, fmt.Errorf("addrIdx out of range: %d 0-%d", resp.AddrIdx, len(highPriorityAddrs)+len(lowPriorityAddrs)-1) } @@ -155,13 +155,13 @@ func (ac *Client) newResults(resp *pbv2.DialResponse, highPriorityAddrs []ma.Mul rch := network.ReachabilityUnknown status := resp.DialStatus switch status { - case pbv2.DialStatus_OK: + case pb.DialStatus_OK: if areAddrsConsistent(dialBackAddr, addr) { rch = network.ReachabilityPublic } else { - status = pbv2.DialStatus_E_DIAL_BACK_ERROR + status = pb.DialStatus_E_DIAL_BACK_ERROR } - case pbv2.DialStatus_E_DIAL_ERROR: + case pb.DialStatus_E_DIAL_ERROR: rch = network.ReachabilityPrivate } return Result{ @@ -172,11 +172,11 @@ func (ac *Client) newResults(resp *pbv2.DialResponse, highPriorityAddrs []ma.Mul }, nil } -func (ac *Client) sendDialData(req *pbv2.DialDataRequest, w pbio.Writer, msg *pbv2.Message) error { +func (ac *Client) sendDialData(req *pb.DialDataRequest, w pbio.Writer, msg *pb.Message) error { nb := req.GetNumBytes() - ddResp := &pbv2.DialDataResponse{Data: ac.dialData} - *msg = pbv2.Message{ - Msg: &pbv2.Message_DialDataResponse{ + ddResp := &pb.DialDataResponse{Data: ac.dialData} + *msg = pb.Message{ + Msg: &pb.Message_DialDataResponse{ DialDataResponse: ddResp, }, } @@ -194,7 +194,7 @@ func (ac *Client) sendDialData(req *pbv2.DialDataRequest, w pbio.Writer, msg *pb return nil } -func newDialRequest(highPriorityAddrs, lowPriorityAddrs []ma.Multiaddr, nonce uint64) pbv2.Message { +func newDialRequest(highPriorityAddrs, lowPriorityAddrs []ma.Multiaddr, nonce uint64) pb.Message { addrbs := make([][]byte, len(highPriorityAddrs)+len(lowPriorityAddrs)) for i, a := range highPriorityAddrs { addrbs[i] = a.Bytes() @@ -202,9 +202,9 @@ func newDialRequest(highPriorityAddrs, lowPriorityAddrs []ma.Multiaddr, nonce ui for i, a := range lowPriorityAddrs { addrbs[len(highPriorityAddrs)+i] = a.Bytes() } - return pbv2.Message{ - Msg: &pbv2.Message_DialRequest{ - DialRequest: &pbv2.DialRequest{ + return pb.Message{ + Msg: &pb.Message_DialRequest{ + DialRequest: &pb.DialRequest{ Addrs: addrbs, Nonce: nonce, }, @@ -234,7 +234,7 @@ func (ac *Client) handleDialBack(s network.Stream) { defer s.Close() r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.DialBack + var msg pb.DialBack if err := r.ReadMsg(&msg); err != nil { log.Debugf("failed to read dialback msg from %s: %s", s.Conn().RemotePeer(), err) s.Reset() diff --git a/p2p/protocol/autonatv2/pbv2/autonat.pb.go b/p2p/protocol/autonatv2/pb/autonatv2.pb.go similarity index 58% rename from p2p/protocol/autonatv2/pbv2/autonat.pb.go rename to p2p/protocol/autonatv2/pb/autonatv2.pb.go index 67e08fef15..7b3ea83107 100644 --- a/p2p/protocol/autonatv2/pbv2/autonat.pb.go +++ b/p2p/protocol/autonatv2/pb/autonatv2.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.30.0 // protoc v3.21.12 -// source: pbv2/autonat.proto +// source: pb/autonatv2.proto -package pbv2 +package pb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -56,11 +56,11 @@ func (x DialStatus) String() string { } func (DialStatus) Descriptor() protoreflect.EnumDescriptor { - return file_pbv2_autonat_proto_enumTypes[0].Descriptor() + return file_pb_autonatv2_proto_enumTypes[0].Descriptor() } func (DialStatus) Type() protoreflect.EnumType { - return &file_pbv2_autonat_proto_enumTypes[0] + return &file_pb_autonatv2_proto_enumTypes[0] } func (x DialStatus) Number() protoreflect.EnumNumber { @@ -69,7 +69,7 @@ func (x DialStatus) Number() protoreflect.EnumNumber { // Deprecated: Use DialStatus.Descriptor instead. func (DialStatus) EnumDescriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{0} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{0} } type DialResponse_ResponseStatus int32 @@ -108,11 +108,11 @@ func (x DialResponse_ResponseStatus) String() string { } func (DialResponse_ResponseStatus) Descriptor() protoreflect.EnumDescriptor { - return file_pbv2_autonat_proto_enumTypes[1].Descriptor() + return file_pb_autonatv2_proto_enumTypes[1].Descriptor() } func (DialResponse_ResponseStatus) Type() protoreflect.EnumType { - return &file_pbv2_autonat_proto_enumTypes[1] + return &file_pb_autonatv2_proto_enumTypes[1] } func (x DialResponse_ResponseStatus) Number() protoreflect.EnumNumber { @@ -121,7 +121,7 @@ func (x DialResponse_ResponseStatus) Number() protoreflect.EnumNumber { // Deprecated: Use DialResponse_ResponseStatus.Descriptor instead. func (DialResponse_ResponseStatus) EnumDescriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{3, 0} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{3, 0} } type Message struct { @@ -141,7 +141,7 @@ type Message struct { func (x *Message) Reset() { *x = Message{} if protoimpl.UnsafeEnabled { - mi := &file_pbv2_autonat_proto_msgTypes[0] + mi := &file_pb_autonatv2_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -154,7 +154,7 @@ func (x *Message) String() string { func (*Message) ProtoMessage() {} func (x *Message) ProtoReflect() protoreflect.Message { - mi := &file_pbv2_autonat_proto_msgTypes[0] + mi := &file_pb_autonatv2_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -167,7 +167,7 @@ func (x *Message) ProtoReflect() protoreflect.Message { // Deprecated: Use Message.ProtoReflect.Descriptor instead. func (*Message) Descriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{0} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{0} } func (m *Message) GetMsg() isMessage_Msg { @@ -245,7 +245,7 @@ type DialRequest struct { func (x *DialRequest) Reset() { *x = DialRequest{} if protoimpl.UnsafeEnabled { - mi := &file_pbv2_autonat_proto_msgTypes[1] + mi := &file_pb_autonatv2_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -258,7 +258,7 @@ func (x *DialRequest) String() string { func (*DialRequest) ProtoMessage() {} func (x *DialRequest) ProtoReflect() protoreflect.Message { - mi := &file_pbv2_autonat_proto_msgTypes[1] + mi := &file_pb_autonatv2_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -271,7 +271,7 @@ func (x *DialRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DialRequest.ProtoReflect.Descriptor instead. func (*DialRequest) Descriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{1} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{1} } func (x *DialRequest) GetAddrs() [][]byte { @@ -300,7 +300,7 @@ type DialDataRequest struct { func (x *DialDataRequest) Reset() { *x = DialDataRequest{} if protoimpl.UnsafeEnabled { - mi := &file_pbv2_autonat_proto_msgTypes[2] + mi := &file_pb_autonatv2_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -313,7 +313,7 @@ func (x *DialDataRequest) String() string { func (*DialDataRequest) ProtoMessage() {} func (x *DialDataRequest) ProtoReflect() protoreflect.Message { - mi := &file_pbv2_autonat_proto_msgTypes[2] + mi := &file_pb_autonatv2_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -326,7 +326,7 @@ func (x *DialDataRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DialDataRequest.ProtoReflect.Descriptor instead. func (*DialDataRequest) Descriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{2} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{2} } func (x *DialDataRequest) GetAddrIdx() uint32 { @@ -348,15 +348,15 @@ type DialResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Status DialResponse_ResponseStatus `protobuf:"varint,1,opt,name=status,proto3,enum=autonatv2.pbv2.DialResponse_ResponseStatus" json:"status,omitempty"` + Status DialResponse_ResponseStatus `protobuf:"varint,1,opt,name=status,proto3,enum=autonatv2.pb.DialResponse_ResponseStatus" json:"status,omitempty"` AddrIdx uint32 `protobuf:"varint,2,opt,name=addrIdx,proto3" json:"addrIdx,omitempty"` - DialStatus DialStatus `protobuf:"varint,3,opt,name=dialStatus,proto3,enum=autonatv2.pbv2.DialStatus" json:"dialStatus,omitempty"` + DialStatus DialStatus `protobuf:"varint,3,opt,name=dialStatus,proto3,enum=autonatv2.pb.DialStatus" json:"dialStatus,omitempty"` } func (x *DialResponse) Reset() { *x = DialResponse{} if protoimpl.UnsafeEnabled { - mi := &file_pbv2_autonat_proto_msgTypes[3] + mi := &file_pb_autonatv2_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -369,7 +369,7 @@ func (x *DialResponse) String() string { func (*DialResponse) ProtoMessage() {} func (x *DialResponse) ProtoReflect() protoreflect.Message { - mi := &file_pbv2_autonat_proto_msgTypes[3] + mi := &file_pb_autonatv2_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -382,7 +382,7 @@ func (x *DialResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DialResponse.ProtoReflect.Descriptor instead. func (*DialResponse) Descriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{3} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{3} } func (x *DialResponse) GetStatus() DialResponse_ResponseStatus { @@ -417,7 +417,7 @@ type DialDataResponse struct { func (x *DialDataResponse) Reset() { *x = DialDataResponse{} if protoimpl.UnsafeEnabled { - mi := &file_pbv2_autonat_proto_msgTypes[4] + mi := &file_pb_autonatv2_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -430,7 +430,7 @@ func (x *DialDataResponse) String() string { func (*DialDataResponse) ProtoMessage() {} func (x *DialDataResponse) ProtoReflect() protoreflect.Message { - mi := &file_pbv2_autonat_proto_msgTypes[4] + mi := &file_pb_autonatv2_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -443,7 +443,7 @@ func (x *DialDataResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DialDataResponse.ProtoReflect.Descriptor instead. func (*DialDataResponse) Descriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{4} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{4} } func (x *DialDataResponse) GetData() []byte { @@ -464,7 +464,7 @@ type DialBack struct { func (x *DialBack) Reset() { *x = DialBack{} if protoimpl.UnsafeEnabled { - mi := &file_pbv2_autonat_proto_msgTypes[5] + mi := &file_pb_autonatv2_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -477,7 +477,7 @@ func (x *DialBack) String() string { func (*DialBack) ProtoMessage() {} func (x *DialBack) ProtoReflect() protoreflect.Message { - mi := &file_pbv2_autonat_proto_msgTypes[5] + mi := &file_pb_autonatv2_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -490,7 +490,7 @@ func (x *DialBack) ProtoReflect() protoreflect.Message { // Deprecated: Use DialBack.ProtoReflect.Descriptor instead. func (*DialBack) Descriptor() ([]byte, []int) { - return file_pbv2_autonat_proto_rawDescGZIP(), []int{5} + return file_pb_autonatv2_proto_rawDescGZIP(), []int{5} } func (x *DialBack) GetNonce() uint64 { @@ -500,100 +500,99 @@ func (x *DialBack) GetNonce() uint64 { return 0 } -var File_pbv2_autonat_proto protoreflect.FileDescriptor - -var file_pbv2_autonat_proto_rawDesc = []byte{ - 0x0a, 0x12, 0x70, 0x62, 0x76, 0x32, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, - 0x70, 0x62, 0x76, 0x32, 0x22, 0xb2, 0x02, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x3f, 0x0a, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, - 0x32, 0x2e, 0x70, 0x62, 0x76, 0x32, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, - 0x74, 0x76, 0x32, 0x2e, 0x70, 0x62, 0x76, 0x32, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0f, 0x64, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, - 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, - 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, 0x70, 0x62, 0x76, 0x32, 0x2e, - 0x44, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, - 0x00, 0x52, 0x0f, 0x64, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x4e, 0x0a, 0x10, 0x64, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, - 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, 0x70, 0x62, 0x76, 0x32, 0x2e, 0x44, 0x69, - 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, - 0x52, 0x10, 0x64, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x39, 0x0a, 0x0b, 0x44, 0x69, 0x61, - 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x12, 0x14, - 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x06, 0x52, 0x05, 0x6e, - 0x6f, 0x6e, 0x63, 0x65, 0x22, 0x47, 0x0a, 0x0f, 0x44, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x49, - 0x64, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x49, 0x64, - 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x75, 0x6d, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x08, 0x6e, 0x75, 0x6d, 0x42, 0x79, 0x74, 0x65, 0x73, 0x22, 0x95, 0x02, - 0x0a, 0x0c, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, - 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, 0x70, 0x62, 0x76, 0x32, 0x2e, - 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 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, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x49, 0x64, 0x78, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x49, 0x64, 0x78, 0x12, 0x3a, 0x0a, - 0x0a, 0x64, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x1a, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, 0x70, 0x62, - 0x76, 0x32, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x64, - 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x6a, 0x0a, 0x0e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x10, 0x45, - 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, - 0x00, 0x12, 0x16, 0x0a, 0x12, 0x45, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x52, - 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x64, 0x12, 0x12, 0x0a, 0x0e, 0x45, 0x5f, 0x44, - 0x49, 0x41, 0x4c, 0x5f, 0x52, 0x45, 0x46, 0x55, 0x53, 0x45, 0x44, 0x10, 0x65, 0x12, 0x16, 0x0a, - 0x11, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x4f, 0x4b, 0x10, 0xc8, 0x01, 0x22, 0x26, 0x0a, 0x10, 0x44, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, - 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x20, 0x0a, - 0x08, 0x44, 0x69, 0x61, 0x6c, 0x42, 0x61, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, - 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x06, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x2a, - 0x4a, 0x0a, 0x0a, 0x44, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, - 0x06, 0x55, 0x4e, 0x55, 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x5f, 0x44, - 0x49, 0x41, 0x4c, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x64, 0x12, 0x15, 0x0a, 0x11, 0x45, - 0x5f, 0x44, 0x49, 0x41, 0x4c, 0x5f, 0x42, 0x41, 0x43, 0x4b, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, - 0x10, 0x65, 0x12, 0x07, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0xc8, 0x01, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, +var File_pb_autonatv2_proto protoreflect.FileDescriptor + +var file_pb_autonatv2_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x70, 0x62, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, + 0x70, 0x62, 0x22, 0xaa, 0x02, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3d, + 0x0a, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, + 0x70, 0x62, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, + 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, + 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, 0x2e, + 0x70, 0x62, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, + 0x00, 0x52, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x49, 0x0a, 0x0f, 0x64, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, + 0x61, 0x74, 0x76, 0x32, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x00, 0x52, 0x0f, 0x64, 0x69, 0x61, 0x6c, 0x44, + 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4c, 0x0a, 0x10, 0x64, 0x69, + 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, + 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x10, 0x64, 0x69, 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x22, + 0x39, 0x0a, 0x0b, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x05, 0x61, + 0x64, 0x64, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x06, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x22, 0x47, 0x0a, 0x0f, 0x44, 0x69, + 0x61, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x64, 0x64, 0x72, 0x49, 0x64, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x49, 0x64, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x75, 0x6d, 0x42, 0x79, + 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6e, 0x75, 0x6d, 0x42, 0x79, + 0x74, 0x65, 0x73, 0x22, 0x91, 0x02, 0x0a, 0x0c, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, 0x32, + 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 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, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x49, + 0x64, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x49, 0x64, + 0x78, 0x12, 0x38, 0x0a, 0x0a, 0x64, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x61, 0x75, 0x74, 0x6f, 0x6e, 0x61, 0x74, 0x76, + 0x32, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x0a, 0x64, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x6a, 0x0a, 0x0e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, + 0x10, 0x45, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x5f, 0x45, 0x52, 0x52, 0x4f, + 0x52, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x45, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, + 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x64, 0x12, 0x12, 0x0a, 0x0e, 0x45, + 0x5f, 0x44, 0x49, 0x41, 0x4c, 0x5f, 0x52, 0x45, 0x46, 0x55, 0x53, 0x45, 0x44, 0x10, 0x65, 0x12, + 0x16, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x5f, 0x4f, 0x4b, 0x10, 0xc8, 0x01, 0x22, 0x26, 0x0a, 0x10, 0x44, 0x69, 0x61, 0x6c, 0x44, + 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x20, 0x0a, 0x08, 0x44, 0x69, 0x61, 0x6c, 0x42, 0x61, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x6e, + 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x06, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, + 0x65, 0x2a, 0x4a, 0x0a, 0x0a, 0x44, 0x69, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x0a, 0x0a, 0x06, 0x55, 0x4e, 0x55, 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x45, + 0x5f, 0x44, 0x49, 0x41, 0x4c, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x64, 0x12, 0x15, 0x0a, + 0x11, 0x45, 0x5f, 0x44, 0x49, 0x41, 0x4c, 0x5f, 0x42, 0x41, 0x43, 0x4b, 0x5f, 0x45, 0x52, 0x52, + 0x4f, 0x52, 0x10, 0x65, 0x12, 0x07, 0x0a, 0x02, 0x4f, 0x4b, 0x10, 0xc8, 0x01, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_pbv2_autonat_proto_rawDescOnce sync.Once - file_pbv2_autonat_proto_rawDescData = file_pbv2_autonat_proto_rawDesc + file_pb_autonatv2_proto_rawDescOnce sync.Once + file_pb_autonatv2_proto_rawDescData = file_pb_autonatv2_proto_rawDesc ) -func file_pbv2_autonat_proto_rawDescGZIP() []byte { - file_pbv2_autonat_proto_rawDescOnce.Do(func() { - file_pbv2_autonat_proto_rawDescData = protoimpl.X.CompressGZIP(file_pbv2_autonat_proto_rawDescData) +func file_pb_autonatv2_proto_rawDescGZIP() []byte { + file_pb_autonatv2_proto_rawDescOnce.Do(func() { + file_pb_autonatv2_proto_rawDescData = protoimpl.X.CompressGZIP(file_pb_autonatv2_proto_rawDescData) }) - return file_pbv2_autonat_proto_rawDescData -} - -var file_pbv2_autonat_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_pbv2_autonat_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_pbv2_autonat_proto_goTypes = []interface{}{ - (DialStatus)(0), // 0: autonatv2.pbv2.DialStatus - (DialResponse_ResponseStatus)(0), // 1: autonatv2.pbv2.DialResponse.ResponseStatus - (*Message)(nil), // 2: autonatv2.pbv2.Message - (*DialRequest)(nil), // 3: autonatv2.pbv2.DialRequest - (*DialDataRequest)(nil), // 4: autonatv2.pbv2.DialDataRequest - (*DialResponse)(nil), // 5: autonatv2.pbv2.DialResponse - (*DialDataResponse)(nil), // 6: autonatv2.pbv2.DialDataResponse - (*DialBack)(nil), // 7: autonatv2.pbv2.DialBack -} -var file_pbv2_autonat_proto_depIdxs = []int32{ - 3, // 0: autonatv2.pbv2.Message.dialRequest:type_name -> autonatv2.pbv2.DialRequest - 5, // 1: autonatv2.pbv2.Message.dialResponse:type_name -> autonatv2.pbv2.DialResponse - 4, // 2: autonatv2.pbv2.Message.dialDataRequest:type_name -> autonatv2.pbv2.DialDataRequest - 6, // 3: autonatv2.pbv2.Message.dialDataResponse:type_name -> autonatv2.pbv2.DialDataResponse - 1, // 4: autonatv2.pbv2.DialResponse.status:type_name -> autonatv2.pbv2.DialResponse.ResponseStatus - 0, // 5: autonatv2.pbv2.DialResponse.dialStatus:type_name -> autonatv2.pbv2.DialStatus + return file_pb_autonatv2_proto_rawDescData +} + +var file_pb_autonatv2_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_pb_autonatv2_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_pb_autonatv2_proto_goTypes = []interface{}{ + (DialStatus)(0), // 0: autonatv2.pb.DialStatus + (DialResponse_ResponseStatus)(0), // 1: autonatv2.pb.DialResponse.ResponseStatus + (*Message)(nil), // 2: autonatv2.pb.Message + (*DialRequest)(nil), // 3: autonatv2.pb.DialRequest + (*DialDataRequest)(nil), // 4: autonatv2.pb.DialDataRequest + (*DialResponse)(nil), // 5: autonatv2.pb.DialResponse + (*DialDataResponse)(nil), // 6: autonatv2.pb.DialDataResponse + (*DialBack)(nil), // 7: autonatv2.pb.DialBack +} +var file_pb_autonatv2_proto_depIdxs = []int32{ + 3, // 0: autonatv2.pb.Message.dialRequest:type_name -> autonatv2.pb.DialRequest + 5, // 1: autonatv2.pb.Message.dialResponse:type_name -> autonatv2.pb.DialResponse + 4, // 2: autonatv2.pb.Message.dialDataRequest:type_name -> autonatv2.pb.DialDataRequest + 6, // 3: autonatv2.pb.Message.dialDataResponse:type_name -> autonatv2.pb.DialDataResponse + 1, // 4: autonatv2.pb.DialResponse.status:type_name -> autonatv2.pb.DialResponse.ResponseStatus + 0, // 5: autonatv2.pb.DialResponse.dialStatus:type_name -> autonatv2.pb.DialStatus 6, // [6:6] is the sub-list for method output_type 6, // [6:6] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name @@ -601,13 +600,13 @@ var file_pbv2_autonat_proto_depIdxs = []int32{ 0, // [0:6] is the sub-list for field type_name } -func init() { file_pbv2_autonat_proto_init() } -func file_pbv2_autonat_proto_init() { - if File_pbv2_autonat_proto != nil { +func init() { file_pb_autonatv2_proto_init() } +func file_pb_autonatv2_proto_init() { + if File_pb_autonatv2_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_pbv2_autonat_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_pb_autonatv2_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Message); i { case 0: return &v.state @@ -619,7 +618,7 @@ func file_pbv2_autonat_proto_init() { return nil } } - file_pbv2_autonat_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_pb_autonatv2_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DialRequest); i { case 0: return &v.state @@ -631,7 +630,7 @@ func file_pbv2_autonat_proto_init() { return nil } } - file_pbv2_autonat_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_pb_autonatv2_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DialDataRequest); i { case 0: return &v.state @@ -643,7 +642,7 @@ func file_pbv2_autonat_proto_init() { return nil } } - file_pbv2_autonat_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_pb_autonatv2_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DialResponse); i { case 0: return &v.state @@ -655,7 +654,7 @@ func file_pbv2_autonat_proto_init() { return nil } } - file_pbv2_autonat_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_pb_autonatv2_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DialDataResponse); i { case 0: return &v.state @@ -667,7 +666,7 @@ func file_pbv2_autonat_proto_init() { return nil } } - file_pbv2_autonat_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_pb_autonatv2_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DialBack); i { case 0: return &v.state @@ -680,7 +679,7 @@ func file_pbv2_autonat_proto_init() { } } } - file_pbv2_autonat_proto_msgTypes[0].OneofWrappers = []interface{}{ + file_pb_autonatv2_proto_msgTypes[0].OneofWrappers = []interface{}{ (*Message_DialRequest)(nil), (*Message_DialResponse)(nil), (*Message_DialDataRequest)(nil), @@ -690,19 +689,19 @@ func file_pbv2_autonat_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_pbv2_autonat_proto_rawDesc, + RawDescriptor: file_pb_autonatv2_proto_rawDesc, NumEnums: 2, NumMessages: 6, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_pbv2_autonat_proto_goTypes, - DependencyIndexes: file_pbv2_autonat_proto_depIdxs, - EnumInfos: file_pbv2_autonat_proto_enumTypes, - MessageInfos: file_pbv2_autonat_proto_msgTypes, + GoTypes: file_pb_autonatv2_proto_goTypes, + DependencyIndexes: file_pb_autonatv2_proto_depIdxs, + EnumInfos: file_pb_autonatv2_proto_enumTypes, + MessageInfos: file_pb_autonatv2_proto_msgTypes, }.Build() - File_pbv2_autonat_proto = out.File - file_pbv2_autonat_proto_rawDesc = nil - file_pbv2_autonat_proto_goTypes = nil - file_pbv2_autonat_proto_depIdxs = nil + File_pb_autonatv2_proto = out.File + file_pb_autonatv2_proto_rawDesc = nil + file_pb_autonatv2_proto_goTypes = nil + file_pb_autonatv2_proto_depIdxs = nil } diff --git a/p2p/protocol/autonatv2/pbv2/autonat.proto b/p2p/protocol/autonatv2/pb/autonatv2.proto similarity index 97% rename from p2p/protocol/autonatv2/pbv2/autonat.proto rename to p2p/protocol/autonatv2/pb/autonatv2.proto index 6d13966d65..84ee68c8c8 100644 --- a/p2p/protocol/autonatv2/pbv2/autonat.proto +++ b/p2p/protocol/autonatv2/pb/autonatv2.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package autonatv2.pbv2; +package autonatv2.pb; message Message { oneof msg { diff --git a/p2p/protocol/autonatv2/server.go b/p2p/protocol/autonatv2/server.go index 79a6656999..d66f0ddade 100644 --- a/p2p/protocol/autonatv2/server.go +++ b/p2p/protocol/autonatv2/server.go @@ -10,7 +10,7 @@ import ( "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/peerstore" - "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pbv2" + "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pb" "github.com/libp2p/go-msgio/pbio" ma "github.com/multiformats/go-multiaddr" @@ -20,11 +20,6 @@ import ( type dataRequestPolicyFunc = func(s network.Stream, dialAddr ma.Multiaddr) bool -const ( - maxHandshakeSizeBytes = 100_000 - minHandshakeSizeBytes = 30_000 -) - type Server struct { dialer host.Host host host.Host @@ -77,7 +72,7 @@ func (as *Server) handleDialRequest(s network.Stream) { p := s.Conn().RemotePeer() r := pbio.NewDelimitedReader(s, maxMsgSize) - var msg pbv2.Message + var msg pb.Message if err := r.ReadMsg(&msg); err != nil { s.Reset() log.Debugf("failed to read request from %s: %s", p, err) @@ -93,6 +88,9 @@ func (as *Server) handleDialRequest(s network.Stream) { var dialAddr ma.Multiaddr var addrIdx int for i, ab := range msg.GetDialRequest().GetAddrs() { + if i >= maxPeerAddresses { + break + } a, err := ma.NewMultiaddrBytes(ab) if err != nil { continue @@ -108,10 +106,10 @@ func (as *Server) handleDialRequest(s network.Stream) { w := pbio.NewDelimitedWriter(s) if dialAddr == nil { - msg = pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ - DialResponse: &pbv2.DialResponse{ - Status: pbv2.DialResponse_E_DIAL_REFUSED, + msg = pb.Message{ + Msg: &pb.Message_DialResponse{ + DialResponse: &pb.DialResponse{ + Status: pb.DialResponse_E_DIAL_REFUSED, }, }, } @@ -125,10 +123,10 @@ func (as *Server) handleDialRequest(s network.Stream) { isDialDataRequired := as.dialDataRequestPolicy(s, dialAddr) if !as.limiter.Accept(p, isDialDataRequired) { - msg = pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ - DialResponse: &pbv2.DialResponse{ - Status: pbv2.DialResponse_E_REQUEST_REJECTED, + msg = pb.Message{ + Msg: &pb.Message_DialResponse{ + DialResponse: &pb.DialResponse{ + Status: pb.DialResponse_E_REQUEST_REJECTED, }, }, } @@ -150,10 +148,10 @@ func (as *Server) handleDialRequest(s network.Stream) { } } status := as.dialBack(s.Conn().RemotePeer(), dialAddr, nonce) - msg = pbv2.Message{ - Msg: &pbv2.Message_DialResponse{ - DialResponse: &pbv2.DialResponse{ - Status: pbv2.DialResponse_ResponseStatus_OK, + msg = pb.Message{ + Msg: &pb.Message_DialResponse{ + DialResponse: &pb.DialResponse{ + Status: pb.DialResponse_ResponseStatus_OK, DialStatus: status, AddrIdx: uint32(addrIdx), }, @@ -177,11 +175,11 @@ func amplificationAttackPrevention(s network.Stream, dialAddr ma.Multiaddr) bool return !connIP.Equal(dialIP) } -func getDialData(w pbio.Writer, r pbio.Reader, msg *pbv2.Message, addrIdx int) error { +func getDialData(w pbio.Writer, r pbio.Reader, msg *pb.Message, addrIdx int) error { numBytes := minHandshakeSizeBytes + rand.Intn(maxHandshakeSizeBytes-minHandshakeSizeBytes) - *msg = pbv2.Message{ - Msg: &pbv2.Message_DialDataRequest{ - DialDataRequest: &pbv2.DialDataRequest{ + *msg = pb.Message{ + Msg: &pb.Message_DialDataRequest{ + DialDataRequest: &pb.DialDataRequest{ AddrIdx: uint32(addrIdx), NumBytes: uint64(numBytes), }, @@ -203,7 +201,7 @@ func getDialData(w pbio.Writer, r pbio.Reader, msg *pbv2.Message, addrIdx int) e return nil } -func (as *Server) dialBack(p peer.ID, addr ma.Multiaddr, nonce uint64) pbv2.DialStatus { +func (as *Server) dialBack(p peer.ID, addr ma.Multiaddr, nonce uint64) pb.DialStatus { ctx, cancel := context.WithTimeout(context.Background(), dialBackDialTimeout) as.dialer.Peerstore().AddAddr(p, addr, peerstore.TempAddrTTL) defer func() { @@ -214,15 +212,15 @@ func (as *Server) dialBack(p peer.ID, addr ma.Multiaddr, nonce uint64) pbv2.Dial }() s, err := as.dialer.NewStream(ctx, p, DialBackProtocol) if err != nil { - return pbv2.DialStatus_E_DIAL_ERROR + return pb.DialStatus_E_DIAL_ERROR } defer s.Close() s.SetDeadline(as.now().Add(dialBackStreamTimeout)) w := pbio.NewDelimitedWriter(s) - if err := w.WriteMsg(&pbv2.DialBack{Nonce: nonce}); err != nil { + if err := w.WriteMsg(&pb.DialBack{Nonce: nonce}); err != nil { s.Reset() - return pbv2.DialStatus_E_DIAL_BACK_ERROR + return pb.DialStatus_E_DIAL_BACK_ERROR } // Since the underlying connection is on a separate dialer, it'll be closed after this function returns. @@ -233,7 +231,7 @@ func (as *Server) dialBack(p peer.ID, addr ma.Multiaddr, nonce uint64) pbv2.Dial b := make([]byte, 1) // Read 1 byte here because 0 len reads are free to return (0, nil) immediately s.Read(b) - return pbv2.DialStatus_OK + return pb.DialStatus_OK } // rateLimiter implements a sliding window rate limit of requests per minute. diff --git a/p2p/protocol/autonatv2/server_test.go b/p2p/protocol/autonatv2/server_test.go index d6f53f0efb..a4b4b7a234 100644 --- a/p2p/protocol/autonatv2/server_test.go +++ b/p2p/protocol/autonatv2/server_test.go @@ -9,7 +9,7 @@ import ( "github.com/libp2p/go-libp2p/core/test" bhost "github.com/libp2p/go-libp2p/p2p/host/blank" swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing" - "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pbv2" + "github.com/libp2p/go-libp2p/p2p/protocol/autonatv2/pb" ma "github.com/multiformats/go-multiaddr" "github.com/stretchr/testify/require" ) @@ -89,7 +89,7 @@ func TestServerDataRequest(t *testing.T) { Idx: 0, Addr: quicAddr, Reachability: network.ReachabilityPublic, - Status: pbv2.DialStatus_OK, + Status: pb.DialStatus_OK, }, res) } @@ -112,7 +112,7 @@ func TestServerDial(t *testing.T) { Idx: 0, Addr: randAddr, Reachability: network.ReachabilityPrivate, - Status: pbv2.DialStatus_E_DIAL_ERROR, + Status: pb.DialStatus_E_DIAL_ERROR, }, res) res, err = c.CheckReachability(context.Background(), nil, c.host.Addrs()) @@ -121,7 +121,7 @@ func TestServerDial(t *testing.T) { Idx: 0, Addr: hostAddrs[0], Reachability: network.ReachabilityPublic, - Status: pbv2.DialStatus_OK, + Status: pb.DialStatus_OK, }, res) }