GNUnet 0.22.1
SOCKS proxy

SOCKS proxy for connections. More...

Collaboration diagram for SOCKS proxy:

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

596{
597 return GNUNET_CONFIGURATION_have_value (cfg, service_name, "SOCKSPORT") ||
599}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static char * service_name
Option -s: service name (hash to get service descriptor)
Definition: gnunet-vpn.c:50
enum GNUNET_GenericReturnValue 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.

References cfg, GNUNET_CONFIGURATION_have_value(), and service_name.

Referenced by GNUNET_SOCKS_do_connect(), and start_connect().

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

613{
614 struct GNUNET_SOCKS_Handshake *ih;
615 struct GNUNET_CONNECTION_Handle *socks5; /* *proxied */
616 char *host0;
617 char *host1;
618 char *user;
619 char *pass;
620 unsigned long long port0;
621 unsigned long long port1;
622
624 return NULL;
627 "SOCKSPORT",
628 &port0))
629 port0 = 9050;
630 /* A typical Tor client should usually try port 9150 for the TBB too, but
631 * GNUnet can probably assume a system Tor installation. */
632 if ((port0 > 65535) || (port0 <= 0))
633 {
635 _ (
636 "Attempting to use invalid port %d as SOCKS proxy for service `%s'.\n"),
637 port0,
639 return NULL;
640 }
643 "PORT",
644 &port1)) ||
645 (port1 > 65535) || (port1 <= 0) ||
648 "HOSTNAME",
649 &host1)))
650 {
652 _ (
653 "Attempting to proxy service `%s' to invalid port %d or hostname.\n"),
655 port1);
656 return NULL;
657 }
658 /* Appeared to still work after host0 corrupted, so either test case is broken, or
659 this whole routine is not being called. */
662 "SOCKSHOST",
663 &host0))
664 host0 = NULL;
665 socks5 = GNUNET_CONNECTION_create_from_connect (cfg,
666 (host0 != NULL) ? host0
667 : "127.0.0.1",
668 port0);
669 GNUNET_free (host0);
670
671 /* Sets to NULL if they do not exist */
674 "SOCKSUSER",
675 &user);
678 "SOCKSPASS",
679 &pass);
680 ih = GNUNET_SOCKS_init_handshake (user, pass);
681 GNUNET_free (user);
682 GNUNET_free (pass);
683
685 GNUNET_free (host1);
686 return GNUNET_SOCKS_run_handshake (ih, socks5);
687}
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_free(ptr)
Wrapper around free.
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:594
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
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:460
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:574
#define LOG(kind,...)
Definition: socks.c:33
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:524
State of the SOCKS5 handshake.
Definition: socks.c:137

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

Here is the call graph for this function: