Removed extraneous client_address assignment.

This appears to not be necessary in the scope and could be a leftover.
Use X-Forwarded-For header for RPC calls.

If X-Forwarded-For header exists, use it as the source of the client rather
than the originating address.
Add option for allowing reverse proxies.
Check for allowed reverse proxies.

This incorporates the configuration option allowed_proxy_from. It will take a list of hosts or CIDR ranges. If the setting contains anything and the connecting host is inside one of those ranges, allow the connection as if the contents of 'X-Forwarded-For' header were the actual host, otherwise just pass it through as if nothing happened.
Add error check in case proxying disallowed by server.
Refactor slightly for better flow.