Changeset 85139 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jul 9, 2020 7:49:52 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139085
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageCloud.cpp
r84692 r85139 31 31 #include <iprt/uuid.h> 32 32 #include <iprt/file.h> 33 #include <iprt/http.h> 33 34 #include <VBox/log.h> 34 35 … … 2107 2108 } 2108 2109 2110 static bool getSystemProxyForUrl(const com::Utf8Str &strUrl, Bstr &strProxy) 2111 { 2112 RTHTTP hHttp; 2113 int rc = RTHttpCreate(&hHttp); 2114 if (RT_FAILURE(rc)) 2115 { 2116 LogRel(("OCI-NET: Failed to create HTTP context (rc=%d)\n", rc)); 2117 return false; 2118 } 2119 rc = RTHttpUseSystemProxySettings(hHttp); 2120 if (RT_FAILURE(rc)) 2121 { 2122 LogRel(("OCI-NET: Failed to use system proxy (rc=%d)\n", rc)); 2123 RTHttpDestroy(hHttp); 2124 return false; 2125 } 2126 2127 RTHTTPPROXYINFO proxy; 2128 RT_ZERO(proxy); 2129 rc = RTHttpGetProxyInfoForUrl(hHttp, strUrl.c_str(), &proxy); 2130 if (RT_FAILURE(rc)) 2131 { 2132 LogRel(("OCI-NET: Failed to get proxy for %s (rc=%d)\n", strUrl.c_str(), rc)); 2133 RTHttpDestroy(hHttp); 2134 return false; 2135 } 2136 const char *pcszProxyScheme = ""; 2137 switch (proxy.enmProxyType) 2138 { 2139 case RTHTTPPROXYTYPE_HTTP: 2140 pcszProxyScheme = "http://"; 2141 break; 2142 case RTHTTPPROXYTYPE_HTTPS: 2143 pcszProxyScheme = "https://"; 2144 break; 2145 case RTHTTPPROXYTYPE_SOCKS4: 2146 pcszProxyScheme = "socks4://"; 2147 break; 2148 case RTHTTPPROXYTYPE_SOCKS5: 2149 pcszProxyScheme = "socks://"; 2150 break; 2151 case RTHTTPPROXYTYPE_UNKNOWN: 2152 LogRel(("OCI-NET: Unknown proxy type. Using direct connecton.")); 2153 RTHttpDestroy(hHttp); 2154 return false; 2155 } 2156 strProxy = BstrFmt("%s%s:%d", pcszProxyScheme, proxy.pszProxyHost, proxy.uProxyPort); 2157 RTHttpFreeProxyInfo(&proxy); 2158 RTHttpDestroy(hHttp); 2159 return true; 2160 } 2161 2109 2162 static HRESULT createLocalGatewayImage(ComPtr<IVirtualBox> virtualBox, const Bstr& aGatewayIso, const Bstr& aGuestAdditionsIso, const Bstr& aProxy) 2110 2163 { … … 2125 2178 2126 2179 ComPtr<ISystemProperties> systemProperties; 2180 ProxyMode_T enmProxyMode; 2181 Bstr strProxy; 2127 2182 ComPtr<IMedium> hd; 2128 2183 Bstr defaultMachineFolder; … … 2131 2186 if (errorOccured(hrc, "Failed to obtain system properties.")) 2132 2187 return hrc; 2188 if (aProxy.isNotEmpty()) 2189 strProxy = aProxy; 2190 else 2191 { 2192 hrc = systemProperties->COMGETTER(ProxyMode)(&enmProxyMode); 2193 if (errorOccured(hrc, "Failed to obtain proxy mode.")) 2194 return hrc; 2195 switch (enmProxyMode) 2196 { 2197 case ProxyMode_NoProxy: 2198 strProxy.setNull(); 2199 break; 2200 case ProxyMode_Manual: 2201 hrc = systemProperties->COMGETTER(ProxyURL)(strProxy.asOutParam()); 2202 if (errorOccured(hrc, "Failed to obtain proxy URL.")) 2203 return hrc; 2204 break; 2205 case ProxyMode_System: 2206 if (!getSystemProxyForUrl("https://dl.fedoraproject.org", strProxy)) 2207 errorOccured(E_FAIL, "Failed to get system proxy for https://dl.fedoraproject.org. Will use direct connection."); 2208 break; 2209 default: /* To get rid of ProxyMode_32BitHack 'warning' */ 2210 RTAssertPanic(); 2211 break; 2212 } 2213 2214 } 2133 2215 hrc = systemProperties->COMGETTER(DefaultMachineFolder)(defaultMachineFolder.asOutParam()); 2134 2216 if (errorOccured(hrc, "Failed to obtain default machine folder.")) … … 2283 2365 return hrc; 2284 2366 2285 if ( aProxy.isNotEmpty())2286 { 2287 hrc = unattended->COMSETTER(Proxy)( aProxy.raw());2367 if (strProxy.isNotEmpty()) 2368 { 2369 hrc = unattended->COMSETTER(Proxy)(strProxy.raw()); 2288 2370 if (errorOccured(hrc, "Failed to set post install script template for the unattended installer.")) 2289 2371 return hrc; 2290 2372 } 2373 2291 2374 hrc = unattended->Prepare(); 2292 2375 if (errorOccured(hrc, "Failed to prepare unattended installation."))
Note:
See TracChangeset
for help on using the changeset viewer.