All New

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Register

Login

All New Register Login

nuno

Joined 4 months ago

Recently created
Least recently created
Recently updated
Least recently updated
All gists 582

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1
2 # ============================================
3 # Rule Management
4 # ============================================
5
6 function fw::block_ip() {
7 local client_ip="$1" target_ip="$2"
8 fw::_forward_exists -s "$client_ip" -d "$target_ip" -j DROP \
9 || iptables -I FORWARD 1 -s "$client_ip" -d "$target_ip" -j DROP

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 # Moved to the top of the function after rule::require_exists
2
3 local peer_name
4 peer_name=$(peers::find_by_ip "$client_ip")
5
6 local subtype
7 subtype=$(peers::get_meta "$peer_name" "subtype")
8
9 local subnet
10 subnet=$(config::subnet_for "$subtype")

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 function cmd::rule::assign() {
2 local name="" peer="" type=""
3 while [[ $# -gt 0 ]]; do
4 case "$1" in
5 --name) name="$2"; shift 2 ;;
6 --peer) peer="$2"; shift 2 ;;
7 --type) type="$2"; shift 2 ;;
8 --help) cmd::rule::help; return ;;
9 *)
10 log::error "Unknown flag: $1"

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 #!/usr/bin/env bash
2
3 # ============================================
4 # Lifecycle
5 # ============================================
6
7 function cmd::watch::on_load() {
8 flag::register --type
9 flag::register --name
10 flag::register --blocked

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 May 12 20:26:25 wireguard python3[321848]: 2026-05-12 20:26:25,985 [ERROR] Failed to load watchlist: Expecting value: line 1 column 1 (char 0)
2
3 May 13 01:07:34 wireguard python3[321848]: 2026-05-13 01:07:34,366 [INFO] Shutting down wgctl-monitor
4
5 May 13 01:07:34 wireguard systemd[1]: Stopping wgctl-monitor.service - wgctl WireGuard Monitor Daemon...
6
7 May 13 01:07:34 wireguard systemd[1]: wgctl-monitor.service: Deactivated successfully.
8
9 May 13 01:07:34 wireguard systemd[1]: Stopped wgctl-monitor.service - wgctl WireGuard Monitor Daemon.

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 def follow_logs(fw_file, wg_file, filter_ip, filter_type, clients_dir, filter_peers=""):
2 """Follow both log files and output formatted events"""
3 import glob, time, select
4
5 proto_map = {1: 'icmp', 6: 'tcp', 17: 'udp'}
6 peer_filter = set(filter_peers.split(',')) if filter_peers else set()
7 function cmd::group::watch() {
8 local name=""
9
10 while [[ $# -gt 0 ]]; do

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 grep -A 20 "function cmd::group::watch" /etc/wireguard/wgctl/commands/group.command.sh
2 function cmd::group::watch() {
3 local name=""
4
5 while [[ $# -gt 0 ]]; do
6 case "$1" in
7 --name) util::require_flag "--name" "${2:-}" || return 1; name="$2"; shift 2 ;;
8 --help) cmd::group::help; return ;;
9 *) log::error "Unknown flag: $1"; return 1 ;;
10 esac

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 function cmd::remove::_cleanup() {
2 local name="${1:-}" client_ip="${2:-}" was_blocked="${3:-false}"
3
4 [[ -n "$client_ip" ]] && fw::flush_peer "$client_ip"
5 peers::remove_from_server "$name" || return 1
6 peers::remove_client_config "$name" || return 1
7 keys::remove "$name" || return 1
8
9 # Remove from all groups
10 while IFS= read -r group_name; do

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 /etc/wireguard/wgctl/commands/list.command.sh \
2 /etc/wireguard/wgctl/commands/block.command.sh \
3 /etc/wireguard/wgctl/commands/unblock.command.sh \
4 /etc/wireguard/wgctl/commands/inspect.command.sh 2>/dev/null
5 /etc/wireguard/wgctl/commands/list.command.sh:function cmd::list::help() {
6 /etc/wireguard/wgctl/commands/list.command.sh- cat <<EOF
7 /etc/wireguard/wgctl/commands/list.command.sh-Usage: wgctl list [options]
8 /etc/wireguard/wgctl/commands/list.command.sh-
9 /etc/wireguard/wgctl/commands/list.command.sh-List all WireGuard clients.
10 /etc/wireguard/wgctl/commands/list.command.sh-

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 function peers::cleanup_config() {
2 local config
3 config=$(config::config_file)
4
5 python3 -c "
6 import re
7 config = open('${config}').read()
8
9 # Normalize multiple blank lines to single blank line
10 config = re.sub(r'\n{3,}', '\n\n', config)
Newer Older

Powered by Opengist ⋅ Load: 111ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文
⋅ KrilHub