socks_request_st.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (c) 2001 Matej Pfajfar.
  2. * Copyright (c) 2001-2004, Roger Dingledine.
  3. * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
  4. * Copyright (c) 2007-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef SOCKS_REQUEST_ST_H
  7. #define SOCKS_REQUEST_ST_H
  8. /** State of a SOCKS request from a user to an OP. Also used to encode other
  9. * information for non-socks user request (such as those on TransPort and
  10. * DNSPort) */
  11. struct socks_request_t {
  12. /** Which version of SOCKS did the client use? One of "0, 4, 5" -- where
  13. * 0 means that no socks handshake ever took place, and this is just a
  14. * stub connection (e.g. see connection_ap_make_link()). */
  15. uint8_t socks_version;
  16. /** If using socks5 authentication, which authentication type did we
  17. * negotiate? currently we support 0 (no authentication) and 2
  18. * (username/password). */
  19. uint8_t auth_type;
  20. /** What is this stream's goal? One of the SOCKS_COMMAND_* values */
  21. uint8_t command;
  22. /** Which kind of listener created this stream? */
  23. uint8_t listener_type;
  24. size_t replylen; /**< Length of <b>reply</b>. */
  25. uint8_t reply[MAX_SOCKS_REPLY_LEN]; /**< Write an entry into this string if
  26. * we want to specify our own socks reply,
  27. * rather than using the default socks4 or
  28. * socks5 socks reply. We use this for the
  29. * two-stage socks5 handshake.
  30. */
  31. char address[MAX_SOCKS_ADDR_LEN]; /**< What address did the client ask to
  32. connect to/resolve? */
  33. uint16_t port; /**< What port did the client ask to connect to? */
  34. unsigned int has_finished : 1; /**< Has the SOCKS handshake finished? Used to
  35. * make sure we send back a socks reply for
  36. * every connection. */
  37. unsigned int got_auth : 1; /**< Have we received any authentication data? */
  38. /** If this is set, we will choose "no authentication" instead of
  39. * "username/password" authentication if both are offered. Used as input to
  40. * parse_socks. */
  41. unsigned int socks_prefer_no_auth : 1;
  42. /** Number of bytes in username; 0 if username is NULL */
  43. size_t usernamelen;
  44. /** Number of bytes in password; 0 if password is NULL */
  45. uint8_t passwordlen;
  46. /** The negotiated username value if any (for socks5), or the entire
  47. * authentication string (for socks4). This value is NOT nul-terminated;
  48. * see usernamelen for its length. */
  49. char *username;
  50. /** The negotiated password value if any (for socks5). This value is NOT
  51. * nul-terminated; see passwordlen for its length. */
  52. char *password;
  53. };
  54. #endif