コード例 #1
0
        public static object GetProxy(this IProxyProvider proxyProvider, Type interfaceType, Type classType)
        {
            if (interfaceType == null)
            {
                throw new ArgumentNullException(nameof(interfaceType));
            }

            if (classType == null)
            {
                throw new ArgumentNullException(nameof(classType));
            }

            return(proxyProvider.GetProxy(interfaceType, classType, (object[])null));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="JobsDataFromTalentLink" /> class.
        /// </summary>
        /// <param name="searchUrl">The search URL.</param>
        /// <param name="lookupValuesParser">The parser for lookup values in the TalentLink HTML.</param>
        /// <param name="proxy">The proxy (optional).</param>
        /// <exception cref="System.ArgumentNullException">sourceUrl</exception>
        public JobsLookupValuesFromTalentLink(Uri searchUrl, IJobLookupValuesParser lookupValuesParser, IProxyProvider proxy)
        {
            if (searchUrl == null)
            {
                throw new ArgumentNullException(nameof(searchUrl));
            }
            if (lookupValuesParser == null)
            {
                throw new ArgumentNullException(nameof(lookupValuesParser));
            }

            _searchUrl          = searchUrl;
            _lookupValuesParser = lookupValuesParser;
            _proxy = proxy;
        }
コード例 #3
0
ファイル: Application.cs プロジェクト: rburda82/proxysearcher
        public Application(ISearchEngine searchEngine,
                           IProxyChecker checker,
                           IHttpDownloaderContainer httpDownloaderContainer,
                           IGeoIP geoIP = null,
                           IProxyProvider proxyProvider = null,
                           ITaskManager taskManager = null)
        {
            this.searchEngine = searchEngine;
            this.checker = checker;
            this.httpDownloaderContainer = httpDownloaderContainer;

            this.proxyProvider = proxyProvider ?? new ProxyProvider();
            this.geoIP = geoIP ?? new TurnOffGeoIP();
            this.taskManager = taskManager ?? new TaskManager();
        }
コード例 #4
0
        public ProxyAuthenticationHandler(HttpClientHandler httpClientHandler, IProxyProvider proxyProvider)
            : base(httpClientHandler)
        {
            if (httpClientHandler == null)
            {
                throw new ArgumentNullException(nameof(httpClientHandler));
            }
            if (proxyProvider == null)
            {
                throw new ArgumentNullException(nameof(proxyProvider));
            }

            _clientHandler = httpClientHandler;
            _proxyProvider = proxyProvider;
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocateApiAddressLookup" /> class.
        /// </summary>
        /// <param name="locateApiUrl">The locate API URL.</param>
        /// <param name="authenticationToken">The authentication token.</param>
        /// <param name="proxyProvider">The proxy provider.</param>
        /// <exception cref="System.ArgumentNullException">authenticationToken</exception>
        public LocateApiAddressLookup(Uri locateApiUrl, string authenticationToken, IProxyProvider proxyProvider)
        {
            if (locateApiUrl == null)
            {
                throw new ArgumentNullException(nameof(locateApiUrl));
            }
            if (String.IsNullOrEmpty(authenticationToken))
            {
                throw new ArgumentNullException(nameof(authenticationToken));
            }

            _locateApiUrl        = locateApiUrl;
            _authenticationToken = authenticationToken;
            _proxyProvider       = proxyProvider;
        }
コード例 #6
0
        public TelegramBot(ISettingsProvider settingsProvider, IProxyProvider proxyProvider = null)
        {
            _settingsProvider = settingsProvider;
            _proxyProvider    = proxyProvider;
            _log = LogFactory.GetLog(GetType());

            _settings = _settingsProvider.GetSettings().Telegram;

            _masterChatID = _settings.MasterChatID;

            _client                        = new TelegramBotClient(_settings.BotToken);
            _client.OnMessage             += BotOnMessage;
            _client.OnCallbackQuery       += BotCallbackQuery;
            _client.OnReceiveError        += BotReceiveError;
            _client.OnReceiveGeneralError += BotReceiveGeneralError;
        }
コード例 #7
0
ファイル: ProxyWorker.cs プロジェクト: vsoff/cashlog-bot
        public ProxyWorker(
            ISettingsService <CashlogSettings> cashlogSettingsService,
            IWorkerController workerController,
            IProxyProvider proxyProvider,
            ILogger logger,
            IProxyConsumer[] proxyConsumers)
        {
            _cashlogSettingsService = cashlogSettingsService ?? throw new ArgumentNullException(nameof(cashlogSettingsService));
            _proxyProvider          = proxyProvider ?? throw new ArgumentNullException(nameof(proxyProvider));
            _logger              = logger ?? throw new ArgumentNullException(nameof(logger));
            _proxyConsumers      = proxyConsumers ?? throw new ArgumentNullException(nameof(proxyConsumers));
            _cachedProxies       = new Queue <WebProxy>();
            _lastWorkingWebProxy = null;

            _worker = workerController.CreateWorker(() => RevalidateProxy().GetAwaiter().GetResult(), _proxyRevalidateInterval, true);
        }
コード例 #8
0
ファイル: Application.cs プロジェクト: hepper/proxysearcher
        public Application(ISearchEngine searchEngine,
                           IProxyChecker checker,
                           IHttpDownloaderContainer httpDownloaderContainer,
                           IGeoIP geoIP = null,
                           IRatingManager ratingManager = null,
                           IProxyProvider proxyProvider = null,
                           ITaskManager taskManager     = null)
        {
            this.searchEngine            = searchEngine;
            this.checker                 = checker;
            this.httpDownloaderContainer = httpDownloaderContainer;

            this.proxyProvider = proxyProvider ?? new ProxyProvider();
            this.geoIP         = geoIP ?? new TurnOffGeoIP();
            this.taskManager   = taskManager ?? new TaskManager();
            this.ratingManager = ratingManager ?? new DisabledRatingManager();
        }
コード例 #9
0
        public static IntPtr CreateDispatchProxy(IntPtr pOuter, IPseudoDispatch proxy)
        {
            IntPtr         zero          = IntPtr.Zero;
            IProxyProvider proxyProvider = proxySupport.GetProxyProvider();

            if (proxyProvider == null)
            {
                throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL");
            }
            int errorCode = proxyProvider.CreateDispatchProxyInstance(pOuter, proxy, out zero);

            Marshal.ReleaseComObject(proxyProvider);
            if (errorCode != HR.S_OK)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("FailedProxyProviderCreation"), errorCode));
            }
            return(zero);
        }
