aboutsummaryrefslogtreecommitdiff
path: root/src/util/socks.c
blob: ad44996281b66f914bde95ed84956c763048eae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
/*
     This file is part of GNUnet.
     Copyright (C) 2009-2013 GNUnet e.V.

     GNUnet is free software: you can redistribute it and/or modify it
     under the terms of the GNU Affero General Public License as published
     by the Free Software Foundation, either version 3 of the License,
     or (at your option) any later version.

     GNUnet is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     Affero General Public License for more details.
*/

/**
 * @file util/socks.c
 * @brief  SOCKS5 connection support
 * @author Jeffrey Burdges
 *
 * These routines should be called only on newly active connections.
 */
#include "platform.h"
#include "gnunet_util_lib.h"


#define LOG(kind,...) GNUNET_log_from (kind, "util-socks", __VA_ARGS__)

#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-socks", syscall)


/* SOCKS5 authentication methods */
#define SOCKS5_AUTH_REJECT 0xFF /* No acceptable auth method */
#define SOCKS5_AUTH_NOAUTH 0x00 /* without authentication */
#define SOCKS5_AUTH_GSSAPI 0x01 /* GSSAPI */
#define SOCKS5_AUTH_USERPASS 0x02 /* User/Password */
#define SOCKS5_AUTH_CHAP 0x03 /* Challenge-Handshake Auth Proto. */
#define SOCKS5_AUTH_EAP 0x05 /* Extensible Authentication Proto. */
#define SOCKS5_AUTH_MAF 0x08 /* Multi-Authentication Framework */


/* SOCKS5 connection responces */
#define SOCKS5_REP_SUCCEEDED 0x00 /* succeeded */
#define SOCKS5_REP_FAIL 0x01 /* general SOCKS serer failure */
#define SOCKS5_REP_NALLOWED 0x02 /* connection not allowed by ruleset */
#define SOCKS5_REP_NUNREACH 0x03 /* Network unreachable */
#define SOCKS5_REP_HUNREACH 0x04 /* Host unreachable */
#define SOCKS5_REP_REFUSED 0x05 /* connection refused */
#define SOCKS5_REP_EXPIRED 0x06 /* TTL expired */
#define SOCKS5_REP_CNOTSUP 0x07 /* Command not supported */
#define SOCKS5_REP_ANOTSUP 0x08 /* Address not supported */
#define SOCKS5_REP_INVADDR 0x09 /* Inalid address */

const char * SOCKS5_REP_names(int rep)
{
  switch (rep) {
    case SOCKS5_REP_SUCCEEDED: return "succeeded";
    case SOCKS5_REP_FAIL: return "general SOCKS server failure";
    case SOCKS5_REP_NALLOWED: return "connection not allowed by ruleset";
    case SOCKS5_REP_NUNREACH: return "Network unreachable";
    case SOCKS5_REP_HUNREACH: return "Host unreachable";
    case SOCKS5_REP_REFUSED: return "connection refused";
    case SOCKS5_REP_EXPIRED: return "TTL expired";
    case SOCKS5_REP_CNOTSUP: return "Command not supported";
    case SOCKS5_REP_ANOTSUP: return "Address not supported";
    case SOCKS5_REP_INVADDR: return "Invalid address";
    default: return NULL;
  }
};


/**
 * Encode a string for the SOCKS5 protocol by prefixing it a byte stating its
 * length and stipping the trailing zero byte.  Truncates any string longer
 * than 255 bytes.
 *
 * @param b buffer to contain the encoded string
 * @param s string to encode
 * @return pointer to the end of the encoded string in the buffer
 */
unsigned char *
SOCK5_proto_string(unsigned char * b,
                   const char * s)
{
  size_t l = strlen(s);

  if (l > 255)
  {
    LOG (GNUNET_ERROR_TYPE_WARNING,
         "SOCKS5 cannot handle hostnames, usernames, or passwords over 255 bytes, truncating.\n");
    l=255;
  }
  *(b++) = (unsigned char) l;
  strncpy ((char *)b, s, l);
  return b+l;
}


#define SOCKS5_step_greet 0
#define SOCKS5_step_auth  1
#define SOCKS5_step_cmd   2
#define SOCKS5_step_done  3

/**
 * State of the SOCKS5 handshake.
 */
struct GNUNET_SOCKS_Handshake
{

  /**
   * Connection handle used for SOCKS5
   */
  struct GNUNET_CONNECTION_Handle *socks5_connection;

