fixed proxy init

This commit is contained in:
csoler 2022-01-09 17:06:10 +01:00
parent 2456dbb2a0
commit e7eb606a4a
2 changed files with 21 additions and 19 deletions

View File

@ -20,7 +20,9 @@ int pqiproxyconnection::proxy_negotiate_connection(int sockfd)
case PROXY_STATE_WAITING_SOCKS_RESPONSE: case PROXY_STATE_WAITING_SOCKS_RESPONSE:
ret = Proxy_Connection_Complete(sockfd); // wait for ACK. ret = Proxy_Connection_Complete(sockfd); // wait for ACK.
break;
if(ret < 1)
break;
case PROXY_STATE_CONNECTION_COMPLETE: case PROXY_STATE_CONNECTION_COMPLETE:
@ -41,6 +43,8 @@ int pqiproxyconnection::proxy_negotiate_connection(int sockfd)
return -1; return -1;
} }
if(ret < 0)
return -1;
#ifdef PROXY_DEBUG #ifdef PROXY_DEBUG
std::cerr << "pqisslproxy::Basic_Connection_Complete() IN PROGRESS"; std::cerr << "pqisslproxy::Basic_Connection_Complete() IN PROGRESS";
@ -225,21 +229,19 @@ int pqiproxyconnection::Proxy_Send_Address(int sockfd)
return ret; // Method Response not complete. return ret; // Method Response not complete.
} }
char socks_request[MAX_SOCKS_REQUEST_LEN] = char socks_request[MAX_SOCKS_REQUEST_LEN] = {
{ 0x05, // SOCKS VERSION. 0x05, // SOCKS VERSION.
0x01, // CONNECT (Tor doesn't support BIND or UDP). 0x01, // CONNECT (Tor doesn't support BIND or UDP).
0x00, // RESERVED. 0x00, // RESERVED.
0x03, // ADDRESS TYPE (Domain Name) 0x03, // ADDRESS TYPE (Domain Name)
0x00, // Length of Domain name... the rest is variable so can't hard code it! 0x00, // Length of Domain name... the rest is variable so can't hard code it!
}; };
/* get the length of the domain name, pack so we can't overflow uint8_t */ /* get the length of the domain name, pack so we can't overflow uint8_t */
uint8_t len = mDomainAddress.length(); uint8_t len = mDomainAddress.length();
socks_request[4] = len; socks_request[4] = len;
for(int i = 0; i < len; i++) for(int i = 0; i < len; i++)
{
socks_request[5 + i] = mDomainAddress[i]; socks_request[5 + i] = mDomainAddress[i];
}
/* now add the port, being careful with packing */ /* now add the port, being careful with packing */
uint16_t net_port = htons(mRemotePort); uint16_t net_port = htons(mRemotePort);

View File

@ -78,19 +78,19 @@ int pqisslproxy::Initiate_Connection()
/********* VERY DIFFERENT **********/ /********* VERY DIFFERENT **********/
int pqisslproxy::Basic_Connection_Complete() int pqisslproxy::Basic_Connection_Complete()
{ {
rslog(RSL_DEBUG_BASIC, pqisslproxyzone, rslog(RSL_DEBUG_BASIC, pqisslproxyzone,
"pqisslproxy::Basic_Connection_Complete()..."); "pqisslproxy::Basic_Connection_Complete()...");
#ifdef PROXY_DEBUG #ifdef PROXY_DEBUG
std::cerr << "pqisslproxy::Basic_Connection_Complete() STATE: " << mProxyState; std::cerr << "pqisslproxy::Basic_Connection_Complete() STATE: " << mProxyState;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if (CheckConnectionTimeout()) if (CheckConnectionTimeout())
{ {
// calls reset. // calls reset.
return -1; return -1;
} }
int ret; int ret;
@ -103,7 +103,7 @@ int pqisslproxy::Basic_Connection_Complete()
reset_locked(); reset_locked();
return ret; return ret;
} }
bool pqisslproxy::connect_parameter(uint32_t type, const std::string &value) bool pqisslproxy::connect_parameter(uint32_t type, const std::string &value)
{ {