fix IP address retrieval logic - correctly handle proxy server