  /**
   * Connection handle initially returned to client
   */
  struct GNUNET_CONNECTION_Handle *target_connection;

  /**
   * Transmission handle on socks5_connection.
   */
  struct GNUNET_CONNECTION_TransmitHandle *th;

  /**
   * Our stage in the SOCKS5 handshake
   */
  int step;

  /**
   * Precomputed SOCKS5 handshake ouput buffer
   */
  unsigned char outbuf[1024];

  /**
   * Pointers delineating protoocol steps in the outbut buffer
   */
  unsigned char * (outstep[4]);

  /**
   * SOCKS5 handshake input buffer
   */
  unsigned char inbuf[1024];

  /**
   * Pointers delimiting the current step in the input buffer
   */
  unsigned char * instart;
  unsigned char * inend;
};


/* Regitering prototypes */

void
register_reciever (struct GNUNET_SOCKS_Handshake *ih, int want);

  /* In fact, the client sends first rule in GNUNet suggests one could take
   * large mac read sizes without fear of screwing up the proxied protocol,
   * but we make a proper SOCKS5 client. */
#define register_reciever_wants(ih) ((SOCKS5_step_cmd == ih->step) ? 10 : 2)


struct GNUNET_CONNECTION_TransmitHandle *
register_sender (struct GNUNET_SOCKS_Handshake *ih);


/**
 * Conclude the SOCKS5 handshake successfully.
 *
 * @param ih SOCKS5 handshake, consumed here.
 * @param c open unused connection, consumed here.
 * @return Connection handle that becomes usable when the handshake completes.
 */
void
SOCKS5_handshake_done(struct GNUNET_SOCKS_Handshake *ih)
{
  GNUNET_CONNECTION_acivate_proxied (ih->target_connection);
}


/**
 * Read one step in the SOCKS5 handshake.
 *
 * @param ih SOCKS5 Handshake
 */
void
SOCKS5_handshake_step (struct GNUNET_SOCKS_Handshake *ih)
{
  unsigned char * b = ih->instart;
  size_t available = ih->inend - b;

  int want = register_reciever_wants(ih);
  if (available < want) {
    register_reciever (ih, want - available);
    return;
  }
  GNUNET_assert (SOCKS5_step_done > ih->step && ih->step >= 0);
  switch (ih->step) {
    case SOCKS5_step_greet:  /* SOCKS5 server's greeting */
      if (b[0] != 5)
      {
        LOG (GNUNET_ERROR_TYPE_ERROR,
             "Not a SOCKS5 server\n");
        GNUNET_assert (0);
      }
      switch (b[1]) {
        case SOCKS5_AUTH_NOAUTH:
          ih->step=SOCKS5_step_cmd;  /* no authentication to do */
          break;
        case SOCKS5_AUTH_USERPASS:
          ih->step=SOCKS5_step_auth;
          break;
        case SOCKS5_AUTH_REJECT:
          LOG (GNUNET_ERROR_TYPE_ERROR,
               "No authentication method accepted\n");
          return;
        default:
          LOG (GNUNET_ERROR_TYPE_ERROR,
               "Not a SOCKS5 server / Nonsensical authentication\n");
          return;
      }
      b += 2;
      break;
    case SOCKS5_step_auth:  /* SOCKS5 server's responce to authentication */
      if (b[1] != 0)
      {
        LOG (GNUNET_ERROR_TYPE_ERROR,
             "SOCKS5 authentication failed\n");
        GNUNET_assert (0);
      }
      ih->step=SOCKS5_step_cmd;
      b += 2;
      break;
    case SOCKS5_step_cmd:  /* SOCKS5 server's responce to command */
      if (b[0] != 5)
      {
        LOG (GNUNET_ERROR_TYPE_ERROR,
             "SOCKS5 protocol error\n");
        GNUNET_assert (0);
      }
      if (0 != b[1]) {
        LOG (GNUNET_ERROR_TYPE_ERROR,
             "SOCKS5 connection error : %s\n",
             SOCKS5_REP_names(b[1]));
        return;
      }
      b += 3;
      /* There is no reason to verify host and port afaik. */
      switch (*(b++)) {
        case 1: /* IPv4 */
          b += sizeof(struct in_addr);  /* 4 */
          break;
        case 4: /* IPv6 */
          b += sizeof(struct in6_addr);  /* 16 */
          break;
        case 3: /* hostname */
          b += *b;
          break;
      }
      b += 2;  /* port */
      if (b > ih->inend) {
        register_reciever (ih, b - ih->inend);
        return;
      }
      ih->step = SOCKS5_step_done;
      LOG (GNUNET_ERROR_TYPE_DEBUG,
           "SOCKS5 server : %s\n",
           SOCKS5_REP_names(b[1]));
      ih->instart = b;
      SOCKS5_handshake_done (ih);
      return;
    case SOCKS5_step_done:
      GNUNET_assert (0);
  }
  ih->instart = b;
  /* Do not reschedule the sender unless we're done reading.
   * I imagine this lets us avoid ever cancelling the transmit handle. */
  register_sender (ih);
}


