server

package
v0.0.0-...-32d98f7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultIpLookupTimeout = 2 * time.Second
	DefaultTimeout         = 5 * time.Second
)

Functions

func IncrIPLookupMetrics

func IncrIPLookupMetrics(status string)

func IncrRespMetrics

func IncrRespMetrics(inputType, respBy, respType string)

func MetricMiddleware

func MetricMiddleware(h http.HandlerFunc) http.HandlerFunc

MetricMiddleware is middlerware to record prometheus metrics for http request

func MetricRegister

func MetricRegister(registerer prometheus.Registerer)

MetricRegister register metrics when server starts

func MetricRegisterOn

func MetricRegisterOn(registerer prometheus.Registerer)

MetricRegisterOn register needed promutheus metrics on given registerer

func MetricUnRegister

func MetricUnRegister(registerer prometheus.Registerer)

MetricUnRegister unregister metrics when server shutdown

func MetricUnRegisterFrom

func MetricUnRegisterFrom(registerer prometheus.Registerer)

MetricUnRegisterFrom unregister metrics from registerer

func WhoisHandler

func WhoisHandler(cli *whois.Client, resolver *Resolver, acsLogger logrus.FieldLogger) http.HandlerFunc

WhoisHandler handles POST requests to 'apiWhoisPath'

Types

type IP

type IP struct {
	Type string `json:"type,omitempty"`
	IP   string `json:"ip,omitempty"`
}

IP is the output structure for ips in InternalWhoisResp

type Resolver

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

Resolver controls lookups ips for given domain

func NewResolver

func NewResolver(timeout time.Duration) *Resolver

NewResolver initializes resolver and lookup timeout

func (*Resolver) Lookup

func (ip *Resolver) Lookup(ctx context.Context, domain string, tsFmt string) (ips []IP, err error)

Lookup lookups ipv4s and ipv6s for given domain, return in API output format

type Server

type Server struct {
	Killed chan struct{}
	// contains filtered or unexported fields
}

Server is whois api server to interact with database, cache, logger, ...

func New

func New(cfg *ServerCfg, errLogger, acsLogger logrus.FieldLogger) (*Server, error)

New initialize whois api server

func (*Server) Close

func (s *Server) Close()

Close will close the server and wait for fully killed signal

func (*Server) Start

func (s *Server) Start(servAddr, metricAddr string)

Start starts whois api server and listen for the stop signal to control lifetime of server

type ServerCfg

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

func NewServerCfg

func NewServerCfg(iptimeout, timeout time.Duration) *ServerCfg

type WhoisIPResp

type WhoisIPResp struct {
	Whois *wip.Whois `json:"whois"`
	Type  string     `json:"type"`
	Notes struct {
		OriginalQuery string `json:"query"`
		Error         string `json:"error,omitempty"`
	} `json:"notes"`
	QueriedDate string `json:"queried_date"`
}

WhoisIPResp represent whois response format for ip

type WhoisReq

type WhoisReq struct {
	Query       string `json:"query"`
	IP          bool   `json:"ip"`
	WhoisServer string `json:"whois_server"`
}

WhoisReq represents whois requests from user

type WhoisResp

type WhoisResp struct {
	Whois *wd.Whois `json:"whois"`
	Type  string    `json:"type"`
	Notes struct {
		OriginalQuery string   `json:"query"`
		PublicSuffixs []string `json:"public_suffixs,omitempty"`
		Error         string   `json:"error,omitempty"`
	} `json:"notes"`
	IP          []IP   `json:"ip,omitempty"`
	QueriedDate string `json:"queried_date"`
}

WhoisResp represent whois response format

Jump to

Keyboard shortcuts

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