コード例 #10
0
        public static IntPtr CreateOuterProxyInstance(IProxyManager proxyManager, ref Guid riid)
        {
            IntPtr         zero          = IntPtr.Zero;
            IProxyProvider proxyProvider = proxySupport.GetProxyProvider();

            if (proxyProvider == null)
            {
                throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL");
            }
            Guid guid      = riid;
            int  errorCode = proxyProvider.CreateOuterProxyInstance(proxyManager, ref guid, out zero);

            Marshal.ReleaseComObject(proxyProvider);
            if (errorCode != HR.S_OK)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("FailedProxyProviderCreation"), errorCode));
            }
            return(zero);
        }
コード例 #11
0
ファイル: Devourer.cs プロジェクト: Alister742/ParseKit
        public Devourer(List<DevourTarget> initialTargets, IProxyProvider proxies, IPageValidator validator = null)
        {
            if (initialTargets == null || initialTargets.Count == 0 /*|| reader == null */ || proxies == null)
                throw new ArgumentException("Bad arguments");

            PreventSimilarTargetDownload = false;
            CookieOptions = CookieOptions.Empty;

            _proxies = proxies;
            _validator = validator;

            _successTargets = new List<Uri>();
            _faultTargets = new List<DevourTarget>();
            _allTargets = new HashSet<string>();

            InitializeStartTargets(initialTargets);

            SubscribeProxyProvider();
        }
