Skip to content

Commit

Permalink
Merge branch 'main' of github.com:streetpea/chiaki-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
streetpea committed Nov 28, 2024
2 parents fb48006 + 1441911 commit 9d76d55
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/src/remote/holepunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#define SELECT_CANDIDATE_CONNECTION_SEC 5
#define RANDOM_ALLOCATION_GUESSES_NUMBER 75
#define RANDOM_ALLOCATION_SOCKS_NUMBER 250
#define CHECK_CANDIDATES_REQUEST_NUMBER 1
#define WAIT_RESPONSE_TIMEOUT_SEC 1
#define MSG_TYPE_REQ 0x06000000
#define MSG_TYPE_RESP 0x07000000
Expand Down Expand Up @@ -3592,11 +3593,11 @@ static ChiakiErrorCode check_candidates(
ChiakiErrorCode err = CHIAKI_ERR_SUCCESS;

// Set up request buffer
uint8_t request_buf[3][88] = {0};
uint8_t request_id[3][5] = {0};
uint8_t request_buf[CHECK_CANDIDATES_REQUEST_NUMBER][88] = {0};
uint8_t request_id[CHECK_CANDIDATES_REQUEST_NUMBER][5] = {0};

// send 3 requests for connection pairing with ps
for(int i = 0; i < 3; i++)
// send CHECK_CANDIDATES_REQUEST_NUMBER requests for connection pairing with ps
for(int i = 0; i < CHECK_CANDIDATES_REQUEST_NUMBER; i++)
{
chiaki_random_bytes_crypt(request_id[i], sizeof(request_id[i]));
*(uint32_t*)&request_buf[i][0x00] = htonl(MSG_TYPE_REQ);
Expand Down Expand Up @@ -4079,7 +4080,7 @@ static ChiakiErrorCode check_candidates(
responses_received[i]++;
responses = responses_received[i];
CHIAKI_LOGV(session->log, "Received response %d", responses);
if(responses > 2)
if(responses > (CHECK_CANDIDATES_REQUEST_NUMBER - 1))
{
selected_sock = candidate_sock;
selected_candidate = candidate;
Expand Down

0 comments on commit 9d76d55

Please sign in to comment.