Documentation ¶
Overview ¶
Package server implements an HTTPS web server. The configuration is idiosyncratic, and not intended to be suitable for everyone.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Location ¶ added in v0.14.2
Location returns both the registered and location country codes for the current request, if they are different.
func Registered ¶ added in v0.14.2
Registered returns the registered country codes for the current request.
Types ¶
type GeoBlocker ¶ added in v0.14.1
type GeoBlocker struct { Allow bool // permit only specified countries, instead of blocking them ErrorLog *log.Logger Reporter func(r *http.Request, location string, ip net.IP) string ReportSingle bool // report just location or registered country, not both Store string // storage location for database // contains filtered or unexported fields }
GeoBlocker holds the parameters and state for geo-blocking. Typically only one is needed.
func (*GeoBlocker) GeoBlock ¶ added in v0.14.1
func (gb *GeoBlocker) GeoBlock(next http.Handler) http.Handler
GeoBlock initialises and returns a handler to block IPs for some locations.
func (*GeoBlocker) Locate ¶ added in v1.2.0
func (gb *GeoBlocker) Locate(ipStr string) (country, registered string, ip net.IP)
Locate looks up a remote address in the geolocation database, and returns the countries of origin and registration.
func (*GeoBlocker) RejectsCounted ¶ added in v1.4.0
func (gb *GeoBlocker) RejectsCounted() (rejects int)
RejectsCounted returns a statistic of the total number of requests rejected, and resets the count.
func (*GeoBlocker) Start ¶ added in v0.14.1
func (gb *GeoBlocker) Start(countries []string)
Start initialises the geo-blocker.
type Server ¶
type Server struct { // logging ErrorLog *log.Logger InfoLog *log.Logger // HTTPS CertEmail string // notifications from Let's Encrypt CertPath string // folder for certificates Domains []string // domains to be served (empty for HTTP) // port addresses AddrHTTP string AddrHTTPS string }
Server specifies the parameters for a web server.