예제 #1
0
 /// <summary>
 /// Constructor for a local proxy's request handler.
 /// </summary>
 /// <param name="proxy">Proxy this request handler belongs to.</param>
 /// <param name="socket">Client socket.</param>
 public LocalRequestHandler(RCLocalProxy proxy, Socket socket)
     : base(proxy, socket)
 {
     _requestId = _proxy.NextRequestId;
     _proxy.NextRequestId = _proxy.NextRequestId + 1;
     _requestTimeout = LOCAL_REQUEST_PACKAGE_DEFAULT_TIMEOUT;
 }
예제 #2
0
파일: Program.cs 프로젝트: o0111/ruralcafe
        /// <summary>
        /// Starts the local proxy.
        /// </summary>
        /// <param name="startCrawler">Whether the crawler should be started.</param>
        public static RCLocalProxy StartLocalProxy(bool startCrawler)
        {
            // create the proxy
            RCLocalProxy localProxy = new RCLocalProxy(
                IPAddress.Parse(Properties.Connection.Default.LOCAL_PROXY_IP_ADDRESS),
                Properties.Connection.Default.LOCAL_PROXY_LISTEN_PORT,
                Properties.Connection.Default.LOCAL_PROXY_HTTPS_PORT,
                Properties.Files.Default.BASE_DIR + Path.DirectorySeparatorChar + LOCAL_PROXY_PATH,
                INDEX_PATH,
                ((long)(Properties.Files.Default.LOCAL_MAX_CACHE_SIZE_MIB)) * 1024 * 1024,
                LOCAL_CACHE_PATH,
                WIKI_DUMP_FILE,
                PACKAGE_PATH);

            if (startCrawler)
            {
                CrawlerWrapper cw = new CrawlerWrapper(localProxy);
                cw.StartCrawler();
            }

            // set the remote proxy
            localProxy.SetRemoteProxy(IPAddress.Parse(Properties.Connection.Default.REMOTE_PROXY_IP_ADDRESS),
                Properties.Connection.Default.REMOTE_PROXY_LISTEN_PORT);
            localProxy.RemoteProxyHTTPSPort = Properties.Connection.Default.REMOTE_PROXY_HTTPS_PORT;

            // XXX: currently this doesn't work if the remote proxy must be reached through a firewall/gateway.
            // XXX: it would be a chain of 2 proxies anyway and needs tunneling support
            if (Properties.Connection.Default.REMOTE_PROXY_IP_ADDRESS != Properties.Connection.Default.LOCAL_PROXY_IP_ADDRESS)
            {
                // FIXME Either we must require a gateway to be set in this case or check if one is given...
                // set the gateway proxy info and login for the local proxy
                //localProxy.SetGatewayProxy(IPAddress.Parse(Properties.Settings.Default.EXTERNAL_PROXY_IP_ADDRESS), Properties.Settings.Default.EXTERNAL_PROXY_LISTEN_PORT,
                //                           Properties.Settings.Default.EXTERNAL_PROXY_LOGIN, Properties.Settings.Default.EXTERNAL_PROXY_PASS);
            }

            // set the RC search page
            localProxy.SetRCSearchPage(Properties.Files.Default.DEFAULT_SEARCH_PAGE);
            // Set network status and auto detection
            localProxy.NetworkStatus = Properties.Network.Default.NETWORK_STATUS;
            localProxy.DetectNetworkStatusAuto = Properties.Network.Default.DETECT_NETWORK_AUTO;

            // start local listener thread
            Thread localListenerThread = new Thread(new ThreadStart(localProxy.StartListener));
            localListenerThread.Name = "localListenerThread";
            localListenerThread.Start();

            // start local HTTPS listener thread
            Thread localHttpsListenerThread = new Thread(new ThreadStart(localProxy.StartHttpsListener));
            localHttpsListenerThread.Name = "localHTTPSListenerThread";
            localHttpsListenerThread.Start();

            // start local requester thread
            Thread localRequesterThread = new Thread(new ThreadStart(localProxy.StartDispatcher));
            localRequesterThread.Name = "localRequesterThread";
            localRequesterThread.Start();

            // Start the timer
            localProxy.StartPeriodicTimer();

            // listen for cc connection
            return localProxy;
        }
