Tor  0.4.7.0-alpha-dev
Macros | Functions
proto_socks.h File Reference

Header for proto_socks.c. More...

Go to the source code of this file.

Macros

#define socks_request_free(req)    FREE_AND_NULL(socks_request_t, socks_request_free_, (req))
 

Functions

struct socks_request_tsocks_request_new (void)
 
void socks_request_free_ (struct socks_request_t *req)
 
int fetch_from_buf_socks (struct buf_t *buf, socks_request_t *req, int log_sockstype, int safe_socks)
 
int fetch_from_buf_socks_client (buf_t *buf, int state, char **reason)
 

Detailed Description

Header for proto_socks.c.

Definition in file proto_socks.h.

Function Documentation

◆ fetch_from_buf_socks()

int fetch_from_buf_socks ( buf_t *  buf,
socks_request_t req,
int  log_sockstype,
int  safe_socks 
)

There is a (possibly incomplete) socks handshake on buf, of one of the forms

  • socks4: "socksheader username\\0"
  • socks4a: "socksheader username\\0 destaddr\\0"
  • socks5 phase one: "version #methods methods"
  • socks5 phase two: "version command 0 addresstype..." If it's a complete and valid handshake, and destaddr fits in MAX_SOCKS_ADDR_LEN bytes, then pull the handshake off the buf, assign to req, and return 1.

If it's invalid or too big, return -1.

Else it's not all there yet, leave buf alone and return 0.

If you want to specify the socks reply, write it into req->reply and set req->replylen, else leave req->replylen alone.

If log_sockstype is non-zero, then do a notice-level log of whether the connection is possibly leaking DNS requests locally or not.

If safe_socks is true, then reject unsafe socks protocols.

If returning 0 or -1, req->address and req->port are undefined.

Definition at line 829 of file proto_socks.c.

◆ fetch_from_buf_socks_client()

int fetch_from_buf_socks_client ( buf_t *  buf,
int  state,
char **  reason 
)

Inspect a reply from SOCKS server stored in buf according to state, removing the protocol data upon success. Return 0 on incomplete response, 1 on success and -1 on error, in which case reason is set to a descriptive message (free() when finished with it).

As a special case, 2 is returned when user/pass is required during SOCKS5 handshake and user/pass is configured.

Definition at line 1005 of file proto_socks.c.

Referenced by connection_fetch_from_buf_socks_client().

◆ socks_request_free_()

void socks_request_free_ ( socks_request_t req)

Free all storage held in the socks_request_t req.

Definition at line 94 of file proto_socks.c.

◆ socks_request_new()

struct socks_request_t* socks_request_new ( void  )

Return a new socks_request_t.

Definition at line 87 of file proto_socks.c.