diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f3bcf88..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ - -.pc diff --git a/README.md b/README.md index 446ce4c..bc0a302 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Pure Golang NMSG Library `go-nmsg` is a pure go implementation of the NMSG container and payload -format used by the C (nmsg)[https://github.com/farsightsec/nmsg] toolkit +format used by the C [nmsg](https://github.com/farsightsec/nmsg) toolkit and library. ## Synopsis @@ -17,7 +17,7 @@ output.SetMaxSize(nmsg.MaxContainerSize, 0) for { - payload, err := inp.Recv() + payload, err := input.Recv() if err != nil { if nmsg.IsDataError(err) { continue @@ -41,7 +41,7 @@ `go-nmsg` requires the following open source libraries: - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" "github.com/dnstap/golang-dnstap" ## Limitations diff --git a/container.go b/container.go index b7c32e8..bd4a7a2 100644 --- a/container.go +++ b/container.go @@ -16,7 +16,7 @@ "io" "math/rand" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) const ( @@ -29,15 +29,8 @@ var ( nmsgMagic = [4]byte{'N', 'M', 'S', 'G'} errBadMagic = errors.New("Bad NMSG Magic Number") - u32max uint32 = (1 << 31) containerOverhead = 10 - fragmentOverhead = 10 + 4 + proto.Size( - &NmsgFragment{ - Id: &u32max, - Current: &u32max, - Last: &u32max, - Crc: &u32max, - }) + fragmentOverhead = 10 + 4 + 24 ) type containerHeader struct { diff --git a/genproto.sh b/genproto.sh new file mode 100755 index 0000000..51c968e --- /dev/null +++ b/genproto.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +go_package() { + local file pkg line script + file=$1; shift + pkg=$1; shift + + line="option go_package = \"$pkg\";" + grep "^$line\$" $file > /dev/null && return + + script="/^package nmsg/|a|$line|.|w|q|" + if grep "^option go_package" $file > /dev/null; then + script="/^option go_package/d|1|${script}" + fi + echo "$script" | tr '|' '\n' | ed $file || exit +} + +dir=$(dirname $0) +[ -n "$dir" ] && cd $dir + +go_package nmsg.proto "github.com/farsightsec/go-nmsg;nmsg" +protoc --go_out=../../.. nmsg.proto + +cd nmsg_base +for f in *.proto; do + go_package $f "github.com/farsightsec/go-nmsg/nmsg_base" +done + +protoc --go_out=../../../.. *.proto diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..4f0d622 --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module github.com/farsightsec/go-nmsg + +require ( + github.com/dnstap/golang-dnstap v0.4.0 + google.golang.org/protobuf v1.25.0 + gopkg.in/yaml.v2 v2.4.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6a37898 --- /dev/null +++ b/go.sum @@ -0,0 +1,88 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/dnstap/golang-dnstap v0.4.0 h1:KRHBoURygdGtBjDI2w4HifJfMAhhOqDuktAokaSa234= +github.com/dnstap/golang-dnstap v0.4.0/go.mod h1:FqsSdH58NAmkAvKcpyxht7i4FoBjKu8E4JUPt8ipSUs= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/farsightsec/golang-framestream v0.3.0 h1:/spFQHucTle/ZIPkYqrfshQqPe2VQEzesH243TjIwqA= +github.com/farsightsec/golang-framestream v0.3.0/go.mod h1:eNde4IQyEiA5br02AouhEHCu3p3UzrCdFR4LuQHklMI= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/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.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/miekg/dns v1.1.31 h1:sJFOl9BgwbYAWOGEwr61FU28pqsBNdpRBnhGXtO06Oo= +github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/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-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe h1:6fAMxZRR6sl1Uq8U61gxU+kPTs2tR8uOySCbBP7BN/M= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/nmsg.go b/nmsg.go index c605f8b..9c32c3d 100644 --- a/nmsg.go +++ b/nmsg.go @@ -6,14 +6,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//go:generate protoc --go_out=. nmsg.proto +//go:generate ./genproto.sh package nmsg import ( "hash/crc32" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) // Container size limits to avoid silly fragmentation and memory diff --git a/nmsg.pb.go b/nmsg.pb.go index 6b05995..2e24a6e 100644 --- a/nmsg.pb.go +++ b/nmsg.pb.go @@ -1,223 +1,404 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: nmsg.proto -// DO NOT EDIT! - -/* -Package nmsg is a generated protocol buffer package. - -It is generated from these files: - nmsg.proto - -It has these top-level messages: - Nmsg - NmsgFragment - NmsgPayload -*/ + package nmsg -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// 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.ProtoPackageIsVersion2 // please upgrade the proto package +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type Nmsg struct { - Payloads []*NmsgPayload `protobuf:"bytes,1,rep,name=payloads" json:"payloads,omitempty"` - PayloadCrcs []uint32 `protobuf:"varint,2,rep,name=payload_crcs" json:"payload_crcs,omitempty"` - Sequence *uint32 `protobuf:"varint,3,opt,name=sequence" json:"sequence,omitempty"` - SequenceId *uint64 `protobuf:"varint,4,opt,name=sequence_id" json:"sequence_id,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Nmsg) Reset() { *m = Nmsg{} } -func (m *Nmsg) String() string { return proto.CompactTextString(m) } -func (*Nmsg) ProtoMessage() {} -func (*Nmsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Nmsg) GetPayloads() []*NmsgPayload { - if m != nil { - return m.Payloads + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Payloads []*NmsgPayload `protobuf:"bytes,1,rep,name=payloads" json:"payloads,omitempty"` + PayloadCrcs []uint32 `protobuf:"varint,2,rep,name=payload_crcs,json=payloadCrcs" json:"payload_crcs,omitempty"` + Sequence *uint32 `protobuf:"varint,3,opt,name=sequence" json:"sequence,omitempty"` + SequenceId *uint64 `protobuf:"varint,4,opt,name=sequence_id,json=sequenceId" json:"sequence_id,omitempty"` +} + +func (x *Nmsg) Reset() { + *x = Nmsg{} + if protoimpl.UnsafeEnabled { + mi := &file_nmsg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Nmsg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Nmsg) ProtoMessage() {} + +func (x *Nmsg) ProtoReflect() protoreflect.Message { + mi := &file_nmsg_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Nmsg.ProtoReflect.Descriptor instead. +func (*Nmsg) Descriptor() ([]byte, []int) { + return file_nmsg_proto_rawDescGZIP(), []int{0} +} + +func (x *Nmsg) GetPayloads() []*NmsgPayload { + if x != nil { + return x.Payloads } return nil } -func (m *Nmsg) GetPayloadCrcs() []uint32 { - if m != nil { - return m.PayloadCrcs +func (x *Nmsg) GetPayloadCrcs() []uint32 { + if x != nil { + return x.PayloadCrcs } return nil } -func (m *Nmsg) GetSequence() uint32 { - if m != nil && m.Sequence != nil { - return *m.Sequence - } - return 0 -} - -func (m *Nmsg) GetSequenceId() uint64 { - if m != nil && m.SequenceId != nil { - return *m.SequenceId +func (x *Nmsg) GetSequence() uint32 { + if x != nil && x.Sequence != nil { + return *x.Sequence + } + return 0 +} + +func (x *Nmsg) GetSequenceId() uint64 { + if x != nil && x.SequenceId != nil { + return *x.SequenceId } return 0 } type NmsgFragment struct { - Id *uint32 `protobuf:"varint,1,req,name=id" json:"id,omitempty"` - Current *uint32 `protobuf:"varint,2,req,name=current" json:"current,omitempty"` - Last *uint32 `protobuf:"varint,3,req,name=last" json:"last,omitempty"` - Fragment []byte `protobuf:"bytes,4,req,name=fragment" json:"fragment,omitempty"` - Crc *uint32 `protobuf:"varint,5,opt,name=crc" json:"crc,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *NmsgFragment) Reset() { *m = NmsgFragment{} } -func (m *NmsgFragment) String() string { return proto.CompactTextString(m) } -func (*NmsgFragment) ProtoMessage() {} -func (*NmsgFragment) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -func (m *NmsgFragment) GetId() uint32 { - if m != nil && m.Id != nil { - return *m.Id - } - return 0 -} - -func (m *NmsgFragment) GetCurrent() uint32 { - if m != nil && m.Current != nil { - return *m.Current - } - return 0 -} - -func (m *NmsgFragment) GetLast() uint32 { - if m != nil && m.Last != nil { - return *m.Last - } - return 0 -} - -func (m *NmsgFragment) GetFragment() []byte { - if m != nil { - return m.Fragment + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *uint32 `protobuf:"varint,1,req,name=id" json:"id,omitempty"` + Current *uint32 `protobuf:"varint,2,req,name=current" json:"current,omitempty"` + Last *uint32 `protobuf:"varint,3,req,name=last" json:"last,omitempty"` + Fragment []byte `protobuf:"bytes,4,req,name=fragment" json:"fragment,omitempty"` + Crc *uint32 `protobuf:"varint,5,opt,name=crc" json:"crc,omitempty"` +} + +func (x *NmsgFragment) Reset() { + *x = NmsgFragment{} + if protoimpl.UnsafeEnabled { + mi := &file_nmsg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NmsgFragment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NmsgFragment) ProtoMessage() {} + +func (x *NmsgFragment) ProtoReflect() protoreflect.Message { + mi := &file_nmsg_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NmsgFragment.ProtoReflect.Descriptor instead. +func (*NmsgFragment) Descriptor() ([]byte, []int) { + return file_nmsg_proto_rawDescGZIP(), []int{1} +} + +func (x *NmsgFragment) GetId() uint32 { + if x != nil && x.Id != nil { + return *x.Id + } + return 0 +} + +func (x *NmsgFragment) GetCurrent() uint32 { + if x != nil && x.Current != nil { + return *x.Current + } + return 0 +} + +func (x *NmsgFragment) GetLast() uint32 { + if x != nil && x.Last != nil { + return *x.Last + } + return 0 +} + +func (x *NmsgFragment) GetFragment() []byte { + if x != nil { + return x.Fragment } return nil } -func (m *NmsgFragment) GetCrc() uint32 { - if m != nil && m.Crc != nil { - return *m.Crc +func (x *NmsgFragment) GetCrc() uint32 { + if x != nil && x.Crc != nil { + return *x.Crc } return 0 } type NmsgPayload struct { - Vid *uint32 `protobuf:"varint,1,req,name=vid" json:"vid,omitempty"` - Msgtype *uint32 `protobuf:"varint,2,req,name=msgtype" json:"msgtype,omitempty"` - TimeSec *int64 `protobuf:"varint,3,req,name=time_sec" json:"time_sec,omitempty"` - TimeNsec *uint32 `protobuf:"fixed32,4,req,name=time_nsec" json:"time_nsec,omitempty"` - Payload []byte `protobuf:"bytes,5,opt,name=payload" json:"payload,omitempty"` - Source *uint32 `protobuf:"varint,7,opt,name=source" json:"source,omitempty"` - Operator *uint32 `protobuf:"varint,8,opt,name=operator" json:"operator,omitempty"` - Group *uint32 `protobuf:"varint,9,opt,name=group" json:"group,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *NmsgPayload) Reset() { *m = NmsgPayload{} } -func (m *NmsgPayload) String() string { return proto.CompactTextString(m) } -func (*NmsgPayload) ProtoMessage() {} -func (*NmsgPayload) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } - -func (m *NmsgPayload) GetVid() uint32 { - if m != nil && m.Vid != nil { - return *m.Vid - } - return 0 -} - -func (m *NmsgPayload) GetMsgtype() uint32 { - if m != nil && m.Msgtype != nil { - return *m.Msgtype - } - return 0 -} - -func (m *NmsgPayload) GetTimeSec() int64 { - if m != nil && m.TimeSec != nil { - return *m.TimeSec - } - return 0 -} - -func (m *NmsgPayload) GetTimeNsec() uint32 { - if m != nil && m.TimeNsec != nil { - return *m.TimeNsec - } - return 0 -} - -func (m *NmsgPayload) GetPayload() []byte { - if m != nil { - return m.Payload + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Vid *uint32 `protobuf:"varint,1,req,name=vid" json:"vid,omitempty"` + Msgtype *uint32 `protobuf:"varint,2,req,name=msgtype" json:"msgtype,omitempty"` + TimeSec *int64 `protobuf:"varint,3,req,name=time_sec,json=timeSec" json:"time_sec,omitempty"` + TimeNsec *uint32 `protobuf:"fixed32,4,req,name=time_nsec,json=timeNsec" json:"time_nsec,omitempty"` + Payload []byte `protobuf:"bytes,5,opt,name=payload" json:"payload,omitempty"` + Source *uint32 `protobuf:"varint,7,opt,name=source" json:"source,omitempty"` + Operator *uint32 `protobuf:"varint,8,opt,name=operator" json:"operator,omitempty"` + Group *uint32 `protobuf:"varint,9,opt,name=group" json:"group,omitempty"` +} + +func (x *NmsgPayload) Reset() { + *x = NmsgPayload{} + if protoimpl.UnsafeEnabled { + mi := &file_nmsg_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NmsgPayload) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NmsgPayload) ProtoMessage() {} + +func (x *NmsgPayload) ProtoReflect() protoreflect.Message { + mi := &file_nmsg_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NmsgPayload.ProtoReflect.Descriptor instead. +func (*NmsgPayload) Descriptor() ([]byte, []int) { + return file_nmsg_proto_rawDescGZIP(), []int{2} +} + +func (x *NmsgPayload) GetVid() uint32 { + if x != nil && x.Vid != nil { + return *x.Vid + } + return 0 +} + +func (x *NmsgPayload) GetMsgtype() uint32 { + if x != nil && x.Msgtype != nil { + return *x.Msgtype + } + return 0 +} + +func (x *NmsgPayload) GetTimeSec() int64 { + if x != nil && x.TimeSec != nil { + return *x.TimeSec + } + return 0 +} + +func (x *NmsgPayload) GetTimeNsec() uint32 { + if x != nil && x.TimeNsec != nil { + return *x.TimeNsec + } + return 0 +} + +func (x *NmsgPayload) GetPayload() []byte { + if x != nil { + return x.Payload } return nil } -func (m *NmsgPayload) GetSource() uint32 { - if m != nil && m.Source != nil { - return *m.Source - } - return 0 -} - -func (m *NmsgPayload) GetOperator() uint32 { - if m != nil && m.Operator != nil { - return *m.Operator - } - return 0 -} - -func (m *NmsgPayload) GetGroup() uint32 { - if m != nil && m.Group != nil { - return *m.Group - } - return 0 -} - -func init() { - proto.RegisterType((*Nmsg)(nil), "nmsg.Nmsg") - proto.RegisterType((*NmsgFragment)(nil), "nmsg.NmsgFragment") - proto.RegisterType((*NmsgPayload)(nil), "nmsg.NmsgPayload") -} - -func init() { proto.RegisterFile("nmsg.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 259 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x4c, 0x8f, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0x86, 0x15, 0xc7, 0x25, 0xe9, 0xc5, 0x05, 0x6a, 0x18, 0x3c, 0x46, 0x61, 0xe9, 0xd4, 0x81, - 0x87, 0x60, 0x44, 0x8c, 0x6c, 0x91, 0xe5, 0x9a, 0x50, 0xa9, 0x89, 0x8d, 0xed, 0x20, 0xf5, 0x35, - 0x78, 0x62, 0xee, 0xdc, 0x54, 0xea, 0x94, 0xf8, 0xfb, 0xef, 0xbe, 0xbb, 0x03, 0x98, 0xc6, 0x38, - 0xec, 0x7d, 0x70, 0xc9, 0x49, 0x4e, 0xff, 0xdd, 0x37, 0xf0, 0x77, 0xfc, 0xca, 0x17, 0xa8, 0xbd, - 0x3e, 0x9f, 0x9c, 0x3e, 0x44, 0x55, 0xb4, 0xe5, 0xae, 0x79, 0xdd, 0xee, 0x73, 0x31, 0xa5, 0x1f, - 0x97, 0x44, 0x3e, 0x83, 0x58, 0x8a, 0x7a, 0x13, 0x4c, 0x54, 0x0c, 0x0b, 0x37, 0xf2, 0x11, 0xea, - 0x68, 0x7f, 0x66, 0x3b, 0x19, 0xab, 0xca, 0xb6, 0x40, 0xf2, 0x04, 0xcd, 0x95, 0xf4, 0xc7, 0x83, - 0xe2, 0x08, 0x79, 0xf7, 0x09, 0x82, 0x5c, 0x6f, 0x41, 0x0f, 0xa3, 0x9d, 0x92, 0x04, 0x60, 0x98, - 0x15, 0x2d, 0xc3, 0x86, 0x07, 0xa8, 0xcc, 0x1c, 0x02, 0x62, 0x74, 0x12, 0x10, 0xc0, 0x4f, 0x3a, - 0x26, 0xf4, 0xb1, 0xcb, 0x84, 0xaf, 0xa5, 0x0d, 0x65, 0x6c, 0x27, 0x64, 0x03, 0x25, 0x6e, 0xa0, - 0x56, 0x34, 0xae, 0xfb, 0x2b, 0xa0, 0xb9, 0x5d, 0x13, 0xc3, 0xdf, 0x5b, 0x35, 0x46, 0xe9, 0xec, - 0xed, 0xa2, 0x46, 0x59, 0x3a, 0x8e, 0xb6, 0x8f, 0xd6, 0x64, 0x7d, 0x29, 0xb7, 0xb0, 0xce, 0x64, - 0x22, 0x44, 0xfe, 0x8a, 0xba, 0x96, 0x4b, 0xf3, 0x0c, 0x21, 0xef, 0xe1, 0x2e, 0xba, 0x39, 0xe0, - 0x89, 0x55, 0x3e, 0x11, 0x2d, 0xce, 0xdb, 0xa0, 0x93, 0x0b, 0xaa, 0xce, 0x64, 0x03, 0xab, 0x21, - 0xb8, 0xd9, 0xab, 0x35, 0x3d, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0x73, 0x07, 0x52, 0x34, 0x6b, - 0x01, 0x00, 0x00, -} +func (x *NmsgPayload) GetSource() uint32 { + if x != nil && x.Source != nil { + return *x.Source + } + return 0 +} + +func (x *NmsgPayload) GetOperator() uint32 { + if x != nil && x.Operator != nil { + return *x.Operator + } + return 0 +} + +func (x *NmsgPayload) GetGroup() uint32 { + if x != nil && x.Group != nil { + return *x.Group + } + return 0 +} + +var File_nmsg_proto protoreflect.FileDescriptor + +var file_nmsg_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6e, 0x6d, + 0x73, 0x67, 0x22, 0x95, 0x01, 0x0a, 0x04, 0x4e, 0x6d, 0x73, 0x67, 0x12, 0x2d, 0x0a, 0x08, 0x70, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, + 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x4e, 0x6d, 0x73, 0x67, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x52, 0x08, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x63, 0x72, 0x63, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0d, + 0x52, 0x0b, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x43, 0x72, 0x63, 0x73, 0x12, 0x1a, 0x0a, + 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x71, + 0x75, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, + 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x22, 0x7a, 0x0a, 0x0c, 0x4e, 0x6d, + 0x73, 0x67, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x07, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x61, 0x73, 0x74, 0x18, 0x03, 0x20, 0x02, + 0x28, 0x0d, 0x52, 0x04, 0x6c, 0x61, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x72, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x03, 0x63, 0x72, 0x63, 0x22, 0xd5, 0x01, 0x0a, 0x0b, 0x4e, 0x6d, 0x73, 0x67, 0x50, + 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x02, 0x28, 0x0d, 0x52, 0x03, 0x76, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x07, 0x6d, 0x73, 0x67, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x63, 0x18, 0x03, + 0x20, 0x02, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x53, 0x65, 0x63, 0x12, 0x1b, 0x0a, + 0x09, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6e, 0x73, 0x65, 0x63, 0x18, 0x04, 0x20, 0x02, 0x28, 0x07, + 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x4e, 0x73, 0x65, 0x63, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x42, 0x25, + 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, + 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, + 0x3b, 0x6e, 0x6d, 0x73, 0x67, +} + +var ( + file_nmsg_proto_rawDescOnce sync.Once + file_nmsg_proto_rawDescData = file_nmsg_proto_rawDesc +) + +func file_nmsg_proto_rawDescGZIP() []byte { + file_nmsg_proto_rawDescOnce.Do(func() { + file_nmsg_proto_rawDescData = protoimpl.X.CompressGZIP(file_nmsg_proto_rawDescData) + }) + return file_nmsg_proto_rawDescData +} + +var file_nmsg_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_nmsg_proto_goTypes = []interface{}{ + (*Nmsg)(nil), // 0: nmsg.Nmsg + (*NmsgFragment)(nil), // 1: nmsg.NmsgFragment + (*NmsgPayload)(nil), // 2: nmsg.NmsgPayload +} +var file_nmsg_proto_depIdxs = []int32{ + 2, // 0: nmsg.Nmsg.payloads:type_name -> nmsg.NmsgPayload + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_nmsg_proto_init() } +func file_nmsg_proto_init() { + if File_nmsg_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_nmsg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Nmsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_nmsg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NmsgFragment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_nmsg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NmsgPayload); 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_nmsg_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_nmsg_proto_goTypes, + DependencyIndexes: file_nmsg_proto_depIdxs, + MessageInfos: file_nmsg_proto_msgTypes, + }.Build() + File_nmsg_proto = out.File + file_nmsg_proto_rawDesc = nil + file_nmsg_proto_goTypes = nil + file_nmsg_proto_depIdxs = nil +} diff --git a/nmsg.proto b/nmsg.proto index a3d0435..49dfed5 100644 --- a/nmsg.proto +++ b/nmsg.proto @@ -1,5 +1,6 @@ syntax = "proto2"; package nmsg; +option go_package = "github.com/farsightsec/go-nmsg;nmsg"; message Nmsg { repeated NmsgPayload payloads = 1; diff --git a/nmsg_base/base.go b/nmsg_base/base.go index 750d8ce..2b2f267 100644 --- a/nmsg_base/base.go +++ b/nmsg_base/base.go @@ -11,7 +11,7 @@ import ( "github.com/dnstap/golang-dnstap" "github.com/farsightsec/go-nmsg" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) func (p *Ncap) GetVid() uint32 { return 1 } diff --git a/nmsg_base/compat.go b/nmsg_base/compat.go new file mode 100644 index 0000000..97875ba --- /dev/null +++ b/nmsg_base/compat.go @@ -0,0 +1,78 @@ +package nmsg_base + +// +// Compatibility definitions for code written against older versions +// of the nmsg_base .proto files. +// + +type DnsQRType = DnsQR_DnsQRType + +const ( + DnsQRType_UDP_INVALID = DnsQR_UDP_INVALID + DnsQRType_UDP_QUERY_RESPONSE = DnsQR_UDP_QUERY_RESPONSE + DnsQRType_UDP_UNANSWERED_QUERY = DnsQR_UDP_UNANSWERED_QUERY + DnsQRType_UDP_UNSOLICITED_RESPONSE = DnsQR_UDP_UNSOLICITED_RESPONSE + DnsQRType_TCP = DnsQR_TCP + DnsQRType_ICMP = DnsQR_ICMP + DnsQRType_UDP_QUERY_ONLY = DnsQR_UDP_QUERY_ONLY + DnsQRType_UDP_RESPONSE_ONLY = DnsQR_UDP_RESPONSE_ONLY +) + +type UdpChecksum = DnsQR_UdpChecksum + +const ( + UdpChecksum_ERROR = DnsQR_ERROR + UdpChecksum_ABSENT = DnsQR_ABSENT + UdpChecksum_INCORRECT = DnsQR_INCORRECT + UdpChecksum_CORRECT = DnsQR_CORRECT +) + +type EmailType = Email_EmailType + +const ( + EmailType_unknown = Email_unknown + EmailType_spamtrap = Email_spamtrap + EmailType_rej_network = Email_rej_network + EmailType_rej_content = Email_rej_content + EmailType_rej_user = Email_rej_user +) + +type EncodeType = Encode_EncodeType + +const ( + EncodeType_TEXT = Encode_TEXT + EncodeType_JSON = Encode_JSON + EncodeType_YAML = Encode_YAML + EncodeType_MSGPACK = Encode_MSGPACK + EncodeType_XML = Encode_XML +) + +type HttpType = Http_HttpType + +const ( + HttpType_unknown = Http_unknown + HttpType_sinkhole = Http_sinkhole +) + +type LinkType = Linkpair_Linktype + +const ( + Linktype_anchor = Linkpair_anchor + Linktype_redirect = Linkpair_redirect +) + +type NcapType Ncap_NcapType + +const ( + NcapType_IPV4 = Ncap_IPV4 + NcapType_IPV6 = Ncap_IPV6 + NcapType_Legacy = Ncap_Legacy +) + +type NcapLegacyType = Ncap_NcapLegacyType + +const ( + NcapLegacyType_Ncap_UDP = Ncap_UDP + NcapLegacyType_Ncap_TCP = Ncap_TCP + NcapLegacyType_Ncap_ICMP = Ncap_ICMP +) diff --git a/nmsg_base/dns.pb.go b/nmsg_base/dns.pb.go index a51317d..0d23b6e 100644 --- a/nmsg_base/dns.pb.go +++ b/nmsg_base/dns.pb.go @@ -1,152 +1,218 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: dns.proto -// DO NOT EDIT! - -/* -Package nmsg_base is a generated protocol buffer package. - -It is generated from these files: - dns.proto - dnsqr.proto - email.proto - encode.proto - http.proto - ipconn.proto - linkpair.proto - logline.proto - ncap.proto - packet.proto - pkt.proto - xml.proto - -It has these top-level messages: - Dns - DnsQR - Email - Encode - Http - IPConn - Linkpair - LogLine - Ncap - Packet - Pkt - Xml -*/ + package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// 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.ProtoPackageIsVersion2 // please upgrade the proto package +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type Dns struct { - Section *uint32 `protobuf:"varint,6,opt,name=section" json:"section,omitempty"` - Qname []byte `protobuf:"bytes,7,opt,name=qname" json:"qname,omitempty"` - Qtype *uint32 `protobuf:"varint,8,opt,name=qtype" json:"qtype,omitempty"` - Qclass *uint32 `protobuf:"varint,9,opt,name=qclass" json:"qclass,omitempty"` - Rrname []byte `protobuf:"bytes,1,opt,name=rrname" json:"rrname,omitempty"` - Rrtype *uint32 `protobuf:"varint,2,opt,name=rrtype" json:"rrtype,omitempty"` - Rrclass *uint32 `protobuf:"varint,3,opt,name=rrclass" json:"rrclass,omitempty"` - Rrttl *uint32 `protobuf:"varint,4,opt,name=rrttl" json:"rrttl,omitempty"` - Rdata [][]byte `protobuf:"bytes,5,rep,name=rdata" json:"rdata,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Dns) Reset() { *m = Dns{} } -func (m *Dns) String() string { return proto.CompactTextString(m) } -func (*Dns) ProtoMessage() {} -func (*Dns) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Dns) GetSection() uint32 { - if m != nil && m.Section != nil { - return *m.Section - } - return 0 -} - -func (m *Dns) GetQname() []byte { - if m != nil { - return m.Qname + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Section *uint32 `protobuf:"varint,6,opt,name=section" json:"section,omitempty"` + Qname []byte `protobuf:"bytes,7,opt,name=qname" json:"qname,omitempty"` + Qtype *uint32 `protobuf:"varint,8,opt,name=qtype" json:"qtype,omitempty"` + Qclass *uint32 `protobuf:"varint,9,opt,name=qclass" json:"qclass,omitempty"` + Rrname []byte `protobuf:"bytes,1,opt,name=rrname" json:"rrname,omitempty"` + Rrtype *uint32 `protobuf:"varint,2,opt,name=rrtype" json:"rrtype,omitempty"` + Rrclass *uint32 `protobuf:"varint,3,opt,name=rrclass" json:"rrclass,omitempty"` + Rrttl *uint32 `protobuf:"varint,4,opt,name=rrttl" json:"rrttl,omitempty"` + Rdata [][]byte `protobuf:"bytes,5,rep,name=rdata" json:"rdata,omitempty"` +} + +func (x *Dns) Reset() { + *x = Dns{} + if protoimpl.UnsafeEnabled { + mi := &file_dns_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Dns) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Dns) ProtoMessage() {} + +func (x *Dns) ProtoReflect() protoreflect.Message { + mi := &file_dns_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Dns.ProtoReflect.Descriptor instead. +func (*Dns) Descriptor() ([]byte, []int) { + return file_dns_proto_rawDescGZIP(), []int{0} +} + +func (x *Dns) GetSection() uint32 { + if x != nil && x.Section != nil { + return *x.Section + } + return 0 +} + +func (x *Dns) GetQname() []byte { + if x != nil { + return x.Qname } return nil } -func (m *Dns) GetQtype() uint32 { - if m != nil && m.Qtype != nil { - return *m.Qtype - } - return 0 -} - -func (m *Dns) GetQclass() uint32 { - if m != nil && m.Qclass != nil { - return *m.Qclass - } - return 0 -} - -func (m *Dns) GetRrname() []byte { - if m != nil { - return m.Rrname +func (x *Dns) GetQtype() uint32 { + if x != nil && x.Qtype != nil { + return *x.Qtype + } + return 0 +} + +func (x *Dns) GetQclass() uint32 { + if x != nil && x.Qclass != nil { + return *x.Qclass + } + return 0 +} + +func (x *Dns) GetRrname() []byte { + if x != nil { + return x.Rrname } return nil } -func (m *Dns) GetRrtype() uint32 { - if m != nil && m.Rrtype != nil { - return *m.Rrtype - } - return 0 -} - -func (m *Dns) GetRrclass() uint32 { - if m != nil && m.Rrclass != nil { - return *m.Rrclass - } - return 0 -} - -func (m *Dns) GetRrttl() uint32 { - if m != nil && m.Rrttl != nil { - return *m.Rrttl - } - return 0 -} - -func (m *Dns) GetRdata() [][]byte { - if m != nil { - return m.Rdata +func (x *Dns) GetRrtype() uint32 { + if x != nil && x.Rrtype != nil { + return *x.Rrtype + } + return 0 +} + +func (x *Dns) GetRrclass() uint32 { + if x != nil && x.Rrclass != nil { + return *x.Rrclass + } + return 0 +} + +func (x *Dns) GetRrttl() uint32 { + if x != nil && x.Rrttl != nil { + return *x.Rrttl + } + return 0 +} + +func (x *Dns) GetRdata() [][]byte { + if x != nil { + return x.Rdata } return nil } -func init() { - proto.RegisterType((*Dns)(nil), "nmsg.base.Dns") -} - -func init() { proto.RegisterFile("dns.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 148 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0xc9, 0x2b, 0xd6, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, 0x4b, 0x4a, 0x2c, 0x4e, - 0x55, 0x9a, 0xcc, 0xc8, 0xc5, 0xec, 0x92, 0x57, 0x2c, 0xc4, 0xcf, 0xc5, 0x5e, 0x9c, 0x9a, 0x5c, - 0x92, 0x99, 0x9f, 0x27, 0xc1, 0xa6, 0xc0, 0xa8, 0xc1, 0x2b, 0xc4, 0xcb, 0xc5, 0x5a, 0x98, 0x97, - 0x98, 0x9b, 0x2a, 0xc1, 0x0e, 0xe4, 0xf2, 0x80, 0xb9, 0x25, 0x95, 0x05, 0xa9, 0x12, 0x1c, 0x60, - 0x59, 0x3e, 0x2e, 0xb6, 0xc2, 0xe4, 0x9c, 0xc4, 0xe2, 0x62, 0x09, 0x4e, 0x18, 0xbf, 0xa8, 0x08, - 0xac, 0x9c, 0x11, 0xac, 0x1c, 0xcc, 0x07, 0xab, 0x67, 0x02, 0xcb, 0x03, 0x8d, 0x2f, 0x2a, 0x82, - 0x68, 0x60, 0x86, 0x19, 0x0f, 0x54, 0x50, 0x92, 0x23, 0xc1, 0x02, 0xe7, 0xa6, 0x24, 0x96, 0x24, - 0x4a, 0xb0, 0x2a, 0x30, 0x6b, 0xf0, 0x00, 0x02, 0x00, 0x00, 0xff, 0xff, 0x75, 0x4a, 0x12, 0x4c, - 0xac, 0x00, 0x00, 0x00, -} +var File_dns_proto protoreflect.FileDescriptor + +var file_dns_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x64, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, 0x6d, 0x73, + 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xd9, 0x01, 0x0a, 0x03, 0x44, 0x6e, 0x73, 0x12, 0x18, + 0x0a, 0x07, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x07, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x71, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x71, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x71, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x71, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, + 0x72, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x72, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x72, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x72, 0x72, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x72, 0x72, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, + 0x72, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x72, 0x74, 0x74, 0x6c, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x72, 0x72, 0x74, 0x74, 0x6c, 0x12, 0x14, 0x0a, 0x05, + 0x72, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x05, 0x72, 0x64, 0x61, + 0x74, 0x61, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, + 0x6e, 0x6d, 0x73, 0x67, 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_dns_proto_rawDescOnce sync.Once + file_dns_proto_rawDescData = file_dns_proto_rawDesc +) + +func file_dns_proto_rawDescGZIP() []byte { + file_dns_proto_rawDescOnce.Do(func() { + file_dns_proto_rawDescData = protoimpl.X.CompressGZIP(file_dns_proto_rawDescData) + }) + return file_dns_proto_rawDescData +} + +var file_dns_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_dns_proto_goTypes = []interface{}{ + (*Dns)(nil), // 0: nmsg.base.Dns +} +var file_dns_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_dns_proto_init() } +func file_dns_proto_init() { + if File_dns_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_dns_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Dns); 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_dns_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_dns_proto_goTypes, + DependencyIndexes: file_dns_proto_depIdxs, + MessageInfos: file_dns_proto_msgTypes, + }.Build() + File_dns_proto = out.File + file_dns_proto_rawDesc = nil + file_dns_proto_goTypes = nil + file_dns_proto_depIdxs = nil +} diff --git a/nmsg_base/dns.proto b/nmsg_base/dns.proto index 0e3cfd9..d50c7aa 100644 --- a/nmsg_base/dns.proto +++ b/nmsg_base/dns.proto @@ -1,5 +1,6 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message Dns { optional uint32 section = 6; diff --git a/nmsg_base/dnsqr.pb.go b/nmsg_base/dnsqr.pb.go index 9452635..384a453 100644 --- a/nmsg_base/dnsqr.pb.go +++ b/nmsg_base/dnsqr.pb.go @@ -1,334 +1,512 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: dnsqr.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -type DnsQRType int32 +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) const ( - DnsQRType_UDP_INVALID DnsQRType = 0 - DnsQRType_UDP_QUERY_RESPONSE DnsQRType = 1 - DnsQRType_UDP_UNANSWERED_QUERY DnsQRType = 2 - DnsQRType_UDP_UNSOLICITED_RESPONSE DnsQRType = 3 - DnsQRType_TCP DnsQRType = 4 - DnsQRType_ICMP DnsQRType = 5 - DnsQRType_UDP_QUERY_ONLY DnsQRType = 6 - DnsQRType_UDP_RESPONSE_ONLY DnsQRType = 7 -) - -var DnsQRType_name = map[int32]string{ - 0: "UDP_INVALID", - 1: "UDP_QUERY_RESPONSE", - 2: "UDP_UNANSWERED_QUERY", - 3: "UDP_UNSOLICITED_RESPONSE", - 4: "TCP", - 5: "ICMP", - 6: "UDP_QUERY_ONLY", - 7: "UDP_RESPONSE_ONLY", -} -var DnsQRType_value = map[string]int32{ - "UDP_INVALID": 0, - "UDP_QUERY_RESPONSE": 1, - "UDP_UNANSWERED_QUERY": 2, - "UDP_UNSOLICITED_RESPONSE": 3, - "TCP": 4, - "ICMP": 5, - "UDP_QUERY_ONLY": 6, - "UDP_RESPONSE_ONLY": 7, -} - -func (x DnsQRType) Enum() *DnsQRType { - p := new(DnsQRType) + // 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 DnsQR_DnsQRType int32 + +const ( + DnsQR_UDP_INVALID DnsQR_DnsQRType = 0 + DnsQR_UDP_QUERY_RESPONSE DnsQR_DnsQRType = 1 + DnsQR_UDP_UNANSWERED_QUERY DnsQR_DnsQRType = 2 + DnsQR_UDP_UNSOLICITED_RESPONSE DnsQR_DnsQRType = 3 + DnsQR_TCP DnsQR_DnsQRType = 4 + DnsQR_ICMP DnsQR_DnsQRType = 5 + DnsQR_UDP_QUERY_ONLY DnsQR_DnsQRType = 6 + DnsQR_UDP_RESPONSE_ONLY DnsQR_DnsQRType = 7 +) + +// Enum value maps for DnsQR_DnsQRType. +var ( + DnsQR_DnsQRType_name = map[int32]string{ + 0: "UDP_INVALID", + 1: "UDP_QUERY_RESPONSE", + 2: "UDP_UNANSWERED_QUERY", + 3: "UDP_UNSOLICITED_RESPONSE", + 4: "TCP", + 5: "ICMP", + 6: "UDP_QUERY_ONLY", + 7: "UDP_RESPONSE_ONLY", + } + DnsQR_DnsQRType_value = map[string]int32{ + "UDP_INVALID": 0, + "UDP_QUERY_RESPONSE": 1, + "UDP_UNANSWERED_QUERY": 2, + "UDP_UNSOLICITED_RESPONSE": 3, + "TCP": 4, + "ICMP": 5, + "UDP_QUERY_ONLY": 6, + "UDP_RESPONSE_ONLY": 7, + } +) + +func (x DnsQR_DnsQRType) Enum() *DnsQR_DnsQRType { + p := new(DnsQR_DnsQRType) *p = x return p } -func (x DnsQRType) String() string { - return proto.EnumName(DnsQRType_name, int32(x)) -} -func (x *DnsQRType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(DnsQRType_value, data, "DnsQRType") + +func (x DnsQR_DnsQRType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DnsQR_DnsQRType) Descriptor() protoreflect.EnumDescriptor { + return file_dnsqr_proto_enumTypes[0].Descriptor() +} + +func (DnsQR_DnsQRType) Type() protoreflect.EnumType { + return &file_dnsqr_proto_enumTypes[0] +} + +func (x DnsQR_DnsQRType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *DnsQR_DnsQRType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = DnsQRType(value) - return nil -} -func (DnsQRType) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{0} } - -type UdpChecksum int32 + *x = DnsQR_DnsQRType(num) + return nil +} + +// Deprecated: Use DnsQR_DnsQRType.Descriptor instead. +func (DnsQR_DnsQRType) EnumDescriptor() ([]byte, []int) { + return file_dnsqr_proto_rawDescGZIP(), []int{0, 0} +} + +type DnsQR_UdpChecksum int32 const ( - UdpChecksum_ERROR UdpChecksum = 0 - UdpChecksum_ABSENT UdpChecksum = 1 - UdpChecksum_INCORRECT UdpChecksum = 2 - UdpChecksum_CORRECT UdpChecksum = 3 -) - -var UdpChecksum_name = map[int32]string{ - 0: "ERROR", - 1: "ABSENT", - 2: "INCORRECT", - 3: "CORRECT", -} -var UdpChecksum_value = map[string]int32{ - "ERROR": 0, - "ABSENT": 1, - "INCORRECT": 2, - "CORRECT": 3, -} - -func (x UdpChecksum) Enum() *UdpChecksum { - p := new(UdpChecksum) + DnsQR_ERROR DnsQR_UdpChecksum = 0 + DnsQR_ABSENT DnsQR_UdpChecksum = 1 + DnsQR_INCORRECT DnsQR_UdpChecksum = 2 + DnsQR_CORRECT DnsQR_UdpChecksum = 3 +) + +// Enum value maps for DnsQR_UdpChecksum. +var ( + DnsQR_UdpChecksum_name = map[int32]string{ + 0: "ERROR", + 1: "ABSENT", + 2: "INCORRECT", + 3: "CORRECT", + } + DnsQR_UdpChecksum_value = map[string]int32{ + "ERROR": 0, + "ABSENT": 1, + "INCORRECT": 2, + "CORRECT": 3, + } +) + +func (x DnsQR_UdpChecksum) Enum() *DnsQR_UdpChecksum { + p := new(DnsQR_UdpChecksum) *p = x return p } -func (x UdpChecksum) String() string { - return proto.EnumName(UdpChecksum_name, int32(x)) -} -func (x *UdpChecksum) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(UdpChecksum_value, data, "UdpChecksum") + +func (x DnsQR_UdpChecksum) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DnsQR_UdpChecksum) Descriptor() protoreflect.EnumDescriptor { + return file_dnsqr_proto_enumTypes[1].Descriptor() +} + +func (DnsQR_UdpChecksum) Type() protoreflect.EnumType { + return &file_dnsqr_proto_enumTypes[1] +} + +func (x DnsQR_UdpChecksum) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *DnsQR_UdpChecksum) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = UdpChecksum(value) - return nil -} -func (UdpChecksum) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{1} } + *x = DnsQR_UdpChecksum(num) + return nil +} + +// Deprecated: Use DnsQR_UdpChecksum.Descriptor instead. +func (DnsQR_UdpChecksum) EnumDescriptor() ([]byte, []int) { + return file_dnsqr_proto_rawDescGZIP(), []int{0, 1} +} type DnsQR struct { - Type *DnsQRType `protobuf:"varint,1,req,name=type,enum=nmsg.base.DnsQRType" json:"type,omitempty"` - QueryIp []byte `protobuf:"bytes,2,req,name=query_ip" json:"query_ip,omitempty"` - ResponseIp []byte `protobuf:"bytes,3,req,name=response_ip" json:"response_ip,omitempty"` - Proto *uint32 `protobuf:"varint,4,req,name=proto" json:"proto,omitempty"` - QueryPort *uint32 `protobuf:"varint,5,req,name=query_port" json:"query_port,omitempty"` - ResponsePort *uint32 `protobuf:"varint,6,req,name=response_port" json:"response_port,omitempty"` - Id *uint32 `protobuf:"varint,7,req,name=id" json:"id,omitempty"` - Qname []byte `protobuf:"bytes,8,opt,name=qname" json:"qname,omitempty"` - Qtype *uint32 `protobuf:"varint,9,opt,name=qtype" json:"qtype,omitempty"` - Qclass *uint32 `protobuf:"varint,10,opt,name=qclass" json:"qclass,omitempty"` - Rcode *uint32 `protobuf:"varint,11,opt,name=rcode" json:"rcode,omitempty"` - QueryPacket [][]byte `protobuf:"bytes,12,rep,name=query_packet" json:"query_packet,omitempty"` - QueryTimeSec []int64 `protobuf:"varint,13,rep,name=query_time_sec" json:"query_time_sec,omitempty"` - QueryTimeNsec []int32 `protobuf:"fixed32,14,rep,name=query_time_nsec" json:"query_time_nsec,omitempty"` - ResponsePacket [][]byte `protobuf:"bytes,15,rep,name=response_packet" json:"response_packet,omitempty"` - ResponseTimeSec []int64 `protobuf:"varint,16,rep,name=response_time_sec" json:"response_time_sec,omitempty"` - ResponseTimeNsec []int32 `protobuf:"fixed32,17,rep,name=response_time_nsec" json:"response_time_nsec,omitempty"` - Tcp []byte `protobuf:"bytes,18,opt,name=tcp" json:"tcp,omitempty"` - Icmp []byte `protobuf:"bytes,19,opt,name=icmp" json:"icmp,omitempty"` - Timeout *float64 `protobuf:"fixed64,20,opt,name=timeout" json:"timeout,omitempty"` - UdpChecksum *UdpChecksum `protobuf:"varint,21,opt,name=udp_checksum,enum=nmsg.base.UdpChecksum" json:"udp_checksum,omitempty"` - ResolverAddressZeroed *bool `protobuf:"varint,22,opt,name=resolver_address_zeroed" json:"resolver_address_zeroed,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *DnsQR) Reset() { *m = DnsQR{} } -func (m *DnsQR) String() string { return proto.CompactTextString(m) } -func (*DnsQR) ProtoMessage() {} -func (*DnsQR) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} } - -func (m *DnsQR) GetType() DnsQRType { - if m != nil && m.Type != nil { - return *m.Type - } - return DnsQRType_UDP_INVALID -} - -func (m *DnsQR) GetQueryIp() []byte { - if m != nil { - return m.QueryIp - } - return nil -} - -func (m *DnsQR) GetResponseIp() []byte { - if m != nil { - return m.ResponseIp - } - return nil -} - -func (m *DnsQR) GetProto() uint32 { - if m != nil && m.Proto != nil { - return *m.Proto - } - return 0 -} - -func (m *DnsQR) GetQueryPort() uint32 { - if m != nil && m.QueryPort != nil { - return *m.QueryPort - } - return 0 -} - -func (m *DnsQR) GetResponsePort() uint32 { - if m != nil && m.ResponsePort != nil { - return *m.ResponsePort - } - return 0 -} - -func (m *DnsQR) GetId() uint32 { - if m != nil && m.Id != nil { - return *m.Id - } - return 0 -} - -func (m *DnsQR) GetQname() []byte { - if m != nil { - return m.Qname - } - return nil -} - -func (m *DnsQR) GetQtype() uint32 { - if m != nil && m.Qtype != nil { - return *m.Qtype - } - return 0 -} - -func (m *DnsQR) GetQclass() uint32 { - if m != nil && m.Qclass != nil { - return *m.Qclass - } - return 0 -} - -func (m *DnsQR) GetRcode() uint32 { - if m != nil && m.Rcode != nil { - return *m.Rcode - } - return 0 -} - -func (m *DnsQR) GetQueryPacket() [][]byte { - if m != nil { - return m.QueryPacket - } - return nil -} - -func (m *DnsQR) GetQueryTimeSec() []int64 { - if m != nil { - return m.QueryTimeSec - } - return nil -} - -func (m *DnsQR) GetQueryTimeNsec() []int32 { - if m != nil { - return m.QueryTimeNsec - } - return nil -} - -func (m *DnsQR) GetResponsePacket() [][]byte { - if m != nil { - return m.ResponsePacket - } - return nil -} - -func (m *DnsQR) GetResponseTimeSec() []int64 { - if m != nil { - return m.ResponseTimeSec - } - return nil -} - -func (m *DnsQR) GetResponseTimeNsec() []int32 { - if m != nil { - return m.ResponseTimeNsec - } - return nil -} - -func (m *DnsQR) GetTcp() []byte { - if m != nil { - return m.Tcp - } - return nil -} - -func (m *DnsQR) GetIcmp() []byte { - if m != nil { - return m.Icmp - } - return nil -} - -func (m *DnsQR) GetTimeout() float64 { - if m != nil && m.Timeout != nil { - return *m.Timeout - } - return 0 -} - -func (m *DnsQR) GetUdpChecksum() UdpChecksum { - if m != nil && m.UdpChecksum != nil { - return *m.UdpChecksum - } - return UdpChecksum_ERROR -} - -func (m *DnsQR) GetResolverAddressZeroed() bool { - if m != nil && m.ResolverAddressZeroed != nil { - return *m.ResolverAddressZeroed + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *DnsQR_DnsQRType `protobuf:"varint,1,req,name=type,enum=nmsg.base.DnsQR_DnsQRType" json:"type,omitempty"` + QueryIp []byte `protobuf:"bytes,2,req,name=query_ip,json=queryIp" json:"query_ip,omitempty"` + ResponseIp []byte `protobuf:"bytes,3,req,name=response_ip,json=responseIp" json:"response_ip,omitempty"` + Proto *uint32 `protobuf:"varint,4,req,name=proto" json:"proto,omitempty"` + QueryPort *uint32 `protobuf:"varint,5,req,name=query_port,json=queryPort" json:"query_port,omitempty"` + ResponsePort *uint32 `protobuf:"varint,6,req,name=response_port,json=responsePort" json:"response_port,omitempty"` + Id *uint32 `protobuf:"varint,7,req,name=id" json:"id,omitempty"` + Qname []byte `protobuf:"bytes,8,opt,name=qname" json:"qname,omitempty"` + Qtype *uint32 `protobuf:"varint,9,opt,name=qtype" json:"qtype,omitempty"` + Qclass *uint32 `protobuf:"varint,10,opt,name=qclass" json:"qclass,omitempty"` + Rcode *uint32 `protobuf:"varint,11,opt,name=rcode" json:"rcode,omitempty"` + QueryPacket [][]byte `protobuf:"bytes,12,rep,name=query_packet,json=queryPacket" json:"query_packet,omitempty"` + QueryTimeSec []int64 `protobuf:"varint,13,rep,name=query_time_sec,json=queryTimeSec" json:"query_time_sec,omitempty"` + QueryTimeNsec []int32 `protobuf:"fixed32,14,rep,name=query_time_nsec,json=queryTimeNsec" json:"query_time_nsec,omitempty"` + ResponsePacket [][]byte `protobuf:"bytes,15,rep,name=response_packet,json=responsePacket" json:"response_packet,omitempty"` + ResponseTimeSec []int64 `protobuf:"varint,16,rep,name=response_time_sec,json=responseTimeSec" json:"response_time_sec,omitempty"` + ResponseTimeNsec []int32 `protobuf:"fixed32,17,rep,name=response_time_nsec,json=responseTimeNsec" json:"response_time_nsec,omitempty"` + Tcp []byte `protobuf:"bytes,18,opt,name=tcp" json:"tcp,omitempty"` + Icmp []byte `protobuf:"bytes,19,opt,name=icmp" json:"icmp,omitempty"` + Timeout *float64 `protobuf:"fixed64,20,opt,name=timeout" json:"timeout,omitempty"` + UdpChecksum *DnsQR_UdpChecksum `protobuf:"varint,21,opt,name=udp_checksum,json=udpChecksum,enum=nmsg.base.DnsQR_UdpChecksum" json:"udp_checksum,omitempty"` + ResolverAddressZeroed *bool `protobuf:"varint,22,opt,name=resolver_address_zeroed,json=resolverAddressZeroed" json:"resolver_address_zeroed,omitempty"` +} + +func (x *DnsQR) Reset() { + *x = DnsQR{} + if protoimpl.UnsafeEnabled { + mi := &file_dnsqr_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DnsQR) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DnsQR) ProtoMessage() {} + +func (x *DnsQR) ProtoReflect() protoreflect.Message { + mi := &file_dnsqr_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DnsQR.ProtoReflect.Descriptor instead. +func (*DnsQR) Descriptor() ([]byte, []int) { + return file_dnsqr_proto_rawDescGZIP(), []int{0} +} + +func (x *DnsQR) GetType() DnsQR_DnsQRType { + if x != nil && x.Type != nil { + return *x.Type + } + return DnsQR_UDP_INVALID +} + +func (x *DnsQR) GetQueryIp() []byte { + if x != nil { + return x.QueryIp + } + return nil +} + +func (x *DnsQR) GetResponseIp() []byte { + if x != nil { + return x.ResponseIp + } + return nil +} + +func (x *DnsQR) GetProto() uint32 { + if x != nil && x.Proto != nil { + return *x.Proto + } + return 0 +} + +func (x *DnsQR) GetQueryPort() uint32 { + if x != nil && x.QueryPort != nil { + return *x.QueryPort + } + return 0 +} + +func (x *DnsQR) GetResponsePort() uint32 { + if x != nil && x.ResponsePort != nil { + return *x.ResponsePort + } + return 0 +} + +func (x *DnsQR) GetId() uint32 { + if x != nil && x.Id != nil { + return *x.Id + } + return 0 +} + +func (x *DnsQR) GetQname() []byte { + if x != nil { + return x.Qname + } + return nil +} + +func (x *DnsQR) GetQtype() uint32 { + if x != nil && x.Qtype != nil { + return *x.Qtype + } + return 0 +} + +func (x *DnsQR) GetQclass() uint32 { + if x != nil && x.Qclass != nil { + return *x.Qclass + } + return 0 +} + +func (x *DnsQR) GetRcode() uint32 { + if x != nil && x.Rcode != nil { + return *x.Rcode + } + return 0 +} + +func (x *DnsQR) GetQueryPacket() [][]byte { + if x != nil { + return x.QueryPacket + } + return nil +} + +func (x *DnsQR) GetQueryTimeSec() []int64 { + if x != nil { + return x.QueryTimeSec + } + return nil +} + +func (x *DnsQR) GetQueryTimeNsec() []int32 { + if x != nil { + return x.QueryTimeNsec + } + return nil +} + +func (x *DnsQR) GetResponsePacket() [][]byte { + if x != nil { + return x.ResponsePacket + } + return nil +} + +func (x *DnsQR) GetResponseTimeSec() []int64 { + if x != nil { + return x.ResponseTimeSec + } + return nil +} + +func (x *DnsQR) GetResponseTimeNsec() []int32 { + if x != nil { + return x.ResponseTimeNsec + } + return nil +} + +func (x *DnsQR) GetTcp() []byte { + if x != nil { + return x.Tcp + } + return nil +} + +func (x *DnsQR) GetIcmp() []byte { + if x != nil { + return x.Icmp + } + return nil +} + +func (x *DnsQR) GetTimeout() float64 { + if x != nil && x.Timeout != nil { + return *x.Timeout + } + return 0 +} + +func (x *DnsQR) GetUdpChecksum() DnsQR_UdpChecksum { + if x != nil && x.UdpChecksum != nil { + return *x.UdpChecksum + } + return DnsQR_ERROR +} + +func (x *DnsQR) GetResolverAddressZeroed() bool { + if x != nil && x.ResolverAddressZeroed != nil { + return *x.ResolverAddressZeroed } return false } -func init() { - proto.RegisterType((*DnsQR)(nil), "nmsg.base.DnsQR") - proto.RegisterEnum("nmsg.base.DnsQRType", DnsQRType_name, DnsQRType_value) - proto.RegisterEnum("nmsg.base.UdpChecksum", UdpChecksum_name, UdpChecksum_value) -} - -func init() { proto.RegisterFile("dnsqr.proto", fileDescriptor1) } - -var fileDescriptor1 = []byte{ - // 491 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x54, 0x92, 0xdb, 0x6e, 0x9b, 0x40, - 0x10, 0x86, 0x6b, 0xe3, 0xe3, 0x70, 0xf4, 0xc6, 0x71, 0xb6, 0x55, 0xa5, 0x5a, 0xb9, 0xaa, 0xa2, - 0xca, 0x17, 0x79, 0x82, 0xba, 0x98, 0x0b, 0x24, 0x17, 0x1c, 0xc0, 0xad, 0x72, 0x85, 0x28, 0xac, - 0x5a, 0x2b, 0xe1, 0xb8, 0xb8, 0x52, 0xfa, 0x48, 0x7d, 0xb1, 0xbe, 0x46, 0x87, 0x25, 0xc1, 0xce, - 0x1d, 0xf3, 0xfd, 0x33, 0xff, 0xfc, 0xcb, 0x2e, 0xc8, 0x49, 0xc6, 0xcb, 0x6a, 0x55, 0x54, 0x79, - 0x9d, 0x93, 0x69, 0x96, 0xf2, 0x9f, 0xab, 0x1f, 0x11, 0x67, 0xd7, 0xff, 0x24, 0x18, 0x6e, 0x32, - 0x7e, 0xe7, 0x91, 0x6b, 0x18, 0xd4, 0x4f, 0x05, 0xa3, 0xbd, 0x65, 0xff, 0xa3, 0x76, 0x3b, 0x5f, - 0x75, 0x3d, 0x2b, 0xa1, 0x07, 0xa8, 0x11, 0x03, 0x26, 0xe5, 0x91, 0x55, 0x4f, 0xe1, 0xa1, 0xa0, - 0x7d, 0xec, 0x53, 0xc8, 0x05, 0xc8, 0x15, 0xe3, 0x45, 0x9e, 0x71, 0xd6, 0x40, 0x49, 0x40, 0x15, - 0x86, 0x62, 0x11, 0x1d, 0x60, 0xa9, 0x12, 0x02, 0xd0, 0x4e, 0x15, 0x79, 0x55, 0xd3, 0xa1, 0x60, - 0x97, 0xa0, 0x76, 0x73, 0x02, 0x8f, 0x04, 0x06, 0xe8, 0x1f, 0x12, 0x3a, 0x16, 0xdf, 0xe8, 0x52, - 0x66, 0x51, 0xca, 0xe8, 0x64, 0xd9, 0x6b, 0x4d, 0x4b, 0x11, 0x70, 0x8a, 0xa5, 0x4a, 0x34, 0x18, - 0x95, 0xf1, 0x63, 0xc4, 0x39, 0x05, 0x51, 0xa3, 0x5c, 0xc5, 0x79, 0xc2, 0xa8, 0x2c, 0xca, 0x39, - 0x28, 0xcf, 0x3b, 0xa3, 0xf8, 0x81, 0xd5, 0x54, 0x59, 0x4a, 0xe8, 0xb1, 0x00, 0xad, 0xa5, 0xf5, - 0x21, 0x65, 0x21, 0x67, 0x31, 0x55, 0x91, 0x4b, 0xe4, 0x0a, 0xf4, 0x33, 0x9e, 0x35, 0x82, 0x86, - 0x82, 0xde, 0x08, 0xa7, 0x98, 0xad, 0x93, 0x2e, 0x9c, 0xde, 0xc2, 0xac, 0x13, 0x3a, 0x33, 0x43, - 0x98, 0xbd, 0x03, 0xf2, 0x5a, 0x12, 0x7e, 0x33, 0xe1, 0x27, 0x83, 0x54, 0xc7, 0x05, 0x25, 0xe2, - 0x44, 0x0a, 0x0c, 0x0e, 0x71, 0x5a, 0xd0, 0x0b, 0x51, 0xe9, 0x30, 0x6e, 0xba, 0xf3, 0x63, 0x4d, - 0xe7, 0x08, 0x7a, 0xe4, 0x13, 0x28, 0xc7, 0xa4, 0x08, 0xe3, 0x5f, 0x2c, 0x7e, 0xe0, 0xc7, 0x94, - 0x5e, 0x22, 0xd5, 0x6e, 0x17, 0x67, 0x17, 0xb3, 0x4f, 0x0a, 0xf3, 0x59, 0x25, 0x1f, 0xe0, 0x0a, - 0xb7, 0xe6, 0x8f, 0xbf, 0x59, 0x15, 0x46, 0x49, 0x82, 0xdf, 0x3c, 0xfc, 0xc3, 0xaa, 0x9c, 0x25, - 0x74, 0x81, 0x83, 0x93, 0x9b, 0xbf, 0x3d, 0x98, 0x9e, 0x6e, 0x52, 0x07, 0x79, 0xbf, 0xd9, 0x85, - 0xb6, 0xf3, 0x6d, 0xbd, 0xb5, 0x37, 0xc6, 0x1b, 0xfc, 0x35, 0xa4, 0x01, 0x77, 0x7b, 0xcb, 0xbb, - 0x0f, 0x3d, 0xcb, 0xdf, 0xb9, 0x8e, 0x6f, 0x19, 0x3d, 0x42, 0x61, 0xde, 0xf0, 0xbd, 0xb3, 0x76, - 0xfc, 0xef, 0x96, 0x67, 0x6d, 0xda, 0x16, 0xa3, 0x4f, 0xde, 0x03, 0x6d, 0x15, 0xdf, 0xdd, 0xda, - 0xa6, 0x1d, 0xa0, 0xd4, 0xcd, 0x49, 0x64, 0x0c, 0x52, 0x60, 0xee, 0x8c, 0x01, 0x99, 0xc0, 0xc0, - 0x36, 0xbf, 0xee, 0x8c, 0x21, 0xbe, 0x03, 0xed, 0xb4, 0xc2, 0x75, 0xb6, 0xf7, 0xc6, 0x08, 0xdf, - 0xc1, 0xac, 0x61, 0x2f, 0x83, 0x2d, 0x1e, 0xdf, 0x7c, 0xc6, 0x78, 0x67, 0x87, 0x9b, 0xc2, 0xd0, - 0xf2, 0x3c, 0xd7, 0xc3, 0x9c, 0x00, 0xa3, 0xf5, 0x17, 0xdf, 0x72, 0x02, 0xcc, 0xa6, 0xc2, 0xd4, - 0x76, 0x4c, 0xd7, 0xf3, 0x2c, 0x33, 0xc0, 0x40, 0x32, 0x8c, 0x5f, 0x0a, 0xe9, 0x7f, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x04, 0x82, 0x9b, 0xdb, 0xf1, 0x02, 0x00, 0x00, -} +var File_dnsqr_proto protoreflect.FileDescriptor + +var file_dnsqr_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x64, 0x6e, 0x73, 0x71, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, + 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xd3, 0x07, 0x0a, 0x05, 0x44, 0x6e, 0x73, + 0x51, 0x52, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, + 0x32, 0x1a, 0x2e, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x44, 0x6e, 0x73, + 0x51, 0x52, 0x2e, 0x44, 0x6e, 0x73, 0x51, 0x52, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x69, 0x70, 0x18, 0x02, + 0x20, 0x02, 0x28, 0x0c, 0x52, 0x07, 0x71, 0x75, 0x65, 0x72, 0x79, 0x49, 0x70, 0x12, 0x1f, 0x0a, + 0x0b, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x02, + 0x28, 0x0c, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x49, 0x70, 0x12, 0x14, + 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x04, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x05, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x6f, + 0x72, 0x74, 0x18, 0x05, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x09, 0x71, 0x75, 0x65, 0x72, 0x79, 0x50, + 0x6f, 0x72, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, + 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x07, + 0x20, 0x02, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x71, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x71, 0x74, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x71, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x71, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x71, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, + 0x72, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x72, 0x63, 0x6f, + 0x64, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0b, 0x71, 0x75, 0x65, 0x72, 0x79, 0x50, + 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x63, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0c, 0x71, + 0x75, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x65, 0x63, 0x12, 0x26, 0x0a, 0x0f, 0x71, + 0x75, 0x65, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6e, 0x73, 0x65, 0x63, 0x18, 0x0e, + 0x20, 0x03, 0x28, 0x0f, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x4e, + 0x73, 0x65, 0x63, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, + 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x2a, 0x0a, 0x11, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x73, 0x65, + 0x63, 0x18, 0x10, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x65, 0x63, 0x12, 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6e, 0x73, 0x65, 0x63, 0x18, 0x11, + 0x20, 0x03, 0x28, 0x0f, 0x52, 0x10, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x69, + 0x6d, 0x65, 0x4e, 0x73, 0x65, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x63, 0x70, 0x18, 0x12, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x03, 0x74, 0x63, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6d, 0x70, + 0x18, 0x13, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x69, 0x63, 0x6d, 0x70, 0x12, 0x18, 0x0a, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x14, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x3f, 0x0a, 0x0c, 0x75, 0x64, 0x70, 0x5f, 0x63, 0x68, + 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x6e, + 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x44, 0x6e, 0x73, 0x51, 0x52, 0x2e, 0x55, + 0x64, 0x70, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x52, 0x0b, 0x75, 0x64, 0x70, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x12, 0x36, 0x0a, 0x17, 0x72, 0x65, 0x73, 0x6f, 0x6c, + 0x76, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x7a, 0x65, 0x72, 0x6f, + 0x65, 0x64, 0x18, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5a, 0x65, 0x72, 0x6f, 0x65, 0x64, 0x22, + 0xaa, 0x01, 0x0a, 0x09, 0x44, 0x6e, 0x73, 0x51, 0x52, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, + 0x0b, 0x55, 0x44, 0x50, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x16, + 0x0a, 0x12, 0x55, 0x44, 0x50, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x5f, 0x52, 0x45, 0x53, 0x50, + 0x4f, 0x4e, 0x53, 0x45, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x44, 0x50, 0x5f, 0x55, 0x4e, + 0x41, 0x4e, 0x53, 0x57, 0x45, 0x52, 0x45, 0x44, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x02, + 0x12, 0x1c, 0x0a, 0x18, 0x55, 0x44, 0x50, 0x5f, 0x55, 0x4e, 0x53, 0x4f, 0x4c, 0x49, 0x43, 0x49, + 0x54, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x53, 0x50, 0x4f, 0x4e, 0x53, 0x45, 0x10, 0x03, 0x12, 0x07, + 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x43, 0x4d, 0x50, 0x10, + 0x05, 0x12, 0x12, 0x0a, 0x0e, 0x55, 0x44, 0x50, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x5f, 0x4f, + 0x4e, 0x4c, 0x59, 0x10, 0x06, 0x12, 0x15, 0x0a, 0x11, 0x55, 0x44, 0x50, 0x5f, 0x52, 0x45, 0x53, + 0x50, 0x4f, 0x4e, 0x53, 0x45, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x07, 0x22, 0x40, 0x0a, 0x0b, + 0x55, 0x64, 0x70, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x12, 0x09, 0x0a, 0x05, 0x45, + 0x52, 0x52, 0x4f, 0x52, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x42, 0x53, 0x45, 0x4e, 0x54, + 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x49, 0x4e, 0x43, 0x4f, 0x52, 0x52, 0x45, 0x43, 0x54, 0x10, + 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x52, 0x52, 0x45, 0x43, 0x54, 0x10, 0x03, 0x42, 0x2a, + 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, + 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, + 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_dnsqr_proto_rawDescOnce sync.Once + file_dnsqr_proto_rawDescData = file_dnsqr_proto_rawDesc +) + +func file_dnsqr_proto_rawDescGZIP() []byte { + file_dnsqr_proto_rawDescOnce.Do(func() { + file_dnsqr_proto_rawDescData = protoimpl.X.CompressGZIP(file_dnsqr_proto_rawDescData) + }) + return file_dnsqr_proto_rawDescData +} + +var file_dnsqr_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_dnsqr_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_dnsqr_proto_goTypes = []interface{}{ + (DnsQR_DnsQRType)(0), // 0: nmsg.base.DnsQR.DnsQRType + (DnsQR_UdpChecksum)(0), // 1: nmsg.base.DnsQR.UdpChecksum + (*DnsQR)(nil), // 2: nmsg.base.DnsQR +} +var file_dnsqr_proto_depIdxs = []int32{ + 0, // 0: nmsg.base.DnsQR.type:type_name -> nmsg.base.DnsQR.DnsQRType + 1, // 1: nmsg.base.DnsQR.udp_checksum:type_name -> nmsg.base.DnsQR.UdpChecksum + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_dnsqr_proto_init() } +func file_dnsqr_proto_init() { + if File_dnsqr_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_dnsqr_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DnsQR); 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_dnsqr_proto_rawDesc, + NumEnums: 2, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_dnsqr_proto_goTypes, + DependencyIndexes: file_dnsqr_proto_depIdxs, + EnumInfos: file_dnsqr_proto_enumTypes, + MessageInfos: file_dnsqr_proto_msgTypes, + }.Build() + File_dnsqr_proto = out.File + file_dnsqr_proto_rawDesc = nil + file_dnsqr_proto_goTypes = nil + file_dnsqr_proto_depIdxs = nil +} diff --git a/nmsg_base/dnsqr.proto b/nmsg_base/dnsqr.proto index e98826b..2aa196b 100644 --- a/nmsg_base/dnsqr.proto +++ b/nmsg_base/dnsqr.proto @@ -1,25 +1,26 @@ syntax = "proto2"; package nmsg.base; - -enum DnsQRType { - UDP_INVALID = 0; - UDP_QUERY_RESPONSE = 1; - UDP_UNANSWERED_QUERY = 2; - UDP_UNSOLICITED_RESPONSE = 3; - TCP = 4; - ICMP = 5; - UDP_QUERY_ONLY = 6; - UDP_RESPONSE_ONLY = 7; -} - -enum UdpChecksum { - ERROR = 0; - ABSENT = 1; - INCORRECT = 2; - CORRECT = 3; -} +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message DnsQR { + enum DnsQRType { + UDP_INVALID = 0; + UDP_QUERY_RESPONSE = 1; + UDP_UNANSWERED_QUERY = 2; + UDP_UNSOLICITED_RESPONSE = 3; + TCP = 4; + ICMP = 5; + UDP_QUERY_ONLY = 6; + UDP_RESPONSE_ONLY = 7; + } + + enum UdpChecksum { + ERROR = 0; + ABSENT = 1; + INCORRECT = 2; + CORRECT = 3; + } + required DnsQRType type = 1; // the 9-tuple diff --git a/nmsg_base/email.pb.go b/nmsg_base/email.pb.go index 45d1524..2df11e5 100644 --- a/nmsg_base/email.pb.go +++ b/nmsg_base/email.pb.go @@ -1,163 +1,294 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: email.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -type EmailType int32 +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) const ( - EmailType_unknown EmailType = 0 - EmailType_spamtrap EmailType = 1 - EmailType_rej_network EmailType = 2 - EmailType_rej_content EmailType = 3 - EmailType_rej_user EmailType = 4 -) - -var EmailType_name = map[int32]string{ - 0: "unknown", - 1: "spamtrap", - 2: "rej_network", - 3: "rej_content", - 4: "rej_user", -} -var EmailType_value = map[string]int32{ - "unknown": 0, - "spamtrap": 1, - "rej_network": 2, - "rej_content": 3, - "rej_user": 4, -} - -func (x EmailType) Enum() *EmailType { - p := new(EmailType) + // 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 Email_EmailType int32 + +const ( + Email_unknown Email_EmailType = 0 + Email_spamtrap Email_EmailType = 1 + Email_rej_network Email_EmailType = 2 + Email_rej_content Email_EmailType = 3 + Email_rej_user Email_EmailType = 4 +) + +// Enum value maps for Email_EmailType. +var ( + Email_EmailType_name = map[int32]string{ + 0: "unknown", + 1: "spamtrap", + 2: "rej_network", + 3: "rej_content", + 4: "rej_user", + } + Email_EmailType_value = map[string]int32{ + "unknown": 0, + "spamtrap": 1, + "rej_network": 2, + "rej_content": 3, + "rej_user": 4, + } +) + +func (x Email_EmailType) Enum() *Email_EmailType { + p := new(Email_EmailType) *p = x return p } -func (x EmailType) String() string { - return proto.EnumName(EmailType_name, int32(x)) -} -func (x *EmailType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(EmailType_value, data, "EmailType") + +func (x Email_EmailType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Email_EmailType) Descriptor() protoreflect.EnumDescriptor { + return file_email_proto_enumTypes[0].Descriptor() +} + +func (Email_EmailType) Type() protoreflect.EnumType { + return &file_email_proto_enumTypes[0] +} + +func (x Email_EmailType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Email_EmailType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = EmailType(value) - return nil -} -func (EmailType) EnumDescriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } + *x = Email_EmailType(num) + return nil +} + +// Deprecated: Use Email_EmailType.Descriptor instead. +func (Email_EmailType) EnumDescriptor() ([]byte, []int) { + return file_email_proto_rawDescGZIP(), []int{0, 0} +} type Email struct { - Type *EmailType `protobuf:"varint,8,opt,name=type,enum=nmsg.base.EmailType" json:"type,omitempty"` - Headers []byte `protobuf:"bytes,2,opt,name=headers" json:"headers,omitempty"` - Srcip []byte `protobuf:"bytes,3,opt,name=srcip" json:"srcip,omitempty"` - Srchost []byte `protobuf:"bytes,4,opt,name=srchost" json:"srchost,omitempty"` - Helo []byte `protobuf:"bytes,5,opt,name=helo" json:"helo,omitempty"` - From []byte `protobuf:"bytes,6,opt,name=from" json:"from,omitempty"` - Rcpt [][]byte `protobuf:"bytes,7,rep,name=rcpt" json:"rcpt,omitempty"` - Bodyurl [][]byte `protobuf:"bytes,9,rep,name=bodyurl" json:"bodyurl,omitempty"` - Body []byte `protobuf:"bytes,10,opt,name=body" json:"body,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Email) Reset() { *m = Email{} } -func (m *Email) String() string { return proto.CompactTextString(m) } -func (*Email) ProtoMessage() {} -func (*Email) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } - -func (m *Email) GetType() EmailType { - if m != nil && m.Type != nil { - return *m.Type - } - return EmailType_unknown -} - -func (m *Email) GetHeaders() []byte { - if m != nil { - return m.Headers - } - return nil -} - -func (m *Email) GetSrcip() []byte { - if m != nil { - return m.Srcip - } - return nil -} - -func (m *Email) GetSrchost() []byte { - if m != nil { - return m.Srchost - } - return nil -} - -func (m *Email) GetHelo() []byte { - if m != nil { - return m.Helo - } - return nil -} - -func (m *Email) GetFrom() []byte { - if m != nil { - return m.From - } - return nil -} - -func (m *Email) GetRcpt() [][]byte { - if m != nil { - return m.Rcpt - } - return nil -} - -func (m *Email) GetBodyurl() [][]byte { - if m != nil { - return m.Bodyurl - } - return nil -} - -func (m *Email) GetBody() []byte { - if m != nil { - return m.Body - } - return nil -} - -func init() { - proto.RegisterType((*Email)(nil), "nmsg.base.Email") - proto.RegisterEnum("nmsg.base.EmailType", EmailType_name, EmailType_value) -} - -func init() { proto.RegisterFile("email.proto", fileDescriptor2) } - -var fileDescriptor2 = []byte{ - // 222 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x44, 0x8e, 0x41, 0x4e, 0xc3, 0x30, - 0x10, 0x45, 0x49, 0x93, 0x90, 0x66, 0x52, 0xc0, 0x8a, 0x58, 0xcc, 0xb2, 0xea, 0x0a, 0xb1, 0xc8, - 0x82, 0x3b, 0x70, 0x03, 0xc4, 0x16, 0xb9, 0xe9, 0x40, 0x4a, 0x13, 0x8f, 0x35, 0x76, 0x54, 0xf5, - 0x40, 0xdc, 0x13, 0xdb, 0x28, 0x74, 0xf9, 0xdf, 0x7b, 0xb6, 0x06, 0x1a, 0x9a, 0xf4, 0x71, 0xec, - 0xac, 0xb0, 0xe7, 0xb6, 0x36, 0x93, 0xfb, 0xea, 0xf6, 0xda, 0xd1, 0xee, 0x27, 0x83, 0xf2, 0x35, - 0xaa, 0x76, 0x07, 0x85, 0xbf, 0x58, 0xc2, 0xf5, 0x36, 0x7b, 0xba, 0x7f, 0x79, 0xec, 0xfe, 0x9b, - 0x2e, 0xf9, 0xb7, 0xe0, 0xda, 0x07, 0xa8, 0x06, 0xd2, 0x07, 0x12, 0x87, 0xab, 0x90, 0x6d, 0xda, - 0x3b, 0x28, 0x9d, 0xf4, 0x47, 0x8b, 0x79, 0x9a, 0xc1, 0x87, 0x39, 0xb0, 0xf3, 0x58, 0x24, 0xb0, - 0x81, 0x62, 0xa0, 0x91, 0xb1, 0x5c, 0xd6, 0xa7, 0xf0, 0x84, 0xb7, 0xcb, 0x92, 0xde, 0x7a, 0xac, - 0xb6, 0xf9, 0xdf, 0xd3, 0x3d, 0x1f, 0x2e, 0xb3, 0x8c, 0x58, 0x27, 0x10, 0x74, 0x04, 0x08, 0x31, - 0x7e, 0x7e, 0x87, 0xfa, 0x7a, 0x46, 0x03, 0xd5, 0x6c, 0x4e, 0x86, 0xcf, 0x46, 0xdd, 0x84, 0x6e, - 0xed, 0xac, 0x9e, 0xbc, 0x68, 0xab, 0xb2, 0xf0, 0x4d, 0x23, 0xf4, 0xfd, 0x61, 0xc8, 0x9f, 0x59, - 0x4e, 0x6a, 0xb5, 0x80, 0x9e, 0x8d, 0x27, 0xe3, 0x55, 0x1e, 0xfb, 0x08, 0x66, 0x47, 0xa2, 0x8a, - 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6b, 0xe2, 0x02, 0x36, 0x18, 0x01, 0x00, 0x00, -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Email_EmailType `protobuf:"varint,8,opt,name=type,enum=nmsg.base.Email_EmailType" json:"type,omitempty"` + Headers []byte `protobuf:"bytes,2,opt,name=headers" json:"headers,omitempty"` + Srcip []byte `protobuf:"bytes,3,opt,name=srcip" json:"srcip,omitempty"` + Srchost []byte `protobuf:"bytes,4,opt,name=srchost" json:"srchost,omitempty"` + Helo []byte `protobuf:"bytes,5,opt,name=helo" json:"helo,omitempty"` + From []byte `protobuf:"bytes,6,opt,name=from" json:"from,omitempty"` + Rcpt [][]byte `protobuf:"bytes,7,rep,name=rcpt" json:"rcpt,omitempty"` + Bodyurl [][]byte `protobuf:"bytes,9,rep,name=bodyurl" json:"bodyurl,omitempty"` + Body []byte `protobuf:"bytes,10,opt,name=body" json:"body,omitempty"` +} + +func (x *Email) Reset() { + *x = Email{} + if protoimpl.UnsafeEnabled { + mi := &file_email_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Email) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Email) ProtoMessage() {} + +func (x *Email) ProtoReflect() protoreflect.Message { + mi := &file_email_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Email.ProtoReflect.Descriptor instead. +func (*Email) Descriptor() ([]byte, []int) { + return file_email_proto_rawDescGZIP(), []int{0} +} + +func (x *Email) GetType() Email_EmailType { + if x != nil && x.Type != nil { + return *x.Type + } + return Email_unknown +} + +func (x *Email) GetHeaders() []byte { + if x != nil { + return x.Headers + } + return nil +} + +func (x *Email) GetSrcip() []byte { + if x != nil { + return x.Srcip + } + return nil +} + +func (x *Email) GetSrchost() []byte { + if x != nil { + return x.Srchost + } + return nil +} + +func (x *Email) GetHelo() []byte { + if x != nil { + return x.Helo + } + return nil +} + +func (x *Email) GetFrom() []byte { + if x != nil { + return x.From + } + return nil +} + +func (x *Email) GetRcpt() [][]byte { + if x != nil { + return x.Rcpt + } + return nil +} + +func (x *Email) GetBodyurl() [][]byte { + if x != nil { + return x.Bodyurl + } + return nil +} + +func (x *Email) GetBody() []byte { + if x != nil { + return x.Body + } + return nil +} + +var File_email_proto protoreflect.FileDescriptor + +var file_email_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, + 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xc3, 0x02, 0x0a, 0x05, 0x45, 0x6d, 0x61, + 0x69, 0x6c, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x1a, 0x2e, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x45, 0x6d, 0x61, + 0x69, 0x6c, 0x2e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, + 0x73, 0x72, 0x63, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x72, 0x63, + 0x69, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x72, 0x63, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x07, 0x73, 0x72, 0x63, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x68, 0x65, 0x6c, 0x6f, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x65, 0x6c, 0x6f, + 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, + 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x63, 0x70, 0x74, 0x18, 0x07, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x04, 0x72, 0x63, 0x70, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x6f, 0x64, 0x79, + 0x75, 0x72, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x07, 0x62, 0x6f, 0x64, 0x79, 0x75, + 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x56, 0x0a, 0x09, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, + 0x12, 0x0c, 0x0a, 0x08, 0x73, 0x70, 0x61, 0x6d, 0x74, 0x72, 0x61, 0x70, 0x10, 0x01, 0x12, 0x0f, + 0x0a, 0x0b, 0x72, 0x65, 0x6a, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x10, 0x02, 0x12, + 0x0f, 0x0a, 0x0b, 0x72, 0x65, 0x6a, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x10, 0x03, + 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x6a, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x10, 0x04, 0x42, 0x2a, + 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, + 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, + 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_email_proto_rawDescOnce sync.Once + file_email_proto_rawDescData = file_email_proto_rawDesc +) + +func file_email_proto_rawDescGZIP() []byte { + file_email_proto_rawDescOnce.Do(func() { + file_email_proto_rawDescData = protoimpl.X.CompressGZIP(file_email_proto_rawDescData) + }) + return file_email_proto_rawDescData +} + +var file_email_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_email_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_email_proto_goTypes = []interface{}{ + (Email_EmailType)(0), // 0: nmsg.base.Email.EmailType + (*Email)(nil), // 1: nmsg.base.Email +} +var file_email_proto_depIdxs = []int32{ + 0, // 0: nmsg.base.Email.type:type_name -> nmsg.base.Email.EmailType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_email_proto_init() } +func file_email_proto_init() { + if File_email_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_email_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Email); 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_email_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_email_proto_goTypes, + DependencyIndexes: file_email_proto_depIdxs, + EnumInfos: file_email_proto_enumTypes, + MessageInfos: file_email_proto_msgTypes, + }.Build() + File_email_proto = out.File + file_email_proto_rawDesc = nil + file_email_proto_goTypes = nil + file_email_proto_depIdxs = nil +} diff --git a/nmsg_base/email.proto b/nmsg_base/email.proto index a1af375..31af807 100644 --- a/nmsg_base/email.proto +++ b/nmsg_base/email.proto @@ -1,15 +1,16 @@ syntax = "proto2"; package nmsg.base; - -enum EmailType { - unknown = 0; - spamtrap = 1; - rej_network = 2; - rej_content = 3; - rej_user = 4; -} +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message Email { + enum EmailType { + unknown = 0; + spamtrap = 1; + rej_network = 2; + rej_content = 3; + rej_user = 4; + } + optional EmailType type = 8; optional bytes headers = 2; optional bytes srcip = 3; diff --git a/nmsg_base/encode.pb.go b/nmsg_base/encode.pb.go index d00ada9..903e72d 100644 --- a/nmsg_base/encode.pb.go +++ b/nmsg_base/encode.pb.go @@ -1,103 +1,227 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: encode.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -type EncodeType int32 +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) const ( - EncodeType_TEXT EncodeType = 0 - EncodeType_JSON EncodeType = 1 - EncodeType_YAML EncodeType = 2 - EncodeType_MSGPACK EncodeType = 3 - EncodeType_XML EncodeType = 4 -) - -var EncodeType_name = map[int32]string{ - 0: "TEXT", - 1: "JSON", - 2: "YAML", - 3: "MSGPACK", - 4: "XML", -} -var EncodeType_value = map[string]int32{ - "TEXT": 0, - "JSON": 1, - "YAML": 2, - "MSGPACK": 3, - "XML": 4, -} - -func (x EncodeType) Enum() *EncodeType { - p := new(EncodeType) + // 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 Encode_EncodeType int32 + +const ( + Encode_TEXT Encode_EncodeType = 0 + Encode_JSON Encode_EncodeType = 1 + Encode_YAML Encode_EncodeType = 2 + Encode_MSGPACK Encode_EncodeType = 3 + Encode_XML Encode_EncodeType = 4 +) + +// Enum value maps for Encode_EncodeType. +var ( + Encode_EncodeType_name = map[int32]string{ + 0: "TEXT", + 1: "JSON", + 2: "YAML", + 3: "MSGPACK", + 4: "XML", + } + Encode_EncodeType_value = map[string]int32{ + "TEXT": 0, + "JSON": 1, + "YAML": 2, + "MSGPACK": 3, + "XML": 4, + } +) + +func (x Encode_EncodeType) Enum() *Encode_EncodeType { + p := new(Encode_EncodeType) *p = x return p } -func (x EncodeType) String() string { - return proto.EnumName(EncodeType_name, int32(x)) -} -func (x *EncodeType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(EncodeType_value, data, "EncodeType") + +func (x Encode_EncodeType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Encode_EncodeType) Descriptor() protoreflect.EnumDescriptor { + return file_encode_proto_enumTypes[0].Descriptor() +} + +func (Encode_EncodeType) Type() protoreflect.EnumType { + return &file_encode_proto_enumTypes[0] +} + +func (x Encode_EncodeType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Encode_EncodeType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = EncodeType(value) + *x = Encode_EncodeType(num) return nil } -func (EncodeType) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } + +// Deprecated: Use Encode_EncodeType.Descriptor instead. +func (Encode_EncodeType) EnumDescriptor() ([]byte, []int) { + return file_encode_proto_rawDescGZIP(), []int{0, 0} +} type Encode struct { - Type *EncodeType `protobuf:"varint,1,req,name=type,enum=nmsg.base.EncodeType" json:"type,omitempty"` - Payload []byte `protobuf:"bytes,2,req,name=payload" json:"payload,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Encode) Reset() { *m = Encode{} } -func (m *Encode) String() string { return proto.CompactTextString(m) } -func (*Encode) ProtoMessage() {} -func (*Encode) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } - -func (m *Encode) GetType() EncodeType { - if m != nil && m.Type != nil { - return *m.Type - } - return EncodeType_TEXT -} - -func (m *Encode) GetPayload() []byte { - if m != nil { - return m.Payload + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Encode_EncodeType `protobuf:"varint,1,req,name=type,enum=nmsg.base.Encode_EncodeType" json:"type,omitempty"` + Payload []byte `protobuf:"bytes,2,req,name=payload" json:"payload,omitempty"` +} + +func (x *Encode) Reset() { + *x = Encode{} + if protoimpl.UnsafeEnabled { + mi := &file_encode_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Encode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Encode) ProtoMessage() {} + +func (x *Encode) ProtoReflect() protoreflect.Message { + mi := &file_encode_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Encode.ProtoReflect.Descriptor instead. +func (*Encode) Descriptor() ([]byte, []int) { + return file_encode_proto_rawDescGZIP(), []int{0} +} + +func (x *Encode) GetType() Encode_EncodeType { + if x != nil && x.Type != nil { + return *x.Type + } + return Encode_TEXT +} + +func (x *Encode) GetPayload() []byte { + if x != nil { + return x.Payload } return nil } -func init() { - proto.RegisterType((*Encode)(nil), "nmsg.base.Encode") - proto.RegisterEnum("nmsg.base.EncodeType", EncodeType_name, EncodeType_value) -} - -func init() { proto.RegisterFile("encode.proto", fileDescriptor3) } - -var fileDescriptor3 = []byte{ - // 148 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xcd, 0x4b, 0xce, - 0x4f, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, 0x4b, - 0x4a, 0x2c, 0x4e, 0x55, 0xb2, 0xe3, 0x62, 0x73, 0x05, 0x4b, 0x09, 0x29, 0x73, 0xb1, 0x94, 0x54, - 0x16, 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x69, 0xf0, 0x19, 0x89, 0xea, 0xc1, 0xd5, 0xe8, 0x41, 0x14, - 0x84, 0x00, 0x25, 0x85, 0xf8, 0xb9, 0xd8, 0x0b, 0x12, 0x2b, 0x73, 0xf2, 0x13, 0x53, 0x24, 0x98, - 0x80, 0xea, 0x78, 0xb4, 0x1c, 0xb8, 0xb8, 0x90, 0xa4, 0x39, 0xb8, 0x58, 0x42, 0x5c, 0x23, 0x42, - 0x04, 0x18, 0x40, 0x2c, 0xaf, 0x60, 0x7f, 0x3f, 0x01, 0x46, 0x10, 0x2b, 0xd2, 0xd1, 0xd7, 0x47, - 0x80, 0x49, 0x88, 0x9b, 0x8b, 0xdd, 0x37, 0xd8, 0x3d, 0xc0, 0xd1, 0xd9, 0x5b, 0x80, 0x59, 0x88, - 0x9d, 0x8b, 0x39, 0x02, 0x28, 0xca, 0x02, 0x08, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x9e, 0xfe, 0xff, - 0x9b, 0x00, 0x00, 0x00, -} +var File_encode_proto protoreflect.FileDescriptor + +var file_encode_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, + 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x96, 0x01, 0x0a, 0x06, 0x45, 0x6e, + 0x63, 0x6f, 0x64, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, + 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x45, + 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, + 0x64, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, + 0x22, 0x40, 0x0a, 0x0a, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, + 0x0a, 0x04, 0x54, 0x45, 0x58, 0x54, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4a, 0x53, 0x4f, 0x4e, + 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x59, 0x41, 0x4d, 0x4c, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, + 0x4d, 0x53, 0x47, 0x50, 0x41, 0x43, 0x4b, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x58, 0x4d, 0x4c, + 0x10, 0x04, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, + 0x6e, 0x6d, 0x73, 0x67, 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_encode_proto_rawDescOnce sync.Once + file_encode_proto_rawDescData = file_encode_proto_rawDesc +) + +func file_encode_proto_rawDescGZIP() []byte { + file_encode_proto_rawDescOnce.Do(func() { + file_encode_proto_rawDescData = protoimpl.X.CompressGZIP(file_encode_proto_rawDescData) + }) + return file_encode_proto_rawDescData +} + +var file_encode_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_encode_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_encode_proto_goTypes = []interface{}{ + (Encode_EncodeType)(0), // 0: nmsg.base.Encode.EncodeType + (*Encode)(nil), // 1: nmsg.base.Encode +} +var file_encode_proto_depIdxs = []int32{ + 0, // 0: nmsg.base.Encode.type:type_name -> nmsg.base.Encode.EncodeType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_encode_proto_init() } +func file_encode_proto_init() { + if File_encode_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_encode_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Encode); 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_encode_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_encode_proto_goTypes, + DependencyIndexes: file_encode_proto_depIdxs, + EnumInfos: file_encode_proto_enumTypes, + MessageInfos: file_encode_proto_msgTypes, + }.Build() + File_encode_proto = out.File + file_encode_proto_rawDesc = nil + file_encode_proto_goTypes = nil + file_encode_proto_depIdxs = nil +} diff --git a/nmsg_base/encode.proto b/nmsg_base/encode.proto index 896b04e..3c64139 100644 --- a/nmsg_base/encode.proto +++ b/nmsg_base/encode.proto @@ -1,15 +1,16 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; -enum EncodeType { - TEXT = 0; - JSON = 1; - YAML = 2; - MSGPACK = 3; - XML = 4; -} message Encode { + enum EncodeType { + TEXT = 0; + JSON = 1; + YAML = 2; + MSGPACK = 3; + XML = 4; + } required EncodeType type = 1; required bytes payload = 2; } diff --git a/nmsg_base/http.pb.go b/nmsg_base/http.pb.go index a969f90..7c2eb52 100644 --- a/nmsg_base/http.pb.go +++ b/nmsg_base/http.pb.go @@ -1,227 +1,371 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: http.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -type HttpType int32 +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) const ( - // unknown = 0; - HttpType_sinkhole HttpType = 1 -) - -var HttpType_name = map[int32]string{ - 1: "sinkhole", -} -var HttpType_value = map[string]int32{ - "sinkhole": 1, -} - -func (x HttpType) Enum() *HttpType { - p := new(HttpType) + // 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 Http_HttpType int32 + +const ( + Http_unknown Http_HttpType = 0 + Http_sinkhole Http_HttpType = 1 +) + +// Enum value maps for Http_HttpType. +var ( + Http_HttpType_name = map[int32]string{ + 0: "unknown", + 1: "sinkhole", + } + Http_HttpType_value = map[string]int32{ + "unknown": 0, + "sinkhole": 1, + } +) + +func (x Http_HttpType) Enum() *Http_HttpType { + p := new(Http_HttpType) *p = x return p } -func (x HttpType) String() string { - return proto.EnumName(HttpType_name, int32(x)) -} -func (x *HttpType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(HttpType_value, data, "HttpType") + +func (x Http_HttpType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Http_HttpType) Descriptor() protoreflect.EnumDescriptor { + return file_http_proto_enumTypes[0].Descriptor() +} + +func (Http_HttpType) Type() protoreflect.EnumType { + return &file_http_proto_enumTypes[0] +} + +func (x Http_HttpType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Http_HttpType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = HttpType(value) - return nil -} -func (HttpType) EnumDescriptor() ([]byte, []int) { return fileDescriptor4, []int{0} } + *x = Http_HttpType(num) + return nil +} + +// Deprecated: Use Http_HttpType.Descriptor instead. +func (Http_HttpType) EnumDescriptor() ([]byte, []int) { + return file_http_proto_rawDescGZIP(), []int{0, 0} +} type Http struct { - Type *HttpType `protobuf:"varint,1,req,name=type,enum=nmsg.base.HttpType" json:"type,omitempty"` - Srcip []byte `protobuf:"bytes,2,opt,name=srcip" json:"srcip,omitempty"` - Srchost []byte `protobuf:"bytes,3,opt,name=srchost" json:"srchost,omitempty"` - Srcport *uint32 `protobuf:"varint,4,opt,name=srcport" json:"srcport,omitempty"` - Dstip []byte `protobuf:"bytes,5,opt,name=dstip" json:"dstip,omitempty"` - Dstport *uint32 `protobuf:"varint,6,opt,name=dstport" json:"dstport,omitempty"` - Request []byte `protobuf:"bytes,7,opt,name=request" json:"request,omitempty"` - P0FGenre []byte `protobuf:"bytes,65,opt,name=p0f_genre" json:"p0f_genre,omitempty"` - P0FDetail []byte `protobuf:"bytes,66,opt,name=p0f_detail" json:"p0f_detail,omitempty"` - P0FDist *int32 `protobuf:"varint,67,opt,name=p0f_dist" json:"p0f_dist,omitempty"` - P0FLink []byte `protobuf:"bytes,68,opt,name=p0f_link" json:"p0f_link,omitempty"` - P0FTos []byte `protobuf:"bytes,69,opt,name=p0f_tos" json:"p0f_tos,omitempty"` - P0FFw *uint32 `protobuf:"varint,70,opt,name=p0f_fw" json:"p0f_fw,omitempty"` - P0FNat *uint32 `protobuf:"varint,71,opt,name=p0f_nat" json:"p0f_nat,omitempty"` - P0FReal *uint32 `protobuf:"varint,72,opt,name=p0f_real" json:"p0f_real,omitempty"` - P0FScore *int32 `protobuf:"varint,73,opt,name=p0f_score" json:"p0f_score,omitempty"` - P0FMflags *uint32 `protobuf:"varint,74,opt,name=p0f_mflags" json:"p0f_mflags,omitempty"` - P0FUptime *int32 `protobuf:"varint,75,opt,name=p0f_uptime" json:"p0f_uptime,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Http) Reset() { *m = Http{} } -func (m *Http) String() string { return proto.CompactTextString(m) } -func (*Http) ProtoMessage() {} -func (*Http) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{0} } - -func (m *Http) GetType() HttpType { - if m != nil && m.Type != nil { - return *m.Type - } - return HttpType_sinkhole -} - -func (m *Http) GetSrcip() []byte { - if m != nil { - return m.Srcip - } - return nil -} - -func (m *Http) GetSrchost() []byte { - if m != nil { - return m.Srchost - } - return nil -} - -func (m *Http) GetSrcport() uint32 { - if m != nil && m.Srcport != nil { - return *m.Srcport - } - return 0 -} - -func (m *Http) GetDstip() []byte { - if m != nil { - return m.Dstip - } - return nil -} - -func (m *Http) GetDstport() uint32 { - if m != nil && m.Dstport != nil { - return *m.Dstport - } - return 0 -} - -func (m *Http) GetRequest() []byte { - if m != nil { - return m.Request - } - return nil -} - -func (m *Http) GetP0FGenre() []byte { - if m != nil { - return m.P0FGenre - } - return nil -} - -func (m *Http) GetP0FDetail() []byte { - if m != nil { - return m.P0FDetail - } - return nil -} - -func (m *Http) GetP0FDist() int32 { - if m != nil && m.P0FDist != nil { - return *m.P0FDist - } - return 0 -} - -func (m *Http) GetP0FLink() []byte { - if m != nil { - return m.P0FLink - } - return nil -} - -func (m *Http) GetP0FTos() []byte { - if m != nil { - return m.P0FTos - } - return nil -} - -func (m *Http) GetP0FFw() uint32 { - if m != nil && m.P0FFw != nil { - return *m.P0FFw - } - return 0 -} - -func (m *Http) GetP0FNat() uint32 { - if m != nil && m.P0FNat != nil { - return *m.P0FNat - } - return 0 -} - -func (m *Http) GetP0FReal() uint32 { - if m != nil && m.P0FReal != nil { - return *m.P0FReal - } - return 0 -} - -func (m *Http) GetP0FScore() int32 { - if m != nil && m.P0FScore != nil { - return *m.P0FScore - } - return 0 -} - -func (m *Http) GetP0FMflags() uint32 { - if m != nil && m.P0FMflags != nil { - return *m.P0FMflags - } - return 0 -} - -func (m *Http) GetP0FUptime() int32 { - if m != nil && m.P0FUptime != nil { - return *m.P0FUptime - } - return 0 -} - -func init() { - proto.RegisterType((*Http)(nil), "nmsg.base.Http") - proto.RegisterEnum("nmsg.base.HttpType", HttpType_name, HttpType_value) -} - -func init() { proto.RegisterFile("http.proto", fileDescriptor4) } - -var fileDescriptor4 = []byte{ - // 268 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x4c, 0xd0, 0x4d, 0x4f, 0xf3, 0x30, - 0x0c, 0x07, 0x70, 0xb5, 0x4f, 0xbb, 0x75, 0xd6, 0xb6, 0x67, 0x94, 0x8b, 0x8f, 0x83, 0xd3, 0xc4, - 0xa1, 0x42, 0x7c, 0x03, 0xde, 0x07, 0x5c, 0xb9, 0xa3, 0xb2, 0xa5, 0x2f, 0x22, 0x6d, 0x42, 0xe2, - 0x09, 0xf1, 0x41, 0xf9, 0x3e, 0x38, 0x56, 0x3b, 0x71, 0xf4, 0xef, 0x6f, 0xc7, 0x56, 0x00, 0x1a, - 0x22, 0x5b, 0x58, 0x67, 0xc8, 0xe4, 0xb3, 0xbe, 0xf3, 0x75, 0xf1, 0x5e, 0x7a, 0x75, 0xfe, 0x13, - 0x43, 0xb2, 0xe5, 0x24, 0x3f, 0x83, 0x84, 0xbe, 0xad, 0xc2, 0x68, 0x1d, 0x6f, 0x96, 0x57, 0xa7, - 0xc5, 0xb1, 0xa5, 0x08, 0xf1, 0x2b, 0x47, 0xf9, 0x02, 0x52, 0xef, 0x76, 0xad, 0xc5, 0x78, 0x1d, - 0x6d, 0xe6, 0xf9, 0x7f, 0x98, 0x72, 0xd9, 0x18, 0x4f, 0xf8, 0xef, 0x0f, 0x58, 0xe3, 0x08, 0x13, - 0x86, 0x45, 0x18, 0xd8, 0x7b, 0xe2, 0x81, 0x74, 0xcc, 0xb9, 0x94, 0x7c, 0x22, 0x39, 0x83, 0x53, - 0x9f, 0x07, 0xc5, 0x2f, 0x4c, 0xa5, 0xe3, 0x04, 0x66, 0xf6, 0xb2, 0x7a, 0xab, 0x55, 0xef, 0x14, - 0x5e, 0x0b, 0xe5, 0x00, 0x81, 0xf6, 0x8a, 0xca, 0x56, 0xe3, 0x8d, 0xd8, 0x0a, 0x32, 0xb1, 0x96, - 0x07, 0x6f, 0x59, 0xd2, 0x51, 0x74, 0xdb, 0x7f, 0xe0, 0xdd, 0xb8, 0x2c, 0x08, 0x19, 0x8f, 0xf7, - 0x02, 0x4b, 0x98, 0x04, 0xa8, 0xbe, 0xf0, 0x61, 0x5c, 0x1e, 0xea, 0xbe, 0x24, 0x7c, 0x14, 0x18, - 0xde, 0x70, 0xaa, 0xd4, 0xb8, 0x15, 0x19, 0xce, 0xf1, 0x3b, 0xc3, 0xe7, 0x3c, 0xc9, 0xa2, 0xe1, - 0x9c, 0xae, 0xd2, 0x65, 0xed, 0xf1, 0x59, 0xda, 0x06, 0x3b, 0x58, 0x6a, 0x3b, 0x85, 0x2f, 0xa1, - 0xef, 0x02, 0x21, 0x3b, 0xfe, 0xdb, 0x1c, 0x32, 0xcf, 0x87, 0x35, 0x46, 0xab, 0x55, 0xf4, 0x1b, - 0x00, 0x00, 0xff, 0xff, 0xa3, 0x64, 0x11, 0x56, 0x89, 0x01, 0x00, 0x00, -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Http_HttpType `protobuf:"varint,1,req,name=type,enum=nmsg.base.Http_HttpType" json:"type,omitempty"` + Srcip []byte `protobuf:"bytes,2,opt,name=srcip" json:"srcip,omitempty"` + Srchost []byte `protobuf:"bytes,3,opt,name=srchost" json:"srchost,omitempty"` + Srcport *uint32 `protobuf:"varint,4,opt,name=srcport" json:"srcport,omitempty"` + Dstip []byte `protobuf:"bytes,5,opt,name=dstip" json:"dstip,omitempty"` + Dstport *uint32 `protobuf:"varint,6,opt,name=dstport" json:"dstport,omitempty"` + Request []byte `protobuf:"bytes,7,opt,name=request" json:"request,omitempty"` + P0FGenre []byte `protobuf:"bytes,65,opt,name=p0f_genre,json=p0fGenre" json:"p0f_genre,omitempty"` + P0FDetail []byte `protobuf:"bytes,66,opt,name=p0f_detail,json=p0fDetail" json:"p0f_detail,omitempty"` + P0FDist *int32 `protobuf:"varint,67,opt,name=p0f_dist,json=p0fDist" json:"p0f_dist,omitempty"` + P0FLink []byte `protobuf:"bytes,68,opt,name=p0f_link,json=p0fLink" json:"p0f_link,omitempty"` + P0FTos []byte `protobuf:"bytes,69,opt,name=p0f_tos,json=p0fTos" json:"p0f_tos,omitempty"` + P0FFw *uint32 `protobuf:"varint,70,opt,name=p0f_fw,json=p0fFw" json:"p0f_fw,omitempty"` + P0FNat *uint32 `protobuf:"varint,71,opt,name=p0f_nat,json=p0fNat" json:"p0f_nat,omitempty"` + P0FReal *uint32 `protobuf:"varint,72,opt,name=p0f_real,json=p0fReal" json:"p0f_real,omitempty"` + P0FScore *int32 `protobuf:"varint,73,opt,name=p0f_score,json=p0fScore" json:"p0f_score,omitempty"` + P0FMflags *uint32 `protobuf:"varint,74,opt,name=p0f_mflags,json=p0fMflags" json:"p0f_mflags,omitempty"` + P0FUptime *int32 `protobuf:"varint,75,opt,name=p0f_uptime,json=p0fUptime" json:"p0f_uptime,omitempty"` +} + +func (x *Http) Reset() { + *x = Http{} + if protoimpl.UnsafeEnabled { + mi := &file_http_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Http) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Http) ProtoMessage() {} + +func (x *Http) ProtoReflect() protoreflect.Message { + mi := &file_http_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Http.ProtoReflect.Descriptor instead. +func (*Http) Descriptor() ([]byte, []int) { + return file_http_proto_rawDescGZIP(), []int{0} +} + +func (x *Http) GetType() Http_HttpType { + if x != nil && x.Type != nil { + return *x.Type + } + return Http_unknown +} + +func (x *Http) GetSrcip() []byte { + if x != nil { + return x.Srcip + } + return nil +} + +func (x *Http) GetSrchost() []byte { + if x != nil { + return x.Srchost + } + return nil +} + +func (x *Http) GetSrcport() uint32 { + if x != nil && x.Srcport != nil { + return *x.Srcport + } + return 0 +} + +func (x *Http) GetDstip() []byte { + if x != nil { + return x.Dstip + } + return nil +} + +func (x *Http) GetDstport() uint32 { + if x != nil && x.Dstport != nil { + return *x.Dstport + } + return 0 +} + +func (x *Http) GetRequest() []byte { + if x != nil { + return x.Request + } + return nil +} + +func (x *Http) GetP0FGenre() []byte { + if x != nil { + return x.P0FGenre + } + return nil +} + +func (x *Http) GetP0FDetail() []byte { + if x != nil { + return x.P0FDetail + } + return nil +} + +func (x *Http) GetP0FDist() int32 { + if x != nil && x.P0FDist != nil { + return *x.P0FDist + } + return 0 +} + +func (x *Http) GetP0FLink() []byte { + if x != nil { + return x.P0FLink + } + return nil +} + +func (x *Http) GetP0FTos() []byte { + if x != nil { + return x.P0FTos + } + return nil +} + +func (x *Http) GetP0FFw() uint32 { + if x != nil && x.P0FFw != nil { + return *x.P0FFw + } + return 0 +} + +func (x *Http) GetP0FNat() uint32 { + if x != nil && x.P0FNat != nil { + return *x.P0FNat + } + return 0 +} + +func (x *Http) GetP0FReal() uint32 { + if x != nil && x.P0FReal != nil { + return *x.P0FReal + } + return 0 +} + +func (x *Http) GetP0FScore() int32 { + if x != nil && x.P0FScore != nil { + return *x.P0FScore + } + return 0 +} + +func (x *Http) GetP0FMflags() uint32 { + if x != nil && x.P0FMflags != nil { + return *x.P0FMflags + } + return 0 +} + +func (x *Http) GetP0FUptime() int32 { + if x != nil && x.P0FUptime != nil { + return *x.P0FUptime + } + return 0 +} + +var File_http_proto protoreflect.FileDescriptor + +var file_http_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, 0x6d, + 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xa0, 0x04, 0x0a, 0x04, 0x48, 0x74, 0x74, 0x70, + 0x12, 0x2c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x18, + 0x2e, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x2e, + 0x48, 0x74, 0x74, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x73, 0x72, 0x63, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, + 0x72, 0x63, 0x69, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x72, 0x63, 0x68, 0x6f, 0x73, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x73, 0x72, 0x63, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x18, + 0x0a, 0x07, 0x73, 0x72, 0x63, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x07, 0x73, 0x72, 0x63, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x73, 0x74, 0x69, + 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x64, 0x73, 0x74, 0x69, 0x70, 0x12, 0x18, + 0x0a, 0x07, 0x64, 0x73, 0x74, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x07, 0x64, 0x73, 0x74, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x30, 0x66, 0x5f, 0x67, 0x65, 0x6e, 0x72, 0x65, 0x18, + 0x41, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x70, 0x30, 0x66, 0x47, 0x65, 0x6e, 0x72, 0x65, 0x12, + 0x1d, 0x0a, 0x0a, 0x70, 0x30, 0x66, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x42, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x09, 0x70, 0x30, 0x66, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x19, + 0x0a, 0x08, 0x70, 0x30, 0x66, 0x5f, 0x64, 0x69, 0x73, 0x74, 0x18, 0x43, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x07, 0x70, 0x30, 0x66, 0x44, 0x69, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x30, 0x66, + 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x44, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x30, 0x66, + 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x30, 0x66, 0x5f, 0x74, 0x6f, 0x73, 0x18, + 0x45, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x30, 0x66, 0x54, 0x6f, 0x73, 0x12, 0x15, 0x0a, + 0x06, 0x70, 0x30, 0x66, 0x5f, 0x66, 0x77, 0x18, 0x46, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x70, + 0x30, 0x66, 0x46, 0x77, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x30, 0x66, 0x5f, 0x6e, 0x61, 0x74, 0x18, + 0x47, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x70, 0x30, 0x66, 0x4e, 0x61, 0x74, 0x12, 0x19, 0x0a, + 0x08, 0x70, 0x30, 0x66, 0x5f, 0x72, 0x65, 0x61, 0x6c, 0x18, 0x48, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x07, 0x70, 0x30, 0x66, 0x52, 0x65, 0x61, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x30, 0x66, 0x5f, + 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x49, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x30, 0x66, + 0x53, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x30, 0x66, 0x5f, 0x6d, 0x66, 0x6c, + 0x61, 0x67, 0x73, 0x18, 0x4a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x70, 0x30, 0x66, 0x4d, 0x66, + 0x6c, 0x61, 0x67, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x30, 0x66, 0x5f, 0x75, 0x70, 0x74, 0x69, + 0x6d, 0x65, 0x18, 0x4b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x30, 0x66, 0x55, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x22, 0x25, 0x0a, 0x08, 0x48, 0x74, 0x74, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x0b, 0x0a, 0x07, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, + 0x73, 0x69, 0x6e, 0x6b, 0x68, 0x6f, 0x6c, 0x65, 0x10, 0x01, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, + 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, 0x2f, 0x6e, 0x6d, 0x73, + 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_http_proto_rawDescOnce sync.Once + file_http_proto_rawDescData = file_http_proto_rawDesc +) + +func file_http_proto_rawDescGZIP() []byte { + file_http_proto_rawDescOnce.Do(func() { + file_http_proto_rawDescData = protoimpl.X.CompressGZIP(file_http_proto_rawDescData) + }) + return file_http_proto_rawDescData +} + +var file_http_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_http_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_http_proto_goTypes = []interface{}{ + (Http_HttpType)(0), // 0: nmsg.base.Http.HttpType + (*Http)(nil), // 1: nmsg.base.Http +} +var file_http_proto_depIdxs = []int32{ + 0, // 0: nmsg.base.Http.type:type_name -> nmsg.base.Http.HttpType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_http_proto_init() } +func file_http_proto_init() { + if File_http_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_http_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Http); 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_http_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_http_proto_goTypes, + DependencyIndexes: file_http_proto_depIdxs, + EnumInfos: file_http_proto_enumTypes, + MessageInfos: file_http_proto_msgTypes, + }.Build() + File_http_proto = out.File + file_http_proto_rawDesc = nil + file_http_proto_goTypes = nil + file_http_proto_depIdxs = nil +} diff --git a/nmsg_base/http.proto b/nmsg_base/http.proto index 4c35c15..0f1dc19 100644 --- a/nmsg_base/http.proto +++ b/nmsg_base/http.proto @@ -1,12 +1,13 @@ syntax = "proto2"; package nmsg.base; - -enum HttpType { - // unknown = 0; - sinkhole = 1; -} +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message Http { + enum HttpType { + unknown = 0; + sinkhole = 1; + } + required HttpType type = 1; optional bytes srcip = 2; optional bytes srchost = 3; diff --git a/nmsg_base/ipconn.pb.go b/nmsg_base/ipconn.pb.go index 33cfa1c..3d395ae 100644 --- a/nmsg_base/ipconn.pb.go +++ b/nmsg_base/ipconn.pb.go @@ -1,80 +1,181 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: ipconn.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + 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 +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 IPConn struct { - Proto *uint32 `protobuf:"varint,1,opt,name=proto" json:"proto,omitempty"` - Srcip []byte `protobuf:"bytes,2,opt,name=srcip" json:"srcip,omitempty"` - Srcport *uint32 `protobuf:"varint,3,opt,name=srcport" json:"srcport,omitempty"` - Dstip []byte `protobuf:"bytes,4,opt,name=dstip" json:"dstip,omitempty"` - Dstport *uint32 `protobuf:"varint,5,opt,name=dstport" json:"dstport,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Proto *uint32 `protobuf:"varint,1,opt,name=proto" json:"proto,omitempty"` + Srcip []byte `protobuf:"bytes,2,opt,name=srcip" json:"srcip,omitempty"` + Srcport *uint32 `protobuf:"varint,3,opt,name=srcport" json:"srcport,omitempty"` + Dstip []byte `protobuf:"bytes,4,opt,name=dstip" json:"dstip,omitempty"` + Dstport *uint32 `protobuf:"varint,5,opt,name=dstport" json:"dstport,omitempty"` } -func (m *IPConn) Reset() { *m = IPConn{} } -func (m *IPConn) String() string { return proto.CompactTextString(m) } -func (*IPConn) ProtoMessage() {} -func (*IPConn) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} } +func (x *IPConn) Reset() { + *x = IPConn{} + if protoimpl.UnsafeEnabled { + mi := &file_ipconn_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func (m *IPConn) GetProto() uint32 { - if m != nil && m.Proto != nil { - return *m.Proto +func (x *IPConn) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IPConn) ProtoMessage() {} + +func (x *IPConn) ProtoReflect() protoreflect.Message { + mi := &file_ipconn_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IPConn.ProtoReflect.Descriptor instead. +func (*IPConn) Descriptor() ([]byte, []int) { + return file_ipconn_proto_rawDescGZIP(), []int{0} +} + +func (x *IPConn) GetProto() uint32 { + if x != nil && x.Proto != nil { + return *x.Proto } return 0 } -func (m *IPConn) GetSrcip() []byte { - if m != nil { - return m.Srcip +func (x *IPConn) GetSrcip() []byte { + if x != nil { + return x.Srcip } return nil } -func (m *IPConn) GetSrcport() uint32 { - if m != nil && m.Srcport != nil { - return *m.Srcport +func (x *IPConn) GetSrcport() uint32 { + if x != nil && x.Srcport != nil { + return *x.Srcport } return 0 } -func (m *IPConn) GetDstip() []byte { - if m != nil { - return m.Dstip +func (x *IPConn) GetDstip() []byte { + if x != nil { + return x.Dstip } return nil } -func (m *IPConn) GetDstport() uint32 { - if m != nil && m.Dstport != nil { - return *m.Dstport +func (x *IPConn) GetDstport() uint32 { + if x != nil && x.Dstport != nil { + return *x.Dstport } return 0 } -func init() { - proto.RegisterType((*IPConn)(nil), "nmsg.base.IPConn") +var File_ipconn_proto protoreflect.FileDescriptor + +var file_ipconn_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x69, 0x70, 0x63, 0x6f, 0x6e, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, + 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x7e, 0x0a, 0x06, 0x49, 0x50, 0x43, + 0x6f, 0x6e, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x72, 0x63, + 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x72, 0x63, 0x69, 0x70, 0x12, + 0x18, 0x0a, 0x07, 0x73, 0x72, 0x63, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x07, 0x73, 0x72, 0x63, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x73, 0x74, + 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x64, 0x73, 0x74, 0x69, 0x70, 0x12, + 0x18, 0x0a, 0x07, 0x64, 0x73, 0x74, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x07, 0x64, 0x73, 0x74, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, 0x74, + 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, 0x2f, 0x6e, 0x6d, 0x73, 0x67, + 0x5f, 0x62, 0x61, 0x73, 0x65, } -func init() { proto.RegisterFile("ipconn.proto", fileDescriptor5) } +var ( + file_ipconn_proto_rawDescOnce sync.Once + file_ipconn_proto_rawDescData = file_ipconn_proto_rawDesc +) -var fileDescriptor5 = []byte{ - // 109 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xc9, 0x2c, 0x48, 0xce, - 0xcf, 0xcb, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, 0x4b, - 0x4a, 0x2c, 0x4e, 0x55, 0x0a, 0xe7, 0x62, 0xf3, 0x0c, 0x70, 0x06, 0x4a, 0x09, 0xf1, 0x72, 0xb1, - 0x82, 0x65, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x41, 0xdc, 0xe2, 0xa2, 0xe4, 0xcc, 0x02, 0x09, - 0x26, 0x20, 0x97, 0x47, 0x88, 0x9f, 0x8b, 0x1d, 0xc8, 0x2d, 0xc8, 0x2f, 0x2a, 0x91, 0x60, 0x86, - 0xc9, 0xa7, 0x14, 0x97, 0x00, 0xe5, 0x59, 0x60, 0xf2, 0x40, 0x2e, 0x58, 0x9e, 0x15, 0x24, 0x0f, - 0x08, 0x00, 0x00, 0xff, 0xff, 0x83, 0x37, 0xd2, 0x7d, 0x72, 0x00, 0x00, 0x00, +func file_ipconn_proto_rawDescGZIP() []byte { + file_ipconn_proto_rawDescOnce.Do(func() { + file_ipconn_proto_rawDescData = protoimpl.X.CompressGZIP(file_ipconn_proto_rawDescData) + }) + return file_ipconn_proto_rawDescData } + +var file_ipconn_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_ipconn_proto_goTypes = []interface{}{ + (*IPConn)(nil), // 0: nmsg.base.IPConn +} +var file_ipconn_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_ipconn_proto_init() } +func file_ipconn_proto_init() { + if File_ipconn_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_ipconn_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IPConn); 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_ipconn_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_ipconn_proto_goTypes, + DependencyIndexes: file_ipconn_proto_depIdxs, + MessageInfos: file_ipconn_proto_msgTypes, + }.Build() + File_ipconn_proto = out.File + file_ipconn_proto_rawDesc = nil + file_ipconn_proto_goTypes = nil + file_ipconn_proto_depIdxs = nil +} diff --git a/nmsg_base/ipconn.proto b/nmsg_base/ipconn.proto index 9dd11ff..45aa9b5 100644 --- a/nmsg_base/ipconn.proto +++ b/nmsg_base/ipconn.proto @@ -1,5 +1,6 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message IPConn { optional uint32 proto = 1; diff --git a/nmsg_base/linkpair.pb.go b/nmsg_base/linkpair.pb.go index ceb8b0e..1bfe81e 100644 --- a/nmsg_base/linkpair.pb.go +++ b/nmsg_base/linkpair.pb.go @@ -1,110 +1,235 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: linkpair.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -type Linktype int32 +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) const ( - Linktype_anchor Linktype = 0 - Linktype_redirect Linktype = 1 -) - -var Linktype_name = map[int32]string{ - 0: "anchor", - 1: "redirect", -} -var Linktype_value = map[string]int32{ - "anchor": 0, - "redirect": 1, -} - -func (x Linktype) Enum() *Linktype { - p := new(Linktype) + // 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 Linkpair_Linktype int32 + +const ( + Linkpair_anchor Linkpair_Linktype = 0 + Linkpair_redirect Linkpair_Linktype = 1 +) + +// Enum value maps for Linkpair_Linktype. +var ( + Linkpair_Linktype_name = map[int32]string{ + 0: "anchor", + 1: "redirect", + } + Linkpair_Linktype_value = map[string]int32{ + "anchor": 0, + "redirect": 1, + } +) + +func (x Linkpair_Linktype) Enum() *Linkpair_Linktype { + p := new(Linkpair_Linktype) *p = x return p } -func (x Linktype) String() string { - return proto.EnumName(Linktype_name, int32(x)) -} -func (x *Linktype) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(Linktype_value, data, "Linktype") + +func (x Linkpair_Linktype) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Linkpair_Linktype) Descriptor() protoreflect.EnumDescriptor { + return file_linkpair_proto_enumTypes[0].Descriptor() +} + +func (Linkpair_Linktype) Type() protoreflect.EnumType { + return &file_linkpair_proto_enumTypes[0] +} + +func (x Linkpair_Linktype) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Linkpair_Linktype) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = Linktype(value) - return nil -} -func (Linktype) EnumDescriptor() ([]byte, []int) { return fileDescriptor6, []int{0} } + *x = Linkpair_Linktype(num) + return nil +} + +// Deprecated: Use Linkpair_Linktype.Descriptor instead. +func (Linkpair_Linktype) EnumDescriptor() ([]byte, []int) { + return file_linkpair_proto_rawDescGZIP(), []int{0, 0} +} type Linkpair struct { - Type *Linktype `protobuf:"varint,1,req,name=type,enum=nmsg.base.Linktype" json:"type,omitempty"` - Src []byte `protobuf:"bytes,2,req,name=src" json:"src,omitempty"` - Dst []byte `protobuf:"bytes,3,req,name=dst" json:"dst,omitempty"` - Headers []byte `protobuf:"bytes,5,opt,name=headers" json:"headers,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Linkpair) Reset() { *m = Linkpair{} } -func (m *Linkpair) String() string { return proto.CompactTextString(m) } -func (*Linkpair) ProtoMessage() {} -func (*Linkpair) Descriptor() ([]byte, []int) { return fileDescriptor6, []int{0} } - -func (m *Linkpair) GetType() Linktype { - if m != nil && m.Type != nil { - return *m.Type - } - return Linktype_anchor -} - -func (m *Linkpair) GetSrc() []byte { - if m != nil { - return m.Src - } - return nil -} - -func (m *Linkpair) GetDst() []byte { - if m != nil { - return m.Dst - } - return nil -} - -func (m *Linkpair) GetHeaders() []byte { - if m != nil { - return m.Headers - } - return nil -} - -func init() { - proto.RegisterType((*Linkpair)(nil), "nmsg.base.Linkpair") - proto.RegisterEnum("nmsg.base.Linktype", Linktype_name, Linktype_value) -} - -func init() { proto.RegisterFile("linkpair.proto", fileDescriptor6) } - -var fileDescriptor6 = []byte{ - // 149 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0xc9, 0xcc, 0xcb, - 0x2e, 0x48, 0xcc, 0x2c, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, - 0xd7, 0x4b, 0x4a, 0x2c, 0x4e, 0x55, 0x8a, 0xe0, 0xe2, 0xf0, 0x81, 0x4a, 0x0a, 0x29, 0x72, 0xb1, - 0x94, 0x54, 0x16, 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x69, 0xf0, 0x19, 0x09, 0xeb, 0xc1, 0x55, 0xe9, - 0x81, 0x94, 0x80, 0xa4, 0x84, 0xb8, 0xb9, 0x98, 0x8b, 0x8b, 0x92, 0x25, 0x98, 0x80, 0x2a, 0x78, - 0x40, 0x9c, 0x94, 0xe2, 0x12, 0x09, 0x66, 0x30, 0x87, 0x9f, 0x8b, 0x3d, 0x23, 0x35, 0x31, 0x25, - 0xb5, 0xa8, 0x58, 0x82, 0x55, 0x81, 0x51, 0x83, 0x47, 0x4b, 0x05, 0x62, 0x32, 0x58, 0x1b, 0x17, - 0x17, 0x5b, 0x62, 0x5e, 0x72, 0x46, 0x7e, 0x91, 0x00, 0x83, 0x10, 0x0f, 0x17, 0x47, 0x51, 0x6a, - 0x4a, 0x66, 0x51, 0x6a, 0x72, 0x89, 0x00, 0x23, 0x20, 0x00, 0x00, 0xff, 0xff, 0x64, 0x13, 0x33, - 0xdf, 0x9b, 0x00, 0x00, 0x00, -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Linkpair_Linktype `protobuf:"varint,1,req,name=type,enum=nmsg.base.Linkpair_Linktype" json:"type,omitempty"` + Src []byte `protobuf:"bytes,2,req,name=src" json:"src,omitempty"` + Dst []byte `protobuf:"bytes,3,req,name=dst" json:"dst,omitempty"` + Headers []byte `protobuf:"bytes,5,opt,name=headers" json:"headers,omitempty"` +} + +func (x *Linkpair) Reset() { + *x = Linkpair{} + if protoimpl.UnsafeEnabled { + mi := &file_linkpair_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Linkpair) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Linkpair) ProtoMessage() {} + +func (x *Linkpair) ProtoReflect() protoreflect.Message { + mi := &file_linkpair_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Linkpair.ProtoReflect.Descriptor instead. +func (*Linkpair) Descriptor() ([]byte, []int) { + return file_linkpair_proto_rawDescGZIP(), []int{0} +} + +func (x *Linkpair) GetType() Linkpair_Linktype { + if x != nil && x.Type != nil { + return *x.Type + } + return Linkpair_anchor +} + +func (x *Linkpair) GetSrc() []byte { + if x != nil { + return x.Src + } + return nil +} + +func (x *Linkpair) GetDst() []byte { + if x != nil { + return x.Dst + } + return nil +} + +func (x *Linkpair) GetHeaders() []byte { + if x != nil { + return x.Headers + } + return nil +} + +var File_linkpair_proto protoreflect.FileDescriptor + +var file_linkpair_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x6c, 0x69, 0x6e, 0x6b, 0x70, 0x61, 0x69, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x09, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xa0, 0x01, 0x0a, 0x08, + 0x4c, 0x69, 0x6e, 0x6b, 0x70, 0x61, 0x69, 0x72, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, + 0x73, 0x65, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, 0x70, 0x61, 0x69, 0x72, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, + 0x74, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x72, + 0x63, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x03, 0x73, 0x72, 0x63, 0x12, 0x10, 0x0a, 0x03, + 0x64, 0x73, 0x74, 0x18, 0x03, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x03, 0x64, 0x73, 0x74, 0x12, 0x18, + 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0x24, 0x0a, 0x08, 0x4c, 0x69, 0x6e, 0x6b, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x61, 0x6e, 0x63, 0x68, 0x6f, 0x72, 0x10, 0x00, + 0x12, 0x0c, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x01, 0x42, 0x2a, + 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, + 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, + 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_linkpair_proto_rawDescOnce sync.Once + file_linkpair_proto_rawDescData = file_linkpair_proto_rawDesc +) + +func file_linkpair_proto_rawDescGZIP() []byte { + file_linkpair_proto_rawDescOnce.Do(func() { + file_linkpair_proto_rawDescData = protoimpl.X.CompressGZIP(file_linkpair_proto_rawDescData) + }) + return file_linkpair_proto_rawDescData +} + +var file_linkpair_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_linkpair_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_linkpair_proto_goTypes = []interface{}{ + (Linkpair_Linktype)(0), // 0: nmsg.base.Linkpair.Linktype + (*Linkpair)(nil), // 1: nmsg.base.Linkpair +} +var file_linkpair_proto_depIdxs = []int32{ + 0, // 0: nmsg.base.Linkpair.type:type_name -> nmsg.base.Linkpair.Linktype + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_linkpair_proto_init() } +func file_linkpair_proto_init() { + if File_linkpair_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_linkpair_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Linkpair); 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_linkpair_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_linkpair_proto_goTypes, + DependencyIndexes: file_linkpair_proto_depIdxs, + EnumInfos: file_linkpair_proto_enumTypes, + MessageInfos: file_linkpair_proto_msgTypes, + }.Build() + File_linkpair_proto = out.File + file_linkpair_proto_rawDesc = nil + file_linkpair_proto_goTypes = nil + file_linkpair_proto_depIdxs = nil +} diff --git a/nmsg_base/linkpair.proto b/nmsg_base/linkpair.proto index 04f10a8..7efa6ba 100644 --- a/nmsg_base/linkpair.proto +++ b/nmsg_base/linkpair.proto @@ -1,12 +1,13 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; -enum Linktype { - anchor = 0; - redirect = 1; -} message Linkpair { + enum Linktype { + anchor = 0; + redirect = 1; + } required Linktype type = 1; required bytes src = 2; required bytes dst = 3; diff --git a/nmsg_base/logline.pb.go b/nmsg_base/logline.pb.go index aac48be..536abc9 100644 --- a/nmsg_base/logline.pb.go +++ b/nmsg_base/logline.pb.go @@ -1,55 +1,153 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: logline.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + 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 +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 LogLine struct { - Category []byte `protobuf:"bytes,1,opt,name=category" json:"category,omitempty"` - Message []byte `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Category []byte `protobuf:"bytes,1,opt,name=category" json:"category,omitempty"` + Message []byte `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } -func (m *LogLine) Reset() { *m = LogLine{} } -func (m *LogLine) String() string { return proto.CompactTextString(m) } -func (*LogLine) ProtoMessage() {} -func (*LogLine) Descriptor() ([]byte, []int) { return fileDescriptor7, []int{0} } +func (x *LogLine) Reset() { + *x = LogLine{} + if protoimpl.UnsafeEnabled { + mi := &file_logline_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func (m *LogLine) GetCategory() []byte { - if m != nil { - return m.Category +func (x *LogLine) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogLine) ProtoMessage() {} + +func (x *LogLine) ProtoReflect() protoreflect.Message { + mi := &file_logline_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogLine.ProtoReflect.Descriptor instead. +func (*LogLine) Descriptor() ([]byte, []int) { + return file_logline_proto_rawDescGZIP(), []int{0} +} + +func (x *LogLine) GetCategory() []byte { + if x != nil { + return x.Category } return nil } -func (m *LogLine) GetMessage() []byte { - if m != nil { - return m.Message +func (x *LogLine) GetMessage() []byte { + if x != nil { + return x.Message } return nil } -func init() { - proto.RegisterType((*LogLine)(nil), "nmsg.base.LogLine") +var File_logline_proto protoreflect.FileDescriptor + +var file_logline_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x6c, 0x6f, 0x67, 0x6c, 0x69, 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x09, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x07, 0x4c, 0x6f, + 0x67, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x2a, 0x5a, 0x28, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, + 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, 0x2f, 0x6e, 0x6d, + 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, } -func init() { proto.RegisterFile("logline.proto", fileDescriptor7) } +var ( + file_logline_proto_rawDescOnce sync.Once + file_logline_proto_rawDescData = file_logline_proto_rawDesc +) -var fileDescriptor7 = []byte{ - // 93 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xcd, 0xc9, 0x4f, 0xcf, - 0xc9, 0xcc, 0x4b, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, - 0x4b, 0x4a, 0x2c, 0x4e, 0x55, 0xd2, 0xe1, 0x62, 0xf7, 0xc9, 0x4f, 0xf7, 0x01, 0xca, 0x09, 0x09, - 0x70, 0x71, 0x24, 0x27, 0x96, 0xa4, 0xa6, 0xe7, 0x17, 0x55, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, - 0x08, 0xf1, 0x73, 0xb1, 0xe7, 0xa6, 0x16, 0x17, 0x27, 0xa6, 0xa7, 0x4a, 0x30, 0x81, 0x04, 0x00, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x6e, 0x4e, 0xe7, 0x48, 0x48, 0x00, 0x00, 0x00, +func file_logline_proto_rawDescGZIP() []byte { + file_logline_proto_rawDescOnce.Do(func() { + file_logline_proto_rawDescData = protoimpl.X.CompressGZIP(file_logline_proto_rawDescData) + }) + return file_logline_proto_rawDescData } + +var file_logline_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_logline_proto_goTypes = []interface{}{ + (*LogLine)(nil), // 0: nmsg.base.LogLine +} +var file_logline_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_logline_proto_init() } +func file_logline_proto_init() { + if File_logline_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_logline_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LogLine); 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_logline_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_logline_proto_goTypes, + DependencyIndexes: file_logline_proto_depIdxs, + MessageInfos: file_logline_proto_msgTypes, + }.Build() + File_logline_proto = out.File + file_logline_proto_rawDesc = nil + file_logline_proto_goTypes = nil + file_logline_proto_depIdxs = nil +} diff --git a/nmsg_base/logline.proto b/nmsg_base/logline.proto index 0328413..deb16e6 100644 --- a/nmsg_base/logline.proto +++ b/nmsg_base/logline.proto @@ -1,5 +1,6 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message LogLine { optional bytes category = 1; diff --git a/nmsg_base/ncap.pb.go b/nmsg_base/ncap.pb.go index ea6ee57..e5a7411 100644 --- a/nmsg_base/ncap.pb.go +++ b/nmsg_base/ncap.pb.go @@ -1,180 +1,333 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: ncap.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -type NcapType int32 +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) const ( - NcapType_IPV4 NcapType = 0 - NcapType_IPV6 NcapType = 1 - NcapType_Legacy NcapType = 2 -) - -var NcapType_name = map[int32]string{ - 0: "IPV4", - 1: "IPV6", - 2: "Legacy", -} -var NcapType_value = map[string]int32{ - "IPV4": 0, - "IPV6": 1, - "Legacy": 2, -} - -func (x NcapType) Enum() *NcapType { - p := new(NcapType) + // 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 Ncap_NcapType int32 + +const ( + Ncap_IPV4 Ncap_NcapType = 0 + Ncap_IPV6 Ncap_NcapType = 1 + Ncap_Legacy Ncap_NcapType = 2 +) + +// Enum value maps for Ncap_NcapType. +var ( + Ncap_NcapType_name = map[int32]string{ + 0: "IPV4", + 1: "IPV6", + 2: "Legacy", + } + Ncap_NcapType_value = map[string]int32{ + "IPV4": 0, + "IPV6": 1, + "Legacy": 2, + } +) + +func (x Ncap_NcapType) Enum() *Ncap_NcapType { + p := new(Ncap_NcapType) *p = x return p } -func (x NcapType) String() string { - return proto.EnumName(NcapType_name, int32(x)) -} -func (x *NcapType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(NcapType_value, data, "NcapType") + +func (x Ncap_NcapType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Ncap_NcapType) Descriptor() protoreflect.EnumDescriptor { + return file_ncap_proto_enumTypes[0].Descriptor() +} + +func (Ncap_NcapType) Type() protoreflect.EnumType { + return &file_ncap_proto_enumTypes[0] +} + +func (x Ncap_NcapType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Ncap_NcapType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = NcapType(value) - return nil -} -func (NcapType) EnumDescriptor() ([]byte, []int) { return fileDescriptor8, []int{0} } - -type NcapLegacyType int32 + *x = Ncap_NcapType(num) + return nil +} + +// Deprecated: Use Ncap_NcapType.Descriptor instead. +func (Ncap_NcapType) EnumDescriptor() ([]byte, []int) { + return file_ncap_proto_rawDescGZIP(), []int{0, 0} +} + +type Ncap_NcapLegacyType int32 const ( - NcapLegacyType_Ncap_UDP NcapLegacyType = 0 - NcapLegacyType_Ncap_TCP NcapLegacyType = 1 - NcapLegacyType_Ncap_ICMP NcapLegacyType = 2 -) - -var NcapLegacyType_name = map[int32]string{ - 0: "Ncap_UDP", - 1: "Ncap_TCP", - 2: "Ncap_ICMP", -} -var NcapLegacyType_value = map[string]int32{ - "Ncap_UDP": 0, - "Ncap_TCP": 1, - "Ncap_ICMP": 2, -} - -func (x NcapLegacyType) Enum() *NcapLegacyType { - p := new(NcapLegacyType) + Ncap_UDP Ncap_NcapLegacyType = 0 + Ncap_TCP Ncap_NcapLegacyType = 1 + Ncap_ICMP Ncap_NcapLegacyType = 2 +) + +// Enum value maps for Ncap_NcapLegacyType. +var ( + Ncap_NcapLegacyType_name = map[int32]string{ + 0: "UDP", + 1: "TCP", + 2: "ICMP", + } + Ncap_NcapLegacyType_value = map[string]int32{ + "UDP": 0, + "TCP": 1, + "ICMP": 2, + } +) + +func (x Ncap_NcapLegacyType) Enum() *Ncap_NcapLegacyType { + p := new(Ncap_NcapLegacyType) *p = x return p } -func (x NcapLegacyType) String() string { - return proto.EnumName(NcapLegacyType_name, int32(x)) -} -func (x *NcapLegacyType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(NcapLegacyType_value, data, "NcapLegacyType") + +func (x Ncap_NcapLegacyType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Ncap_NcapLegacyType) Descriptor() protoreflect.EnumDescriptor { + return file_ncap_proto_enumTypes[1].Descriptor() +} + +func (Ncap_NcapLegacyType) Type() protoreflect.EnumType { + return &file_ncap_proto_enumTypes[1] +} + +func (x Ncap_NcapLegacyType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Ncap_NcapLegacyType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = NcapLegacyType(value) - return nil -} -func (NcapLegacyType) EnumDescriptor() ([]byte, []int) { return fileDescriptor8, []int{1} } + *x = Ncap_NcapLegacyType(num) + return nil +} + +// Deprecated: Use Ncap_NcapLegacyType.Descriptor instead. +func (Ncap_NcapLegacyType) EnumDescriptor() ([]byte, []int) { + return file_ncap_proto_rawDescGZIP(), []int{0, 1} +} type Ncap struct { - Type *NcapType `protobuf:"varint,1,req,name=type,enum=nmsg.base.NcapType" json:"type,omitempty"` - Payload []byte `protobuf:"bytes,2,req,name=payload" json:"payload,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Ncap_NcapType `protobuf:"varint,1,req,name=type,enum=nmsg.base.Ncap_NcapType" json:"type,omitempty"` + Payload []byte `protobuf:"bytes,2,req,name=payload" json:"payload,omitempty"` // legacy NCAP fields - Ltype *NcapLegacyType `protobuf:"varint,3,opt,name=ltype,enum=nmsg.base.NcapLegacyType" json:"ltype,omitempty"` - Srcip []byte `protobuf:"bytes,4,opt,name=srcip" json:"srcip,omitempty"` - Dstip []byte `protobuf:"bytes,5,opt,name=dstip" json:"dstip,omitempty"` - Lint0 *uint32 `protobuf:"varint,6,opt,name=lint0" json:"lint0,omitempty"` - Lint1 *uint32 `protobuf:"varint,7,opt,name=lint1" json:"lint1,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Ncap) Reset() { *m = Ncap{} } -func (m *Ncap) String() string { return proto.CompactTextString(m) } -func (*Ncap) ProtoMessage() {} -func (*Ncap) Descriptor() ([]byte, []int) { return fileDescriptor8, []int{0} } - -func (m *Ncap) GetType() NcapType { - if m != nil && m.Type != nil { - return *m.Type - } - return NcapType_IPV4 -} - -func (m *Ncap) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil -} - -func (m *Ncap) GetLtype() NcapLegacyType { - if m != nil && m.Ltype != nil { - return *m.Ltype - } - return NcapLegacyType_Ncap_UDP -} - -func (m *Ncap) GetSrcip() []byte { - if m != nil { - return m.Srcip - } - return nil -} - -func (m *Ncap) GetDstip() []byte { - if m != nil { - return m.Dstip - } - return nil -} - -func (m *Ncap) GetLint0() uint32 { - if m != nil && m.Lint0 != nil { - return *m.Lint0 + Ltype *Ncap_NcapLegacyType `protobuf:"varint,3,opt,name=ltype,enum=nmsg.base.Ncap_NcapLegacyType" json:"ltype,omitempty"` + Srcip []byte `protobuf:"bytes,4,opt,name=srcip" json:"srcip,omitempty"` + Dstip []byte `protobuf:"bytes,5,opt,name=dstip" json:"dstip,omitempty"` + Lint0 *uint32 `protobuf:"varint,6,opt,name=lint0" json:"lint0,omitempty"` + Lint1 *uint32 `protobuf:"varint,7,opt,name=lint1" json:"lint1,omitempty"` +} + +func (x *Ncap) Reset() { + *x = Ncap{} + if protoimpl.UnsafeEnabled { + mi := &file_ncap_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Ncap) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Ncap) ProtoMessage() {} + +func (x *Ncap) ProtoReflect() protoreflect.Message { + mi := &file_ncap_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Ncap.ProtoReflect.Descriptor instead. +func (*Ncap) Descriptor() ([]byte, []int) { + return file_ncap_proto_rawDescGZIP(), []int{0} +} + +func (x *Ncap) GetType() Ncap_NcapType { + if x != nil && x.Type != nil { + return *x.Type + } + return Ncap_IPV4 +} + +func (x *Ncap) GetPayload() []byte { + if x != nil { + return x.Payload + } + return nil +} + +func (x *Ncap) GetLtype() Ncap_NcapLegacyType { + if x != nil && x.Ltype != nil { + return *x.Ltype + } + return Ncap_UDP +} + +func (x *Ncap) GetSrcip() []byte { + if x != nil { + return x.Srcip + } + return nil +} + +func (x *Ncap) GetDstip() []byte { + if x != nil { + return x.Dstip + } + return nil +} + +func (x *Ncap) GetLint0() uint32 { + if x != nil && x.Lint0 != nil { + return *x.Lint0 } return 0 } -func (m *Ncap) GetLint1() uint32 { - if m != nil && m.Lint1 != nil { - return *m.Lint1 +func (x *Ncap) GetLint1() uint32 { + if x != nil && x.Lint1 != nil { + return *x.Lint1 } return 0 } -func init() { - proto.RegisterType((*Ncap)(nil), "nmsg.base.Ncap") - proto.RegisterEnum("nmsg.base.NcapType", NcapType_name, NcapType_value) - proto.RegisterEnum("nmsg.base.NcapLegacyType", NcapLegacyType_name, NcapLegacyType_value) -} - -func init() { proto.RegisterFile("ncap.proto", fileDescriptor8) } - -var fileDescriptor8 = []byte{ - // 218 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xca, 0x4b, 0x4e, 0x2c, - 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, 0x4b, 0x4a, 0x2c, - 0x4e, 0x55, 0x5a, 0xc0, 0xc8, 0xc5, 0xe2, 0x07, 0x94, 0x11, 0x52, 0xe4, 0x62, 0x29, 0xa9, 0x2c, - 0x48, 0x95, 0x60, 0x54, 0x60, 0xd2, 0xe0, 0x33, 0x12, 0xd6, 0x83, 0x2b, 0xd1, 0x03, 0x49, 0x87, - 0x00, 0xa5, 0x84, 0xf8, 0xb9, 0xd8, 0x0b, 0x12, 0x2b, 0x73, 0xf2, 0x13, 0x53, 0x24, 0x98, 0x80, - 0xaa, 0x78, 0x84, 0x34, 0xb8, 0x58, 0x73, 0xc0, 0x9a, 0x98, 0x15, 0x18, 0x81, 0x9a, 0x24, 0xd1, - 0x34, 0xf9, 0xa4, 0xa6, 0x27, 0x26, 0x57, 0x82, 0xb5, 0xf2, 0x72, 0xb1, 0x16, 0x17, 0x25, 0x67, - 0x16, 0x48, 0xb0, 0x00, 0x55, 0xf2, 0x80, 0xb8, 0x29, 0xc5, 0x25, 0x40, 0x2e, 0x2b, 0x8c, 0x9b, - 0x93, 0x99, 0x57, 0x62, 0x20, 0xc1, 0x06, 0xe4, 0xf2, 0xc2, 0xb8, 0x86, 0x12, 0xec, 0x20, 0xae, - 0x96, 0x16, 0x17, 0x07, 0xdc, 0x09, 0x1c, 0x5c, 0x2c, 0x9e, 0x01, 0x61, 0x26, 0x02, 0x0c, 0x50, - 0x96, 0x99, 0x00, 0xa3, 0x10, 0x17, 0x17, 0x1b, 0xc4, 0x26, 0x01, 0x26, 0x2d, 0x6b, 0x2e, 0x3e, - 0x34, 0x9b, 0x79, 0x20, 0xba, 0xe3, 0x43, 0x5d, 0x02, 0x80, 0xba, 0x60, 0xbc, 0x10, 0xe7, 0x00, - 0xa0, 0x4e, 0x5e, 0x2e, 0x4e, 0x30, 0xcf, 0xd3, 0xd9, 0x37, 0x40, 0x80, 0x09, 0x10, 0x00, 0x00, - 0xff, 0xff, 0x36, 0x82, 0xd0, 0xf3, 0x23, 0x01, 0x00, 0x00, -} +var File_ncap_proto protoreflect.FileDescriptor + +var file_ncap_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x6e, 0x63, 0x61, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, 0x6d, + 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0xb6, 0x02, 0x0a, 0x04, 0x4e, 0x63, 0x61, 0x70, + 0x12, 0x2c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x18, + 0x2e, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x4e, 0x63, 0x61, 0x70, 0x2e, + 0x4e, 0x63, 0x61, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0c, 0x52, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x34, 0x0a, 0x05, 0x6c, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x4e, 0x63, 0x61, 0x70, 0x2e, 0x4e, 0x63, 0x61, 0x70, 0x4c, 0x65, 0x67, + 0x61, 0x63, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x6c, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x73, 0x72, 0x63, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, + 0x72, 0x63, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x73, 0x74, 0x69, 0x70, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x05, 0x64, 0x73, 0x74, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, + 0x6e, 0x74, 0x30, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x74, 0x30, + 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x74, 0x31, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x05, 0x6c, 0x69, 0x6e, 0x74, 0x31, 0x22, 0x2a, 0x0a, 0x08, 0x4e, 0x63, 0x61, 0x70, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x50, 0x56, 0x34, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, + 0x49, 0x50, 0x56, 0x36, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, + 0x10, 0x02, 0x22, 0x2c, 0x0a, 0x0e, 0x4e, 0x63, 0x61, 0x70, 0x4c, 0x65, 0x67, 0x61, 0x63, 0x79, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, + 0x03, 0x54, 0x43, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x43, 0x4d, 0x50, 0x10, 0x02, + 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, + 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, + 0x73, 0x67, 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_ncap_proto_rawDescOnce sync.Once + file_ncap_proto_rawDescData = file_ncap_proto_rawDesc +) + +func file_ncap_proto_rawDescGZIP() []byte { + file_ncap_proto_rawDescOnce.Do(func() { + file_ncap_proto_rawDescData = protoimpl.X.CompressGZIP(file_ncap_proto_rawDescData) + }) + return file_ncap_proto_rawDescData +} + +var file_ncap_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_ncap_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_ncap_proto_goTypes = []interface{}{ + (Ncap_NcapType)(0), // 0: nmsg.base.Ncap.NcapType + (Ncap_NcapLegacyType)(0), // 1: nmsg.base.Ncap.NcapLegacyType + (*Ncap)(nil), // 2: nmsg.base.Ncap +} +var file_ncap_proto_depIdxs = []int32{ + 0, // 0: nmsg.base.Ncap.type:type_name -> nmsg.base.Ncap.NcapType + 1, // 1: nmsg.base.Ncap.ltype:type_name -> nmsg.base.Ncap.NcapLegacyType + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_ncap_proto_init() } +func file_ncap_proto_init() { + if File_ncap_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_ncap_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Ncap); 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_ncap_proto_rawDesc, + NumEnums: 2, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_ncap_proto_goTypes, + DependencyIndexes: file_ncap_proto_depIdxs, + EnumInfos: file_ncap_proto_enumTypes, + MessageInfos: file_ncap_proto_msgTypes, + }.Build() + File_ncap_proto = out.File + file_ncap_proto_rawDesc = nil + file_ncap_proto_goTypes = nil + file_ncap_proto_depIdxs = nil +} diff --git a/nmsg_base/ncap.proto b/nmsg_base/ncap.proto index aec20da..c04e3b0 100644 --- a/nmsg_base/ncap.proto +++ b/nmsg_base/ncap.proto @@ -1,19 +1,20 @@ syntax = "proto2"; package nmsg.base; - -enum NcapType { - IPV4 = 0; - IPV6 = 1; - Legacy = 2; -} - -enum NcapLegacyType { - Ncap_UDP = 0; - Ncap_TCP = 1; - Ncap_ICMP = 2; -} +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message Ncap { + enum NcapType { + IPV4 = 0; + IPV6 = 1; + Legacy = 2; + } + + enum NcapLegacyType { + UDP = 0; + TCP = 1; + ICMP = 2; + } + required NcapType type = 1; required bytes payload = 2; diff --git a/nmsg_base/packet.pb.go b/nmsg_base/packet.pb.go index 51fcc85..deea6a5 100644 --- a/nmsg_base/packet.pb.go +++ b/nmsg_base/packet.pb.go @@ -1,17 +1,24 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: packet.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type PacketType int32 @@ -23,70 +30,188 @@ PacketType_IP PacketType = 1 ) -var PacketType_name = map[int32]string{ - 1: "IP", -} -var PacketType_value = map[string]int32{ - "IP": 1, -} +// Enum value maps for PacketType. +var ( + PacketType_name = map[int32]string{ + 1: "IP", + } + PacketType_value = map[string]int32{ + "IP": 1, + } +) func (x PacketType) Enum() *PacketType { p := new(PacketType) *p = x return p } + func (x PacketType) String() string { - return proto.EnumName(PacketType_name, int32(x)) -} -func (x *PacketType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(PacketType_value, data, "PacketType") + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PacketType) Descriptor() protoreflect.EnumDescriptor { + return file_packet_proto_enumTypes[0].Descriptor() +} + +func (PacketType) Type() protoreflect.EnumType { + return &file_packet_proto_enumTypes[0] +} + +func (x PacketType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *PacketType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = PacketType(value) + *x = PacketType(num) return nil } -func (PacketType) EnumDescriptor() ([]byte, []int) { return fileDescriptor9, []int{0} } + +// Deprecated: Use PacketType.Descriptor instead. +func (PacketType) EnumDescriptor() ([]byte, []int) { + return file_packet_proto_rawDescGZIP(), []int{0} +} type Packet struct { - PayloadType *PacketType `protobuf:"varint,1,req,name=payload_type,enum=nmsg.base.PacketType" json:"payload_type,omitempty"` - Payload []byte `protobuf:"bytes,2,req,name=payload" json:"payload,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Packet) Reset() { *m = Packet{} } -func (m *Packet) String() string { return proto.CompactTextString(m) } -func (*Packet) ProtoMessage() {} -func (*Packet) Descriptor() ([]byte, []int) { return fileDescriptor9, []int{0} } - -func (m *Packet) GetPayloadType() PacketType { - if m != nil && m.PayloadType != nil { - return *m.PayloadType + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PayloadType *PacketType `protobuf:"varint,1,req,name=payload_type,json=payloadType,enum=nmsg.base.PacketType" json:"payload_type,omitempty"` + Payload []byte `protobuf:"bytes,2,req,name=payload" json:"payload,omitempty"` +} + +func (x *Packet) Reset() { + *x = Packet{} + if protoimpl.UnsafeEnabled { + mi := &file_packet_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Packet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Packet) ProtoMessage() {} + +func (x *Packet) ProtoReflect() protoreflect.Message { + mi := &file_packet_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Packet.ProtoReflect.Descriptor instead. +func (*Packet) Descriptor() ([]byte, []int) { + return file_packet_proto_rawDescGZIP(), []int{0} +} + +func (x *Packet) GetPayloadType() PacketType { + if x != nil && x.PayloadType != nil { + return *x.PayloadType } return PacketType_IP } -func (m *Packet) GetPayload() []byte { - if m != nil { - return m.Payload +func (x *Packet) GetPayload() []byte { + if x != nil { + return x.Payload } return nil } -func init() { - proto.RegisterType((*Packet)(nil), "nmsg.base.Packet") - proto.RegisterEnum("nmsg.base.PacketType", PacketType_name, PacketType_value) -} - -func init() { proto.RegisterFile("packet.proto", fileDescriptor9) } - -var fileDescriptor9 = []byte{ - // 111 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x48, 0x4c, 0xce, - 0x4e, 0x2d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, 0x4b, - 0x4a, 0x2c, 0x4e, 0x55, 0x72, 0xe3, 0x62, 0x0b, 0x00, 0x4b, 0x09, 0x69, 0x83, 0x14, 0x55, 0xe6, - 0xe4, 0x27, 0xa6, 0xc4, 0x97, 0x54, 0x16, 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x69, 0xf0, 0x19, 0x89, - 0xea, 0xc1, 0xd5, 0xea, 0x41, 0x14, 0x86, 0x00, 0x25, 0x85, 0xf8, 0xb9, 0xd8, 0xa1, 0x8a, 0x25, - 0x98, 0x80, 0xea, 0x78, 0xb4, 0x44, 0xb8, 0xb8, 0x90, 0xa4, 0xd9, 0xb8, 0x98, 0x3c, 0x03, 0x04, - 0x18, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x3e, 0xce, 0x93, 0x77, 0x00, 0x00, 0x00, -} +var File_packet_proto protoreflect.FileDescriptor + +var file_packet_proto_rawDesc = []byte{ + 0x0a, 0x0c, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, + 0x6e, 0x6d, 0x73, 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x5c, 0x0a, 0x06, 0x50, 0x61, 0x63, + 0x6b, 0x65, 0x74, 0x12, 0x38, 0x0a, 0x0c, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6e, 0x6d, 0x73, 0x67, + 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x0b, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x07, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x2a, 0x14, 0x0a, 0x0a, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x49, 0x50, 0x10, 0x01, 0x42, 0x2a, 0x5a, + 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, 0x73, + 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, 0x2f, + 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, +} + +var ( + file_packet_proto_rawDescOnce sync.Once + file_packet_proto_rawDescData = file_packet_proto_rawDesc +) + +func file_packet_proto_rawDescGZIP() []byte { + file_packet_proto_rawDescOnce.Do(func() { + file_packet_proto_rawDescData = protoimpl.X.CompressGZIP(file_packet_proto_rawDescData) + }) + return file_packet_proto_rawDescData +} + +var file_packet_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_packet_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_packet_proto_goTypes = []interface{}{ + (PacketType)(0), // 0: nmsg.base.PacketType + (*Packet)(nil), // 1: nmsg.base.Packet +} +var file_packet_proto_depIdxs = []int32{ + 0, // 0: nmsg.base.Packet.payload_type:type_name -> nmsg.base.PacketType + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_packet_proto_init() } +func file_packet_proto_init() { + if File_packet_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_packet_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Packet); 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_packet_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_packet_proto_goTypes, + DependencyIndexes: file_packet_proto_depIdxs, + EnumInfos: file_packet_proto_enumTypes, + MessageInfos: file_packet_proto_msgTypes, + }.Build() + File_packet_proto = out.File + file_packet_proto_rawDesc = nil + file_packet_proto_goTypes = nil + file_packet_proto_depIdxs = nil +} diff --git a/nmsg_base/packet.proto b/nmsg_base/packet.proto index 0444e48..d3da915 100644 --- a/nmsg_base/packet.proto +++ b/nmsg_base/packet.proto @@ -1,5 +1,6 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; enum PacketType { // An IPv4 or IPv6 packet. The packet begins immediately with the IP diff --git a/nmsg_base/pkt.pb.go b/nmsg_base/pkt.pb.go index e4466a3..bb1b8cf 100644 --- a/nmsg_base/pkt.pb.go +++ b/nmsg_base/pkt.pb.go @@ -1,55 +1,152 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: pkt.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + 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 +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 Pkt struct { - Payload []byte `protobuf:"bytes,1,req,name=payload" json:"payload,omitempty"` - LenFrame *uint32 `protobuf:"varint,2,opt,name=len_frame" json:"len_frame,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Payload []byte `protobuf:"bytes,1,req,name=payload" json:"payload,omitempty"` + LenFrame *uint32 `protobuf:"varint,2,opt,name=len_frame,json=lenFrame" json:"len_frame,omitempty"` } -func (m *Pkt) Reset() { *m = Pkt{} } -func (m *Pkt) String() string { return proto.CompactTextString(m) } -func (*Pkt) ProtoMessage() {} -func (*Pkt) Descriptor() ([]byte, []int) { return fileDescriptor10, []int{0} } +func (x *Pkt) Reset() { + *x = Pkt{} + if protoimpl.UnsafeEnabled { + mi := &file_pkt_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func (m *Pkt) GetPayload() []byte { - if m != nil { - return m.Payload +func (x *Pkt) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pkt) ProtoMessage() {} + +func (x *Pkt) ProtoReflect() protoreflect.Message { + mi := &file_pkt_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pkt.ProtoReflect.Descriptor instead. +func (*Pkt) Descriptor() ([]byte, []int) { + return file_pkt_proto_rawDescGZIP(), []int{0} +} + +func (x *Pkt) GetPayload() []byte { + if x != nil { + return x.Payload } return nil } -func (m *Pkt) GetLenFrame() uint32 { - if m != nil && m.LenFrame != nil { - return *m.LenFrame +func (x *Pkt) GetLenFrame() uint32 { + if x != nil && x.LenFrame != nil { + return *x.LenFrame } return 0 } -func init() { - proto.RegisterType((*Pkt)(nil), "nmsg.base.Pkt") +var File_pkt_proto protoreflect.FileDescriptor + +var file_pkt_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x70, 0x6b, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, 0x6d, 0x73, + 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3c, 0x0a, 0x03, 0x50, 0x6b, 0x74, 0x12, 0x18, 0x0a, + 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x07, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x65, 0x6e, 0x5f, 0x66, + 0x72, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x6c, 0x65, 0x6e, 0x46, + 0x72, 0x61, 0x6d, 0x65, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, + 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, 0x61, 0x73, 0x65, } -func init() { proto.RegisterFile("pkt.proto", fileDescriptor10) } +var ( + file_pkt_proto_rawDescOnce sync.Once + file_pkt_proto_rawDescData = file_pkt_proto_rawDesc +) -var fileDescriptor10 = []byte{ - // 89 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x2c, 0xc8, 0x2e, 0xd1, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, 0x4b, 0x4a, 0x2c, 0x4e, - 0x55, 0xd2, 0xe4, 0x62, 0x0e, 0xc8, 0x2e, 0x11, 0xe2, 0xe7, 0x62, 0x2f, 0x48, 0xac, 0xcc, 0xc9, - 0x4f, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd2, 0xe0, 0x11, 0x12, 0xe4, 0xe2, 0xcc, 0x49, 0xcd, 0x8b, - 0x4f, 0x2b, 0x4a, 0xcc, 0x4d, 0x95, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x05, 0x04, 0x00, 0x00, 0xff, - 0xff, 0x9d, 0xda, 0xa2, 0xb6, 0x41, 0x00, 0x00, 0x00, +func file_pkt_proto_rawDescGZIP() []byte { + file_pkt_proto_rawDescOnce.Do(func() { + file_pkt_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkt_proto_rawDescData) + }) + return file_pkt_proto_rawDescData } + +var file_pkt_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_pkt_proto_goTypes = []interface{}{ + (*Pkt)(nil), // 0: nmsg.base.Pkt +} +var file_pkt_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_pkt_proto_init() } +func file_pkt_proto_init() { + if File_pkt_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkt_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Pkt); 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_pkt_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_pkt_proto_goTypes, + DependencyIndexes: file_pkt_proto_depIdxs, + MessageInfos: file_pkt_proto_msgTypes, + }.Build() + File_pkt_proto = out.File + file_pkt_proto_rawDesc = nil + file_pkt_proto_goTypes = nil + file_pkt_proto_depIdxs = nil +} diff --git a/nmsg_base/pkt.proto b/nmsg_base/pkt.proto index 250ca5f..e8e0cb2 100644 --- a/nmsg_base/pkt.proto +++ b/nmsg_base/pkt.proto @@ -1,5 +1,6 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message Pkt { required bytes payload = 1; diff --git a/nmsg_base/xml.pb.go b/nmsg_base/xml.pb.go index 5608860..29078ec 100644 --- a/nmsg_base/xml.pb.go +++ b/nmsg_base/xml.pb.go @@ -1,55 +1,153 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) // source: xml.proto -// DO NOT EDIT! package nmsg_base -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + 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 +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 Xml struct { - Xmltype []byte `protobuf:"bytes,1,req,name=xmltype" json:"xmltype,omitempty"` - Xmlpayload []byte `protobuf:"bytes,2,req,name=xmlpayload" json:"xmlpayload,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Xmltype []byte `protobuf:"bytes,1,req,name=xmltype" json:"xmltype,omitempty"` + Xmlpayload []byte `protobuf:"bytes,2,req,name=xmlpayload" json:"xmlpayload,omitempty"` } -func (m *Xml) Reset() { *m = Xml{} } -func (m *Xml) String() string { return proto.CompactTextString(m) } -func (*Xml) ProtoMessage() {} -func (*Xml) Descriptor() ([]byte, []int) { return fileDescriptor11, []int{0} } +func (x *Xml) Reset() { + *x = Xml{} + if protoimpl.UnsafeEnabled { + mi := &file_xml_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func (m *Xml) GetXmltype() []byte { - if m != nil { - return m.Xmltype +func (x *Xml) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Xml) ProtoMessage() {} + +func (x *Xml) ProtoReflect() protoreflect.Message { + mi := &file_xml_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Xml.ProtoReflect.Descriptor instead. +func (*Xml) Descriptor() ([]byte, []int) { + return file_xml_proto_rawDescGZIP(), []int{0} +} + +func (x *Xml) GetXmltype() []byte { + if x != nil { + return x.Xmltype } return nil } -func (m *Xml) GetXmlpayload() []byte { - if m != nil { - return m.Xmlpayload +func (x *Xml) GetXmlpayload() []byte { + if x != nil { + return x.Xmlpayload } return nil } -func init() { - proto.RegisterType((*Xml)(nil), "nmsg.base.Xml") +var File_xml_proto protoreflect.FileDescriptor + +var file_xml_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x78, 0x6d, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, 0x6d, 0x73, + 0x67, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x03, 0x58, 0x6d, 0x6c, 0x12, 0x18, 0x0a, + 0x07, 0x78, 0x6d, 0x6c, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x07, + 0x78, 0x6d, 0x6c, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x78, 0x6d, 0x6c, 0x70, 0x61, + 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x0a, 0x78, 0x6d, 0x6c, + 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, + 0x63, 0x2f, 0x67, 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, 0x2f, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x62, + 0x61, 0x73, 0x65, } -func init() { proto.RegisterFile("xml.proto", fileDescriptor11) } +var ( + file_xml_proto_rawDescOnce sync.Once + file_xml_proto_rawDescData = file_xml_proto_rawDesc +) -var fileDescriptor11 = []byte{ - // 86 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xac, 0xc8, 0xcd, 0xd1, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcc, 0xcb, 0x2d, 0x4e, 0xd7, 0x4b, 0x4a, 0x2c, 0x4e, - 0x55, 0xd2, 0xe2, 0x62, 0x8e, 0xc8, 0xcd, 0x11, 0xe2, 0xe7, 0x62, 0x07, 0x4a, 0x97, 0x54, 0x16, - 0xa4, 0x4a, 0x30, 0x2a, 0x30, 0x69, 0xf0, 0x08, 0x09, 0x71, 0x71, 0x01, 0x05, 0x0a, 0x12, 0x2b, - 0x73, 0xf2, 0x13, 0x53, 0x24, 0x98, 0x40, 0x62, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x92, - 0x10, 0x81, 0x42, 0x00, 0x00, 0x00, +func file_xml_proto_rawDescGZIP() []byte { + file_xml_proto_rawDescOnce.Do(func() { + file_xml_proto_rawDescData = protoimpl.X.CompressGZIP(file_xml_proto_rawDescData) + }) + return file_xml_proto_rawDescData } + +var file_xml_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_xml_proto_goTypes = []interface{}{ + (*Xml)(nil), // 0: nmsg.base.Xml +} +var file_xml_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_xml_proto_init() } +func file_xml_proto_init() { + if File_xml_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_xml_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Xml); 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_xml_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_xml_proto_goTypes, + DependencyIndexes: file_xml_proto_depIdxs, + MessageInfos: file_xml_proto_msgTypes, + }.Build() + File_xml_proto = out.File + file_xml_proto_rawDesc = nil + file_xml_proto_goTypes = nil + file_xml_proto_depIdxs = nil +} diff --git a/nmsg_base/xml.proto b/nmsg_base/xml.proto index e82b3aa..b2df2f9 100644 --- a/nmsg_base/xml.proto +++ b/nmsg_base/xml.proto @@ -1,5 +1,6 @@ syntax = "proto2"; package nmsg.base; +option go_package = "github.com/farsightsec/go-nmsg/nmsg_base"; message Xml { required bytes xmltype = 1; diff --git a/payload.go b/payload.go index 70180bb..3f43c67 100644 --- a/payload.go +++ b/payload.go @@ -12,7 +12,7 @@ "encoding/binary" "time" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) // Payload encapsulates an nmsg message in a NmsgPayload, suitable for sending to diff --git a/payload_test.go b/payload_test.go index 8ca470a..f237358 100644 --- a/payload_test.go +++ b/payload_test.go @@ -12,11 +12,10 @@ "testing" "github.com/farsightsec/go-nmsg" - "github.com/golang/protobuf/proto" ) func testMessage(length int) nmsg.Message { - return &testMsg{Bytes: make([]byte, length)} + return &TestMessage{Bytes: make([]byte, length)} } func testPayload(length int) *nmsg.NmsgPayload { @@ -27,19 +26,11 @@ return p } -type testMsg struct { - Bytes []byte `protobuf:"bytes,2,opt,name=bytes"` -} - -func (t *testMsg) GetVid() uint32 { return 10 } -func (t *testMsg) GetMsgtype() uint32 { return 20 } - -func (t *testMsg) Reset() { *t = testMsg{} } -func (t *testMsg) String() string { return proto.CompactTextString(t) } -func (t *testMsg) ProtoMessage() {} +func (t *TestMessage) GetVid() uint32 { return 10 } +func (t *TestMessage) GetMsgtype() uint32 { return 20 } func init() { - nmsg.Register(&testMsg{}) + nmsg.Register(&TestMessage{}) } func TestRegister(t *testing.T) { @@ -47,7 +38,7 @@ if err != nil { t.Error(err) } - if _, ok := msg.(*testMsg); !ok { + if _, ok := msg.(*TestMessage); !ok { t.Errorf("NewMessage returned wrong type") } } @@ -63,7 +54,7 @@ t.Error(err) } - if tp, ok := m.(*testMsg); !ok { + if tp, ok := m.(*TestMessage); !ok { t.Errorf("Wrong type from payload") } else if len(tp.Bytes) != 1000 { t.Error("decode failed") diff --git a/payload_test.pb_test.go b/payload_test.pb_test.go new file mode 100644 index 0000000..c64ec42 --- /dev/null +++ b/payload_test.pb_test.go @@ -0,0 +1,143 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0-devel +// protoc (unknown) +// source: payload_test.proto + +package nmsg_test + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type TestMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Bytes []byte `protobuf:"bytes,2,opt,name=bytes" json:"bytes,omitempty"` +} + +func (x *TestMessage) Reset() { + *x = TestMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_payload_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestMessage) ProtoMessage() {} + +func (x *TestMessage) ProtoReflect() protoreflect.Message { + mi := &file_payload_test_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TestMessage.ProtoReflect.Descriptor instead. +func (*TestMessage) Descriptor() ([]byte, []int) { + return file_payload_test_proto_rawDescGZIP(), []int{0} +} + +func (x *TestMessage) GetBytes() []byte { + if x != nil { + return x.Bytes + } + return nil +} + +var File_payload_test_proto protoreflect.FileDescriptor + +var file_payload_test_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x22, + 0x23, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, + 0x79, 0x74, 0x65, 0x73, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x66, 0x61, 0x72, 0x73, 0x69, 0x67, 0x68, 0x74, 0x73, 0x65, 0x63, 0x2f, 0x67, + 0x6f, 0x2d, 0x6e, 0x6d, 0x73, 0x67, 0x3b, 0x6e, 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x65, 0x73, 0x74, +} + +var ( + file_payload_test_proto_rawDescOnce sync.Once + file_payload_test_proto_rawDescData = file_payload_test_proto_rawDesc +) + +func file_payload_test_proto_rawDescGZIP() []byte { + file_payload_test_proto_rawDescOnce.Do(func() { + file_payload_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_payload_test_proto_rawDescData) + }) + return file_payload_test_proto_rawDescData +} + +var file_payload_test_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_payload_test_proto_goTypes = []interface{}{ + (*TestMessage)(nil), // 0: nmsg_test.TestMessage +} +var file_payload_test_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_payload_test_proto_init() } +func file_payload_test_proto_init() { + if File_payload_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_payload_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestMessage); 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_payload_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_payload_test_proto_goTypes, + DependencyIndexes: file_payload_test_proto_depIdxs, + MessageInfos: file_payload_test_proto_msgTypes, + }.Build() + File_payload_test_proto = out.File + file_payload_test_proto_rawDesc = nil + file_payload_test_proto_goTypes = nil + file_payload_test_proto_depIdxs = nil +} diff --git a/payload_test.proto b/payload_test.proto new file mode 100644 index 0000000..9c17f2c --- /dev/null +++ b/payload_test.proto @@ -0,0 +1,7 @@ +syntax = "proto2"; +package nmsg_test; +option go_package = "github.com/farsightsec/go-nmsg;nmsg_test"; + +message TestMessage { + optional bytes bytes = 2; +} diff --git a/zlib_test.go b/zlib_test.go index 25b7be2..dffdce0 100644 --- a/zlib_test.go +++ b/zlib_test.go @@ -38,11 +38,11 @@ if err != nil { t.Fatal(err) } - mi, ok := mm.(*testMsg) + mi, ok := mm.(*TestMessage) if !ok { t.Error("received message of wrong type") } - if len(mi.Bytes) != len(m.(*testMsg).Bytes) { + if len(mi.Bytes) != len(m.(*TestMessage).Bytes) { t.Error("received message of wrong length") } for i := range mi.Bytes {