コード例 #12
0
        public ApiPortService(string endpoint, ProductInformation info, IProxyProvider proxyProvider)
        {
            if (string.IsNullOrWhiteSpace(endpoint))
            {
                throw new ArgumentOutOfRangeException(nameof(endpoint), endpoint, LocalizedStrings.MustBeValidEndpoint);
            }
            if (proxyProvider == null)
            {
                throw new ArgumentNullException(nameof(proxyProvider));
            }

            // Create the URI directly from a string (rather than using a hard-coded scheme or port) because
            // even though production use of ApiPort should always use HTTPS, developers using a non-production
            // portability service URL (via the -e command line parameter) may need to specify a different
            // scheme or port.
            var uri   = new Uri(endpoint);
            var proxy = proxyProvider.GetProxy(uri);

            // replace the handler with the proxy aware handler
            var clientHandler = new HttpClientHandler
            {
#if !FEATURE_SERVICE_POINT_MANAGER
                SslProtocols = CompressedHttpClient.SupportedSSLProtocols,
#endif
                Proxy = proxy,
                AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate)
            };

            // HTTP handler pipeline can be injected here, around the client handler
            HttpMessageHandler messageHandler = clientHandler;

            if (proxy != null)
            {
                messageHandler = new ProxyAuthenticationHandler(clientHandler, proxyProvider);
            }

            _client = new CompressedHttpClient(info, messageHandler)
            {
                BaseAddress = new Uri(endpoint),
                Timeout     = Timeout
            };
        }
コード例 #13
0
        public static IntPtr CreateDispatchProxy(IntPtr pOuter, IPseudoDispatch proxy)
        {
            IntPtr         pInner        = IntPtr.Zero;
            IProxyProvider proxyProvider = proxySupport.GetProxyProvider();

            if (proxyProvider == null)
            {
                throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL");
            }
            int hr = proxyProvider.CreateDispatchProxyInstance(pOuter, proxy, out pInner);

            Marshal.ReleaseComObject(proxyProvider);

            if (hr != HR.S_OK)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.FailedProxyProviderCreation), hr));
            }

            return(pInner);
        }
コード例 #14
0
        public static IntPtr CreateOuterProxyInstance(IProxyManager proxyManager, ref Guid riid)
        {
            IntPtr         pOuter        = IntPtr.Zero;
            IProxyProvider proxyProvider = proxySupport.GetProxyProvider();

            if (proxyProvider == null)
            {
                throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL");
            }
            Guid riid2 = riid;
            int  hr    = proxyProvider.CreateOuterProxyInstance(proxyManager, ref riid2, out pOuter);

            Marshal.ReleaseComObject(proxyProvider);

            if (hr != HR.S_OK)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.FailedProxyProviderCreation), hr));
            }

            return(pOuter);
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobsDataFromTribePad" /> class.
        /// </summary>
        /// <param name="lookupValuesApiUrl">The search URL.</param>
        /// <param name="builtInLookupValuesParser">The parser for lookup values in built-in fields in the TribePad XML.</param>
        /// <param name="customFieldLookupValuesParser">The parser for lookup values in custom fields in the TribePad XML.</param>
        /// <param name="workPatternSplitter">A way to return work patterns that represent multiple values as multiple patterns; <c>null</c> if not required</param>
        /// <param name="proxy">The proxy (optional).</param>
        /// <exception cref="System.ArgumentNullException">lookupValuesApiUrl</exception>
        /// <exception cref="System.ArgumentNullException">builtInLookupValuesParser</exception>
        /// <exception cref="System.ArgumentNullException">customFieldLookupValuesParser</exception>
        public JobsLookupValuesFromTribePad(Uri lookupValuesApiUrl, IJobLookupValuesParser builtInLookupValuesParser, IJobLookupValuesParser customFieldLookupValuesParser, IWorkPatternSplitter workPatternSplitter, IProxyProvider proxy)
        {
            if (lookupValuesApiUrl == null)
            {
                throw new ArgumentNullException(nameof(lookupValuesApiUrl));
            }
            if (builtInLookupValuesParser == null)
            {
                throw new ArgumentNullException(nameof(builtInLookupValuesParser));
            }
            if (customFieldLookupValuesParser == null)
            {
                throw new ArgumentNullException(nameof(customFieldLookupValuesParser));
            }

            _lookupValuesApiUrl            = lookupValuesApiUrl;
            _builtInLookupValuesParser     = builtInLookupValuesParser;
            _customFieldLookupValuesParser = customFieldLookupValuesParser;
            _workPatternSplitter           = workPatternSplitter;
            _proxy = proxy;
        }
コード例 #16
0
ファイル: Devourer.cs プロジェクト: Alister742/ParseKit
        public Devourer(List <DevourTarget> initialTargets, IProxyProvider proxies, IPageValidator validator = null)
        {
            if (initialTargets == null || initialTargets.Count == 0 /*|| reader == null */ || proxies == null)
            {
                throw new ArgumentException("Bad arguments");
            }

            PreventSimilarTargetDownload = false;
            CookieOptions = CookieOptions.Empty;

            _proxies   = proxies;
            _validator = validator;

            _successTargets = new List <Uri>();
            _faultTargets   = new List <DevourTarget>();
            _allTargets     = new HashSet <string>();

            InitializeStartTargets(initialTargets);

            SubscribeProxyProvider();
        }
