diff --git a/client/client.go b/client/client.go index 5955b9d..761543b 100644 --- a/client/client.go +++ b/client/client.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "git.0cd.xyz/michael/mcstatus/client/pb" + "git.0cd.xyz/michael/mcstatus/mcstatuspb" "github.com/golang/protobuf/jsonpb" ) @@ -37,12 +37,18 @@ func (client *Client) write() error { if err := client.Conn.SetWriteDeadline(time.Now().Add(10 * time.Second)); err != nil { return err } - client.Conn.Write(handshake(client.Addr, client.Port, client.Version)) + _, err := client.Conn.Write(handshake(client.Addr, client.Port, client.Version)) + if err != nil { + if netErr, ok := err.(net.Error); ok && netErr.Timeout() { + return err + } + return err + } return nil } -func (client *Client) read() (*pb.Response, error) { - var response pb.Response +func (client *Client) read() (*mcstatuspb.Response, error) { + var response mcstatuspb.Response buf := make([]byte, 1024) n, err := client.Conn.Read(buf) if err != nil { diff --git a/client/status.go b/client/status.go index e568934..d9ff428 100644 --- a/client/status.go +++ b/client/status.go @@ -3,11 +3,11 @@ package client import ( "time" - "git.0cd.xyz/michael/mcstatus/client/pb" + "git.0cd.xyz/michael/mcstatus/mcstatuspb" ) // GetStatus gets minecraft server status -func (client *Client) GetStatus() (*pb.Response, error) { +func (client *Client) GetStatus() (*mcstatuspb.Response, error) { for { if err := client.write(); err != nil { return nil, err @@ -21,11 +21,14 @@ func (client *Client) GetStatus() (*pb.Response, error) { } // PingServer pings Minecraft server -func (client *Client) PingServer() time.Duration { +func (client *Client) PingServer() (time.Duration, error) { ping := make([]byte, 1) start := time.Now() - client.Conn.Write([]byte{0x01, 0x00}) + _, err := client.Conn.Write([]byte{0x01, 0x00}) + if err != nil { + return 0, err + } _, _ = client.Conn.Read(ping[:]) diff := time.Now().Sub(start) - return diff + return diff, nil } diff --git a/client/pb/response.pb.go b/mcstatuspb/response.pb.go similarity index 56% rename from client/pb/response.pb.go rename to mcstatuspb/response.pb.go index 398deff..4a7ade5 100644 --- a/client/pb/response.pb.go +++ b/mcstatuspb/response.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.25.0-devel // protoc v3.14.0 -// source: response.proto +// source: protobuf/response.proto -package pb +package mcstatuspb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -34,7 +34,7 @@ type Response struct { func (x *Response) Reset() { *x = Response{} if protoimpl.UnsafeEnabled { - mi := &file_response_proto_msgTypes[0] + mi := &file_protobuf_response_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -47,7 +47,7 @@ func (x *Response) String() string { func (*Response) ProtoMessage() {} func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_response_proto_msgTypes[0] + mi := &file_protobuf_response_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -60,7 +60,7 @@ func (x *Response) ProtoReflect() protoreflect.Message { // Deprecated: Use Response.ProtoReflect.Descriptor instead. func (*Response) Descriptor() ([]byte, []int) { - return file_response_proto_rawDescGZIP(), []int{0} + return file_protobuf_response_proto_rawDescGZIP(), []int{0} } func (x *Response) GetVersion() *Response_Version { @@ -103,7 +103,7 @@ type Response_Version struct { func (x *Response_Version) Reset() { *x = Response_Version{} if protoimpl.UnsafeEnabled { - mi := &file_response_proto_msgTypes[1] + mi := &file_protobuf_response_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -116,7 +116,7 @@ func (x *Response_Version) String() string { func (*Response_Version) ProtoMessage() {} func (x *Response_Version) ProtoReflect() protoreflect.Message { - mi := &file_response_proto_msgTypes[1] + mi := &file_protobuf_response_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -129,7 +129,7 @@ func (x *Response_Version) ProtoReflect() protoreflect.Message { // Deprecated: Use Response_Version.ProtoReflect.Descriptor instead. func (*Response_Version) Descriptor() ([]byte, []int) { - return file_response_proto_rawDescGZIP(), []int{0, 0} + return file_protobuf_response_proto_rawDescGZIP(), []int{0, 0} } func (x *Response_Version) GetName() string { @@ -159,7 +159,7 @@ type Response_Players struct { func (x *Response_Players) Reset() { *x = Response_Players{} if protoimpl.UnsafeEnabled { - mi := &file_response_proto_msgTypes[2] + mi := &file_protobuf_response_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -172,7 +172,7 @@ func (x *Response_Players) String() string { func (*Response_Players) ProtoMessage() {} func (x *Response_Players) ProtoReflect() protoreflect.Message { - mi := &file_response_proto_msgTypes[2] + mi := &file_protobuf_response_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -185,7 +185,7 @@ func (x *Response_Players) ProtoReflect() protoreflect.Message { // Deprecated: Use Response_Players.ProtoReflect.Descriptor instead. func (*Response_Players) Descriptor() ([]byte, []int) { - return file_response_proto_rawDescGZIP(), []int{0, 1} + return file_protobuf_response_proto_rawDescGZIP(), []int{0, 1} } func (x *Response_Players) GetMax() int32 { @@ -221,7 +221,7 @@ type Response_Description struct { func (x *Response_Description) Reset() { *x = Response_Description{} if protoimpl.UnsafeEnabled { - mi := &file_response_proto_msgTypes[3] + mi := &file_protobuf_response_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -234,7 +234,7 @@ func (x *Response_Description) String() string { func (*Response_Description) ProtoMessage() {} func (x *Response_Description) ProtoReflect() protoreflect.Message { - mi := &file_response_proto_msgTypes[3] + mi := &file_protobuf_response_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -247,7 +247,7 @@ func (x *Response_Description) ProtoReflect() protoreflect.Message { // Deprecated: Use Response_Description.ProtoReflect.Descriptor instead. func (*Response_Description) Descriptor() ([]byte, []int) { - return file_response_proto_rawDescGZIP(), []int{0, 2} + return file_protobuf_response_proto_rawDescGZIP(), []int{0, 2} } func (x *Response_Description) GetExtra() []*Response_Description_Extra { @@ -276,7 +276,7 @@ type Response_Players_Sample struct { func (x *Response_Players_Sample) Reset() { *x = Response_Players_Sample{} if protoimpl.UnsafeEnabled { - mi := &file_response_proto_msgTypes[4] + mi := &file_protobuf_response_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -289,7 +289,7 @@ func (x *Response_Players_Sample) String() string { func (*Response_Players_Sample) ProtoMessage() {} func (x *Response_Players_Sample) ProtoReflect() protoreflect.Message { - mi := &file_response_proto_msgTypes[4] + mi := &file_protobuf_response_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -302,7 +302,7 @@ func (x *Response_Players_Sample) ProtoReflect() protoreflect.Message { // Deprecated: Use Response_Players_Sample.ProtoReflect.Descriptor instead. func (*Response_Players_Sample) Descriptor() ([]byte, []int) { - return file_response_proto_rawDescGZIP(), []int{0, 1, 0} + return file_protobuf_response_proto_rawDescGZIP(), []int{0, 1, 0} } func (x *Response_Players_Sample) GetName() string { @@ -330,7 +330,7 @@ type Response_Description_Extra struct { func (x *Response_Description_Extra) Reset() { *x = Response_Description_Extra{} if protoimpl.UnsafeEnabled { - mi := &file_response_proto_msgTypes[5] + mi := &file_protobuf_response_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -343,7 +343,7 @@ func (x *Response_Description_Extra) String() string { func (*Response_Description_Extra) ProtoMessage() {} func (x *Response_Description_Extra) ProtoReflect() protoreflect.Message { - mi := &file_response_proto_msgTypes[5] + mi := &file_protobuf_response_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -356,7 +356,7 @@ func (x *Response_Description_Extra) ProtoReflect() protoreflect.Message { // Deprecated: Use Response_Description_Extra.ProtoReflect.Descriptor instead. func (*Response_Description_Extra) Descriptor() ([]byte, []int) { - return file_response_proto_rawDescGZIP(), []int{0, 2, 0} + return file_protobuf_response_proto_rawDescGZIP(), []int{0, 2, 0} } func (x *Response_Description_Extra) GetText() string { @@ -366,76 +366,82 @@ func (x *Response_Description_Extra) GetText() string { return "" } -var File_response_proto protoreflect.FileDescriptor +var File_protobuf_response_proto protoreflect.FileDescriptor -var file_response_proto_rawDesc = []byte{ - 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x02, 0x70, 0x62, 0x22, 0x8a, 0x04, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x2e, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, - 0x73, 0x12, 0x3a, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, - 0x07, 0x66, 0x61, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x66, 0x61, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x1a, 0x39, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x1a, 0x96, 0x01, 0x0a, 0x07, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x10, - 0x0a, 0x03, 0x6d, 0x61, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6d, 0x61, 0x78, - 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x06, 0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x73, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x2e, 0x53, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x06, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x1a, 0x2c, 0x0a, - 0x06, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x1a, 0x74, 0x0a, 0x0b, 0x44, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x0a, 0x05, 0x65, 0x78, - 0x74, 0x72, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, - 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x74, 0x65, 0x78, 0x74, 0x1a, 0x1b, 0x0a, 0x05, 0x45, 0x78, 0x74, 0x72, 0x61, 0x12, 0x12, 0x0a, - 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, - 0x74, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x2e, 0x30, 0x63, 0x64, 0x2e, 0x78, 0x79, 0x7a, - 0x2f, 0x6d, 0x69, 0x63, 0x68, 0x61, 0x65, 0x6c, 0x2f, 0x6d, 0x63, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, +var file_protobuf_response_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x6d, 0x63, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0xd6, 0x04, 0x0a, + 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6d, 0x63, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3d, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, + 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6d, 0x63, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x52, 0x07, + 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x49, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6d, + 0x63, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x61, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x61, 0x76, 0x69, 0x63, 0x6f, 0x6e, 0x1a, 0x39, 0x0a, 0x07, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x1a, 0xa5, 0x01, 0x0a, 0x07, 0x50, 0x6c, 0x61, 0x79, + 0x65, 0x72, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x03, 0x6d, 0x61, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x42, 0x0a, + 0x06, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, + 0x6d, 0x63, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x73, 0x2e, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x06, 0x73, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x1a, 0x2c, 0x0a, 0x06, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x1a, + 0x83, 0x01, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x43, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, + 0x2e, 0x6d, 0x63, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x44, 0x65, 0x73, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x52, 0x05, 0x65, + 0x78, 0x74, 0x72, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x1a, 0x1b, 0x0a, 0x05, 0x45, 0x78, 0x74, 0x72, + 0x61, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x65, 0x78, 0x74, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x2e, 0x30, 0x63, 0x64, + 0x2e, 0x78, 0x79, 0x7a, 0x2f, 0x6d, 0x69, 0x63, 0x68, 0x61, 0x65, 0x6c, 0x2f, 0x6d, 0x63, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x2f, 0x6d, 0x63, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_response_proto_rawDescOnce sync.Once - file_response_proto_rawDescData = file_response_proto_rawDesc + file_protobuf_response_proto_rawDescOnce sync.Once + file_protobuf_response_proto_rawDescData = file_protobuf_response_proto_rawDesc ) -func file_response_proto_rawDescGZIP() []byte { - file_response_proto_rawDescOnce.Do(func() { - file_response_proto_rawDescData = protoimpl.X.CompressGZIP(file_response_proto_rawDescData) +func file_protobuf_response_proto_rawDescGZIP() []byte { + file_protobuf_response_proto_rawDescOnce.Do(func() { + file_protobuf_response_proto_rawDescData = protoimpl.X.CompressGZIP(file_protobuf_response_proto_rawDescData) }) - return file_response_proto_rawDescData + return file_protobuf_response_proto_rawDescData } -var file_response_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_response_proto_goTypes = []interface{}{ - (*Response)(nil), // 0: pb.Response - (*Response_Version)(nil), // 1: pb.Response.Version - (*Response_Players)(nil), // 2: pb.Response.Players - (*Response_Description)(nil), // 3: pb.Response.Description - (*Response_Players_Sample)(nil), // 4: pb.Response.Players.Sample - (*Response_Description_Extra)(nil), // 5: pb.Response.Description.Extra +var file_protobuf_response_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_protobuf_response_proto_goTypes = []interface{}{ + (*Response)(nil), // 0: mcstatus.protobuf.Response + (*Response_Version)(nil), // 1: mcstatus.protobuf.Response.Version + (*Response_Players)(nil), // 2: mcstatus.protobuf.Response.Players + (*Response_Description)(nil), // 3: mcstatus.protobuf.Response.Description + (*Response_Players_Sample)(nil), // 4: mcstatus.protobuf.Response.Players.Sample + (*Response_Description_Extra)(nil), // 5: mcstatus.protobuf.Response.Description.Extra } -var file_response_proto_depIdxs = []int32{ - 1, // 0: pb.Response.version:type_name -> pb.Response.Version - 2, // 1: pb.Response.players:type_name -> pb.Response.Players - 3, // 2: pb.Response.description:type_name -> pb.Response.Description - 4, // 3: pb.Response.Players.sample:type_name -> pb.Response.Players.Sample - 5, // 4: pb.Response.Description.extra:type_name -> pb.Response.Description.Extra +var file_protobuf_response_proto_depIdxs = []int32{ + 1, // 0: mcstatus.protobuf.Response.version:type_name -> mcstatus.protobuf.Response.Version + 2, // 1: mcstatus.protobuf.Response.players:type_name -> mcstatus.protobuf.Response.Players + 3, // 2: mcstatus.protobuf.Response.description:type_name -> mcstatus.protobuf.Response.Description + 4, // 3: mcstatus.protobuf.Response.Players.sample:type_name -> mcstatus.protobuf.Response.Players.Sample + 5, // 4: mcstatus.protobuf.Response.Description.extra:type_name -> mcstatus.protobuf.Response.Description.Extra 5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name @@ -443,13 +449,13 @@ var file_response_proto_depIdxs = []int32{ 0, // [0:5] is the sub-list for field type_name } -func init() { file_response_proto_init() } -func file_response_proto_init() { - if File_response_proto != nil { +func init() { file_protobuf_response_proto_init() } +func file_protobuf_response_proto_init() { + if File_protobuf_response_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_response_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_protobuf_response_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Response); i { case 0: return &v.state @@ -461,7 +467,7 @@ func file_response_proto_init() { return nil } } - file_response_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_protobuf_response_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Response_Version); i { case 0: return &v.state @@ -473,7 +479,7 @@ func file_response_proto_init() { return nil } } - file_response_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_protobuf_response_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Response_Players); i { case 0: return &v.state @@ -485,7 +491,7 @@ func file_response_proto_init() { return nil } } - file_response_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_protobuf_response_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Response_Description); i { case 0: return &v.state @@ -497,7 +503,7 @@ func file_response_proto_init() { return nil } } - file_response_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_protobuf_response_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Response_Players_Sample); i { case 0: return &v.state @@ -509,7 +515,7 @@ func file_response_proto_init() { return nil } } - file_response_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_protobuf_response_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Response_Description_Extra); i { case 0: return &v.state @@ -526,18 +532,18 @@ func file_response_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_response_proto_rawDesc, + RawDescriptor: file_protobuf_response_proto_rawDesc, NumEnums: 0, NumMessages: 6, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_response_proto_goTypes, - DependencyIndexes: file_response_proto_depIdxs, - MessageInfos: file_response_proto_msgTypes, + GoTypes: file_protobuf_response_proto_goTypes, + DependencyIndexes: file_protobuf_response_proto_depIdxs, + MessageInfos: file_protobuf_response_proto_msgTypes, }.Build() - File_response_proto = out.File - file_response_proto_rawDesc = nil - file_response_proto_goTypes = nil - file_response_proto_depIdxs = nil + File_protobuf_response_proto = out.File + file_protobuf_response_proto_rawDesc = nil + file_protobuf_response_proto_goTypes = nil + file_protobuf_response_proto_depIdxs = nil } diff --git a/response.proto b/protobuf/response.proto similarity index 86% rename from response.proto rename to protobuf/response.proto index 7e4f869..3bd3bca 100644 --- a/response.proto +++ b/protobuf/response.proto @@ -1,8 +1,8 @@ syntax="proto3"; -package pb; +package mcstatus.protobuf; -option go_package = "git.0cd.xyz/michael/mcstatus/pb"; +option go_package = "git.0cd.xyz/michael/mcstatus/mcstatuspb"; message Response { message Version {