/* // benchmarking variables protected DateTime handleRequestStart; protected DateTime handleRequestEnd; protected DateTime downloadPagesStart; protected DateTime downloadPagesEnd; protected DateTime transmitStart; protected DateTime transmitEnd; */ //public static List<int> linksOnResultsPage = new List<int>(); //public static List<int> imagesOnResultsPage = new List<int>(); //public static List<int> imagesOnTargetPage = new List<int>(); /// <summary> /// Constructor for a remote proxy's request handler. /// </summary> /// <param name="proxy">Proxy this request handler belongs to.</param> /// <param name="context">Client context.</param> public RemoteRequestHandler(RCRemoteProxy proxy, HttpListenerContext context) : base(proxy, context, REMOTE_REQUEST_PACKAGE_DEFAULT_TIMEOUT) { _quota = Properties.Settings.Default.DEFAULT_QUOTA; _package = new Package(); _killYourself = false; }
/* // benchmarking variables protected DateTime handleRequestStart; protected DateTime handleRequestEnd; protected DateTime downloadPagesStart; protected DateTime downloadPagesEnd; protected DateTime transmitStart; protected DateTime transmitEnd; */ //public static List<int> linksOnResultsPage = new List<int>(); //public static List<int> imagesOnResultsPage = new List<int>(); //public static List<int> imagesOnTargetPage = new List<int>(); /// <summary> /// Constructor for a remote proxy's request handler. /// </summary> /// <param name="proxy">Proxy this request handler belongs to.</param> /// <param name="socket">Client socket.</param> public RemoteRequestHandler(RCRemoteProxy proxy, Socket socket) : base(proxy, socket) { _requestId = _proxy.NextRequestId; _proxy.NextRequestId = proxy.NextRequestId + 1; _requestTimeout = REMOTE_REQUEST_PACKAGE_DEFAULT_TIMEOUT; _quota = DEFAULT_QUOTA; _package = new Package(); }
/// <summary> /// Start the remote proxy. /// </summary> public static RCRemoteProxy StartRemoteProxy() { // create the proxy RCRemoteProxy remoteProxy = new RCRemoteProxy( IPAddress.Parse(Properties.Connection.Default.REMOTE_PROXY_IP_ADDRESS), Properties.Connection.Default.REMOTE_PROXY_LISTEN_PORT, Properties.Connection.Default.REMOTE_PROXY_HTTPS_PORT, Properties.Files.Default.BASE_DIR + Path.DirectorySeparatorChar + REMOTE_PROXY_PATH, ((long)(Properties.Files.Default.REMOTE_MAX_CACHE_SIZE_MIB)) * 1024 * 1024, REMOTE_CACHE_PATH, PACKAGE_PATH); /* // XXX: buggy... // XXX: currently only used if both proxies are running on the same machine if (REMOTE_PROXY_IP_ADDRESS == LOCAL_PROXY_IP_ADDRESS) { // set the gateway proxy info and login for the remote proxy remoteProxy.SetGatewayProxy(GATEWAY_PROXY_IP_ADDRESS, GATEWAY_PROXY_LISTEN_PORT, GATEWAY_PROXY_LOGIN, GATEWAY_PROXY_PASS); }*/ // Remote Proxy is always online. remoteProxy.NetworkStatus = RCProxy.NetworkStatusCode.Online; // set the maximum downlink speed to the local proxy remoteProxy.MAXIMUM_DOWNLINK_BANDWIDTH = Properties.Network.Default.MAXIMUM_DOWNLOAD_SPEED; // set the default low watermark for each request RemoteRequestHandler.DEFAULT_LOW_WATERMARK = Properties.Settings.Default.DEFAULT_QUOTA / LOW_WATERMARK_DIVIDOR_QUOTA; // start remote listener thread Thread remoteListenerThread = new Thread(new ThreadStart(remoteProxy.StartListener)); remoteListenerThread.Name = String.Format("remoteListenerThread"); remoteListenerThread.Start(); // start remote HTTPS listener thread Thread remoteHttpsListenerThread = new Thread(new ThreadStart(remoteProxy.StartHttpsListener)); remoteHttpsListenerThread.Name = "remoteHTTPSListenerThread"; remoteHttpsListenerThread.Start(); // start remote requester thread Thread remoteRequesterThread = new Thread(new ThreadStart(remoteProxy.StartDispatcher)); remoteRequesterThread.Name = String.Format("remoteRequesterThread"); remoteRequesterThread.Start(); // listen for cc connection return remoteProxy; }
/// <summary> /// Start the remote proxy. /// </summary> public static RCRemoteProxy StartRemoteProxy() { // create the proxy RCRemoteProxy remoteProxy = new RCRemoteProxy(REMOTE_PROXY_IP_ADDRESS, REMOTE_PROXY_LISTEN_PORT, REMOTE_PROXY_PATH, REMOTE_CACHE_PATH, PACKAGE_PATH, LOGS_PATH); /* // XXX: buggy... // XXX: currently only used if both proxies are running on the same machine if (REMOTE_PROXY_IP_ADDRESS == LOCAL_PROXY_IP_ADDRESS) { // set the gateway proxy info and login for the remote proxy remoteProxy.SetGatewayProxy(GATEWAY_PROXY_IP_ADDRESS, GATEWAY_PROXY_LISTEN_PORT, GATEWAY_PROXY_LOGIN, GATEWAY_PROXY_PASS); }*/ // set the maximum downlink speed to the local proxy remoteProxy.MAXIMUM_DOWNLINK_BANDWIDTH = MAXIMUM_DOWNLINK_SPEED; remoteProxy.NetworkStatus = NETWORK_STATUS; // load the blacklisted domains remoteProxy.LoadBlacklist("blacklist.txt"); // set the default quota, depth, watermark for each request RemoteRequestHandler.DEFAULT_QUOTA = DEFAULT_QUOTA; RemoteRequestHandler.DEFAULT_MAX_DEPTH = DEFAULT_DEPTH; RemoteRequestHandler.DEFAULT_RICHNESS = DEFAULT_RICHNESS; RemoteRequestHandler.DEFAULT_LOW_WATERMARK = DEFAULT_LOW_WATERMARK; // start remote listener thread Thread remoteListenerThread = new Thread(new ThreadStart(remoteProxy.StartListener)); remoteListenerThread.Name = String.Format("remoteListenerThread"); remoteListenerThread.Start(); // listen for cc connection return remoteProxy; }
/// <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 RemoteInternalRequestHandler(RCRemoteProxy proxy, HttpListenerContext context) : base(proxy, context, routines, defaultMethod) { }