Documentation ¶
Index ¶
- func AlphabetizeConstraints(constraints map[string]*KeyConstraint) []string
- func AlphabetizeKeyData(keyData map[string]*KeyData) []string
- func AlphabetizeSettings(settings map[string]*ServerSetting) []string
- func BuildKey(s string) map[string]string
- func DnsKeyData() map[string]*KeyData
- func GenerateSHA256(s string) string
- func GenerateSHA512(s string) string
- func GetToday() string
- func HttpKeyData() map[string]*KeyData
- func ReadFile(path string) ([]byte, error)
- type DnsServer
- type HttpServer
- type Key
- func (k *Key) ClearHits()
- func (k *Key) GetDnsKeyConstraints() map[string]*KeyConstraint
- func (k *Key) GetHits() int
- func (k *Key) GetHttpKeyConstraints() map[string]*KeyConstraint
- func (k *Key) HitLimitDnsConstraint(constraint string, q *dns.Question) bool
- func (k *Key) HitLimitHttpConstraint(constraint string, r *http.Request) bool
- func (k *Key) HitMaxDnsConstraint(constraint string, q *dns.Question) bool
- func (k *Key) HitMaxHttpConstraint(constraint string, r *http.Request) bool
- func (k *Key) IsActive(r *http.Request, q *dns.Question) (bool, string)
- func (k *Key) TimeDnsConstraint(constraint string, q *dns.Question) bool
- func (k *Key) TimeHttpConstraint(constraint string, r *http.Request) bool
- func (k *Key) UpdateHits()
- func (k *Key) UserAgentHttpConstraint(constraint string, r *http.Request) bool
- type KeyConstraint
- type KeyData
- type ServerSetting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlphabetizeConstraints ¶
func AlphabetizeConstraints(constraints map[string]*KeyConstraint) []string
AlphabetizeConstraints takes in a map of KeyData and returns the keys/names in alphabetical order.
func AlphabetizeKeyData ¶
AlphabetizeKeyData takes in a map of KeyData and returns the keys/names in alphabetical order.
func AlphabetizeSettings ¶
func AlphabetizeSettings(settings map[string]*ServerSetting) []string
AlphabetizeSettings takes in a map of ServerSettings and returns the keys/names in alphabetical order.
func BuildKey ¶
BuildKey takes the string data and generates all supported hashes A map with the hash type as key and hash as value is returned
func DnsKeyData ¶
func GenerateSHA256 ¶
GenerateSHA256 takes a string, generates a SHA256 hash and sends back as hex string
func GenerateSHA512 ¶
GenerateSHA512 takes a string, generates a SHA512 hash and sends back as hex string
func HttpKeyData ¶
Types ¶
type DnsServer ¶
type DnsServer struct { State map[string]*ServerSetting Server *dns.Server Keys map[string]*Key DefaultTTL uint Running bool SendingKey bool }
DnsServer struct, uses following map keys for modifiable settings "Listen": listening IP address "Domain": the root level domain name we're authoratative over "DefaultTTL": default Time To Live (TTL) for DNS responses
func GetDnsServer ¶
func GetDnsServer() *DnsServer
GetDnsServer returns a starting point for the DnsServer and DnsState structs for use throughout keyserver
func (*DnsServer) AddKey ¶
AddKey does the fun stuff, takes in the data generates the hasehs and adds it to the end of the Keys slice within the HttpServer
func (*DnsServer) AppendResult ¶
AppendResult prepares response for ServeDNS Taken directly from OJ's code
type HttpServer ¶
type HttpServer struct { Server *http.Server State map[string]*ServerSetting Keys map[string]*Key Running bool }
HttpServer struct, uses following map keys for modifiable settings "Listen": listening IP address "Port": listening port "DefaultPage": default page returned with no key matchings "ServerHeader": option HTTP response 'Server' header
func GetHttpServer ¶
func GetHttpServer() *HttpServer
GetHttpServer returns a starting point for the HttpServer and HttpState structs for use throughout keyserver
func (*HttpServer) AddKey ¶
func (h *HttpServer) AddKey(k *Key, name string) error
AddKey does the fun stuff, takes in the data generates the hasehs and adds it to the end of the Keys slice within the HttpServer
func (*HttpServer) ServeHTTP ¶
func (h *HttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP allows SubHTTPServer to handle http requests The requested URL path needs to match a key's Data["URL"].Value to evaluate the Key
func (*HttpServer) StartHTTP ¶
func (h *HttpServer) StartHTTP()
StartHTTP is the exported function to call and get the HTTP server running.
func (*HttpServer) StartHTTPS ¶
func (h *HttpServer) StartHTTPS()
StartHTTPS is the exported function to call and get the HTTPS/TLS server running.
type Key ¶
type Key struct { Type string On bool Disabled bool SendAlerts bool HitCounter map[string]int LastHit string Data map[string]*KeyData Constraints map[string]*KeyConstraint Hashes map[string]string }
Key contains attributes that fit both Http and Dns keys
func (*Key) GetDnsKeyConstraints ¶
func (k *Key) GetDnsKeyConstraints() map[string]*KeyConstraint
func (*Key) GetHits ¶
GetHits returns the hit counter but ensures theres an entry for the current day.
func (*Key) GetHttpKeyConstraints ¶
func (k *Key) GetHttpKeyConstraints() map[string]*KeyConstraint
GetHttpKeyConstraints returns all possible key constraints for an HttpKey
func (*Key) HitLimitDnsConstraint ¶
HitLimitDnsConstraint is a key constraint that returns true if the number of hits is below the supplied limit
func (*Key) HitLimitHttpConstraint ¶
HitLimitHttpConstraint is a key constraint that returns true if the number of hits is below the supplied limit
func (*Key) HitMaxDnsConstraint ¶
HitMaxDnsConstraint is a key constraint that returns true if the number of hits is above the supplied value
func (*Key) HitMaxHttpConstraint ¶
HitMaxHttpConstraint is a key constraint that returns true if the number of hits is above the supplied value
func (*Key) IsActive ¶
IsActive determines whether a key is active for the HttpServer The string returned is the "reason" the key is active or inactive, manually turned on or due to a constraint
func (*Key) TimeDnsConstraint ¶
TimeConstraint is a key constraint that returns true if the current time falls within a specified timeframe. DNS request data not needed as we just want the current time.
func (*Key) TimeHttpConstraint ¶
TimeHttpConstraint is a key constraint that returns true if the current time falls within a specified timeframe. http.Request data not needed as we just want the current time.
func (*Key) UpdateHits ¶
func (k *Key) UpdateHits()
UpdateHits updates the HitCounter for the current day