The apparent remote address for a proxy connection is the gateway, but
in fact the information is going to some remote server. Therefore, once
we've identified a proxy connection, overwrite the remote address in
the query with the true remote host.
This means fixing up the query structure with the gateway address next
time, so keep track of the connection remote address and restore it on
each query.