81 lines
2.3 KiB
C++
81 lines
2.3 KiB
C++
|
#include <arpa/inet.h>
|
||
|
#include <string>
|
||
|
#include <cstring>
|
||
|
#include <src/ProxiedClient.h>
|
||
|
#include <event2/thread.h>
|
||
|
#include <iomanip>
|
||
|
|
||
|
using namespace std;
|
||
|
using namespace ts::flood;
|
||
|
|
||
|
void hexout(std::ostream& os, unsigned char c)
|
||
|
{
|
||
|
unsigned char uc = static_cast<unsigned char>(c);
|
||
|
os << std::setw(2) << std::setfill('0') << (unsigned int)uc << ' ';
|
||
|
}
|
||
|
|
||
|
void hexdump(std::ostream& outs, const std::string& s, size_t line_len = 16)
|
||
|
{
|
||
|
std::ostringstream os;
|
||
|
const std::string::size_type slen(s.size());
|
||
|
int i(0);
|
||
|
std::string::size_type pos(0);
|
||
|
const std::streamsize lines(slen / line_len);
|
||
|
const std::streamsize chars(slen % line_len);
|
||
|
std::ios::fmtflags f(os.flags());
|
||
|
|
||
|
os << "Length: " << s.length() << "/" << std::hex << "0x" << s.length() << endl;
|
||
|
for(std::streamsize line = 0; line <= lines - (chars == 0 ? 1 : 0); ++line)
|
||
|
{
|
||
|
os << std::hex << setfill('0') << setw(3) << line * line_len << " | ";
|
||
|
for(i = 0; i < line_len; ++i)
|
||
|
{
|
||
|
if(pos < s.length())
|
||
|
hexout(os, s[pos]);
|
||
|
else os << " ";
|
||
|
pos++;
|
||
|
}
|
||
|
os << " | ";
|
||
|
if(pos - line_len < s.length()){
|
||
|
auto av = s.substr(pos - line_len);
|
||
|
for(char c : av.substr(0, min(av.length(), line_len))){
|
||
|
if(isprint(c))
|
||
|
os << c << " ";
|
||
|
else
|
||
|
os << "." << " ";
|
||
|
}
|
||
|
}
|
||
|
os << '\n';
|
||
|
}
|
||
|
os.flags(f);
|
||
|
outs << os.str() << endl;
|
||
|
}
|
||
|
|
||
|
int main(int argc, char** argv){
|
||
|
sockaddr_in remoteAddress{}, proxyAddress{};
|
||
|
memset(&remoteAddress, 0, sizeof(remoteAddress));
|
||
|
memset(&proxyAddress, 0, sizeof(proxyAddress));
|
||
|
|
||
|
|
||
|
proxyAddress.sin_family = AF_INET;
|
||
|
proxyAddress.sin_port = htons(1085);
|
||
|
proxyAddress.sin_addr.s_addr = inet_addr("185.89.100.17");
|
||
|
|
||
|
/*
|
||
|
proxyAddress.sin_family = AF_INET;
|
||
|
proxyAddress.sin_port = htons(1080);
|
||
|
proxyAddress.sin_addr.s_addr = inet_addr("54.38.22.7");
|
||
|
*/
|
||
|
|
||
|
remoteAddress.sin_family = AF_INET;
|
||
|
remoteAddress.sin_port = htons(1100);
|
||
|
remoteAddress.sin_addr.s_addr = inet_addr("87.106.252.164");
|
||
|
|
||
|
assert(evthread_use_pthreads() == 0);
|
||
|
event_base* evBase = event_base_new();
|
||
|
|
||
|
ProxiedClient client(evBase, proxyAddress, remoteAddress);
|
||
|
client.connect();
|
||
|
|
||
|
event_base_dispatch(evBase);
|
||
|
}
|