/**
 * Callback to read from the SOCKS5 proxy.
 *
 * @param client the service
 * @param handler function to call with the message
 * @param handler_cls closure for @a handler
 */
void
reciever (void *cls,
          const void *buf, size_t available,
          const struct sockaddr * addr,
          socklen_t addrlen, int errCode)
{
  struct GNUNET_SOCKS_Handshake * ih = cls;
  GNUNET_assert (&ih->inend[available] < &ih->inbuf[1024]);
  GNUNET_memcpy(ih->inend, buf, available);
  ih->inend += available;
  SOCKS5_handshake_step (ih);
}


/**
 * Register callback to read from the SOCKS5 proxy.
 *
 * @param client the service
 * @param handler function to call with the message
 * @param handler_cls closure for @a handler
 */
void
register_reciever (struct GNUNET_SOCKS_Handshake *ih, int want)
{
  GNUNET_CONNECTION_receive (ih->socks5_connection,
                             want,
                             GNUNET_TIME_relative_get_minute_ (),
                             &reciever,
                             ih);
}


/**
 * Register SOCKS5 handshake sender
 *
 * @param cls closure (SOCKS handshake)
 * @param size number of bytes available in @a buf
 * @param buf where the callee should write the message
 * @return number of bytes written to @a buf
 */
size_t
transmit_ready (void *cls,
                size_t size,
                void *buf)
{
  struct GNUNET_SOCKS_Handshake * ih = cls;

  /* connection.c has many routines that call us with buf == NULL :
   * signal_transmit_error() - DNS, etc. active
   *   connect_fail_continuation()
   *     connect_probe_continuation() - timeout
   *     try_connect_using_address() - DNS failure/timeout
   *     transmit_timeout() - retry failed?
   * GNUNET_CONNECTION_notify_transmit_ready() can schedule :
   *   transmit_timeout() - DNS still working
   *   connect_error() - DNS done but no socket?
   * transmit_ready() - scheduler shutdown or timeout, or signal_transmit_error()
   * We'd need to dig into the scheduler to guess at the reason, as
   * connection.c tells us nothing itself, but mostly its timouts.
   * Initially, we'll simply ignore this and leave massive timeouts, but
   * maybe that should change for error handling pruposes.  It appears that
   * successful operations, including DNS resolution, do not use this.  */
  if (NULL == buf)
  {
    if (0 == ih->step)
    {
      LOG (GNUNET_ERROR_TYPE_WARNING,
	   "Timeout contacting SOCKS server, retrying indefinitely, but probably hopeless.\n");
      register_sender (ih);
    }
    else
    {
      LOG (GNUNET_ERROR_TYPE_ERROR,
	   "Timeout during mid SOCKS handshake (step %u), probably not a SOCKS server.\n",
	   ih->step);
      GNUNET_break (0);
    }
    return 0;
  }

  GNUNET_assert ( (1024 >= size) && (size > 0) );
  GNUNET_assert ( (SOCKS5_step_done > ih->step) && (ih->step >= 0) );
  unsigned char * b = ih->outstep[ih->step];
  unsigned char * e = ih->outstep[ih->step+1];
  GNUNET_assert (e <= &ih->outbuf[1024]);
  unsigned int l = e - b;
  GNUNET_assert (size >= l);
  GNUNET_memcpy (buf,
                 b,
                 l);
  register_reciever (ih,
                     register_reciever_wants (ih));
  return l;
}


/**
 * Register SOCKS5 handshake sender
 *
 * @param ih handshake
 * @return non-NULL if the notify callback was queued,
 *         NULL if we are already going to notify someone else (busy)
 */
