Renamed file

master
Keith Irwin 2022-09-15 21:21:59 -06:00
parent f761459ee2
commit f8c0415761
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
7 changed files with 10 additions and 9 deletions

View File

@ -87,7 +87,7 @@ if ! peers="$(sudo /usr/bin/wg show "${TLD}" allowed-ips)"; then
fi
# Get peer domains
if ! peers="$("${LIB_DIR}/wg_peer_list" tsv <<<"${peers}")"; then
if ! peers="$("${LIB_DIR}/ips_to_peers" tsv <<<"${peers}")"; then
printf 'ERROR! Failed to retrieve peers for %s!\n' "${ip}" >>"${LOGFILE}"
exit 10
fi

View File

@ -60,7 +60,7 @@ if [ "${user_peers}" == "" ]; then
fi
# Get peer domains
if ! peer="$("${LIB_DIR}/wg_peer_list" tsv <<<"${user_peers}" | grep "${pubkey}")"; then
if ! peer="$("${LIB_DIR}/ips_to_peers" tsv <<<"${user_peers}" | grep "${pubkey}")"; then
printf 'ERROR! Peer %s not found for user %s!\n' "${pubkey}" "${ip}" >>"${LOGFILE}" &
printf 'Peer not found\n' | "${LIB_DIR}/http_res" 404
exit 6

View File

@ -61,7 +61,7 @@ if [ "${un}" != '' ]; then
fi
# Get domains for each peer
if peers="[$("${LIB_DIR}/wg_peer_list" json <<<"${peers}")]"; then
if peers="[$("${LIB_DIR}/ips_to_peers" json <<<"${peers}")]"; then
printf '{"token":"%s","peers":%s}' "${token}" "${peers}" | "${LIB_DIR}/http_res" 200 'application/json'
printf 'Sent peers to admin %s\n' "${ip}" >>"${LOGFILE}"
else

View File

@ -94,7 +94,7 @@ if [ "${user_peers}" == "" ]; then
fi
# Create new IPs
if ! peers="$("${LIB_DIR}/wg_peer_list" tsv <<<"${user_peers}")"; then
if ! peers="$("${LIB_DIR}/ips_to_peers" tsv <<<"${user_peers}")"; then
printf 'ERROR! Failed to parse peers for %s!\n' "${ip}" >>"${LOGFILE}"
exit 10
fi

View File

@ -61,7 +61,7 @@ if [ "${user_peers}" == "" ]; then
fi
# Get peer domains
if ! peer="$("${LIB_DIR}/wg_peer_list" tsv <<<"${user_peers}" | grep "${pubkey}")"; then
if ! peer="$("${LIB_DIR}/ips_to_peers" tsv <<<"${user_peers}" | grep "${pubkey}")"; then
printf 'ERROR! Peer %s not found for user %s!\n' "${pubkey}" "${ip}" >>"${LOGFILE}" &
printf 'Peer not found\n' | "${LIB_DIR}/http_res" 404
exit 6

View File

@ -56,7 +56,7 @@ if [ "${user_peers}" == '' ]; then
fi
# Get domains for each one
if peers="[$("${LIB_DIR}/wg_peer_list" json <<<"${user_peers}")]"; then
if peers="[$("${LIB_DIR}/ips_to_peers" json <<<"${user_peers}")]"; then
printf '{"token":"%s","peers":%s}' "${token}" "${peers}" | "${LIB_DIR}/http_res" 200 'application/json'
printf 'Sent peers to user %s\n' "${ip}" >>"${LOGFILE}"
else

View File

@ -1,7 +1,8 @@
#!/bin/bash
# FILE: wg_peer_list
# DESCRIPTION: Get peers in the same subnet as an ip
# USAGE: wg_peer_list json <<<"${user_peers}"
# FILE: ips_to_peers
# DESCRIPTION: Takes a list of IPs from wg show allowed-ips
# and adds domains using rdns lookups
# USAGE: ips_to_peers json <<<"${user_peers}"
# ERRORS:
# 3: bad usage
# 4: nslookup failed