ipstream

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

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.

Documentation

Overview

Package ipstream scans byte streams and emits IP/non-IP segments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Processor

type Processor func(raw []byte, ok bool, addr netip.Addr)

Processor receives each segment; ok means raw parsed as addr.

type Streamer

type Streamer struct {
	// contains filtered or unexported fields
}

Streamer incrementally scans written bytes for IPv4/IPv6 addresses.

func NewStreamer

func NewStreamer(p Processor) *Streamer

NewStreamer creates a new Streamer with the provided segment processor.

func (*Streamer) Close

func (s *Streamer) Close() error

Close flushes pending token data.

func (*Streamer) Write

func (s *Streamer) Write(p []byte) (int, error)

Write scans p; call Close to flush a trailing token.

Directories

Path Synopsis
cmd
ipstream command
Package main provides the ipstream command.
Package main provides the ipstream command.

Jump to

Keyboard shortcuts

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