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.

124 lines
2.7 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. --*/
  19. #include <wininetp.h>
  20. #include "aproxp.h"
  21. #include "apdetect.h"
  22. // this isnt the most efficient thing
  23. // should probably move this to autoprox class...
  24. //
  25. DWORD
  26. WINAPI
  27. GetProxyDetectType(VOID)
  28. {
  29. static DWORD _adType = PROXY_AUTO_DETECT_TYPE_DEFAULT;
  30. static DWORD UseCached = 0;
  31. if (! UseCached )
  32. {
  33. InternetReadRegistryDword("AutoProxyDetectType",
  34. (LPDWORD)&(_adType)
  35. );
  36. if (_adType & PROXY_AUTO_DETECT_CACHE_ME )
  37. {
  38. UseCached = 1;
  39. }
  40. }
  41. return _adType;
  42. }
  43. STDAPI_(BOOL)
  44. DetectAutoProxyUrl(
  45. IN OUT LPSTR lpszAutoProxyUrl,
  46. IN DWORD dwAutoProxyUrlLength,
  47. IN DWORD dwDetectFlags
  48. )
  49. {
  50. BOOL fRet = FALSE;
  51. DWORD error;
  52. DEBUG_ENTER((DBG_SOCKETS,
  53. Bool,
  54. "DetectAutoProxyUrl",
  55. "%x, %u",
  56. lpszAutoProxyUrl,
  57. dwAutoProxyUrlLength
  58. ));
  59. if (!GlobalDataInitialized) {
  60. error = GlobalDataInitialize();
  61. if (error != ERROR_SUCCESS) {
  62. goto quit;
  63. }
  64. }
  65. error = LoadWinsock();
  66. if ( error != ERROR_SUCCESS ) {
  67. goto quit;
  68. }
  69. {
  70. CIpConfig Interfaces;
  71. if ( (GetProxyDetectType() & PROXY_AUTO_DETECT_TYPE_DHCP) & dwDetectFlags ) {
  72. //Interfaces.GetAdapterInfo();
  73. if ( Interfaces.DoInformsOnEachInterface(lpszAutoProxyUrl, dwAutoProxyUrlLength) )
  74. {
  75. //printf("success on DHCP search: got %s\n", szAutoProxyUrl);
  76. fRet = TRUE;
  77. goto quit;
  78. }
  79. }
  80. if ( (GetProxyDetectType() & PROXY_AUTO_DETECT_TYPE_DNS_A) & dwDetectFlags ) {
  81. if ( QueryWellKnownDnsName(lpszAutoProxyUrl, dwAutoProxyUrlLength) == ERROR_SUCCESS)
  82. {
  83. //printf("success on well qualified name search: got %s\n", szAutoProxyUrl);
  84. fRet = TRUE;
  85. goto quit;
  86. }
  87. }
  88. }
  89. quit:
  90. DEBUG_LEAVE(fRet);
  91. return fRet;
  92. }