Changeset 85650 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Aug 8, 2020 2:06:23 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139775
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloud.cpp
r85359 r85650 2108 2108 } 2109 2109 2110 static bool getSystemProxyForUrl(const com::Utf8Str &strUrl, Bstr &strProxy) 2111 { 2110 /** 2111 * @returns COM status code. 2112 * @retval S_OK if url needs proxy. 2113 * @retval S_FALSE if noproxy for the URL. 2114 */ 2115 static HRESULT getSystemProxyForUrl(const com::Utf8Str &strUrl, Bstr &strProxy) 2116 { 2117 /** @todo r=bird: LogRel is pointless here. */ 2112 2118 #ifndef VBOX_WITH_PROXY_INFO 2113 2119 RT_NOREF(strUrl, strProxy); 2114 2120 LogRel(("CLOUD-NET: Proxy support is disabled. Using direct connection.\n")); 2115 return false;2121 return S_FALSE; 2116 2122 #else /* VBOX_WITH_PROXY_INFO */ 2117 RTHTTP hHttp; 2123 HRESULT hrc = E_FAIL; 2124 RTHTTP hHttp; 2118 2125 int rc = RTHttpCreate(&hHttp); 2119 if (RT_FAILURE(rc)) 2120 { 2121 LogRel(("CLOUD-NET: Failed to create HTTP context (rc=%d)\n", rc)); 2122 return false; 2123 } 2124 rc = RTHttpUseSystemProxySettings(hHttp); 2125 if (RT_FAILURE(rc)) 2126 { 2127 LogRel(("CLOUD-NET: Failed to use system proxy (rc=%d)\n", rc)); 2126 if (RT_SUCCESS(rc)) 2127 { 2128 rc = RTHttpUseSystemProxySettings(hHttp); 2129 if (RT_SUCCESS(rc)) 2130 { 2131 RTHTTPPROXYINFO proxy; 2132 rc = RTHttpQueryProxyInfoForUrl(hHttp, strUrl.c_str(), &proxy); 2133 if (RT_SUCCESS(rc)) 2134 { 2135 const char *pcszProxyScheme = ""; 2136 switch (proxy.enmProxyType) 2137 { 2138 case RTHTTPPROXYTYPE_NOPROXY: 2139 pcszProxyScheme = NULL; 2140 hrc = S_FALSE; 2141 break; 2142 case RTHTTPPROXYTYPE_HTTP: 2143 pcszProxyScheme = "http://"; 2144 break; 2145 case RTHTTPPROXYTYPE_HTTPS: 2146 pcszProxyScheme = "https://"; 2147 break; 2148 case RTHTTPPROXYTYPE_SOCKS4: 2149 pcszProxyScheme = "socks4://"; 2150 break; 2151 case RTHTTPPROXYTYPE_SOCKS5: 2152 pcszProxyScheme = "socks://"; 2153 break; 2154 case RTHTTPPROXYTYPE_INVALID: 2155 case RTHTTPPROXYTYPE_UNKNOWN: 2156 case RTHTTPPROXYTYPE_END: 2157 case RTHTTPPROXYTYPE_32BIT_HACK: 2158 break; 2159 } 2160 if (pcszProxyScheme && *pcszProxyScheme != '\0') 2161 { 2162 if (proxy.pszProxyUsername || proxy.pszProxyPassword) 2163 LogRel(("CLOUD-NET: Warning! Code doesn't yet handle proxy user or password. Sorry.\n")); 2164 if (proxy.uProxyPort != UINT32_MAX) 2165 strProxy.printf("%s%s:%d", pcszProxyScheme, proxy.pszProxyHost, proxy.uProxyPort); 2166 else 2167 strProxy.printf("%s%s", pcszProxyScheme, proxy.pszProxyHost); 2168 hrc = S_OK; 2169 } 2170 else if (pcszProxyScheme) 2171 { 2172 LogRel(("CLOUD-NET: Unknown proxy type %d. Using direct connection.\n", proxy.enmProxyType)); 2173 AssertFailed(); 2174 } 2175 RTHttpFreeProxyInfo(&proxy); 2176 } 2177 else 2178 LogRel(("CLOUD-NET: Failed to get proxy for %s (rc=%Rrc)\n", strUrl.c_str(), rc)); 2179 } 2180 else 2181 LogRel(("CLOUD-NET: Failed to use system proxy (rc=%Rrc)\n", rc)); 2128 2182 RTHttpDestroy(hHttp); 2129 return false; 2130 } 2131 2132 RTHTTPPROXYINFO proxy; 2133 RT_ZERO(proxy); 2134 rc = RTHttpGetProxyInfoForUrl(hHttp, strUrl.c_str(), &proxy); 2135 if (RT_FAILURE(rc)) 2136 { 2137 LogRel(("CLOUD-NET: Failed to get proxy for %s (rc=%d)\n", strUrl.c_str(), rc)); 2138 RTHttpDestroy(hHttp); 2139 return false; 2140 } 2141 const char *pcszProxyScheme = ""; 2142 switch (proxy.enmProxyType) 2143 { 2144 case RTHTTPPROXYTYPE_HTTP: 2145 pcszProxyScheme = "http://"; 2146 break; 2147 case RTHTTPPROXYTYPE_HTTPS: 2148 pcszProxyScheme = "https://"; 2149 break; 2150 case RTHTTPPROXYTYPE_SOCKS4: 2151 pcszProxyScheme = "socks4://"; 2152 break; 2153 case RTHTTPPROXYTYPE_SOCKS5: 2154 pcszProxyScheme = "socks://"; 2155 break; 2156 case RTHTTPPROXYTYPE_UNKNOWN: 2157 LogRel(("CLOUD-NET: Unknown proxy type. Using direct connecton.")); 2158 RTHttpDestroy(hHttp); 2159 return false; 2160 } 2161 strProxy = BstrFmt("%s%s:%d", pcszProxyScheme, proxy.pszProxyHost, proxy.uProxyPort); 2162 RTHttpFreeProxyInfo(&proxy); 2163 RTHttpDestroy(hHttp); 2164 return true; 2183 } 2184 else 2185 LogRel(("CLOUD-NET: Failed to create HTTP context (rc=%Rrc)\n", rc)); 2186 return hrc; 2165 2187 #endif /* VBOX_WITH_PROXY_INFO */ 2166 2188 } … … 2210 2232 break; 2211 2233 case ProxyMode_System: 2212 if (!getSystemProxyForUrl("https://dl.fedoraproject.org", strProxy)) 2213 errorOccured(E_FAIL, "Failed to get system proxy for https://dl.fedoraproject.org. Will use direct connection."); 2234 hrc = getSystemProxyForUrl("https://dl.fedoraproject.org", strProxy); 2235 if (FAILED(hrc)) 2236 errorOccured(hrc, "Failed to get system proxy for https://dl.fedoraproject.org. Will use direct connection."); 2214 2237 break; 2215 2238 default: /* To get rid of ProxyMode_32BitHack 'warning' */ 2216 RTAssertPanic();2239 AssertFailed(); 2217 2240 break; 2218 2241 }
Note:
See TracChangeset
for help on using the changeset viewer.