iptablesparser

package module
v0.0.0-...-224ded2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2019 License: MIT Imports: 6 Imported by: 0

README

Iptables-log-parser

This is a parser for logs generated by iptables and Tripwire. You can use it if you want to process your logs eg. from incommnig connection attempts.

Install

go get github.com/JojiiOfficial/Iptables-log-parser

Examples

Reading the file ("/var/log/Tripwire21") line by line, parse it and use it as LogEntry object.

err := ParseFileByLines("/var/log/Tripwire21", func(log *LogEntry) {
  //This callback gets fired for each logEntry in the given file
  fmt.Println(log)
})
if err != nil {
  panic(err)
}

...or use an array

logs, err := ParseFile("/var/log/Tripwire21")
if err != nil {
  panic(err)
}
for _, log := range logs {
  fmt.Println(log)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFileByLines

func ParseFileByLines(filename string, callback func(*LogEntry)) error

ParseFileByLines parses a file and calls the given callback each time it found a LogEntry

Types

type LogEntry

type LogEntry struct {
	Time                                           time.Time
	In, Out, Mac, Src, Dst, Len, TTL, ID, Protocol string
	DestPort, SrcPort                              int
}

LogEntry a entry in log

func ParseFile

func ParseFile(filename string) ([]LogEntry, error)

ParseFile parses a file and returns an array with all found entries

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL