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

All gists

Recently created
Least recently created
Recently updated
Least recently updated

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 function peers::is_blocked() {
2 local name="${1:-}"
3 local block_file
4 block_file="$(ctx::block::path "${name}.block")"
5 [[ ! -f "$block_file" ]] && return 1
6 local result
7 result=$(json::block_is_blocked "$block_file")
8 [[ "$result" == "true" ]]
9 }

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 function fw::restore_block_rules() {
2 while IFS= read -r peer_name; do
3 local block_file
4 block_file="$(ctx::block::path "${peer_name}.block")"
5 [[ ! -f "$block_file" ]] && continue
6
7 local client_ip
8 client_ip=$(peers::get_ip "$peer_name")
9 [[ -z "$client_ip" ]] && continue

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 function cmd::inspect::_blocks_info() {
2 local name="${1:-}"
3 local block_file
4 block_file="$(ctx::block::path "${name}.block")"
5 [[ ! -f "$block_file" ]] && return 0
6
7 local data
8 data=$(json::block_get "$block_file")
9 [[ -z "$data" ]] && return 0

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 local block_file
2 block_file=$(block::file "$name")
3 if [[ -f "$block_file" ]]; then
4 local is_bl
5 is_bl=$(json::block_is_blocked "$block_file")
6 _restricted["$name"]=$( [[ "$is_bl" == "true" ]] && echo true || echo false )
7 else
8 _restricted["$name"]=false
9 fi

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 while IFS= read -r name; do
2 [[ -f "$(ctx::block::path "${name}.block")" ]] \
3 && p_restricted["$name"]=true || p_restricted["$name"]=false
4 local pubkey
5 pubkey=$(keys::public "$name" 2>/dev/null || echo "")
6 if [[ -n "$pubkey" ]] && ! echo "$wg_peers" | grep -qF "$pubkey"; then
7 p_blocked["$name"]=true
8 else
9 p_blocked["$name"]=false
10 fi

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 local block_file
2 block_file="$(ctx::block::path "${name}.block")"
3 local blocks=""
4 if [[ -f "$block_file" ]] && [[ -s "$block_file" ]]; then
5 while IFS=" " read -r client_ip target port proto; do
6 if [[ -z "$target" ]]; then
7 blocks+=" all traffic blocked\n"
8 else
9 local rule=" ${target}"
10 [[ -n "$port" ]] && rule+=":${port}/${proto}"

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 function cmd::unblock::_unblock_all() {
2 local name="${1:?name required}"
3 local client_ip="${2:?client_ip required}"
4 local quiet="${3:-false}"
5
6 local block_file
7 block_file="$(ctx::block::path "${name}.block")"
8
9 # Set direct block to false
10 block::set_direct "$name" "$client_ip" "false"

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 wgctl group block --name test
2 /etc/wireguard/wgctl/core/json_helper.py
3 => DEBUG: 🔍 Blocked all traffic from: 10.1.3.5
4 => DEBUG: 🔍 apply_full: calling block::add_rule for phone-test 10.1.3.5
5 => DEBUG: 🔍 block::add_rule: file=/etc/wireguard/.wgctl/blocks/phone-test.block type=full name=full block
6 => DEBUG: 🔍 block::add_rule: done, file contents:
7 {
8 "peer_ip": "10.1.3.5",
9 "blocked_direct": false,
10 "blocked_by_groups": [

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 grep -n "json.load" /etc/wireguard/wgctl/core/json_helper.py | grep -v "_block_read\|def get\|def rule"
2 16: data = json.load(f)
3 34: data = json.load(f)
4 37: data[key] = json.loads(value)
5 49: data = json.load(f)
6 62: data = json.load(f)
7 76: data = json.load(f)
8 88: data = json.load(f)
9 96: data = json.load(f)
10 105: data = json.load(f)

nuno / gistfile1.txt

0 likes
0 forks
1 files
Last active 3 months ago
1 root@wireguard:~# wgctl group unblock --name test
2 Traceback (most recent call last):
3 File "<string>", line 1, in <module>
4 File "/usr/lib/python3.11/json/__init__.py", line 293, in load
5 return loads(fp.read(),
6 ^^^^^^^^^^^^^^^^
7 File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
8 return _default_decoder.decode(s)
9 ^^^^^^^^^^^^^^^^^^^^^^^^^^
10 File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
Newer Older

Powered by Opengist ⋅ Load: 138ms⋅

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