Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

result: add server to packet result #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/en/docs/Outputs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Other than `Type`, each output module may require additional configuration param

- `json`: the standard JSON output. The output looks like below sample
```json
{"Timestamp":"2020-08-08T00:19:42.567768Z","DNS":{"Id":54443,"Response":true,"Opcode":0,"Authoritative":false,"Truncated":false,"RecursionDesired":true,"RecursionAvailable":true,"Zero":false,"AuthenticatedData":false,"CheckingDisabled":false,"Rcode":0,"Question":[{"Name":"imap.gmail.com.","Qtype":1,"Qclass":1}],"Answer":[{"Hdr":{"Name":"imap.gmail.com.","Rrtype":1,"Class":1,"Ttl":242,"Rdlength":4},"A":"172.217.194.108"},{"Hdr":{"Name":"imap.gmail.com.","Rrtype":1,"Class":1,"Ttl":242,"Rdlength":4},"A":"172.217.194.109"}],"Ns":null,"Extra":null},"IPVersion":4,"SrcIP":"1.1.1.1","DstIP":"2.2.2.2","Protocol":"udp","PacketLength":64}
{"Timestamp":"2020-08-08T00:19:42.567768Z","Server": "default","DNS":{"Id":54443,"Response":true,"Opcode":0,"Authoritative":false,"Truncated":false,"RecursionDesired":true,"RecursionAvailable":true,"Zero":false,"AuthenticatedData":false,"CheckingDisabled":false,"Rcode":0,"Question":[{"Name":"imap.gmail.com.","Qtype":1,"Qclass":1}],"Answer":[{"Hdr":{"Name":"imap.gmail.com.","Rrtype":1,"Class":1,"Ttl":242,"Rdlength":4},"A":"172.217.194.108"},{"Hdr":{"Name":"imap.gmail.com.","Rrtype":1,"Class":1,"Ttl":242,"Rdlength":4},"A":"172.217.194.109"}],"Ns":null,"Extra":null},"IPVersion":4,"SrcIP":"1.1.1.1","DstIP":"2.2.2.2","Protocol":"udp","PacketLength":64}
```
- `csv`: the CSV output. The fields and headers are non-customizable at the moment. to get a custom output, please look at `gotemplate`.
```csv
Expand Down
1 change: 1 addition & 0 deletions internal/capture/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (config captureConfig) processTransport(foundLayerTypes *[]gopacket.LayerTy
}
config.resultChannel <- util.DNSResult{
Timestamp: timestamp,
Server: util.GeneralFlags.ServerName,
DNS: msg, IPVersion: IPVersion, SrcIP: SrcIP.Mask(net.CIDRMask(MaskSize, BitSize)),
DstIP: DstIP.Mask(net.CIDRMask(MaskSize, BitSize)), Protocol: "udp", PacketLength: uint16(len(udp.Payload)),
}
Expand Down
1 change: 1 addition & 0 deletions internal/output/parquet.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type parquetConfig struct {

type parquetRow struct {
Timestamp time.Time `parquet:"timestamp,snappy"`
Server string `parquet:"server,snappy"`
IPVersion uint32 `parquet:"ip_version,snappy,dict"`
SrcIP net.IP `parquet:"src_ip,snappy"`
DstIP net.IP `parquet:"dst_ip,snappy"`
Expand Down
2 changes: 2 additions & 0 deletions internal/util/gob.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
type gobOutput struct{}
type DNSResultBinary struct {
Timestamp time.Time
Server string
DNS []byte //packed version of dns.msg (dns.Msg.Pack())
IPVersion uint8
SrcIP net.IP
Expand All @@ -42,6 +43,7 @@ func (g gobOutput) Marshal(d DNSResult) []byte {
bMsg, _ := d.DNS.Pack()
dnsBin := DNSResultBinary{
Timestamp: d.Timestamp,
Server: d.Server,
DNS: bMsg,
IPVersion: d.IPVersion,
SrcIP: d.SrcIP,
Expand Down
1 change: 1 addition & 0 deletions internal/util/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
// For DNStap, this is probably going to be replaced with something else.
type DNSResult struct {
Timestamp time.Time
Server string
DNS mkdns.Msg
IPVersion uint8
SrcIP net.IP
Expand Down
Loading