Back to godoc.org
go.mozilla.org/iprepd

package iprepd

v0.0.0 (72fb42f)
Latest Go to latest
Published: May 26, 2020 | License: MPL-2.0 | Module: go.mozilla.org/iprepd

Index

Constants

const (
	// TypeIP is the object type for IP addresses
	TypeIP = "ip"

	// TypeEmail is the object type for email addresses
	TypeEmail = "email"
)

func StartDaemon

func StartDaemon(confpath string)

StartDaemon starts a new instance of iprepd using configuration file confpath.

type Client

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

Client is the iprepd service client

func NewClient

func NewClient(url, token string, httpClient *http.Client) (*Client, error)

NewClient is the default constructor for the client

func (*Client) ApplyViolation

func (c *Client) ApplyViolation(vr *ViolationRequest) error

ApplyViolation submits a ViolationRequest to iprepd

func (*Client) BatchApplyViolation

func (c *Client) BatchApplyViolation(typ string, vrs []ViolationRequest) error

BatchApplyViolation submits a batch of ViolationRequests to iprepd

func (*Client) DeleteReputation

func (c *Client) DeleteReputation(objectType, object string) error

DeleteReputation deletes the reputation of a given object and type

func (*Client) Dump

func (c *Client) Dump() ([]Reputation, error)

Dump retrieves all reputation entries

func (*Client) GetReputation

func (c *Client) GetReputation(objectType, object string) (*Reputation, error)

GetReputation fetches the reputation of a given object and type

func (*Client) GetViolations

func (c *Client) GetViolations() ([]Violation, error)

GetViolations gets all existing violations on the server

func (*Client) Heartbeat

func (c *Client) Heartbeat() (bool, error)

Heartbeat checks whether an IPrepd deployment is healthy / reachable

func (*Client) LBHeartbeat

func (c *Client) LBHeartbeat() (bool, error)

LBHeartbeat checks whether an IPrepd LB is healthy / reachable

func (*Client) SetReputation

func (c *Client) SetReputation(r *Reputation) error

SetReputation updates the reputation of a given object and type to a given score

func (*Client) Version

func (c *Client) Version() (*VersionResponse, error)

Version retrieves the version of the IPrepd deployment

type Reputation

type Reputation struct {
	// Object is the object associated with the reputation entry. For example
	// if the type is "ip", object will be an IP address.
	Object string `json:"object"`

	// Type describes the type of object the reputation entry is for
	Type string `json:"type"`

	// Reputation is the reputation score for the object, ranging from 0 to
	// 100 where 100 indicates no violations have been applied to it.
	Reputation int `json:"reputation"`

	// Reviewed is true if the entry has been manually reviewed, this flag indicates
	// a firm confidence in the entry.
	Reviewed bool `json:"reviewed"`

	// LastUpdated indicates when a reputation was last either set manually or via
	// a violation on this entry
	LastUpdated time.Time `json:"lastupdated"`

	// DecayAfter is used to temporarily stop reputation recovery until after the
	// current time has passed the time indicated by DecayAfter. This can be used
	// to for example enforce a mandatory minimum reputation decrease for an object
	// for a set period of time.
	DecayAfter time.Time `json:"decayafter,omitempty"`
}

Reputation stores information related to the reputation of a given object

func (*Reputation) Validate

func (r *Reputation) Validate() error

Validate performs validation of a Reputation type.

type VersionResponse

type VersionResponse struct {
	Commit  string `json:"commit"`
	Version string `json:"version"`
	Source  string `json:"source"`
	Build   string `json:"build"`
}

VersionResponse is the response payload from the /__version__ endpoint

type Violation

type Violation struct {
	// Name of violation as specified in iprepd cfg
	Name string `json:"name"`

	// Penalty is how many points a reputation will be decreased by if this
	// violation is submitted for an object
	Penalty int `json:"penalty"`

	// DecreaseLimit is the lowest possible value this violation will decrease a
	// reputation to. Since the same violation can be applied multiple times to
	// the same object, this can be used to place a lower bound on the total decrease.
	DecreaseLimit int `json:"decreaselimit"`
}

Violation describes a violation penalty that can be applied to an object.

type ViolationRequest

type ViolationRequest struct {
	// The violation name to be applied
	Violation string `json:"violation,omitempty"`

	// The object the violation should be applied to.
	Object string `json:"object,omitempty"`

	// The type of object (e.g., ip).
	Type string `json:"type,omitempty"`

	// An optional recovery suppression value in seconds. If set, it indicates the
	// number of seconds which must pass before the reputation for the object will
	// begin to recover.
	SuppressRecovery int `json:"suppress_recovery,omitempty"`

	// The IP field supports reverse compatibility with older clients. It is essentially
	// the same thing as passing an IP address in the object field, with a type set to
	// ip.
	IP string `json:"ip,omitempty"`
}

ViolationRequest represents the structure used to apply a violation to a given object. This structure is used as the basis for unmarshaling requests to violation handlers in the API.

func (*ViolationRequest) Fixup

func (v *ViolationRequest) Fixup(typestr string)

Fixup is used to convert legacy format violations

func (*ViolationRequest) Validate

func (v *ViolationRequest) Validate() error

Validate performs validation of a ViolationRequest type

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier