Debug logs
This commit is contained in:
@@ -19,7 +19,6 @@ DNSCRYPT_PROXY_PLUGINS_BASE_FILE="${CONTROL_DIR}/plugin"
|
||||
STATIC_RESOLVERS_FILE="${CONTROL_DIR}/static-resolvers"
|
||||
|
||||
DEBUG_ENABLED_FILE="${CONTROL_DIR}/debug.enabled"
|
||||
DEBUG_ENABLED_FILE_LOCK="${DEBUG_ENABLED_FILE}.lock"
|
||||
|
||||
PLUGINS_ENABLED_FILE="${CONTROL_DIR}/plugins.enabled"
|
||||
QUERY_LOGGING_FILE="${CONTROL_DIR}/plugin-query-logging.enabled"
|
||||
@@ -27,6 +26,7 @@ BLOCKING_FILE="${CONTROL_DIR}/plugin-blocking.enabled"
|
||||
|
||||
QUERY_LOG_FILE="${DNSCRYPT_LOG_BASE_DIR}/dnscrypt-query.log"
|
||||
DEBUG_LOG_FILE="${DNSCRYPT_LOG_BASE_DIR}/dnscrypt-osxclient-debug.log"
|
||||
DEBUG_LOG_FILE_LOCK="${DEBUG_LOG_FILE}.lock"
|
||||
|
||||
BLACKLIST_IPS_FILE="${CONTROL_DIR}/blacklist-ips"
|
||||
BLACKLIST_IPS_TMP_FILE="${BLACKLIST_IPS_FILE}.tmp"
|
||||
@@ -62,7 +62,7 @@ logger_debug() {
|
||||
[ -f "$DEBUG_ENABLED_FILE" ] || return
|
||||
local msg="$1"
|
||||
local now="$(date)"
|
||||
lockfile "$DEBUG_ENABLED_FILE_LOCK" -r 1 -l 10
|
||||
echo "$now - $msg" >> "$DEBUG_ENABLED_FILE"
|
||||
rm -f "$DEBUG_ENABLED_FILE_LOCK"
|
||||
lockfile "$DEBUG_LOG_FILE_LOCK" -1 -r 1 -l 5
|
||||
echo "$now - $msg" >> "$DEBUG_LOG_FILE"
|
||||
rm -f "$DEBUG_LOG_FILE_LOCK"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
. ./common.inc
|
||||
|
||||
eval $(stat -s '/dev/console') || exit 1
|
||||
|
||||
logger_debug "OSX console ownership changed"
|
||||
|
||||
wanted_uid="$st_uid"
|
||||
if [ ! -d "$DNSCRYPT_VAR_BASE_DIR" ]; then
|
||||
mkdir -p "$DNSCRYPT_VAR_BASE_DIR" || exit 1
|
||||
|
||||
@@ -19,6 +19,8 @@ update() {
|
||||
|
||||
touch "${STATES_DIR}/updating"
|
||||
|
||||
logger_debug "DNSCrypt-OSXClient configuration changed"
|
||||
|
||||
updated='no'
|
||||
while :; do
|
||||
find "$TICKETS_DIR" -type f -name 'ticket-*' > "$PROCESSED_TICKETS_FILE"
|
||||
|
||||
@@ -10,6 +10,9 @@ if [ x"$1" != 'x--boot' ]; then
|
||||
./check-network-change.sh || exit 0
|
||||
fi
|
||||
|
||||
logger_debug "Network configuration changed"
|
||||
|
||||
|
||||
lockfile -1 -r 30 -l 60 "$HANDLERS_LOCK_FILE" || exit 1
|
||||
./set-dns-to-dhcp.sh
|
||||
if [ ! -e "$DNSCRYPT_FILE" ]; then
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
servers='empty'
|
||||
|
||||
logger_debug "Changing the DNS configuration to use the default DNS resolvers"
|
||||
|
||||
if [ -r "$STATIC_RESOLVERS_FILE" ]; then
|
||||
servers=''
|
||||
while read server; do
|
||||
@@ -12,12 +14,16 @@ if [ -r "$STATIC_RESOLVERS_FILE" ]; then
|
||||
esac
|
||||
done < "$STATIC_RESOLVERS_FILE"
|
||||
[ -z "$servers" ] && servers='empty'
|
||||
logger_debug "Static list of DNS resolvers: [$servers]"
|
||||
fi
|
||||
|
||||
exec networksetup -listallnetworkservices 2>/dev/null | \
|
||||
fgrep -v '*' | while read x ; do
|
||||
networksetup -setdnsservers "$x" $servers
|
||||
done
|
||||
|
||||
logger_debug "Flushing the local DNS cache"
|
||||
|
||||
dscacheutil -flushcache 2> /dev/null
|
||||
killall -HUP mDNSResponder 2> /dev/null
|
||||
exit 0
|
||||
|
||||
@@ -5,10 +5,16 @@
|
||||
servers="$*"
|
||||
|
||||
[ $# -lt 1 ] && exit 1
|
||||
|
||||
logger_debug "Setting DNS resolvers to [$servers]"
|
||||
|
||||
exec networksetup -listallnetworkservices 2>/dev/null | \
|
||||
fgrep -v '*' | while read x ; do
|
||||
networksetup -setdnsservers "$x" $servers
|
||||
done
|
||||
|
||||
logger_debug "Flushing local DNS cache"
|
||||
|
||||
dscacheutil -flushcache 2> /dev/null
|
||||
killall -HUP mDNSResponder 2> /dev/null
|
||||
exit 0
|
||||
|
||||
@@ -32,6 +32,7 @@ try_resolver() {
|
||||
local args="$*"
|
||||
local pid_file="${PID_DIR}/${priority}.pid"
|
||||
|
||||
logger_debug "Running a test dnscrypt proxy for [$description]"
|
||||
rm -f "${RES_DIR}/${priority}"
|
||||
exec alarmer 3 dnscrypt-proxy --pid="$pid_file" \
|
||||
--resolver-name="$RESOLVER_NAME" \
|
||||
@@ -39,11 +40,13 @@ try_resolver() {
|
||||
while read line; do
|
||||
case "$line" in
|
||||
*Proxying\ from\ *)
|
||||
logger_debug "Proxy for [$description] is up"
|
||||
answers=$(exec dig +time=1 +short +tries=2 -p $priority \
|
||||
@"$INTERFACE_PROBES" www.apple.com. 2> /dev/null | \
|
||||
egrep -ic '^[0-9.:]+$')
|
||||
[ -r "$pid_file" ] && kill $(cat -- "$pid_file")
|
||||
if [ $answers -gt 0 ]; then
|
||||
logger_debug "Proxy for [$description] can be used"
|
||||
echo "$args" > "${RES_DIR}/${priority}"
|
||||
echo "$description" > "${DESCRIPTIONS_DIR}/${priority}"
|
||||
fi
|
||||
@@ -63,6 +66,7 @@ get_plugin_args() {
|
||||
libdcplugin_*) plugin_args="${plugin_args} --plugin=${line}" ;;
|
||||
esac
|
||||
done
|
||||
logger_debug "Plugins to be used: [$plugin_args]"
|
||||
echo "$plugin_args"
|
||||
}
|
||||
}
|
||||
@@ -71,8 +75,14 @@ get_plugin_args() {
|
||||
|
||||
ipv6_supported="no"
|
||||
if [ x"$DISABLE_IPV6" = "xno" ]; then
|
||||
logger_debug "Testing IPv6 connectivity"
|
||||
ping6 -c 1 2620:0:ccc::2 > /dev/null 2>&1
|
||||
[ $? = 0 ] && ipv6_supported="yes"
|
||||
if [ $? = 0 ]; then
|
||||
ipv6_supported="yes"
|
||||
logger_debug "IPv6 connectivity detected"
|
||||
else
|
||||
logger_debug "IPv6 connectivity is not available"
|
||||
fi
|
||||
fi
|
||||
|
||||
wait_pids=""
|
||||
@@ -91,7 +101,10 @@ for pid in $wait_pids; do
|
||||
[ x"$best_file" != "x" ] && break
|
||||
done
|
||||
|
||||
[ x"$best_file" = "x" ] && exit 1
|
||||
if [ x"$best_file" = "x" ]; then
|
||||
logger_debug "No usable proxy configuration has been found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
plugins_args=''
|
||||
if [ -r "${DNSCRYPT_PROXY_PLUGINS_BASE_FILE}s.enabled" ]; then
|
||||
@@ -102,12 +115,14 @@ fi
|
||||
|
||||
best_args=$(cat "${RES_DIR}/${best_file}")
|
||||
|
||||
logger_debug "Starting dnscrypt-proxy $best_args"
|
||||
eval dnscrypt-proxy $best_args --local-address="$INTERFACE_PROXY" \
|
||||
--resolver-name="$RESOLVER_NAME" \
|
||||
--pidfile="$PROXY_PID_FILE" --user=daemon --daemonize $plugin_args
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
[ -r "$PROXY_PID_FILE" ] && kill $(cat -- "$PROXY_PID_FILE")
|
||||
logger_debug "dnscrypt-proxy $best_args command failed, retrying"
|
||||
sleep 1
|
||||
killall dnscrypt-proxy
|
||||
sleep 1
|
||||
@@ -118,8 +133,10 @@ if [ $? != 0 ]; then
|
||||
--resolver-name="$RESOLVER_NAME" \
|
||||
--pidfile="$PROXY_PID_FILE" --user=daemon --daemonize $plugin_args || \
|
||||
exit 1
|
||||
logger_debug "dnscrypt-proxy $best_args worked after a retry"
|
||||
fi
|
||||
|
||||
logger_debug "Checking if the current configuration hijacks all DNS queries"
|
||||
i=0
|
||||
while [ $i -lt 30 ]; do
|
||||
./check-local-dns.sh && break
|
||||
@@ -128,8 +145,12 @@ while [ $i -lt 30 ]; do
|
||||
done
|
||||
|
||||
if [ $i -ge 30 ]; then
|
||||
logger_debug "Current configuration hijacks all DNS queries, disabling DNSCrypt"
|
||||
./switch-to-dhcp.sh
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logger_debug "Current configuration doesn't seem to hijack all DNS queries"
|
||||
|
||||
mv "${DESCRIPTIONS_DIR}/${best_file}" \
|
||||
"${STATES_DIR}/dnscrypt-proxy-description" 2>/dev/null || exit 0
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
|
||||
. ./common.inc
|
||||
|
||||
logger_debug "Stopping dnscrypt-proxy"
|
||||
|
||||
if [ -x /usr/bin/pgrep ]; then
|
||||
pgrep -x dnscrypt-proxy | egrep '[0-9]+' > /dev/null || exit 0
|
||||
fi
|
||||
|
||||
[ ! -r "$PROXY_PID_FILE" ] && exit 0
|
||||
pid=$(cat "$PROXY_PID_FILE")
|
||||
[ $pid -lt 2 ] && exit 0
|
||||
|
||||
logger_debug "Trying to stop dnscrypt-proxy by killing pid [$pid]"
|
||||
kill $pid
|
||||
|
||||
i=0
|
||||
@@ -19,3 +24,5 @@ done
|
||||
|
||||
rm -f "$PROXY_PID_FILE"
|
||||
kill -9 $pid
|
||||
|
||||
logger_debug "Killed dnscrypt-proxy with kill -9 pid [$pid]"
|
||||
|
||||
@@ -7,6 +7,8 @@ PAUSE_INCREMENT=0.1
|
||||
|
||||
[ ! -e "$DNSCRYPT_FILE" ] && exit 0
|
||||
|
||||
logger_debug "DNSCrypt has been requested"
|
||||
|
||||
./set-dns-to-dhcp.sh
|
||||
|
||||
pause=0
|
||||
|
||||
Reference in New Issue
Block a user