Proxy Module

Proxy를 통과 하기 위한 모듈을 제작 하게 되었습니다. CURL을 기반으로 C++ Class 랩핑이며 윈도우 및 리눅스에서 사용할 수 있도록 제작 되었습니다.

1. 소스

  • curl_proxy.cpp
  • curl_proxy.h

<code>

#includ

#pragma once
#include <string>
#include <curl/curl.h>

using namespace std;

class curl_proxy_c
{
    public:
    enum HttpMothod { HTTP_GET=1, HTTP_POST, HTTP_PUT, HTTP_DELETE };
    struct WriteThis 
    {
          const char *readptr;
            long sizeleft;
    };
     
        curl_proxy_c();

        virtual ~curl_proxy_c();

        void Init(void);

        void SetProxyAddress(string addr, unsigned short port=3128) ;
        void SetProxyAuth(string id, string passwd) ;

        void SetCallbackContent(void *userctx);

        CURLcode Open(string url);

        void BuildBody(const char *aLine) ;
        void BuildHeader(const char *aLine) ;

        void destroy(void);
        static size_t hfunc( void *ptr, size_t size, size_t nmemb, void *userdata) ;
        static size_t bfunc( void *ptr, size_t size, size_t nmemb, void *userdata) ;
        static size_t rfunc( void *ptr, size_t size, size_t nmemb, void *userp);

        const char * GetResponse(void) ;
        long         GetStatusCode(void){ return m_responsecode ; }

        virtual void OnHttpStatus200(void *userctx);
        virtual void OnHttpStatus201(void *userctx);
        virtual void OnHttpStatus400(void *userctx);
        virtual void OnHttpStatus401(void *userctx);
        virtual void OnHttpStatus404(void *userctx);
        virtual void OnHttpStatus407(void *userctx);
        virtual void OnHttpStatus409(void *userctx);
        virtual void OnHttpStatus426(void *userctx);
        virtual void OnHttpStatus555(void *userctx);
        virtual void OnHttpStatusDefault(void *userctx);

        bool SetParams(const char * parms) ;
        bool SetParams(string param);
        void SetTunnel(bool x);
        bool SetSendData(const void *data, size_t datalen, HttpMothod mhd=HTTP_POST);
        void SetCustumHeader(string chead);

        string GetLastError(void);
        int  GetSocket(void);
    private:
        CURL        * m_ctx;
        CURLcode    m_result;
        bool        m_bproxy;
        int         m_socket;
        bool        m_tunnel;
        string      m_header;
        string      m_body;
        long         m_responsecode;
        void        *m_userctx;
        struct  curl_slist * m_chunk;

        WriteThis   m_pooh;
};

 

e <curl/curl.h>

class {

public:

};

</code>

2. For windows DLL

  • rspxauth.dll
  • wrapper

답글 남기기