runtime

package
v0.0.0-...-b188132 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleTypeNSnitch = iota
	ModuleTypeRecursor
	ModuleTypeAuthority
	ModuleTypeUnknown
)
View Source
const (
	KEY_NAME     = "name"
	KEY_DATA     = "data"
	KEY_HOSTNAME = "hostname"
)
View Source
const (
	EvtTypeCount   = 1
	EvtTypeCard    = 2
	EvtTypeLatency = 3
)
View Source
const (
	STATE_NODE = iota
	STATE_PUBLISHED
	STATE_UPDATED
	STATE_ADDRESS
)
View Source
const DB_TEMPLATE_VERSION = "geo-key-%s"
View Source
const KEY_GEODB_UPDATED = "geodb-updated-time"
View Source
const KEY_START_TIME = "start-time"
View Source
const LIMITER_RPS_THRESHOLD = 500
View Source
const PORT_DISABLED = -1
View Source
const PORT_UNSET = 0
View Source
const UPDATE_DELAY = time.Minute
View Source
const URL_TEMPLATE = "https://download.maxmind.com/app/geoip_download?edition_id=%s&suffix=%s&license_key=%s"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorityConfig

type AuthorityConfig struct {
	Base       Config
	ConfigFile string
	Domains    map[string]*ServerDomain
	ZonesPath  string
	Zones      *zones.ZoneSet
}

type Config

type Config struct {
	DatabasePath      string
	DatabaseTTL       int64
	IncludePath       string
	MaxmindKey        string
	GeoDBPath         string
	TorUrl            string
	LookupCreds       map[string]string
	AdminCreds        map[string]string
	Peers             map[string]anycast.Peer
	BGP               anycast.BGPConfig
	Netblocks         map[string]common.Netblock
	DefaultHttpPort   int
	DefaultHttpsPort  int
	DefaultDnsUdpPort int
	DefaultDnsTcpPort int
	DefaultDnsTlsPort int
	RateThreshold     uint64
	OutboundIPs       []string
	SlackFeedback     map[string]string
}

type ConfigHolder

type ConfigHolder struct {
	MasterConfig Config
	NSnitchs     []NSnitchConfig
	Recursors    []RecursorConfig
	Authorities  []AuthorityConfig
}

func ParseConfig

func ParseConfig(path string, checkonly bool, ignoreplatform bool) ConfigHolder

type ErrNotStarted

type ErrNotStarted struct{}

func (*ErrNotStarted) Error

func (e *ErrNotStarted) Error() string

type ErrResponseTimeout

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

func (*ErrResponseTimeout) Error

func (e *ErrResponseTimeout) Error() string

type Event

type Event struct {
	Key   string
	Type  EventType
	Count uint64
	Value []byte
	Time  uint64
}

type EventType

type EventType uint8

type ExitAddress

type ExitAddress struct {
	IP   string
	Date *time.Time
}

type FailureNotifier

type FailureNotifier func()

type Feedback

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

func StartFeedback

func StartFeedback(cfg Config, rt *Runtime) *Feedback

func (*Feedback) SendFeedback

func (f *Feedback) SendFeedback(p *Payload)

func (*Feedback) SendMessage

func (f *Feedback) SendMessage(s, opDetails string)

func (*Feedback) Stop

func (f *Feedback) Stop()

type Geo

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

func StartGeo

func StartGeo(cfg Config, rt *Runtime, dummy bool) *Geo

func (*Geo) Query

func (g *Geo) Query(ip string) *Query

func (*Geo) Reload

func (g *Geo) Reload()

type Limiter

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

func StartLimiter

func StartLimiter(offset uint64) *Limiter

func (*Limiter) Count

func (l *Limiter) Count(key string)

func (*Limiter) CountAndPass

func (l *Limiter) CountAndPass(ip net.IP) bool

func (*Limiter) Stop

func (l *Limiter) Stop()

type NSnitchConfig

type NSnitchConfig struct {
	Base         Config
	ConfigFile   string
	Domains      map[string]*ServerDomain
	Node         NodeConfig
	RedirectMode string
	WordListPath string
	CorsDomains  []string
	Blacklists   []string
	BlacklistTTL int64
}

