Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) AddHost(ctx context.Context, id HostIdentifier) (err error)
- func (c *Client) GetAllInteractions(ctx context.Context, id HostIdentifier) (interactions []Interaction, err error)
- func (c *Client) GetInteractions(ctx context.Context, id HostIdentifier) (interactions []Interaction, err error)
- type ClientOpt
- type HostIdentifier
- type Interaction
- type Poller
- type PollerOpt
Constants ¶
const ( // DefaultPollerInterval is the default interval at which // the poller will poll the server. DefaultPollerInterval = 1 * time.Second )
Variables ¶
var ( // ErrInvalidAddress is returned when the blind host address cannot // be parsed as a valid address. ErrInvalidAddress = errors.New("invalid address") // ErrMissingScheme is returned when the blind host address is missing the scheme. ErrMissingScheme = errors.New("missing scheme") // ErrMissingHost is returned when the blind host address is missing the host. ErrMissingHost = errors.New("missing host") // ErrAddHost is returned when the client failed to add a host. ErrAddHost = errors.New("failed to add host") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a client that can interact with the blind host server to add hosts and retrieve interactions.
func (*Client) AddHost ¶
func (c *Client) AddHost(ctx context.Context, id HostIdentifier) (err error)
AddHost adds a new interaction host to the blind host server.
func (*Client) GetAllInteractions ¶
func (c *Client) GetAllInteractions(ctx context.Context, id HostIdentifier) (interactions []Interaction, err error)
GetAllInteractions retrieves all the interactions detected for the interaction host with the given HostIdentifier.
func (*Client) GetInteractions ¶
func (c *Client) GetInteractions(ctx context.Context, id HostIdentifier) (interactions []Interaction, err error)
GetInteractions retrieves the new interactions (since last retrieval) detected for the interaction host with the given HostIdentifier.
type ClientOpt ¶
type ClientOpt func(*Client)
ClientOpt is an option to modify a Client.
func WithClient ¶
WithClient is a ClientOpt that sets the given *http.Client as the inner client of the Client. If not provided, the default client is the http.DefaultClient.
type HostIdentifier ¶
HostIdentifier is a unique identifier for an interaction host.
func RandomHostIdentifier ¶
func RandomHostIdentifier() HostIdentifier
RandomHostIdentifier generates a random host identifier by using the Google's UUIDv4 generation library (github.com/google/uuid).
func (HostIdentifier) HostBaseURL ¶
func (h HostIdentifier) HostBaseURL(base string) string
HostBaseURL calculates the base URL of the interaction host, given a base URL.
func (HostIdentifier) HostReqURL ¶
func (h HostIdentifier) HostReqURL(scheme, base, uid string) string
HostReqURL calculates the request URL of the interaction host, given a base URL and a unique identifier. This can be used to uniquely identify each interaction with the interaction host.
func (HostIdentifier) ID ¶
func (h HostIdentifier) ID() string
ID returns the first 8 characters of the interaction host identifier, considered as the id.
func (HostIdentifier) PrivateKey ¶
func (h HostIdentifier) PrivateKey() string
PrivateKey returns the interaction host identifier (UUIDv4) as a string.
type Interaction ¶
type Interaction struct { ID string `json:"id"` Timestamp time.Time `json:"timestamp"` Protocol string `json:"protocol"` Type string `json:"type"` RemoteAddress string `json:"remoteAddress"` RawRequest string `json:"rawRequest"` RawResponse string `json:"rawResponse"` NRequest string `json:"nRequest"` }
Interaction holds all the information that represents an interaction between an HTTP client and the blind host server.
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller is a poller that polls the server for new interactions every DefaultPollerInterval and keeps them in memory.
func NewPoller ¶
NewPoller creates a new poller. It is recommended to use this function instead of creating a poller manually.
The poller will poll the server every DefaultPollerInterval by default.
Use the PollerOpt functions to change the default behaviour.
func (*Poller) BruteSearch ¶
func (p *Poller) BruteSearch(substr string) *Interaction
BruteSearch is like [Search], but searches in all interactions, not just the ones that were polled and kept in memory.
func (*Poller) Close ¶
func (p *Poller) Close()
Close stops the poller. Either use this function or manage a cancellable context yourself.
func (*Poller) Search ¶
func (p *Poller) Search(substr string) *Interaction
Search searches for any interaction that contains the given [substr] in the interaction's request. E.g. in headers, like: Host: [substr]-[id].bh.com.
type PollerOpt ¶
type PollerOpt func(*Poller)
PollerOpt is a function that can be used to change the default behaviour of a poller.
func WithContext ¶
WithContext sets the context of the poller.
func WithHostIdentifier ¶
func WithHostIdentifier(hid HostIdentifier) PollerOpt
WithHostIdentifier sets the host identifier of the poller.
func WithInterval ¶
WithInterval sets the interval at which the poller will poll the server.
func WithRegistrationDisabled ¶
func WithRegistrationDisabled() PollerOpt
WithRegistrationDisabled disables the poller's host registration.