struct GNUNET_CONNECTION_TransmitHandle *
register_sender (struct GNUNET_SOCKS_Handshake *ih)
{
  struct GNUNET_TIME_Relative timeout = GNUNET_TIME_UNIT_MINUTES;

  GNUNET_assert (SOCKS5_step_done > ih->step);
  GNUNET_assert (ih->step >= 0);
  if (0 == ih->step)
    timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3);
  unsigned char * b = ih->outstep[ih->step];
  unsigned char * e = ih->outstep[ih->step+1];
  GNUNET_assert (ih->outbuf <= b && b < e && e < &ih->outbuf[1024]);
  ih->th = GNUNET_CONNECTION_notify_transmit_ready (ih->socks5_connection,
                                                    e - b,
                                                    timeout,
                                                    &transmit_ready,
                                                    ih);
  return ih->th;
}


/**
 * Initialize a SOCKS5 handshake for authentication via username and
 * password.  Tor uses SOCKS username and password authentication to assign
 * programs unique circuits.
 *
 * @param user username for the proxy
 * @param pass password for the proxy
 * @return Valid SOCKS5 hanbdshake handle
 */
struct GNUNET_SOCKS_Handshake *
GNUNET_SOCKS_init_handshake (const char *user, const char *pass)
{
  struct GNUNET_SOCKS_Handshake *ih = GNUNET_new (struct GNUNET_SOCKS_Handshake);
  unsigned char * b = ih->outbuf;

  ih->outstep[SOCKS5_step_greet] = b;
  *(b++) = 5; /* SOCKS5 */
  unsigned char * n = b++;
  *n = 1; /* Number of authentication methods */
  /* We support no authentication even when requesting authentication,
   * but this appears harmless, given the way that Tor uses authentication.
   * And some SOCKS5 servers might require this.  */
  *(b++) = SOCKS5_AUTH_NOAUTH;
  if (NULL != user) {
    *(b++) = SOCKS5_AUTH_USERPASS;
    (*n)++;
  }
  /* There is no apperent reason to support authentication methods beyond
   * username and password since afaik Tor does not support them. */

  /* We authenticate with an empty username and password if the server demands
   * them but we do not have any. */
  if (user == NULL)
    user = "";
  if (pass == NULL)
    pass = "";

  ih->outstep[SOCKS5_step_auth] = b;
  *(b++) = 1; /* subnegotiation ver.: 1 */
  b = SOCK5_proto_string(b,user);
  b = SOCK5_proto_string(b,pass);

  ih->outstep[SOCKS5_step_cmd] = b;

  ih->inend = ih->instart = ih->inbuf;

  return ih;
}


/**
 * Initialize a SOCKS5 handshake without authentication, thereby possibly
 * sharing a Tor circuit with another process.
 *
 * @return Valid SOCKS5 hanbdshake handle
 */
struct GNUNET_SOCKS_Handshake *
GNUNET_SOCKS_init_handshake_noauth ()
{
  return GNUNET_SOCKS_init_handshake (NULL,NULL);
}


/**
 * Build request that the SOCKS5 proxy open a TCP/IP stream to the given host
 * and port.
 *
 * @param ih SOCKS5 handshake
 * @param hostname
 * @param port
 */
void
GNUNET_SOCKS_set_handshake_destination (struct GNUNET_SOCKS_Handshake *ih,
                                         const char *host, uint16_t port)
{
  union {
    struct in_addr in4;
    struct in6_addr in6;
  } ia;
  unsigned char * b = ih->outstep[SOCKS5_step_cmd];

  *(b++) = 5;  /* SOCKS5 */
  *(b++) = 1;  /* Establish a TCP/IP stream */
  *(b++) = 0;  /* reserved */

  /* Specify destination */
  if (1 == inet_pton(AF_INET,host,&ia.in4)) {
    *(b++)= 1;  /* IPv4 */
    GNUNET_memcpy (b, &ia.in4, sizeof(struct in_addr));
    b += sizeof(struct in_addr);  /* 4 */
  } else if (1 == inet_pton(AF_INET6,host,&ia.in6)) {
    *(b++)= 4;  /* IPv6 */
    GNUNET_memcpy (b, &ia.in6, sizeof(struct in6_addr));
    b += sizeof(struct in6_addr);  /* 16 */
  } else {
    *(b++)= 3;  /* hostname */
    b = SOCK5_proto_string (b, host);
  }

  /* Specify port */
  *(uint16_t*)b = htons (port);
  b += 2;

  ih->outstep[SOCKS5_step_done] = b;
}


