feat: first version of the script

This commit is contained in:
2024-08-27 22:06:33 +03:00
parent 65fc1cb2bb
commit 68e416c547
7 changed files with 1082 additions and 4 deletions

66
.github/README.md vendored Normal file
View File

@@ -0,0 +1,66 @@
# ivuorinen/f2b
A fail2ban wrapper for easier management and listing of banned IP's in your jails.
Requires fail2ban to be installed and running. Should work on most Linux distributions.
Developed against `fail2ban` version 0.11.2 on Ubuntu 22.04.4 LTS using nvim.
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) ![GitHub file size in bytes](https://img.shields.io/github/size/ivuorinen/f2b/f2b)
## Installation
```bash
curl https://raw.githubusercontent.com/ivuorinen/f2b/main/f2b > f2b
chmod +x f2b
./f2b version
```
Requiements: `fail2ban` (duh), and few other default tools.
`awk`, `cat`, `date`, `grep`, `ls`, `sed`, `sort`, `tail`, `tr`, `wc`, and `zcat` should be installed.
Those are usually installed by default on most Linux distributions. The script will tell you if something is missing.
If running commands straight from the internet scares you (as it should) you can
open the f2b script in your favourite editor (or here in GitHub) and view the source.
I promise I'm not doing anything weird in the script.
## Usage
It uses several fail2ban commands to get the information it needs, so it needs to be run as root.
```bash
Usage: f2b [command] [options]
list-jails List all jails
status all Show status of all jails
status [jail] Show status of a specific jail
banned Show all banned IP addresses with ban time left
banned [jail] Show all banned IP addresses with ban time left in a jail
ban [ip] Ban IP address in all jails
ban [ip] [jail] Ban IP address in a specific jail
unban [ip] Unban IP address in all jails
unban [ip] [jail] Unban IP address in a specific jail
test [ip] Test if IP address is banned
logs Show fail2ban logs
logs all [ip] Show logs for a specific IP address in all jails
logs [jail] Show logs for a specific jail
logs [jail] [ip] Show logs for a specific jail and IP address
logs-watch Watch fail2ban logs
logs-watch all [ip] Watch logs for a specific IP address
logs-watch [jail] Watch logs for a specific jail
logs-watch [jail] [ip] Watch logs for a specific jail and IP address
test-filter [filter] Test a fail2ban filter
service start Start fail2ban
service stop Stop fail2ban
service restart Restart fail2ban
help Show help
version Show version
```
## Authors
- [@ivuorinen](https://github.com/ivuorinen)
## License
[MIT](https://choosealicense.com/licenses/mit/)

164
.github/labels.yml vendored Normal file
View File

@@ -0,0 +1,164 @@
---
- name: "breaking-change"
color: ee0701
description: "A breaking change for existing users."
- name: "bugfix"
color: ee0701
description: "Inconsistencies or issues which will cause a problem for users or implementors."
- name: "documentation"
color: 0052cc
description: "Solely about the documentation of the project."
- name: "enhancement"
color: 1d76db
description: "Enhancement of the code, not introducing new features."
- name: "refactor"
color: 1d76db
description: "Improvement of existing code, not introducing new features."
- name: "performance"
color: 1d76db
description: "Improving performance, not introducing new features."
- name: "new-feature"
color: 0e8a16
description: "New features or options."
- name: "maintenance"
color: 2af79e
description: "Generic maintenance tasks."
- name: "ci"
color: 1d76db
description: "Work that improves the continue integration."
- name: "dependencies"
color: 1d76db
description: "Upgrade or downgrade of project dependencies."
- name: "translations"
color: d4c5f9
description: "Impacts translations."
- name: "in-progress"
color: fbca04
description: "Issue is currently being resolved by a developer."
- name: "stale"
color: fef2c0
description: "There has not been activity on this issue or PR for quite some time."
- name: "no-stale"
color: fef2c0
description: "This issue or PR is exempted from the stable bot."
- name: "security"
color: ee0701
description: "Marks a security issue that needs to be resolved asap."
- name: "incomplete"
color: fef2c0
description: "Marks a PR or issue that is missing information."
- name: "invalid"
color: fef2c0
description: "Marks a PR or issue that is missing information."
- name: "beginner-friendly"
color: 0e8a16
description: "Good first issue for people wanting to contribute to the project."
- name: "help-wanted"
color: 0e8a16
description: "We need some extra helping hands or expertise in order to resolve this."
- name: "hacktoberfest"
description: "Issues/PRs are participating in the Hacktoberfest."
color: fbca04
- name: "hacktoberfest-accepted"
description: "Issues/PRs are participating in the Hacktoberfest."
color: fbca04
- name: "priority-critical"
color: ee0701
description: "This should be dealt with ASAP. Not fixing this issue would be a serious error."
- name: "priority-high"
color: b60205
description: "After critical issues are fixed, these should be dealt with before any further issues."
- name: "priority-medium"
color: 0e8a16
description: "This issue may be useful, and needs some attention."
- name: "priority-low"
color: e4ea8a
description: "Nice addition, maybe... someday..."
- name: "major"
color: b60205
description: "This PR causes a major version bump in the version number."
- name: "minor"
color: 0e8a16
description: "This PR causes a minor version bump in the version number."
# Areas
- name: area/ansible
color: "0e8a16"
- name: area/docs
color: "0e8a16"
- name: area/github
color: "0e8a16"
- name: area/kubernetes
color: "0e8a16"
- name: area/taskfile
color: "0e8a16"
- name: area/terraform
color: "0e8a16"
# Clusters
- name: cluster/main
color: "ffc300"
- name: cluster/storage
color: "ffc300"
# Renovate Types
- name: renovate/ansible
color: "027fa0"
- name: renovate/container
color: "027fa0"
- name: renovate/github-action
color: "027fa0"
- name: renovate/grafana-dashboard
color: "027fa0"
- name: renovate/github-release
color: "027fa0"
- name: renovate/helm
color: "027fa0"
- name: renovate/terraform
color: "027fa0"
# Semantic Types
- name: type/digest
color: "ffeC19"
- name: type/patch
color: "ffeC19"
- name: type/minor
color: "ff9800"
- name: type/major
color: "f6412d"
# Uncategorized
- name: community
color: "370fb2"
- name: hold
color: "ee0701"
## more info https://github.com/crazy-max/ghaction-github-labeler
- # automerge
name: ":bell: automerge"
color: "8f4fbc"
description: ""
- # bot
name: ":robot: bot"
color: "69cde9"
description: ""
- # bug
name: ":bug: bug"
color: "b60205"
description: ""
- # documentation
name: ":memo: documentation"
color: "c5def5"
description: ""
- # duplicate
name: ":busts_in_silhouette: duplicate"
color: "cccccc"
description: ""
- # enhancement
name: ":sparkles: enhancement"
color: "0054ca"
description: ""
- # feature request
name: ":bulb: feature request"

View File

@@ -15,4 +15,4 @@ permissions:
jobs:
SuperLinter:
uses: ivuorinen/.github/.github/workflows/pr-lint.yml@main
uses: ivuorinen/ivuorinen/.github/workflows/pr-lint.yml@main

View File

@@ -11,4 +11,4 @@ permissions:
jobs:
Draft:
uses: ivuorinen/.github/.github/workflows/sync-labels.yml@main
uses: ivuorinen/ivuorinen/.github/workflows/sync-labels.yml@main

View File

@@ -15,4 +15,4 @@ permissions:
jobs:
stale:
uses: ivuorinen/.github/.github/workflows/stale.yml@main
uses: ivuorinen/ivuorinen/.github/workflows/stale.yml@main

View File

@@ -18,4 +18,4 @@ permissions:
jobs:
SyncLabels:
uses: ivuorinen/.github/.github/workflows/sync-labels.yml@main
uses: ivuorinen/ivuorinen/.github/workflows/sync-labels.yml@main