Client library to send IP reputations to the iprepd service.
Usage:
Create a client:
const IPReputationClient = require('ip-reputation-service-client-js')
const client = new IPReputationClient({
serviceUrl: 'http://<iprepd service host without trailing slash>',
id: '<a hawk ID>',
key: '<a hawk key>',
timeout: <number in ms>
})
Get the reputation for an IP:
client.get('127.0.0.1').then(function (response) {
if (response && response.statusCode === 404) {
console.log('No reputation found for 127.0.0.1');
} else {
console.log('127.0.0.1 has reputation: ', response.body.reputation);
}
});
Set the reputation for an IP:
client.update('127.0.0.1', 79).then(function (response) {
console.log('Set reputation for 127.0.0.1 to 79.');
});
Remove an IP:
client.remove('127.0.0.1').then(function (response) {
console.log('Removed reputation for 127.0.0.1.');
});
Send a violation for an IP:
client.sendViolation('127.0.0.1', 'exceeded-password-reset-failure-rate-limit').then(function (response) {
console.log('Applied violation to 127.0.0.1.');
});
Tests run against the iprepd service with docker-compose from the ip-reputation-js-client repo root:
- Install docker and docker-compose
- Run
docker-compose build
thendocker-compose run --rm test
(note: this may fail on the first run, but should work on subsequent runs due to the web and test containers not waiting long enough for the cache and web servers to start) - Open
coverage/lcov-report/index.html
to see the coverage report