简体   繁体   English

如何与代理服务器创建会话

[英]how to create a session with a proxy server

I have the following problem. 我有以下问题。 I have an application (3rd party) that needs to connect to API via a proxy to request various data again and again. 我有一个需要通过代理连接到API的应用程序(第三方),一次又一次地请求各种数据。 The application has a configuration section where the necessary details can be entered (the app then stores them in a config.ini file). 该应用程序具有一个配置部分,可在其中输入必要的详细信息(然后将其存储在config.ini文件中)。 However, one client doesn't like the proxy user/password to be stored in config files; 但是,一个客户端不希望将代理用户名/密码存储在配置文件中。

As I don't have access to the application's code, the simplest solution I can think of is something along the lines of a tunnel, ie write a simple app/script that would open a connection to the proxy, prompts the user for the username/password and then keep the connection open so that the application can access the proxy without needing username/password everytime. 由于我无权访问应用程序的代码,因此我能想到的最简单的解决方案是沿着隧道的路线进行操作,即编写一个简单的应用程序/脚本来打开与代理的连接,并提示用户输入用户名/ password,然后保持连接打开状态,以便应用程序无需每次都使用用户名/密码即可访问代理。 Is something like this possible? 这样的事情可能吗? I mean I don't to create sort of full blown proxy that would sit between the app and the real proxy server, all I really want is something like a session so that once the IP is authorized to get through the proxy, the consequent requests go through as well. 我的意思是我不会在应用程序和真正的代理服务器之间创建完整的代理,我真正想要的只是一个会话,以便一旦IP被授权通过代理,随后的请求以及通过。

I'd appreciate help and/or any suggestions for an alternate solution 非常感谢您的帮助和/或任何有关替代解决方案的建议

ps the app is win32 only so the solution is for win32 only as well (ie no cygwin, etc.) ps该应用程序仅是win32,因此该解决方案也仅适用于win32(即没有cygwin等)

Thank you 谢谢

Proxy credential caching typically works on a per-process basis, not a per-machine basis. 代理凭据缓存通常在每个进程的基础上工作,而不是在每台计算机的基础上工作。 So, having Application A make a request through the proxy rarely allows Application B to make a request without getting challenged. 因此,让应用程序A通过代理发出请求很少会使应用程序B发出请求而不会受到挑战。

If you can change the application's code, make a single request through the proxy using the desired credentials; 如果您可以更改应用程序的代码,请使用所需的凭据通过代理进行单个请求; eg make a HEAD request for your server's homepage. 例如,向服务器的首页发出HEAD请求。 Most HTTP stacks (eg WinINET) will cache the proxy credentials for the life of the process. 大多数HTTP堆栈(例如WinINET)将在整个过程中缓存代理凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM