Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename iprepd to repd #36

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ RUN mkdir /app && \
groupadd --gid 10001 app && \
useradd --no-create-home --uid 10001 --gid 10001 --home-dir /app app

ADD . /go/src/go.mozilla.org/iprepd
ADD . /go/src/go.mozilla.org/repd
RUN mkdir -p /app/bin && \
go build -o /app/bin/iprepd go.mozilla.org/iprepd/cmd/iprepd
GOPATH="/go" go build -o /app/bin/repd go.mozilla.org/repd/cmd/repd

COPY version.json /app/version.json

USER app
WORKDIR /app
CMD /app/bin/iprepd
CMD /app/bin/repd
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ run: compose/docker-compose.run.yml
CONFIG_VOLUME=$(shell pwd) docker-compose -f compose/docker-compose.base.yml -f compose/docker-compose.run.yml up

test: compose/docker-compose.test.yml
docker-compose -f compose/docker-compose.base.yml -f compose/docker-compose.test.yml run iprepd
docker-compose -f compose/docker-compose.base.yml -f compose/docker-compose.test.yml run repd


.PHONY: build run test
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# iprepd
# repd

iprepd is a centralized reputation daemon that can be used to store reputation information
repd is a centralized reputation daemon that can be used to store reputation information
for various objects such as IP addresses and retrieve reputation scores for the objects.

The project initially focused on managing reputation information for only IP addresses, but
Expand All @@ -12,30 +12,30 @@ mechanism. Multiple instances of the daemon can be deployed using the same Redis

## Configuration

Configuration is done through the configuration file, by default `./iprepd.yaml`. The location
Configuration is done through the configuration file, by default `./repd.yaml`. The location
can be overridden with the `-c` flag.

See [iprepd.yaml.sample](./iprepd.yaml.sample) for an example configuration.
See [repd.yaml.sample](./repd.yaml.sample) for an example configuration.

## Building the Docker image

```bash
./write_version_json.sh
docker build -t iprepd:latest .
docker build -t repd:latest .
```