예제 #3
0
 /// <summary>
 /// Constructor used, when http context is not available any more. E.g. queue deserialization.
 /// </summary>
 /// <param name="proxy">Proxy this request handler belongs to.</param>
 public LocalRequestHandler(RCLocalProxy proxy)
     : base(proxy, LOCAL_REQUEST_PACKAGE_DEFAULT_TIMEOUT)
 {
 }
예제 #4
0
 /// <summary>
 /// Constructor for a local proxy's request handler.
 /// </summary>
 /// <param name="proxy">Proxy this request handler belongs to.</param>
 /// <param name="context">Client context.</param>
 public LocalRequestHandler(RCLocalProxy proxy, HttpListenerContext context)
     : base(proxy, context, LOCAL_REQUEST_PACKAGE_DEFAULT_TIMEOUT)
 {
 }
예제 #5
0
 /// <summary>
 /// A new SessionManager.
 /// </summary>
 /// <param name="proxy">The proxy.</param>
 public SessionManager(RCLocalProxy proxy)
 {
     this._proxy = proxy;
     this._usersXML = proxy.ProxyPath + "users.xml";
 }
예제 #6
0
        /// <summary>
        /// Starts the local proxy.
        /// </summary>
        public static RCLocalProxy StartLocalProxy()
        {
            // create the proxy
            RCLocalProxy localProxy = new RCLocalProxy(LOCAL_PROXY_IP_ADDRESS, LOCAL_PROXY_LISTEN_PORT,
                LOCAL_PROXY_PATH, INDEX_PATH, LOCAL_CACHE_PATH, WIKI_DUMP_FILE, PACKAGE_PATH, LOGS_PATH);

            // set the remote proxy
            localProxy.SetRemoteProxy(REMOTE_PROXY_IP_ADDRESS, REMOTE_PROXY_LISTEN_PORT);

            // XXX: currently this doesn't work if the remote proxy must be reached through a firewall/gateway.
            // XXX: it would be a chain of 2 proxies anyway and needs tunneling support
            if (REMOTE_PROXY_IP_ADDRESS != LOCAL_PROXY_IP_ADDRESS)
            {
                // set the gateway proxy info and login for the local proxy
                localProxy.SetGatewayProxy(GATEWAY_PROXY_IP_ADDRESS, GATEWAY_PROXY_LISTEN_PORT,
                                           GATEWAY_PROXY_LOGIN, GATEWAY_PROXY_PASS);
            }

            // set the RC search page
            localProxy.SetRCSearchPage(DEFAULT_SEARCH_PAGE);
            localProxy.NetworkStatus = NETWORK_STATUS;

            // load the blacklisted domains
            localProxy.LoadBlacklist("blacklist.txt");

            // set the default depth for all requests
            LocalRequestHandler.DEFAULT_QUOTA = DEFAULT_QUOTA;
            LocalRequestHandler.DEFAULT_DEPTH = DEFAULT_DEPTH;
            LocalRequestHandler.DEFAULT_RICHNESS = DEFAULT_RICHNESS;

            // start local listener thread
            Thread localListenerThread = new Thread(new ThreadStart(localProxy.StartListener));
            localListenerThread.Name = String.Format("localListenerThread");
            localListenerThread.Start();

            // start remote requester thread
            Thread localRequesterThread = new Thread(new ThreadStart(localProxy.StartDispatcher));
            localRequesterThread.Name = String.Format("localRequesterThread");
            localRequesterThread.Start();

            // listen for cc connection
            return localProxy;
        }
 /// <summary>
 /// Constructor for a local internal proxy's request handler.
 /// </summary>
 /// <param name="proxy">Proxy this request handler belongs to.</param>
 /// <param name="context">Client context.</param>
 public LocalInternalRequestHandler(RCLocalProxy proxy, HttpListenerContext context)
     : base(proxy, context, routines, defaultMethod)
 {
 }