/**
 * Run a SOCKS5 handshake on an open but unused TCP connection.
 *
 * @param ih SOCKS5 handshake, consumed here.
 * @param c open unused connection, consumed here.
 * @return Connection handle that becomes usable when the SOCKS5 handshake completes.
 */
struct GNUNET_CONNECTION_Handle *
GNUNET_SOCKS_run_handshake(struct GNUNET_SOCKS_Handshake *ih,
                            struct GNUNET_CONNECTION_Handle *c)
{
  ih->socks5_connection=c;
  ih->target_connection = GNUNET_CONNECTION_create_proxied_from_handshake (c);
  register_sender (ih);

  return ih->target_connection;
}


/**
 * Check if a SOCKS proxy is required by a service.  Do not use local service
 * if a SOCKS proxy port is configured as this could deanonymize a user.
 *
 * @param service_name name of service to connect to
 * @param cfg configuration to use
 * @return GNUNET_YES if so, GNUNET_NO if not
 */
int
GNUNET_SOCKS_check_service (const char *service_name,
                            const struct GNUNET_CONFIGURATION_Handle *cfg)
{
  return GNUNET_CONFIGURATION_have_value (cfg, service_name, "SOCKSPORT") ||
         GNUNET_CONFIGURATION_have_value (cfg, service_name, "SOCKSHOST");
}


/**
 * Try to connect to a service configured to use a SOCKS5 proxy.
 *
 * @param service_name name of service to connect to
 * @param cfg configuration to use
 * @return Connection handle that becomes usable when the handshake completes.
 *         NULL if SOCKS not configured or not configured properly
 */
struct GNUNET_CONNECTION_Handle *
GNUNET_SOCKS_do_connect (const char *service_name,
                         const struct GNUNET_CONFIGURATION_Handle *cfg)
{
  struct GNUNET_SOCKS_Handshake *ih;
  struct GNUNET_CONNECTION_Handle *socks5; /* *proxied */
  char *host0;
  char *host1;
  char *user;
  char *pass;
  unsigned long long port0;
  unsigned long long port1;

  if (GNUNET_YES !=
      GNUNET_SOCKS_check_service (service_name, cfg))
    return NULL;
  if (GNUNET_OK !=
      GNUNET_CONFIGURATION_get_value_number (cfg,
                                             service_name,
                                             "SOCKSPORT",
                                             &port0))
    port0 = 9050;
  /* A typical Tor client should usually try port 9150 for the TBB too, but
   * GNUnet can probably assume a system Tor installation. */
  if (port0 > 65535 || port0 <= 0)
  {
    LOG (GNUNET_ERROR_TYPE_WARNING,
	 _("Attempting to use invalid port %d as SOCKS proxy for service `%s'.\n"),
	 port0,
         service_name);
    return NULL;
  }
  if ( (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_number (cfg,
                                               service_name,
                                               "PORT",
                                               &port1)) ||
       (port1 > 65535) ||
       (port1 <= 0) ||
       (GNUNET_OK !=
        GNUNET_CONFIGURATION_get_value_string (cfg,
                                               service_name,
                                               "HOSTNAME",
                                               &host1)))
  {
    LOG (GNUNET_ERROR_TYPE_WARNING,
	 _("Attempting to proxy service `%s' to invalid port %d or hostname.\n"),
	 service_name,
         port1);
    return NULL;
  }
  /* Appeared to still work after host0 corrupted, so either test case is broken, or
     this whole routine is not being called. */
  if (GNUNET_OK !=
      GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "SOCKSHOST", &host0))
    host0 = NULL;
  socks5 = GNUNET_CONNECTION_create_from_connect (cfg,
                                                  (host0 != NULL)
                                                  ? host0
                                                  :"127.0.0.1",
                                                  port0);
  GNUNET_free_non_null (host0);

  /* Sets to NULL if they do not exist */
  (void) GNUNET_CONFIGURATION_get_value_string (cfg,
                                                service_name,
                                                "SOCKSUSER",
                                                &user);
  (void) GNUNET_CONFIGURATION_get_value_string (cfg,
                                                service_name,
                                                "SOCKSPASS",
                                                &pass);
  ih = GNUNET_SOCKS_init_handshake(user,pass);
  GNUNET_free_non_null (user);
  GNUNET_free_non_null (pass);

  GNUNET_SOCKS_set_handshake_destination (ih,
                                          host1,
                                          port1);
  GNUNET_free (host1);
  return GNUNET_SOCKS_run_handshake (ih,
                                     socks5);
}

/* socks.c */