예제 #1
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;
        }
예제 #2
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;
        }