lbtypes

package
v0.0.0-...-37a5d2c Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IPCacheMap = make(map[string]IPCache)

TODO - Put lock and map in single struct for organization - then refactor CheckIP and AddIP to just take the original cachemap struct

View Source
var IPCacheMapLock = sync.RWMutex{}

Functions

func AddIP

func AddIP(ip string, ipcache IPCache)

Types

type ASN

type ASN struct {
	AutonomousSystemOrganization string `maxminddb:"autonomous_system_organization"`
	AutonomousSystemNumber       uint   `maxminddb:"autonomous_system_number"`
}

type City

type City struct {
	City struct {
		Names map[string]string `maxminddb:"names"`
	} `maxminddb:"city"`
	Country struct {
		Names map[string]string `maxminddb:"names"`
	} `maxminddb:"country"`
	RegisteredCountry struct {
		Names map[string]string `maxminddb:"names"`
	} `maxminddb:"registered_country"`
	Traits struct {
		IsAnonymousProxy bool `maxminddb:"is_anonymous_proxy"`
	} `maxminddb:"traits"`
}

https://github.com/oschwald/geoip2-golang/blob/main/reader.go TODO - Review potential MaxMind fields to determine usefulness of any others - really depends on the 'type' of DB we have access to Refactor to provide fields properly from IP/ASN lat/lon are kind of meh but I guess could be useful for some applications - but really it depends on accuracy radius which could maybe be useful here.

type DBRefs

type DBRefs struct {
	Country *maxminddb.Reader
	City    *maxminddb.Reader
	Domain  *maxminddb.Reader
	ASN     *maxminddb.Reader
}

type Domain

type Domain struct {
	Domain string `maxminddb:"domain"`
}

type IPCache

type IPCache struct {
	ASNOrg    string
	Country   string
	City      string
	Domains   []string
	ThreatCat string
}

func CheckIP

func CheckIP(ip string) (IPCache, bool)

TODO - Measure performance and compare to using sync.Map instead

type RunningJobs

type RunningJobs struct {
	JobCount int
	Mw       sync.RWMutex
}

Used to help keep track of jobs in a WaitGroup

func (*RunningJobs) AddJob

func (job *RunningJobs) AddJob()

func (*RunningJobs) GetJobs

func (job *RunningJobs) GetJobs() int

func (*RunningJobs) SubJob

func (job *RunningJobs) SubJob()

type SizeTracker

type SizeTracker struct {
	InputSizeMBytes      int
	OutputSizeMBytes     int
	Mw                   sync.RWMutex
	ActualFilesProcessed int
}

Used to track overall data size processed by the script - accessed by multiple goroutines concurrently so we make it threadsafe

func (*SizeTracker) AddBytes

func (s *SizeTracker) AddBytes(in int, out int)

type WaitGroupCount

type WaitGroupCount struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

Should probably get rid of all of the below since it really isn't necessary now that we are using the jobs tracker instead of this to limit concurrency maxes ////

func (*WaitGroupCount) Add

func (wg *WaitGroupCount) Add(delta int)

func (*WaitGroupCount) Done

func (wg *WaitGroupCount) Done()

func (*WaitGroupCount) GetCount

func (wg *WaitGroupCount) GetCount() int

Jump to

Keyboard shortcuts

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