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 592 of file socks.c.

References GNUNET_CONFIGURATION_have_value().

Referenced by GNUNET_SOCKS_do_connect(), and start_connect().

594 {
595  return GNUNET_CONFIGURATION_have_value(cfg, service_name, "SOCKSPORT") ||
597 }
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 609 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.

611 {
612  struct GNUNET_SOCKS_Handshake *ih;
613  struct GNUNET_CONNECTION_Handle *socks5; /* *proxied */
614  char *host0;
615  char *host1;
616  char *user;
617  char *pass;
618  unsigned long long port0;
619  unsigned long long port1;
620 
622  return NULL;
624  service_name,
625  "SOCKSPORT",
626  &port0))
627  port0 = 9050;
628  /* A typical Tor client should usually try port 9150 for the TBB too, but
629  * GNUnet can probably assume a system Tor installation. */
630  if (port0 > 65535 || port0 <= 0)
631  {
633  _(
634  "Attempting to use invalid port %d as SOCKS proxy for service `%s'.\n"),
635  port0,
636  service_name);
637  return NULL;
638  }
640  service_name,
641  "PORT",
642  &port1)) ||
643  (port1 > 65535) || (port1 <= 0) ||
645  service_name,
646  "HOSTNAME",
647  &host1)))
648  {
650  _(
651  "Attempting to proxy service `%s' to invalid port %d or hostname.\n"),
652  service_name,
653  port1);
654  return NULL;
655  }
656  /* Appeared to still work after host0 corrupted, so either test case is broken, or
657  this whole routine is not being called. */
659  service_name,
660  "SOCKSHOST",
661  &host0))
662  host0 = NULL;
664  (host0 != NULL) ? host0
665  : "127.0.0.1",
666  port0);
667  GNUNET_free_non_null(host0);
668 
669  /* Sets to NULL if they do not exist */
671  service_name,
672  "SOCKSUSER",
673  &user);
675  service_name,
676  "SOCKSPASS",
677  &pass);
678  ih = GNUNET_SOCKS_init_handshake(user, pass);
679  GNUNET_free_non_null(user);
680  GNUNET_free_non_null(pass);
681 
682  GNUNET_SOCKS_set_handshake_destination(ih, host1, port1);
683  GNUNET_free(host1);
684  return GNUNET_SOCKS_run_handshake(ih, socks5);
685 }
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:75
#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:181
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:523
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:592
#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:572
#define GNUNET_YES
Definition: gnunet_common.h:77
State of the SOCKS5 handshake.
Definition: socks.c:135
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:459
Here is the call graph for this function: