Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void sock::perform_sock5_second_handshake() {
- std::uint16_t const port = 4561;
- std::uint8_t ipv4[4]{};
- std::vector<std::uint8_t> handshake_buffer{};
- std::cout << "Performing second handshake\n";
- if (sscanf("1.1.1.1", "%hhu.%hhu.%hhu.%hhu", &ipv4[0], &ipv4[1], &ipv4[2],
- &ipv4[3]) != 4) {
- throw std::runtime_error("Could not parse IPv4 address: 1.1.1.1");
- }
- handshake_buffer.clear();
- handshake_buffer.push_back(0x05); // version
- handshake_buffer.push_back(0x01); // TCP/IP
- handshake_buffer.push_back(0x00); // must be 0x00 always
- handshake_buffer.push_back(0x01); // IPv4
- // how do I specify the hostname here?
- handshake_buffer.push_back(ipv4[0]);
- handshake_buffer.push_back(ipv4[1]);
- handshake_buffer.push_back(ipv4[2]);
- handshake_buffer.push_back(ipv4[3]);
- // host to network short(htons)
- handshake_buffer.push_back(port >> 8);
- handshake_buffer.push_back(port & 0xff);
- ::send(socket_, reinterpret_cast<char const*>( handshake_buffer.data() ), handshake_buffer.size(), 0 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement