| 30 | }; |
| 31 | |
| 32 | request(command_type cmd, const boost::asio::ip::tcp::endpoint& endpoint, |
| 33 | const std::string& user_id) |
| 34 | : version_(version), |
| 35 | command_(cmd), |
| 36 | user_id_(user_id), |
| 37 | null_byte_(0) |
| 38 | { |
| 39 | // Only IPv4 is supported by the SOCKS 4 protocol. |
| 40 | if (endpoint.protocol() != boost::asio::ip::tcp::v4()) |
| 41 | { |
| 42 | throw boost::system::system_error( |
| 43 | boost::asio::error::address_family_not_supported); |
| 44 | } |
| 45 | |
| 46 | // Convert port number to network byte order. |
| 47 | unsigned short port = endpoint.port(); |
| 48 | port_high_byte_ = (port >> 8) & 0xff; |
| 49 | port_low_byte_ = port & 0xff; |
| 50 | |
| 51 | // Save IP address in network byte order. |
| 52 | address_ = endpoint.address().to_v4().to_bytes(); |
| 53 | } |
| 54 | |
| 55 | std::array<boost::asio::const_buffer, 7> buffers() const |
| 56 | { |