0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 23:51:04 +08:00

Merge pull request #3532 from guillon/fix-socks-connect

Fix issues with SOCKS5 proxy connection
This commit is contained in:
Luca Boccassi 2019-06-10 14:11:39 +01:00 committed by GitHub
commit 68558bc394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 10 deletions

15
RELICENSE/guillon.md Normal file
View File

@ -0,0 +1,15 @@
# Permission to Relicense under MPLv2 or any other OSI approved license chosen by the current ZeroMQ BDFL
This is a statement by Christophe Guillon
that grants permission to relicense its copyrights in the libzmq C++
library (ZeroMQ) under the Mozilla Public License v2 (MPLv2) or any other
Open Source Initiative approved license chosen by the current ZeroMQ
BDFL (Benevolent Dictator for Life).
A portion of the commits made by the Github handle "guillon", with
commit author "Christophe Guillon <christophe.guillon.perso@gmail.com>", are copyright of Christophe Guillon .
This document hereby grants the libzmq project team to relicense libzmq,
including all past, present and future contributions of the author listed above.
Christophe Guillon
2019/06/10

View File

@ -207,6 +207,7 @@ void zmq::socks_connecter_t::error ()
_choice_decoder.reset ();
_request_encoder.reset ();
_response_decoder.reset ();
_status = unplugged;
add_reconnect_timer ();
}
@ -215,29 +216,28 @@ int zmq::socks_connecter_t::connect_to_proxy ()
zmq_assert (_s == retired_fd);
// Resolve the address
if (_addr->resolved.tcp_addr != NULL) {
LIBZMQ_DELETE (_addr->resolved.tcp_addr);
if (_proxy_addr->resolved.tcp_addr != NULL) {
LIBZMQ_DELETE (_proxy_addr->resolved.tcp_addr);
}
_addr->resolved.tcp_addr = new (std::nothrow) tcp_address_t ();
alloc_assert (_addr->resolved.tcp_addr);
_proxy_addr->resolved.tcp_addr = new (std::nothrow) tcp_address_t ();
alloc_assert (_proxy_addr->resolved.tcp_addr);
// Automatic fallback to ipv4 is disabled here since this was the existing
// behaviour, however I don't see a real reason for this. Maybe this can
// be changed to true (and then the parameter can be removed entirely).
_s = tcp_open_socket (_addr->address.c_str (), options, false, false,
_addr->resolved.tcp_addr);
_s = tcp_open_socket (_proxy_addr->address.c_str (), options, false, false,
_proxy_addr->resolved.tcp_addr);
if (_s == retired_fd) {
// TODO we should emit some event in this case!
LIBZMQ_DELETE (_addr->resolved.tcp_addr);
LIBZMQ_DELETE (_proxy_addr->resolved.tcp_addr);
return -1;
}
zmq_assert (_addr->resolved.tcp_addr != NULL);
zmq_assert (_proxy_addr->resolved.tcp_addr != NULL);
// Set the socket to non-blocking mode so that we get async connect().
unblock_socket (_s);
const tcp_address_t *const tcp_addr = _addr->resolved.tcp_addr;
const tcp_address_t *const tcp_addr = _proxy_addr->resolved.tcp_addr;
int rc;