Skip to content

MitrickX/otus-golang-2019-project-antibruteforce

Repository files navigation

Otus golang 2019 project - Anti brute force microservice

Build Status

Go Report Card

Specification https://github.com/OtusGolang/final_project/blob/master/01-anti-bruteforce.md

Algorithm

For this anti brute force service Token bucket algorithm (https://en.wikipedia.org/wiki/Token_bucket) is used

GRPC server

To run server execute command grpc, port specify by env var GRPC_PORT

GRPC_PORT=port ./antibruteforce grpc

If GRPC_PORT is missed port server will be started on port 50051

To run server in container do this.

make run

Port 50051 will be available for communicate with GRPC server.
Now you can build CLI client and run commands

GRPC CLI client

Before execute client commands you could specified server host by set up env var GRPC_SERVER_HOST, if this var is missed it will be assumed that server is 127.0.0.1 host
Also you can specify port of GRPC server by env var GRPC_SERVER_HOST, if this var is missed it will be assumed that port is 50051

Example (default):

make build
./antibruteforce auth test 1234 193.192.170.13

Example (set vars):

make build
export GRPC_SERVER_HOST=localhost
export GRPC_SERVER_PORT=50052
./antibruteforce auth test 1234 193.192.170.13

List of CLI client commands

add [flags] - Add IP into black or white list
delete [flags] - Delete ip from black of white list
clear --login= --password= --ip= [flags] - Clear bucket(s) for login, password or ip
auth [flags] - Check that auth is allowed for login, password and ip

Each command support --help option. Use it for explore details of commands

Integration and unit tests

For run integration tests go to build/package and run

make test

For run unit tests run from the root of project and run

go test -v --race -tags unit ./...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages