ipstream
ipstream extracts IPv4 and IPv6 addresses from byte streams.
CLI
The ipstream command filters IP addresses from standard input to standard output, one per line.
Install
Download prebuilt binaries
Download an archive from GitHub Releases.
Optionally, download checksums.txt and verify the archive:
cd path/to/downloads
sha256sum -c checksums.txt --ignore-missing
Extract the archive and place ipstream in your PATH.
Install from source
go install github.com/kibaamor/ipstream/cmd/ipstream@latest
Usage
ipstream < input.log
Examples:
# Extract IPs only.
cat input.log | ipstream
# Show help.
ipstream -h
# Show version metadata.
ipstream -v
Useful flags: -h/--help, -v/--version.
Go Library
The Go library scans arbitrary chunks and reports both IP and non-IP segments through a callback.
Install
go get github.com/kibaamor/ipstream
Usage
Use NewStreamer to scan arbitrary chunks. The callback receives every input segment; ok == true means raw parsed as addr.
package main
import (
"fmt"
"net/netip"
"github.com/kibaamor/ipstream"
)
func main() {
streamer := ipstream.NewStreamer(func(raw []byte, ok bool, addr netip.Addr) {
if ok {
fmt.Println(addr)
}
})
_, _ = streamer.Write([]byte("client=192.168.1.1 "))
_, _ = streamer.Write([]byte("gateway=2001:db8::1"))
_ = streamer.Close() // flushes the final token
}
Output:
192.168.1.1
2001:db8::1
Issues
Bug reports and feature suggestions are welcome in GitHub Issues.
When reporting a bug, please include the input that reproduces it, the expected output, the actual output, and the ipstream -v version information if you are using the CLI.
License
Apache License 2.0. See LICENSE.