コード例 #17
0
        /// <summary>
        /// Creates a new <see cref="HttpWebRequest"/> for the specified URI, with proxy access configured.
        /// </summary>
        /// <param name="requestUri">The request URI.</param>
        /// <returns></returns>
        public HttpWebRequest CreateRequest(Uri requestUri, IProxyProvider proxyProvider)
        {
            var webRequest = (HttpWebRequest)WebRequest.Create(requestUri);

            webRequest.UserAgent = "Escc.Net.HttpRequestClient"; // Some apps require a user-agent to be present
            if (proxyProvider != null)
            {
                IWebProxy proxy = proxyProvider.CreateProxy();
                if (proxy != null)
                {
                    webRequest.Proxy       = proxy;
                    webRequest.Credentials = proxy.Credentials;
                }
                else
                {
                    webRequest.Credentials = CredentialCache.DefaultCredentials;
                }
            }
            else
            {
                webRequest.Credentials = CredentialCache.DefaultCredentials;
            }
            return(webRequest);
        }
コード例 #18
0
 public SettingsController(IHostingEnvironment hostingEnvironment, IOptionsSnapshot <ProxySettings> proxySettings, IProxyProvider proxyProvider)
 {
     _proxySettings      = proxySettings.Value;
     _hostingEnvironment = hostingEnvironment;
     _proxyProvider      = proxyProvider;
 }
コード例 #19
0
        internal IProxyProvider GetProxyProvider()
        {
            if (null == monikerSupportLibrary)
            {
                lock (this)
                {
                    if (null == monikerSupportLibrary)
                    {
                        getCODelegate = null;
                        using (RegistryHandle regKey = RegistryHandle.GetCorrectBitnessHKLMSubkey((IntPtr.Size == 8), ServiceModelInstallStrings.WinFXRegistryKey))
                        {
                            string            file        = regKey.GetStringValue(ServiceModelInstallStrings.RuntimeInstallPathName).TrimEnd('\0') + "\\" + fileName;
                            SafeLibraryHandle tempLibrary = UnsafeNativeMethods.LoadLibrary(file);
                            tempLibrary.DoNotFreeLibraryOnRelease();

                            monikerSupportLibrary = tempLibrary;
                            if (monikerSupportLibrary.IsInvalid)
                            {
                                monikerSupportLibrary.SetHandleAsInvalid();
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ServiceMonikerSupportLoadFailed(file));
                            }
                        }
                    }
                }
            }

            if (null == getCODelegate)
            {
                lock (this)
                {
                    if (null == getCODelegate)
                    {
                        try
                        {
                            IntPtr procaddr = UnsafeNativeMethods.GetProcAddress(monikerSupportLibrary, functionName);
                            getCODelegate = (DelegateDllGetClassObject)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(DelegateDllGetClassObject));
                        }
                        catch (Exception e)
                        {
                            if (Fx.IsFatal(e))
                            {
                                throw;
                            }

                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ComPlusProxyProviderException(SR.GetString(SR.FailedProxyProviderCreation), e));
                        }
                    }
                }
            }

            IClassFactory  cf            = null;
            IProxyProvider proxyProvider = null;

            try
            {
                getCODelegate(ClsidProxyInstanceProvider, typeof(IClassFactory).GUID, ref cf);

                proxyProvider = cf.CreateInstance(null, typeof(IProxyProvider).GUID) as IProxyProvider;
                Thread.MemoryBarrier();
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ComPlusProxyProviderException(SR.GetString(SR.FailedProxyProviderCreation), e));
            }
            finally
            {
                if (null != cf)
                {
                    Marshal.ReleaseComObject(cf);
                    cf = null;
                }
            }

            return(proxyProvider);
        }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GoogleCustomSearch" /> class.
 /// </summary>
 /// <param name="apiKey">The API key.</param>
 /// <param name="searchEngineId">The Google search engine id.</param>
 /// <param name="proxyProvider">The provider for proxy details for making the request to the API.</param>
 public GoogleCustomSearch(string apiKey, string searchEngineId, IProxyProvider proxyProvider)
 {
     _proxyProvider = proxyProvider;
     ApiKey         = apiKey;
     SearchEngineId = searchEngineId;
 }