type NodeConfig

type NodeConfig struct {
	City       string
	State      string
	Country    string
	CountryISO string
	Latitude   float32
	Longitude  float32
	ISP        string
	AS         uint
	Org        string
	TimeZone   string
}

func (*NodeConfig) MakeNodeLoc

func (cfg *NodeConfig) MakeNodeLoc() *common.GeoLocation

type Payload

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

func NewPayload

func NewPayload(operator, dom, err, stack string) *Payload

func (*Payload) LongEncode

func (p *Payload) LongEncode(op string) []byte

func (*Payload) ShortEncode

func (p *Payload) ShortEncode(op string) []byte

type PerSecond

type PerSecond struct {
	Component string
	Type      string
	Count     uint64
}

type Pool

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

func StartIPPool

func StartIPPool(cfgIPs []string) *Pool

func (*Pool) RandomizeTCPDialer

func (p *Pool) RandomizeTCPDialer() *net.Dialer

func (*Pool) RandomizeUDPDialer

func (p *Pool) RandomizeUDPDialer() *net.Dialer

type Query

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

func (*Query) Response

func (q *Query) Response() (*common.GeoLocation, error)

type RecursorConfig

type RecursorConfig struct {
	Base       Config
	ConfigFile string
	Domains    map[string]*ServerDomain
	OpenNic    bool
}

type Runtime

type Runtime struct {
	DB     *leveldb.DB
	Geo    *Geo
	Stats  *Stats
	IPPool *Pool

	RateLimiter *Limiter
	SlackWH     *Feedback
	// contains filtered or unexported fields
}

noinspection GoNameStartsWithPackageName

func NewRuntime

func NewRuntime(cfg Config) *Runtime

func (*Runtime) AddService

func (rt *Runtime) AddService()

func (*Runtime) DBGet

func (rt *Runtime) DBGet(key []byte) (value []byte, err error)

func (*Runtime) DBPut

func (rt *Runtime) DBPut(key, value []byte) (err error)

func (*Runtime) OnFinished

func (rt *Runtime) OnFinished(fn finisher)

func (*Runtime) OnFinishedOrPanic

func (rt *Runtime) OnFinishedOrPanic(fn finisher, pchan chan interface{})

func (*Runtime) Shutdown

func (rt *Runtime) Shutdown()

type ServerDomain

type ServerDomain struct {
	HostName    string
	IPv4        string
	IPv6        string
	CertFile    string
	KeyFile     string
	NameServers []string
	HttpPort    int
	HttpsPort   int
	DnsUdpPort  int
	DnsTcpPort  int
	DnsTlsPort  int
}

type Stats

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

func StartStats

func StartStats(rt *Runtime) *Stats

func (*Stats) AddBroadcastWatcher

func (s *Stats) AddBroadcastWatcher() chan map[string]interface{}

func (*Stats) Card

func (s *Stats) Card(key, value string)

func (*Stats) Count

func (s *Stats) Count(key string)

func (*Stats) CountN

func (s *Stats) CountN(key string, increment uint64)

func (*Stats) Latency

func (s *Stats) Latency(key string, value uint64)

func (*Stats) ListKeys

func (s *Stats) ListKeys(rt *Runtime) (*[]string, error)

func (*Stats) Stop

func (s *Stats) Stop()

func (*Stats) Tick

func (s *Stats) Tick(component, action_type string)

func (*Stats) TickN

func (s *Stats) TickN(component string, action_type string, count uint64)

type TorHash

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

func NewTorHash

func NewTorHash() *TorHash

func (*TorHash) Add

func (t *TorHash) Add(node *TorNode)

func (*TorHash) Exists

func (t *TorHash) Exists(ip string) (string, bool)

func (*TorHash) Len

func (t *TorHash) Len() int

type TorNode

type TorNode struct {
	NodeId    string
	Published *time.Time
	Updated   *time.Time
	Addresses []ExitAddress
}

func NewTorNode

func NewTorNode() *TorNode

Jump to

Keyboard shortcuts

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