Docker images are also [published](https://hub.docker.com/r/mozilla/iprepd/).
Docker images are also [published](https://hub.docker.com/r/mozilla/repd/).

```bash
docker pull mozilla/iprepd:latest
docker run -ti --rm -v `pwd`/iprepd.yaml:/app/iprepd.yaml mozilla/iprepd:latest
docker pull mozilla/repd:latest
docker run -ti --rm -v `pwd`/repd.yaml:/app/repd.yaml mozilla/repd:latest
```

## API

### Authentication

iprepd supports two forms of authentication. Clients can authenticate to the service using either
repd supports two forms of authentication. Clients can authenticate to the service using either
standard API keys, or by using [Hawk authentication](https://github.com/hapijs/hawk).

Standard API key authentication can be configured in the configuration file in the `apikey` (for
Expand All @@ -53,7 +53,7 @@ header in the `Authorization` header when making a request.

Request the reputation for an object of a given type. Responds with 200 and a JSON
document describing the reputation if found. Responds with a 404 if the object is
unknown to iprepd, or is in the exceptions list.
unknown to repd, or is in the exceptions list.

The current supported object types are `ip` for an IP address and `email` for an
email address.
Expand Down Expand Up @@ -147,7 +147,7 @@ error will be logged.

#### GET /violations

Returns violations configured in iprepd in a JSON document.
Returns violations configured in repd in a JSON document.

##### Response body

Expand Down Expand Up @@ -189,7 +189,7 @@ Return version data.

### Legacy endpoints

The initial version of iprepd focused purely on reputation management for IP addresses.
The initial version of repd focused purely on reputation management for IP addresses.
Requests to the legacy endpoints deal only with IP addresses, and are intended to maintain
compatibility with older clients.

Expand All @@ -199,7 +199,7 @@ standard endpoints with a type set to `ip`.
#### GET /10.0.0.1

Request the reputation for an IP address. Responds with 200 and a JSON document describing the
reputation if found. Responds with a 404 if the IP address is unknown to iprepd, or is in the
reputation if found. Responds with a 404 if the IP address is unknown to repd, or is in the
exceptions list.

The response body may include a `decayafter` element if the reputation for the address was changed
Expand Down
2 changes: 1 addition & 1 deletion auth.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion auth_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"bytes"
Expand Down
14 changes: 7 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"bytes"
Expand All @@ -9,7 +9,7 @@ import (
"net/http"
)

// Client is the iprepd service client
// Client is the repd service client
type Client struct {
hostURL string
authStr string
Expand Down Expand Up @@ -86,7 +86,7 @@ func (c *Client) Dump() ([]Reputation, error) {
return ret, nil
}

// Heartbeat checks whether an IPrepd deployment is healthy / reachable
// Heartbeat checks whether an repd deployment is healthy / reachable
func (c *Client) Heartbeat() (bool, error) {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/__heartbeat__", c.hostURL), nil)
if err != nil {
Expand All @@ -99,7 +99,7 @@ func (c *Client) Heartbeat() (bool, error) {
return (resp.StatusCode == http.StatusOK), nil
}

// LBHeartbeat checks whether an IPrepd LB is healthy / reachable
// LBHeartbeat checks whether an repd LB is healthy / reachable
func (c *Client) LBHeartbeat() (bool, error) {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/__lbheartbeat__", c.hostURL), nil)
if err != nil {
Expand Down Expand Up @@ -215,7 +215,7 @@ type VersionResponse struct {
Build string `json:"build"`
}

// Version retrieves the version of the IPrepd deployment
// Version retrieves the version of the repd deployment
func (c *Client) Version() (*VersionResponse, error) {
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/__version__", c.hostURL), nil)
if err != nil {
Expand Down Expand Up @@ -265,7 +265,7 @@ func (c *Client) GetViolations() ([]Violation, error) {
return v, nil
}

// ApplyViolation submits a ViolationRequest to iprepd
// ApplyViolation submits a ViolationRequest to repd
func (c *Client) ApplyViolation(vr *ViolationRequest) error {
if vr == nil {
return errors.New(clientErrViolationRequestNil)
Expand Down Expand Up @@ -302,7 +302,7 @@ func (c *Client) ApplyViolation(vr *ViolationRequest) error {
return nil
}

// BatchApplyViolation submits a batch of ViolationRequests to iprepd
// BatchApplyViolation submits a batch of ViolationRequests to repd
func (c *Client) BatchApplyViolation(typ string, vrs []ViolationRequest) error {
if typ == "" {
return errors.New(clientErrObjectTypeEmpty)
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"errors"
Expand Down
13 changes: 0 additions & 13 deletions cmd/iprepd/main.go

This file was deleted.

13 changes: 13 additions & 0 deletions cmd/repd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import (
"flag"

"go.mozilla.org/repd"
)

func main() {
confpath := flag.String("c", "./repd.yaml", "path to configuration")
flag.Parse()
repd.StartDaemon(*confpath)
}
10 changes: 5 additions & 5 deletions compose/docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ version: '3'

services:
redis:
container_name: iprepd_redis
container_name: repd_redis
image: redis:3.2
ports:
- "6379:6379"

iprepd:
container_name: iprepd_app
image: iprepd:build
repd:
container_name: repd_app
image: repd:build
build:
context: ../.
environment:
- IPREPD_TEST_REDISADDR=redis:6379
- REPD_TEST_REDISADDR=redis:6379
links:
- redis
ports:
Expand Down
4 changes: 2 additions & 2 deletions compose/docker-compose.run.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'

services:
iprepd:
repd:
volumes:
- '$CONFIG_VOLUME:/app/config/'
command: bash -c '/app/bin/iprepd -c /app/config/iprepd.yaml'
command: bash -c '/app/bin/repd -c /app/config/repd.yaml'
4 changes: 2 additions & 2 deletions compose/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: '3'

services:
iprepd:
command: bash -c 'cd /go/src/go.mozilla.org/iprepd && go test -v'
repd:
command: bash -c 'cd /go/src/go.mozilla.org/repd && go test -v'
4 changes: 2 additions & 2 deletions docker_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if [[ -n "$CIRCLE_TAG" ]]; then
tag=$CIRCLE_TAG
fi

docker tag iprepd:build mozilla/iprepd:${tag}
docker tag repd:build mozilla/repd:${tag}

docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"

docker push mozilla/iprepd:${tag}
docker push mozilla/repd:${tag}
2 changes: 1 addition & 1 deletion exception.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"bufio"
Expand Down
2 changes: 1 addition & 1 deletion http.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion http_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion redis.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"fmt"
Expand Down
6 changes: 3 additions & 3 deletions iprepd.go → repd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"fmt"
Expand Down Expand Up @@ -84,7 +84,7 @@ func (cfg *serverCfg) getViolation(v string) *Violation {
var sruntime serverRuntime

func init() {
mozlogrus.Enable("iprepd")
mozlogrus.Enable("repd")
rand.Seed(time.Now().Unix())
}

Expand All @@ -109,7 +109,7 @@ func loadCfg(confpath string) (ret serverCfg, err error) {
return ret, ret.validate()
}

// StartDaemon starts a new instance of iprepd using configuration file confpath.
// StartDaemon starts a new instance of repd using configuration file confpath.
func StartDaemon(confpath string) {
log.Infof("starting daemon")

Expand Down
6 changes: 3 additions & 3 deletions iprepd.yaml.sample → repd.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ violations:
decay:
points: 1
interval: 1s
# Exceptions control IP address exceptions in iprepd. Any IP that matches an exception will
# not be returned by iprepd if it is requested (e.g., it will effectively have a reputation
# Exceptions control IP address exceptions in repd. Any IP that matches an exception will
# not be returned by repd if it is requested (e.g., it will effectively have a reputation
# score of 100). Useful for exempting internal IP addresses.
#
# Note the these exceptions only apply to requests for "ip" type objects, either through
Expand All @@ -80,7 +80,7 @@ exceptions:
file:
- ./exception1.txt
- ./exception2.txt
# If aws is set to true, iprepd will periodically query for known AWS IP address ranges and
# If aws is set to true, repd will periodically query for known AWS IP address ranges and
# add these to the exception list.
aws: false
# versionresponse specifies a path to a file, the contents of which will be returned on a
Expand Down
8 changes: 4 additions & 4 deletions iprepd_test.go → repd_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"encoding/json"
Expand All @@ -14,7 +14,7 @@ const (
testBuild = "testing"
testCommit = "testcommit"
testVersion = "testversion"
testSource = "https://github.com/mozilla-services/iprepd"
testSource = "https://github.com/mozilla-services/repd"
)

func baseTest() error {
Expand Down Expand Up @@ -80,7 +80,7 @@ func baseTest() error {
}

func TestLoadSampleConfig(t *testing.T) {
_, err := loadCfg("./iprepd.yaml.sample")
_, err := loadCfg("./repd.yaml.sample")
assert.Nil(t, err)
}

Expand All @@ -95,7 +95,7 @@ func TestMain(m *testing.M) {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
renv := os.Getenv("IPREPD_TEST_REDISADDR")
renv := os.Getenv("REPD_TEST_REDISADDR")
if renv != "" {
tcfg.Redis.Addr = renv
}
Expand Down
4 changes: 2 additions & 2 deletions score.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"encoding/json"
Expand Down Expand Up @@ -129,7 +129,7 @@ func (r *Reputation) applyDecay() error {

// Violation describes a violation penalty that can be applied to an object.
type Violation struct {
// Name of violation as specified in iprepd cfg
// Name of violation as specified in repd cfg
Name string `json:"name"`

// Penalty is how many points a reputation will be decreased by if this
Expand Down
4 changes: 2 additions & 2 deletions statsd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iprepd
package repd

import (
"time"
Expand All @@ -18,7 +18,7 @@ func newStatsdClient(cfg serverCfg) (*statsdClient, error) {
if err != nil {
return nil, err
}
c.Namespace = "iprepd_server."
c.Namespace = "repd_server."

return &statsdClient{client: c}, nil
}
Expand Down
Loading