{"id":20804978,"url":"https://github.com/lichess-org/leroyjenkins","last_synced_at":"2025-12-27T21:59:09.329Z","repository":{"id":192454238,"uuid":"686754695","full_name":"lichess-org/leroyjenkins","owner":"lichess-org","description":"Follow ban logs to manage ipsets","archived":false,"fork":false,"pushed_at":"2024-06-09T15:46:43.000Z","size":159,"stargazers_count":14,"open_issues_count":2,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-31T06:11:25.415Z","etag":null,"topics":["ipset"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lichess-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-09-03T20:40:41.000Z","updated_at":"2024-11-15T18:47:56.000Z","dependencies_parsed_at":"2023-10-03T19:20:44.380Z","dependency_job_id":null,"html_url":"https://github.com/lichess-org/leroyjenkins","commit_stats":null,"previous_names":["lakinwecker/leroyjenkins"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichess-org%2Fleroyjenkins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichess-org%2Fleroyjenkins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichess-org%2Fleroyjenkins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lichess-org%2Fleroyjenkins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lichess-org","download_url":"https://codeload.github.com/lichess-org/leroyjenkins/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252811001,"owners_count":21807886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ipset"],"created_at":"2024-11-17T19:12:42.391Z","updated_at":"2025-12-27T21:59:09.319Z","avatar_url":"https://github.com/lichess-org.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Leroy Jenkins\n\nUsed when someone needs [to be decisive](https://www.youtube.com/watch?v=mLyOj_QD4a4) amongst [too much planning and inaction](https://www.youtube.com/watch?v=km5FAAQLUT8)\n\n## Usage\n\n*leroyjenkins* reads data from stdin, and assumes each line is an IP address. Use in combination with standard unix tools like `tail -F`. When an IP address shows up too often before its cache times out, it will be added to the nftables set with the specified timeout.\n\n```sh\ntail -F /tmp/ips.log | RUST_LOG=info ./target/release/leroyjenkins --bl-period=1m --bl-threshold=100 --ban-base-time=100s --ban-ttl=1d --table=leroy --ipv6-set=leroy6 --ipv4-set=leroy4\n```\n\n\u003e [!WARNING]\n\u003e *leroyjenkins* itself does nothing to your firewall rules. Use nftables rules similar to the ones below.\n\n\u003e [!NOTE]\n\u003e Must be run with enough privileges to actually modify nftables sets. Otherwise fails with a generic:\n\u003e `Error: Os { code: 71, kind: Uncategorized, message: \"Protocol error\" }`\n\n## Building\n\n```sh\ncargo +nightly build --release\n```\n\nYou need to install the nightly toolchain with `rustup`:\n\n```sh\nrustup toolchain install nightly\n```\n\n## Setup\n\nBefore running, create the nftables table and sets, leroy expects these to exist:\n\n```sh\n#!/usr/sbin/nft -f\n\ntable inet leroy {\n    # Define our sets\n    set leroy4 {\n        type ipv4_addr;\n        timeout 60s;\n        size 65536;\n        flags timeout;\n    }\n\n    set leroy6 {\n        type ipv6_addr;\n        timeout 60s;\n        size 65536;\n        flags timeout;\n    }\n\n    chain input {\n        # accept everybody by default in this chain, with a really\n        # high priority so that we can reject them as early as\n        # possible in the Netfilter system\n        type filter hook input priority -900; policy accept;\n\n        # but if you match, you're out\n        ip  saddr @leroy4         counter name leroyed reject with tcp reset\n        ip6 saddr @leroy6         counter name leroyed reject with tcp reset\n    }\n\n    chain output {\n        # accept everybody by default in this chain, with a really\n        # high priority so that we can reject them as early as\n        # possible in the Netfilter system\n        type filter hook output priority -900; policy accept;\n\n        # but if you match, you're out\n        ip  daddr @leroy4 reject with tcp reset\n        ip6 daddr @leroy6 reject with tcp reset\n    }\n}\n```\n\n## Examples\n\nBecause it reads from stdin and this is Unix, you can pipe stuff into it. Use `tail -F`, use `awk`, use `grep` or `rg` or `ag`.\n\n### Dig some lines out of some application log and use them to ban\n\n```sh\ntail -F /var/log/app/app.ratelimit.log | ag 'naughty.behaviour' | stdbuf --output=L awk '{print $NF}' | leroyjenkins $LEROY_ARGS\n```\n\n### Ban random IPs!\n\nBecause it's Unix, use `bash` and `shuf` to ban a random IP every second for an hour with:\n\n```sh\nwhile sleep 1; do echo `shuf -i1-256 -n1`.`shuf -i1-256 -n1`.`shuf -i1-256 -n1`.`shuf -i1-256 -n1`; done | RUST_LOG=info ./target/release/leroyjenkins --bl-period=10s --bl-threshold=0 --ban-base-time=100s --ban-ttl=1h --table leroy --ipv6-set=leroy6 --ipv4-set=leroy4\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flichess-org%2Fleroyjenkins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flichess-org%2Fleroyjenkins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flichess-org%2Fleroyjenkins/lists"}