基于 POCO 框架的 C++ 版搜狗代理程序

搜狗代理服务器程序,网上已经有 用 Python 实现的版本。这个版本在某些情况下(例如迅雷下载)性能不够好,于是我用 C++ 实现了一个版本,基于 POCO 框架开发,应当具有不错的可移植性。完整的源代码如下:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include <string>
#include <Poco/ErrorHandler.h>
#include <Poco/Net/Socket.h>
#include <Poco/Net/HTTPServer.h>
#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerRequestImpl.h>
#include <Poco/Net/HTTPServerResponse.h>
#include <Poco/Net/HTTPRequestHandler.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Windows.h>

using namespace std;
using namespace Poco;
using namespace Poco::Net;

class EH : public ErrorHandler
{
public:
    virtual void exception(const Exception& exc)
    {
        puts(exc.message().c_str());
        fflush(stdout);
    }

    virtual void exception(const std::exception& exc)
    {
        puts(exc.what());
        fflush(stdout);
    }

    virtual void exception()
    {
        puts("Unknown exception");
        fflush(stdout);
    }
};

const int BUFFER_SIZE = 65536;
char addressFormat[128];
int lower, upper;

class ProxyService : public HTTPRequestHandler
{
    HTTPClientSession client;

    static unsigned int hashTag(const string &s)
    {
        unsigned int code = s.length();
        for (int i = 0; i < s.length() / 4; ++i)
        {
            unsigned int a = (s[i * 4] & 0
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值