Documentation
¶
Overview ¶
Package greynoise is the library behind the greynoise command line: the HTTP client, request shaping, and the typed data models for the GreyNoise Community API.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public API throws under load. Build your endpoint calls and JSON decoding on top of it.
Index ¶
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "greynoise-cli/dev (+https://github.com/tamnd/greynoise-cli)"
DefaultUserAgent identifies the client to GreyNoise. A real, honest User-Agent is both polite and the thing most likely to keep you unblocked.
const Host = "api.greynoise.io"
Host is the site this client talks to, and the host the URI driver in domain.go claims.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the GreyNoise Community API over HTTPS.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client with sensible defaults: a 30 s timeout, a 500 ms minimum gap between requests (polite for a free API), and five retries on transient errors.
func (*Client) GetIP ¶
GetIP looks up one IP address against the GreyNoise Community API.
- GET /v3/community/{ip}
type Config ¶
Config holds optional overrides a caller can pass when building a Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for a GreyNoise Community API client.
type Domain ¶
type Domain struct{}
Domain is the greynoise driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). A valid IP address (contains dots and numeric segments) maps to ("ip", ip).
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type IPInfo ¶
type IPInfo struct {
IP string `kit:"id" json:"ip"`
Noise bool `json:"noise"`
RIOT bool `json:"riot"`
Classification string `json:"classification"`
Name string `json:"name"`
Link string `json:"link"`
LastSeen string `json:"last_seen"`
Message string `json:"message"`
}
IPInfo is the record returned by a GreyNoise Community IP lookup. Fields that are absent in the response (classification, name, link, last_seen) stay as their zero value.