feeds

package
v1.0.32 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(feedsDir string, feedNames []string) (map[string]*model.SetData, error)

Build loads all feed files and returns consolidated SetData This replaces the slow bash implementation with fast Go parsing

Performance: <2s for 50,000+ IPs (vs 45s in bash)

Features: - IPv4/IPv6 automatic separation - CIDR normalization - Comment and empty line filtering - Streaming parsing (memory efficient)

func IsCIDR

func IsCIDR(s string) bool

IsCIDR checks if a string is a valid CIDR Delegates to netutil.IsCIDR for consistency

func IsIPv4

func IsIPv4(ipStr string) bool

IsIPv4 checks if an IP string is IPv4 Delegates to netutil.IsIPv4 for consistency

func IsIPv6

func IsIPv6(ipStr string) bool

IsIPv6 checks if an IP string is IPv6 Delegates to netutil.IsIPv6 for consistency

func ListAvailableFeeds

func ListAvailableFeeds(feedsDir string) ([]string, error)

ListAvailableFeeds returns a list of all available feed names

func LoadFeed

func LoadFeed(feedsDir, feedName string) (*model.SetData, error)

LoadFeed loads a single feed file and returns SetData

func LoadSpecificFeed

func LoadSpecificFeed(feedsDir string, feedName string) ([]string, []string, []string, []string, error)

LoadSpecificFeed loads a single feed by name Returns IPv4 IPs, IPv6 IPs, IPv4 CIDRs, IPv6 CIDRs

func Merge

func Merge(feeds map[string]*model.SetData) *model.SetData

Merge combines multiple SetData into one Useful for consolidating multiple feeds into a single nftables set

Types

type FeedInfo

type FeedInfo struct {
	Name        string
	FilePath    string
	IPv4Count   int
	IPv6Count   int
	LastUpdated string
}

FeedInfo represents metadata about a threat feed

func GetFeedStats

func GetFeedStats(feedsDir string) ([]FeedInfo, error)

GetFeedStats returns statistics about all feeds

func LoadAllFeeds

func LoadAllFeeds(feedsDir string) (map[string]bool, map[string]bool, map[string]bool, map[string]bool, []FeedInfo, error)

LoadAllFeeds loads all feed files from the feeds directory Returns IPv4 IPs, IPv6 IPs, IPv4 CIDRs, IPv6 CIDRs, and feed info

type ParsedEntry

type ParsedEntry struct {
	IPv4   bool   // true if IPv4, false if IPv6
	IsCIDR bool   // true if CIDR range, false if single IP
	Value  string // normalized IP or CIDR
}

ParsedEntry represents a parsed feed line

func ParseFeedLine

func ParseFeedLine(line string) (*ParsedEntry, error)

ParseFeedLine parses a single line from a feed/blacklist/whitelist file Handles multiple formats:

  • Plain IP: "1.2.3.4"
  • CIDR: "1.2.3.0/24"
  • With inline comment: "1.2.3.4 # some comment"
  • With whitespace-separated fields: "1.2.3.4 reason timestamp"

Returns nil, nil for empty lines and comments (skip) Returns nil, error for invalid IPs/CIDRs

func ParseFeedLineSilent

func ParseFeedLineSilent(line string) *ParsedEntry

ParseFeedLineSilent parses a line and returns nil for both skip and error cases Use this when you want to silently ignore invalid entries (like the original loader)

func ParseFeedLineStrict

func ParseFeedLineStrict(line string) (*ParsedEntry, error)

ParseFeedLineStrict is like ParseFeedLine but returns error for invalid entries Use this when you want to know about parsing failures

Jump to

Keyboard shortcuts

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