runtime

package
v0.0.0-...-fb72fe2 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CACHE_EVICTION_RATE = 30 /// expressed in seconds
	CACHE_OPENNIC       = "opennic"
	CACHE_IANA          = "iana"
)
View Source
const (
	KV_TLS_CAPABILITY = "tlscap"
	KV_TLS_SUPPORTED  = "tlsok"
	KV_TCP_PREFERENCE = "tcppref"
	KV_EDNS_ALLERGY   = "skipedns"
	KV_DS_RR_NUM      = "ds_rr_num"
	KV_DNSKEY_RR_NUM  = "dnskey_rr_num"
)
View Source
const (
	ModuleTypeNSnitch = iota
	ModuleTypeRecursor
	ModuleTypeAuthority
	ModuleTypeUnknown
)
View Source
const (
	KEY_NAME     = "name"
	KEY_DATA     = "data"
	KEY_HOSTNAME = "hostname"
)
View Source
const (
	SPEEDTEST_MAX_FILESIZE_EXPONENT = 16 /// 2^exponent will be the resulting filesize for speedtest (basically, we have 1, 2, 4 ... 1024)
	SPEEDTEST_ONE_UNIT              = "" /* 1024-byte string literal not displayed */
)
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 (
	ITEM_CACHE_DNSSEC_DESIGNATION = "dnssec-"
)
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

func AsMsg

func AsMsg(in interface{}) *dns.Msg

func AsRR

func AsRR(in interface{}) []dns.RR

func EqualTLSSupportItem

func EqualTLSSupportItem(a, b *TLSSupport) bool

func MapKey

func MapKey(prefix, suffix string) string

** Helpers and convenience methods

MapKey -- creates a key-value store key with the given prefix and suffix. (to put simply joins them with a colon char)

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
	ThreadedResolver  bool
}

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 DNSCache

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

type DNSCacheHolder

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

func StartCache

func StartCache(log *logrus.Entry, designations ...string) *DNSCacheHolder

StartCache -- Creates, starts and returns a cache object

func (*DNSCacheHolder) Get

func (d *DNSCacheHolder) Get(provider, key string) interface{}

func (*DNSCacheHolder) GetAllWithKey

func (d *DNSCacheHolder) GetAllWithKey(provider, key string) (values []interface{})

func (*DNSCacheHolder) GetBool

func (d *DNSCacheHolder) GetBool(provider, key string) (bool, bool)

func (*DNSCacheHolder) GetInt

func (d *DNSCacheHolder) GetInt(provider, key string) (int, bool)

func (*DNSCacheHolder) GetString

func (d *DNSCacheHolder) GetString(provider, key string) (string, bool)

func (*DNSCacheHolder) Insert

func (d *DNSCacheHolder) Insert(provider, domain string, rr dns.RR, extra *ItemCacheExtra)

func (*DNSCacheHolder) InsertResponse

func (d *DNSCacheHolder) InsertResponse(provider, domain string, r *dns.Msg)

func (*DNSCacheHolder) Put

func (d *DNSCacheHolder) Put(provider, key string, value interface{})

func (*DNSCacheHolder) Retrieve

func (d *DNSCacheHolder) Retrieve(provider, domain string, t uint16, dnssec bool) (ret interface{}, extra *ItemCacheExtra)

func (*DNSCacheHolder) Stop

func (d *DNSCacheHolder) Stop()

Stop -- stops caching (stops cleanup thread)

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 ItemCacheExtra

type ItemCacheExtra struct {
	Nxdomain, Nodata, Cname bool
	Redirect                []*dns.CNAME
}

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
	WellKnowns   map[string]*WellKnown
	BlacklistTTL int64
	DnsReplyv4   string
	DnsReplyv6   string
	Domain       string
}

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
	Cache          *DNSCacheHolder
	SpeedTestFiles map[int]string
	// 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
	CAAIodef    []string
	CAAIssue    []string
	CAAIWild    []string
}

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 TLSSupport

type TLSSupport struct {
	Hostname string
	Ip       string
	Zone     string
}

func NewTLSSupportItem

func NewTLSSupportItem(hostname, ip, zone string) *TLSSupport

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

type WellKnown

type WellKnown struct {
	Path     string
	Body     string
	Base64   bool
	MimeType string
}

Jump to

Keyboard shortcuts

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