コード例 #21
0
 public void SetProxyProvider(IProxyProvider proxyProvider)
 {
     this._proxyProvider = proxyProvider;
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobsDataFromTalentLink" /> class.
 /// </summary>
 /// <param name="resultsUrl">The source URL.</param>
 /// <param name="advertUrl">The advert URL.</param>
 /// <param name="jobResultsParser">The job results parser.</param>
 /// <param name="jobAdvertParser">The job advert parser.</param>
 /// <param name="proxy">The proxy (optional).</param>
 /// <param name="saveHtml">Save a copy of the TalentLink HTML to App_Data</param>
 /// <exception cref="System.ArgumentNullException">sourceUrl</exception>
 public JobsDataFromTalentLink(Uri resultsUrl, Uri advertUrl, IJobResultsParser jobResultsParser, IJobAdvertParser jobAdvertParser, IProxyProvider proxy, bool saveHtml)
 {
     _resultsUrl       = resultsUrl;
     _advertUrl        = advertUrl;
     _proxy            = proxy;
     _jobResultsParser = jobResultsParser;
     _jobAdvertParser  = jobAdvertParser;
     _saveHtml         = saveHtml;
 }
コード例 #23
0
        public object MarshalNativeToManaged(IntPtr pNativeData)
        {
            IProxyProvider prov = (IProxyProvider)Marshal.GetObjectForIUnknown(pNativeData);

            return(new ComProxy(prov).GetTransparentProxy());
        }
コード例 #24
0
 public static object GetProxy(IProxyProvider provider)
 {
     return(new ComProxy(provider).GetTransparentProxy());
 }
コード例 #25
0
 public ComProxy(IProxyProvider provider) : base(provider.Type == typeof(object) ? typeof(MarshalByRefObject) : provider.Type)
 {
     Provider = provider;
 }
コード例 #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="proxyProvider"></param>
 public void SetProxyProvider(IProxyProvider proxyProvider)
 {
     this.httpClientDownloader.SetProxyProvider(proxyProvider);
 }
コード例 #27
0
        /// <summary> 创建代理 </summary>
        /// <param name="interfaceType"></param>
        /// <param name="baseType"></param>
        /// <param name="proxyProvider"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public object CreateProxy(Type interfaceType, Type baseType, IProxyProvider proxyProvider, object key = null)
        {
            var proxiedType = GetProxyType(baseType, interfaceType);

            return(Activator.CreateInstance(proxiedType, proxyProvider, key, new ProxyHandler(this)));
        }
コード例 #28
0
 public ApiPortService(string endpoint, ProductInformation info, IProxyProvider proxyProvider = null)
     : this(endpoint, BuildMessageHandler(endpoint, proxyProvider), info)
 {
 }
コード例 #29
0
 public ProxyExecutor(IProxyProvider provider, object serviceKey = null)
 {
     _proxyProvider = provider;
     _serviceKey    = serviceKey;
 }
コード例 #30
0
 public static TClass GetProxy <TClass>(this IProxyProvider proxyProvider, params object[] parameters)
     where TClass : class
 {
     return(proxyProvider.GetProxy(typeof(TClass), parameters) as TClass);
 }
コード例 #31
0
 public static TClass GetProxy <TClass>(this IProxyProvider proxyProvider)
     where TClass : class
 {
     return(proxyProvider.GetProxy(typeof(TClass), (object[])null) as TClass);
 }
 public GoogleAnalyticsKeywordSource(IProxyProvider proxyProvider)
 {
     _proxyProvider = proxyProvider;
 }
コード例 #33
0
 public static TInterface GetProxy <TInterface, TClass>(this IProxyProvider proxyProvider, params object[] parameters)
     where TInterface : class
     where TClass : TInterface
 {
     return(proxyProvider.GetProxy(typeof(TInterface), typeof(TClass), parameters) as TInterface);
 }
コード例 #34
0
ファイル: Devourer.cs プロジェクト: Alister742/ParseKit
 //RequestParams _params;
 public Devourer(DevourTarget initialTarget, IProxyProvider proxies, IPageValidator validator = null)
     : this(new List<DevourTarget>(new DevourTarget[] { initialTarget }), proxies, validator)
 {
 }