mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Import reading of pcap files
Automatically detect if it is a file (by extension), and do not require specify --input-raw-engine option. Can also run without port, but in this case, it will assume that port value set to `0` and it will show all records from the file.
This commit is contained in:
+12
-1
@@ -51,7 +51,18 @@ func NewRAWInput(address string, config RAWInputConfig) (i *RAWInput) {
|
||||
|
||||
host, _ports, err := net.SplitHostPort(address)
|
||||
if err != nil {
|
||||
log.Fatalf("input-raw: error while parsing address: %s", err)
|
||||
// If we are reading pcap file, no port needed
|
||||
if strings.HasSuffix(address, "pcap") {
|
||||
host = address
|
||||
_ports = "0"
|
||||
err = nil
|
||||
} else {
|
||||
log.Fatalf("input-raw: error while parsing address: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if strings.HasSuffix(host, "pcap") {
|
||||
i.RAWInputConfig.Engine = capture.EnginePcapFile
|
||||
}
|
||||
|
||||
var ports []uint16
|
||||
|
||||
Reference in New Issue
Block a user