SOCKS5 connection support. More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_SOCKS_Handshake |
State of the SOCKS5 handshake. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "util-socks", __VA_ARGS__) |
#define | LOG_STRERROR(kind, syscall) GNUNET_log_from_strerror (kind, "util-socks", syscall) |
#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 */ |
#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 /* Invalid address */ |
#define | SOCKS5_step_greet 0 |
#define | SOCKS5_step_auth 1 |
#define | SOCKS5_step_cmd 2 |
#define | SOCKS5_step_done 3 |
#define | register_reciever_wants(ih) ((SOCKS5_step_cmd == ih->step) ? 10 : 2) |
Functions | |
const char * | SOCKS5_REP_names (int rep) |
unsigned char * | SOCK5_proto_string (unsigned char *b, const char *s) |
Encode a string for the SOCKS5 protocol by prefixing it a byte stating its length and stripping the trailing zero byte. More... | |
void | register_reciever (struct GNUNET_SOCKS_Handshake *ih, int want) |
Register callback to read from the SOCKS5 proxy. More... | |
struct GNUNET_CONNECTION_TransmitHandle * | register_sender (struct GNUNET_SOCKS_Handshake *ih) |
Register SOCKS5 handshake sender. More... | |
void | SOCKS5_handshake_done (struct GNUNET_SOCKS_Handshake *ih) |
Conclude the SOCKS5 handshake successfully. More... | |
void | SOCKS5_handshake_step (struct GNUNET_SOCKS_Handshake *ih) |
Read one step in the SOCKS5 handshake. More... | |
void | receiver (void *cls, const void *buf, size_t available, const struct sockaddr *addr, socklen_t addrlen, int errCode) |
Callback to read from the SOCKS5 proxy. More... | |
size_t | transmit_ready (void *cls, size_t size, void *buf) |
Register SOCKS5 handshake sender. More... | |
struct GNUNET_SOCKS_Handshake * | GNUNET_SOCKS_init_handshake (const char *user, const char *pass) |
Initialize a SOCKS5 handshake for authentication via username and password. More... | |
struct GNUNET_SOCKS_Handshake * | GNUNET_SOCKS_init_handshake_noauth () |
Initialize a SOCKS5 handshake without authentication, thereby possibly sharing a Tor circuit with another process. More... | |
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. More... | |
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. More... | |
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... | |
SOCKS5 connection support.
These routines should be called only on newly active connections.
Definition in file socks.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "util-socks", __VA_ARGS__) |
#define LOG_STRERROR | ( | kind, | |
syscall | |||
) | GNUNET_log_from_strerror (kind, "util-socks", syscall) |
#define SOCKS5_AUTH_REJECT 0xFF /* No acceptable auth method */ |
#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 */ |
#define SOCKS5_REP_FAIL 0x01 /* general SOCKS serer failure */ |
#define SOCKS5_REP_NALLOWED 0x02 /* connection not allowed by ruleset */ |
#define register_reciever_wants | ( | ih | ) | ((SOCKS5_step_cmd == ih->step) ? 10 : 2) |
const char * SOCKS5_REP_names | ( | int | rep | ) |
Definition at line 62 of file socks.c.
References SOCKS5_REP_ANOTSUP, SOCKS5_REP_CNOTSUP, SOCKS5_REP_EXPIRED, SOCKS5_REP_FAIL, SOCKS5_REP_HUNREACH, SOCKS5_REP_INVADDR, SOCKS5_REP_NALLOWED, SOCKS5_REP_NUNREACH, SOCKS5_REP_REFUSED, and SOCKS5_REP_SUCCEEDED.
Referenced by SOCKS5_handshake_step().
unsigned char * SOCK5_proto_string | ( | unsigned char * | b, |
const char * | s | ||
) |
Encode a string for the SOCKS5 protocol by prefixing it a byte stating its length and stripping the trailing zero byte.
Truncates any string longer than 255 bytes.
b | buffer to contain the encoded string |
s | string to encode |
Definition at line 112 of file socks.c.
References GNUNET_ERROR_TYPE_WARNING, and LOG.
Referenced by GNUNET_SOCKS_init_handshake(), and GNUNET_SOCKS_set_handshake_destination().
void register_reciever | ( | struct GNUNET_SOCKS_Handshake * | ih, |
int | want | ||
) |
Register callback to read from the SOCKS5 proxy.
client | the service |
handler | function to call with the message |
handler_cls | closure for handler |
Definition at line 354 of file socks.c.
References GNUNET_TIME_relative_get_minute_(), receiver(), and GNUNET_SOCKS_Handshake::socks5_connection.
Referenced by SOCKS5_handshake_step(), and transmit_ready().
struct GNUNET_CONNECTION_TransmitHandle * register_sender | ( | struct GNUNET_SOCKS_Handshake * | ih | ) |
Register SOCKS5 handshake sender.
ih | handshake |
Definition at line 430 of file socks.c.
References GNUNET_assert, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_MINUTES, GNUNET_SOCKS_Handshake::outbuf, GNUNET_SOCKS_Handshake::outstep, GNUNET_SOCKS_Handshake::socks5_connection, SOCKS5_step_done, GNUNET_SOCKS_Handshake::step, GNUNET_SOCKS_Handshake::th, timeout, and transmit_ready().
Referenced by GNUNET_SOCKS_run_handshake(), SOCKS5_handshake_step(), and transmit_ready().
void SOCKS5_handshake_done | ( | struct GNUNET_SOCKS_Handshake * | ih | ) |
Conclude the SOCKS5 handshake successfully.
ih | SOCKS5 handshake, consumed here. |
c | open unused connection, consumed here. |
Definition at line 204 of file socks.c.
References GNUNET_SOCKS_Handshake::target_connection.
Referenced by SOCKS5_handshake_step().
void SOCKS5_handshake_step | ( | struct GNUNET_SOCKS_Handshake * | ih | ) |
Read one step in the SOCKS5 handshake.
ih | SOCKS5 Handshake |
Definition at line 216 of file socks.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_SOCKS_Handshake::inend, GNUNET_SOCKS_Handshake::instart, LOG, register_reciever(), register_reciever_wants, register_sender(), SOCKS5_AUTH_NOAUTH, SOCKS5_AUTH_REJECT, SOCKS5_AUTH_USERPASS, SOCKS5_handshake_done(), SOCKS5_REP_names(), SOCKS5_step_auth, SOCKS5_step_cmd, SOCKS5_step_done, SOCKS5_step_greet, and GNUNET_SOCKS_Handshake::step.
Referenced by receiver().
void receiver | ( | void * | cls, |
const void * | buf, | ||
size_t | available, | ||
const struct sockaddr * | addr, | ||
socklen_t | addrlen, | ||
int | errCode | ||
) |
Callback to read from the SOCKS5 proxy.
client | the service |
handler | function to call with the message |
handler_cls | closure for handler |
Definition at line 330 of file socks.c.
References GNUNET_assert, GNUNET_memcpy, GNUNET_SOCKS_Handshake::inbuf, GNUNET_SOCKS_Handshake::inend, and SOCKS5_handshake_step().
Referenced by add_acks(), check_timeouts(), create_receiver(), create_rekey(), derive_aes_key(), GCCH_handle_local_data(), get_receiver_delete_it(), get_socket(), GNUNET_TRANSPORT_TESTING_send(), handle_ack(), handle_ack_by_sender(), handle_add_queue_message(), mq_destroy_d(), mq_destroy_kx(), mq_error(), mq_send_d(), mq_send_kx(), receiver_destroy(), register_reciever(), reschedule_receiver_timeout(), secret_destroy(), send_ack(), send_msg_with_kx(), setup_initial_shared_secret_ephemeral(), setup_receiver_mq(), and setup_shared_secret_ephemeral().
size_t transmit_ready | ( | void * | cls, |
size_t | size, | ||
void * | buf | ||
) |
Register SOCKS5 handshake sender.
cls | closure (SOCKS handshake) |
size | number of bytes available in buf |
buf | where the callee should write the message |
Definition at line 373 of file socks.c.
References GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_memcpy, LOG, GNUNET_SOCKS_Handshake::outbuf, GNUNET_SOCKS_Handshake::outstep, register_reciever(), register_reciever_wants, register_sender(), size, SOCKS5_step_done, and GNUNET_SOCKS_Handshake::step.
Referenced by register_sender().
struct GNUNET_SOCKS_Handshake * GNUNET_SOCKS_init_handshake | ( | const char * | user, |
const char * | pass | ||
) |
Initialize a SOCKS5 handshake for authentication via username and password.
Tor uses SOCKS username and password authentication to assign programs unique circuits.
user | username for the proxy |
pass | password for the proxy |
Definition at line 460 of file socks.c.
References GNUNET_new, GNUNET_SOCKS_Handshake::inbuf, GNUNET_SOCKS_Handshake::inend, GNUNET_SOCKS_Handshake::instart, GNUNET_SOCKS_Handshake::outbuf, GNUNET_SOCKS_Handshake::outstep, SOCK5_proto_string(), SOCKS5_AUTH_NOAUTH, SOCKS5_AUTH_USERPASS, SOCKS5_step_auth, SOCKS5_step_cmd, and SOCKS5_step_greet.
Referenced by GNUNET_SOCKS_do_connect(), and GNUNET_SOCKS_init_handshake_noauth().
struct GNUNET_SOCKS_Handshake * GNUNET_SOCKS_init_handshake_noauth | ( | ) |
Initialize a SOCKS5 handshake without authentication, thereby possibly sharing a Tor circuit with another process.
Definition at line 509 of file socks.c.
References GNUNET_SOCKS_init_handshake().
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.
ih | SOCKS5 handshake |
host | |
port |
Definition at line 524 of file socks.c.
References GNUNET_memcpy, GNUNET_SOCKS_Handshake::outstep, port, SOCK5_proto_string(), SOCKS5_step_cmd, and SOCKS5_step_done.
Referenced by GNUNET_SOCKS_do_connect().
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.
ih | SOCKS5 handshake, consumed here. |
c | open unused connection, consumed here. |
Definition at line 574 of file socks.c.
References register_sender(), GNUNET_SOCKS_Handshake::socks5_connection, and GNUNET_SOCKS_Handshake::target_connection.
Referenced by GNUNET_SOCKS_do_connect().