aboutsummaryrefslogtreecommitdiff
path: root/src/util/socks.c
diff options
context:
space:
mode:
authorJeff Burdges <burdges@gnunet.org>2015-08-03 16:44:18 +0000
committerJeff Burdges <burdges@gnunet.org>2015-08-03 16:44:18 +0000
commit09e2898ebb05bc0cec8ba986a30f0a03032eb229 (patch)
treee7ccfe0e05e853add9233e197ee9041b4ff9e66e /src/util/socks.c
parentda37fac0e6f27a112d39e44fd78cda619627d107 (diff)
downloadgnunet-09e2898ebb05bc0cec8ba986a30f0a03032eb229.tar.gz
gnunet-09e2898ebb05bc0cec8ba986a30f0a03032eb229.zip
Woot! It might actually work now, although I should tweak the test
a bit to make sure.
Diffstat (limited to 'src/util/socks.c')
-rw-r--r--src/util/socks.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/util/socks.c b/src/util/socks.c
index d54a086f9..3ae63b6fc 100644
--- a/src/util/socks.c
+++ b/src/util/socks.c
@@ -274,7 +274,6 @@ SOCKS5_handshake_step (struct GNUNET_SOCKS_Handshake *ih)
274 case SOCKS5_step_done: 274 case SOCKS5_step_done:
275 GNUNET_assert (0); 275 GNUNET_assert (0);
276 } 276 }
277 ++ih->step;
278 ih->instart = b; 277 ih->instart = b;
279 /* Do not reschedule the sender unless we're done reading. 278 /* Do not reschedule the sender unless we're done reading.
280 * I imagine this lets us avoid ever cancelling the transmit handle. */ 279 * I imagine this lets us avoid ever cancelling the transmit handle. */
@@ -295,7 +294,6 @@ reciever (void *cls,
295 const struct sockaddr * addr, 294 const struct sockaddr * addr,
296 socklen_t addrlen, int errCode) 295 socklen_t addrlen, int errCode)
297{ 296{
298printf("Meow(%d)",available);
299 struct GNUNET_SOCKS_Handshake * ih = cls; 297 struct GNUNET_SOCKS_Handshake * ih = cls;
300 GNUNET_assert (&ih->inend[available] < &ih->inbuf[1024]); 298 GNUNET_assert (&ih->inend[available] < &ih->inbuf[1024]);
301 memcpy(ih->inend, buf, available); 299 memcpy(ih->inend, buf, available);
@@ -314,7 +312,6 @@ printf("Meow(%d)",available);
314void 312void
315register_reciever (struct GNUNET_SOCKS_Handshake *ih, int want) 313register_reciever (struct GNUNET_SOCKS_Handshake *ih, int want)
316{ 314{
317 printf("register_reciever on step %u for %d bytes.\n", ih->step, want );
318 GNUNET_CONNECTION_receive (ih->socks5_connection, 315 GNUNET_CONNECTION_receive (ih->socks5_connection,
319 want, 316 want,
320 GNUNET_TIME_relative_get_minute_ (), 317 GNUNET_TIME_relative_get_minute_ (),
@@ -372,14 +369,10 @@ transmit_ready (void *cls,
372 } 369 }
373 return 0; 370 return 0;
374 } 371 }
375 printf("Erronious socks.c transmit_ready() callback on step %u with reason %u.\n",
376 ih->step, reason );
377 /* if (reason == 48) register_sender (ih); */ 372 /* if (reason == 48) register_sender (ih); */
378 /* GNUNET_break(0); */ 373 /* GNUNET_break(0); */
379 return 0; 374 return 0;
380 } else 375 }
381 printf("Good socks.c transmit_ready() callback on step %u with reason %u.\n",
382 ih->step, GNUNET_SCHEDULER_get_reason () );
383 376
384 GNUNET_assert (1024 >= size && size > 0); 377 GNUNET_assert (1024 >= size && size > 0);
385 GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0); 378 GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0);
@@ -390,7 +383,6 @@ transmit_ready (void *cls,
390 GNUNET_assert (size >= l && l >= 0); 383 GNUNET_assert (size >= l && l >= 0);
391 memcpy(buf, b, l); 384 memcpy(buf, b, l);
392 register_reciever (ih, register_reciever_wants(ih)); 385 register_reciever (ih, register_reciever_wants(ih));
393 printf("sent(%d)\n",l);
394 return l; 386 return l;
395} 387}
396 388
@@ -407,13 +399,13 @@ register_sender (struct GNUNET_SOCKS_Handshake *ih)
407{ 399{
408 struct GNUNET_TIME_Relative timeout = GNUNET_TIME_UNIT_MINUTES; 400 struct GNUNET_TIME_Relative timeout = GNUNET_TIME_UNIT_MINUTES;
409 401
410 GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0); 402 GNUNET_assert (SOCKS5_step_done > ih->step);
403 GNUNET_assert (ih->step >= 0);
411 if (0 == ih->step) 404 if (0 == ih->step)
412 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3); 405 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3);
413 unsigned char * b = ih->outstep[ih->step]; 406 unsigned char * b = ih->outstep[ih->step];
414 unsigned char * e = ih->outstep[ih->step+1]; 407 unsigned char * e = ih->outstep[ih->step+1];
415 GNUNET_assert (ih->outbuf <= b && b < e && e < &ih->outbuf[1024]); 408 GNUNET_assert (ih->outbuf <= b && b < e && e < &ih->outbuf[1024]);
416 printf("register_sender on step %u for %u bytes.\n", ih->step, (unsigned)(e - b) );
417 ih->th = GNUNET_CONNECTION_notify_transmit_ready (ih->socks5_connection, 409 ih->th = GNUNET_CONNECTION_notify_transmit_ready (ih->socks5_connection,
418 e - b, 410 e - b,
419 timeout, 411 timeout,
@@ -467,6 +459,8 @@ GNUNET_SOCKS_init_handshake (const char *user, const char *pass)
467 459
468 ih->outstep[SOCKS5_step_cmd] = b; 460 ih->outstep[SOCKS5_step_cmd] = b;
469 461
462 ih->inend = ih->instart = ih->inbuf;
463
470 return ih; 464 return ih;
471} 465}
472 466