Neeeeeed token
parent
408736b75b
commit
e17047184c
|
@ -41,7 +41,7 @@ if [ "${token}" == "" ]; then
|
||||||
printf 'Creating token for %s...\n' "${ip}" >>"${LOGFILE}"
|
printf 'Creating token for %s...\n' "${ip}" >>"${LOGFILE}"
|
||||||
token="$(</dev/urandom tr -dc '[:alnum:]' | fold -w64 | head -n1)"
|
token="$(</dev/urandom tr -dc '[:alnum:]' | fold -w64 | head -n1)"
|
||||||
printf '%s\t%s\n' "${ip}" "${token}" >>"${TOKENS_FILE}"
|
printf '%s\t%s\n' "${ip}" "${token}" >>"${TOKENS_FILE}"
|
||||||
fi &
|
fi
|
||||||
|
|
||||||
# Get peer IP list
|
# Get peer IP list
|
||||||
if ! peers="$(sudo /usr/bin/wg show "${TLD}" allowed-ips)"; then
|
if ! peers="$(sudo /usr/bin/wg show "${TLD}" allowed-ips)"; then
|
||||||
|
@ -62,7 +62,7 @@ fi
|
||||||
|
|
||||||
# Get domains for each peer
|
# Get domains for each peer
|
||||||
if peers="[$("${LIB_DIR}/ips_to_peers" 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 '{"token":"%s","peers":%s}' "${token!}" "${peers!}" | "${LIB_DIR}/http_res" 200 'application/json'
|
||||||
printf 'Sent peers to admin %s\n' "${ip}" >>"${LOGFILE}"
|
printf 'Sent peers to admin %s\n' "${ip}" >>"${LOGFILE}"
|
||||||
else
|
else
|
||||||
printf 'ERROR: Failed to lookup user: %s\n' "${ip}" >>"${LOGFILE}"
|
printf 'ERROR: Failed to lookup user: %s\n' "${ip}" >>"${LOGFILE}"
|
||||||
|
|
Loading…
Reference in New Issue