Documentation ¶
Index ¶
- Constants
- func CreateServerRuntime(confpath string)
- func StartDaemon(confpath string)
- type Client
- func (c *Client) ApplyViolation(vr *ViolationRequest) error
- func (c *Client) BatchApplyViolation(typ string, vrs []ViolationRequest) error
- func (c *Client) DeleteReputation(objectType, object string) error
- func (c *Client) Dump() ([]Reputation, error)
- func (c *Client) GetReputation(objectType, object string) (*Reputation, error)
- func (c *Client) GetViolations() ([]Violation, error)
- func (c *Client) Heartbeat() (bool, error)
- func (c *Client) LBHeartbeat() (bool, error)
- func (c *Client) SetReputation(r *Reputation) error
- func (c *Client) Version() (*VersionResponse, error)
- type Reputation
- type ServerCfg
- type VersionResponse
- type Violation
- type ViolationRequest
Constants ¶
const ( // TypeIP is the object type for IP addresses TypeIP = "ip" // TypeEmail is the object type for email addresses TypeEmail = "email" )
Variables ¶
This section is empty.
Functions ¶
func CreateServerRuntime ¶
func CreateServerRuntime(confpath string)
func StartDaemon ¶
func StartDaemon(confpath string)
StartDaemon starts a new instance of iprepd using configuration file confpath.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the iprepd service 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 ¶
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 ¶
GetViolations gets all existing violations on the server
func (*Client) LBHeartbeat ¶
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 RepDump ¶
func RepDump() (ret []Reputation, err error)
func (*Reputation) Validate ¶
func (r *Reputation) Validate() error
Validate performs validation of a Reputation type.
type ServerCfg ¶
type ServerCfg struct { Listen string Redis struct { Addr string Replicas []string ReadTimeout int WriteTimeout int DialTimeout int MaxPoolSize int MinIdleConn int } Auth struct { DisableAuth bool Hawk map[string]string APIKey map[string]string ROHawk map[string]string ROAPIKey map[string]string } IP6Prefix int Violations []Violation Decay struct { Points int Interval time.Duration } Exceptions struct { File []string AWS bool } VersionResponse string Statsd struct { Addr string } Sync struct { MaxLimit int MinimumReputation int DeleteFile bool GCS struct { Filename string Bucketname string } } }
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