GNUnet  0.10.x
Functions
SOCKS proxy

SOCKS proxy for connections. More...

Functions

int GNUNET_SOCKS_check_service (const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Check if a SOCKS proxy is required by a service. More...
 
struct GNUNET_CONNECTION_HandleGNUNET_SOCKS_do_connect (const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Try to connect to a service configured to use a SOCKS5 proxy. More...
 

Detailed Description

SOCKS proxy for connections.

Function Documentation

◆ GNUNET_SOCKS_check_service()

int GNUNET_SOCKS_check_service ( const char *  service_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)

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.

Parameters
service_namename of service to connect to
cfgconfiguration to use
Returns
GNUNET_YES if so, GNUNET_NO if not

Definition at line 575 of file socks.c.

References GNUNET_CONFIGURATION_have_value().

Referenced by GNUNET_SOCKS_do_connect(), and start_connect().

577 {
578  return GNUNET_CONFIGURATION_have_value (cfg, service_name, "SOCKSPORT") ||
579  GNUNET_CONFIGURATION_have_value (cfg, service_name, "SOCKSHOST");
580 }
int GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SOCKS_do_connect()

struct GNUNET_CONNECTION_Handle* GNUNET_SOCKS_do_connect ( const char *  service_name,
const struct GNUNET_CONFIGURATION_Handle cfg 
)

Try to connect to a service configured to use a SOCKS5 proxy.

Parameters
service_namename of service to connect to
cfgconfiguration to use
Returns
Connection handle that becomes usable when the handshake completes. NULL if SOCKS not configured or not configured properly

Definition at line 592 of file socks.c.

References _, GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONNECTION_create_from_connect(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_free_non_null, GNUNET_OK, GNUNET_SOCKS_check_service(), GNUNET_SOCKS_init_handshake(), GNUNET_SOCKS_run_handshake(), GNUNET_SOCKS_set_handshake_destination(), GNUNET_YES, and LOG.

594 {
595  struct GNUNET_SOCKS_Handshake *ih;
596  struct GNUNET_CONNECTION_Handle *socks5; /* *proxied */
597  char *host0;
598  char *host1;
599  char *user;
600  char *pass;
601  unsigned long long port0;
602  unsigned long long port1;
603 
605  return NULL;
607  service_name,
608  "SOCKSPORT",
609  &port0))
610  port0 = 9050;
611  /* A typical Tor client should usually try port 9150 for the TBB too, but
612  * GNUnet can probably assume a system Tor installation. */
613  if (port0 > 65535 || port0 <= 0)
614  {
616  _ (
617  "Attempting to use invalid port %d as SOCKS proxy for service `%s'.\n"),
618  port0,
619  service_name);
620  return NULL;
621  }
623  service_name,
624  "PORT",
625  &port1)) ||
626  (port1 > 65535) || (port1 <= 0) ||
628  service_name,
629  "HOSTNAME",
630  &host1)))
631  {
633  _ (
634  "Attempting to proxy service `%s' to invalid port %d or hostname.\n"),
635  service_name,
636  port1);
637  return NULL;
638  }
639  /* Appeared to still work after host0 corrupted, so either test case is broken, or
640  this whole routine is not being called. */
642  service_name,
643  "SOCKSHOST",
644  &host0))
645  host0 = NULL;
647  (host0 != NULL) ? host0
648  : "127.0.0.1",
649  port0);
650  GNUNET_free_non_null (host0);
651 
652  /* Sets to NULL if they do not exist */
654  service_name,
655  "SOCKSUSER",
656  &user);
658  service_name,
659  "SOCKSPASS",
660  &pass);
661  ih = GNUNET_SOCKS_init_handshake (user, pass);
662  GNUNET_free_non_null (user);
663  GNUNET_free_non_null (pass);
664 
665  GNUNET_SOCKS_set_handshake_destination (ih, host1, port1);
666  GNUNET_free (host1);
667  return GNUNET_SOCKS_run_handshake (ih, socks5);
668 }
struct GNUNET_CONNECTION_Handle * GNUNET_CONNECTION_create_from_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *hostname, uint16_t port)
Create a connection handle by (asynchronously) connecting to a host.
int GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
void GNUNET_SOCKS_set_handshake_destination(struct GNUNET_SOCKS_Handshake *ih, const char *host, uint16_t port)
Build request that the SOCKS5 proxy open a TCP/IP stream to the given host and port.
Definition: socks.c:505
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:51
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
int GNUNET_SOCKS_check_service(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg)
Check if a SOCKS proxy is required by a service.
Definition: socks.c:575
#define LOG(kind,...)
Definition: socks.c:32
struct GNUNET_CONNECTION_Handle * GNUNET_SOCKS_run_handshake(struct GNUNET_SOCKS_Handshake *ih, struct GNUNET_CONNECTION_Handle *c)
Run a SOCKS5 handshake on an open but unused TCP connection.
Definition: socks.c:555
#define GNUNET_YES
Definition: gnunet_common.h:80
State of the SOCKS5 handshake.
Definition: socks.c:125
handle for a network connection
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SOCKS_Handshake * GNUNET_SOCKS_init_handshake(const char *user, const char *pass)
Initialize a SOCKS5 handshake for authentication via username and password.
Definition: socks.c:441
Here is the call graph for this function: