- wgctl hosts command (list, show, add, rm) with tags support - modules/resolve.module.sh — chain: hosts.json → services.json → raw IP - modules/hosts.module.sh — hosts::resolve_ip, hosts::lookup_ip - resolve::ip and resolve::dest used in watch, logs, activity - _WGCTL_RAW=true via --raw flag bypasses all resolution - json_helper.py: hosts_list, hosts_show, hosts_add, hosts_remove, hosts_lookup
22 lines
No EOL
599 B
Bash
22 lines
No EOL
599 B
Bash
#!/usr/bin/env bash
|
|
# hosts.module.sh — host resolution helpers
|
|
|
|
function hosts::exists() {
|
|
local entry_type="${1:-host}" key="${2:-}"
|
|
[[ "$(json::hosts_exists "$(ctx::hosts)" "$entry_type" "$key")" == "true" ]]
|
|
}
|
|
|
|
function hosts::require_exists() {
|
|
local entry_type="${1:-host}" key="${2:-}"
|
|
if ! hosts::exists "$entry_type" "$key"; then
|
|
log::error "${entry_type^} not found: ${key}"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
function hosts::resolve_ip() {
|
|
local ip="${1:-}"
|
|
[[ -z "$ip" ]] && return 0
|
|
[[ ! -f "$(ctx::hosts)" ]] && echo "" && return 0
|
|
json::hosts_lookup "$(ctx::hosts)" "$ip"
|
|
} |