Fixes for general connection behind proxy

I am submitting two fixes for connection handling behind proxies.

The first one deals with environment proxies with user names that contain dots or hyphens, which made the regular expression match fail.

The second one also deals with environment proxies, but in this case with addresses without explicit port definition. During connection instantiation, the self.handle_proxy call referenced member "self.port" before assignment.