search

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the API search client for certs.io

func NewClient

func NewClient(cfg config.Config) *Client

NewClient returns a new API client.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query *Query) ([]certificate.Certificate, error)

Search performs a search and wraps the searchWithCtx method.

func (*Client) StreamSearchResults

func (c *Client) StreamSearchResults(ctx context.Context, query *Query, resultChan chan<- []certificate.Certificate) error

StreamSearchResults performs a search with a context

func (*Client) WithBaseURL

func (c *Client) WithBaseURL(baseURL string) *Client

WithBaseURL sets the base URL for API requests.

func (*Client) WithMaxPages

func (c *Client) WithMaxPages(maxPages uint64) *Client

WithMaxPages sets the maximum number of pages to return.

func (*Client) WithRetries

func (c *Client) WithRetries(retries int) *Client

WithRetries sets the maximum number of retries for API requests.

func (*Client) WithTimeout

func (c *Client) WithTimeout(timeout time.Duration) *Client

WithTimeout sets the timeout for API requests.

type Config

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

type Field

type Field string

Field is a search field.

const (
	// ByDomain searches for certificates by domain.
	ByDomain Field = "domain"
	// ByIP searches for certificates by IP address:port.
	ByServer Field = "server"
	// ByFingerprint searches for certificates by SHA256 fingerprint.
	ByFingerprint Field = "fingerprint_sha256"
	// ByEmail searches for certificates by email address.
	ByEmails Field = "emails"
	// ByIssuer searches for certificates by organization.
	ByOrg Field = "org"
	// BySerial searches for certificates by serial number.
	BySerial Field = "serial"
	// ByCertNames searches for certificates by common name or subject alternative name.
	ByCertNames Field = "ssl_names"
)

func (Field) String

func (f Field) String() string

String returns the string representation of a Field.

type Query

type Query struct {
	Field Field  `json:"field"`
	Value string `json:"term"`
	Page  uint64 `json:"page,omitempty"`
}

Query is the search query for the certs.io API.

type Response

type Response struct {
	Total        uint64                    `json:"total_certificates"`
	Pages        uint64                    `json:"total_pages"`
	CurrentPage  uint64                    `json:"page"`
	Certificates []certificate.Certificate `json:"certificates"`
}

Response is the response from the certs.io API.

type Transport

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

Transport is the HTTP transport for the certs.io API.

func NewTransport

func NewTransport(cfg TransportConfig) *Transport

NewTransport returns a new HTTP transport.

func (*Transport) POST

func (t *Transport) POST(url string, body []byte) (*http.Response, error)

POST performs a POST request to the certs.io API with retries.

type TransportConfig

type TransportConfig struct {
	HTTPTransport http.RoundTripper
	RetryBackoff  func(attempt int) time.Duration
	MaxRetries    int
	ApiKey        string
}

TransportConfig is the configuration for the HTTP transport.

Jump to

Keyboard shortcuts

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