Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. apdetect.cxx
  5. Abstract:
  6. This is the overall generic wrappers and entry code to the
  7. auto-proxy, auto-detection code, that sends DHCP informs,
  8. and mundges through DNS to find an URL for proxy configuration
  9. Author:
  10. Arthur Bierer (arthurbi) 15-Jul-1998
  11. Environment:
  12. User Mode - Win32
  13. Revision History:
  14. Arthur Bierer (arthurbi) 15-Jul-1998
  15. Created
  16. Josh Cohen (joshco) 7-oct-1998
  17. added proxydetecttype
  18. Stephen Sulzer (ssulzer) 24-Feb-2001
  19. WinHttp 5 Autoproxy support
  20. --*/
  21. #include <wininetp.h>
  22. #include "aproxp.h"
  23. #include "apdetect.h"
  24. DWORD
  25. DetectAutoProxyUrl(
  26. IN DWORD dwDetectFlags,
  27. OUT LPSTR * ppszAutoProxyUrl
  28. )
  29. {
  30. DWORD error;
  31. bool bDetected = false;
  32. DEBUG_ENTER((DBG_SOCKETS,
  33. Bool,
  34. "DetectAutoProxyUrl",
  35. "%u, %x",
  36. dwDetectFlags,
  37. ppszAutoProxyUrl
  38. ));
  39. INET_ASSERT(GlobalDataInitialized);
  40. error = LoadWinsock();
  41. if (error != ERROR_SUCCESS)
  42. {
  43. goto quit;
  44. }
  45. if (PROXY_AUTO_DETECT_TYPE_DHCP & dwDetectFlags)
  46. {
  47. CIpConfig Interfaces;
  48. if (Interfaces.DoInformsOnEachInterface(ppszAutoProxyUrl))
  49. {
  50. //printf("success on DHCP search: got %s\n", szAutoProxyUrl);
  51. bDetected = true;
  52. }
  53. }
  54. if (!bDetected && (PROXY_AUTO_DETECT_TYPE_DNS_A & dwDetectFlags))
  55. {
  56. if (QueryWellKnownDnsName(ppszAutoProxyUrl) == ERROR_SUCCESS)
  57. {
  58. //printf("success on well qualified name search: got %s\n", szAutoProxyUrl);
  59. bDetected = true;
  60. }
  61. }
  62. if (bDetected)
  63. {
  64. INET_ASSERT(*ppszAutoProxyUrl);
  65. error = ERROR_SUCCESS;
  66. }
  67. else
  68. {
  69. *ppszAutoProxyUrl = NULL;
  70. error = ERROR_WINHTTP_AUTODETECTION_FAILED;
  71. }
  72. quit:
  73. DEBUG_LEAVE(error);
  74. return error;
  75. }