greynoise

package module
v0.0.0-...-953be2b Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

README

gogreynoise Go Report Card

Golang client for Greynoise.io. The client currently only implements /context, but it is easy to extend other features.

Usage

package greynoise

import (
        "fmt"
        "net"

        greynoise "github.com/dutchcoders/gogreynoise"
)

func ExampleExamples_output() {
        client, err := greynoise.New(
                greynoise.WithKey("{key}"),
        )
        if err != nil {
                panic(err.Error)
        }

        ip := net.ParseIP("8.8.8.8")
        result, err := client.Context(ip)
        if err != nil {
                panic(err.Error)
        }

        fmt.Printf("Actor: %s\n", result.Actor)
}

Contributors

Code released under Apache License 2.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(dest interface{}, src interface{}) error

func WithKey

func WithKey(key string) optionFn

WithKey contains the Greynoise API key

Types

type Client

type Client struct {
	Key string

	*http.Client
	// contains filtered or unexported fields
}

func New

func New(options ...optionFn) (*Client, error)

New returns a Greynoise API client

func (*Client) Context

func (c *Client) Context(ip net.IP) (*ContextResult, error)

Context will return more information about a given IP address. Returns time ranges, IP metadata (network owner, ASN,reverse DNS pointer, country), associated actors, activity tags, and raw port scan and web request information.

func (*Client) Do

func (wd *Client) Do(req *http.Request, v interface{}) error

Do will execute the http.Request and decode the result

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest prepares http.Request to call the Greynoise API

type ContextResult

type ContextResult struct {
	Actor     string `json:"actor"`
	FirstSeen string `json:"first_seen"`
	IP        string `json:"ip"`
	LastSeen  string `json:"last_seen"`
	Metadata  struct {
		ASN          string `json:"asn"`
		Category     string `json:"category"`
		City         string `json:"city"`
		Country      string `json:"country"`
		CountryCode  string `json:"country_code"`
		Organization string `json:"organization"`
		Os           string `json:"os"`
		Rdns         string `json:"rdns"`
		Tor          bool   `json:"tor"`
	} `json:"metadata"`
	RawData struct {
		Scan []struct {
			Port     int64  `json:"port"`
			Protocol string `json:"protocol"`
		} `json:"scan"`
		Web struct {
		} `json:"web"`
	} `json:"raw_data"`
	Seen bool     `json:"seen"`
	Tags []string `json:"tags"`
}

ContextResult is the result of the /context api

type Error

type Error struct {
	ErrorCode   int    `json:"error_code"`
	ErrorString string `json:"error"`
}

func (*Error) Error

func (de *Error) Error() string

type ErrorResult

type ErrorResult struct {
	Error string `json:"error"`
}

ErrorResult is the result when an error occurs

Jump to

Keyboard shortcuts

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