Feature merge request:
Add support for iOS http proxy detection R=pthatcher@webrtc.org, tkchin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/45439004 Patch from Yuriy Shevchuk <youwrk@gmail.com>. Cr-Commit-Position: refs/heads/master@{#9250}
This commit is contained in:
parent
523183b4aa
commit
02ff9117b5
@ -528,6 +528,11 @@ static_library("rtc_base") {
|
|||||||
|
|
||||||
if (is_ios) {
|
if (is_ios) {
|
||||||
all_dependent_configs += [ ":ios_config" ]
|
all_dependent_configs += [ ":ios_config" ]
|
||||||
|
|
||||||
|
sources += [
|
||||||
|
"macconversion.cc",
|
||||||
|
"macconversion.h",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_x11) {
|
if (use_x11) {
|
||||||
|
@ -581,6 +581,9 @@
|
|||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
['OS=="ios"', {
|
['OS=="ios"', {
|
||||||
|
'sources/': [
|
||||||
|
['include', 'macconversion.*'],
|
||||||
|
],
|
||||||
'all_dependent_settings': {
|
'all_dependent_settings': {
|
||||||
'xcode_settings': {
|
'xcode_settings': {
|
||||||
'OTHER_LDFLAGS': [
|
'OTHER_LDFLAGS': [
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
@ -156,4 +156,4 @@ bool p_isCFNumberTrue(CFNumberRef cfn) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
#endif // WEBRTC_MAC || WEBRTC_IOS
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#ifndef WEBRTC_BASE_MACCONVERSION_H_
|
#ifndef WEBRTC_BASE_MACCONVERSION_H_
|
||||||
#define WEBRTC_BASE_MACCONVERSION_H_
|
#define WEBRTC_BASE_MACCONVERSION_H_
|
||||||
|
|
||||||
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
|
||||||
@ -34,6 +34,6 @@ bool p_convertCFNumberToInt(CFNumberRef cfn, int* i);
|
|||||||
// given a CFNumberRef, determine if it represents a true value.
|
// given a CFNumberRef, determine if it represents a true value.
|
||||||
bool p_isCFNumberTrue(CFNumberRef cfn);
|
bool p_isCFNumberTrue(CFNumberRef cfn);
|
||||||
|
|
||||||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
#endif // WEBRTC_MAC || WEBRTC_IOS
|
||||||
|
|
||||||
#endif // WEBRTC_BASE_MACCONVERSION_H_
|
#endif // WEBRTC_BASE_MACCONVERSION_H_
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
#include "macconversion.h"
|
#include "macconversion.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WEBRTC_IOS
|
||||||
|
#include <CFNetwork/CFNetwork.h>
|
||||||
|
#include "macconversion.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/base/fileutils.h"
|
#include "webrtc/base/fileutils.h"
|
||||||
@ -1179,6 +1184,56 @@ bool GetMacProxySettings(ProxyInfo* proxy) {
|
|||||||
}
|
}
|
||||||
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
|
||||||
|
|
||||||
|
#ifdef WEBRTC_IOS
|
||||||
|
// iOS has only http proxy
|
||||||
|
bool GetiOSProxySettings(ProxyInfo* proxy) {
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
CFDictionaryRef proxy_dict = CFNetworkCopySystemProxySettings();
|
||||||
|
if (!proxy_dict) {
|
||||||
|
LOG(LS_ERROR) << "CFNetworkCopySystemProxySettings failed";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFNumberRef proxiesHTTPEnable = (CFNumberRef)CFDictionaryGetValue(
|
||||||
|
proxy_dict, kCFNetworkProxiesHTTPEnable);
|
||||||
|
if (!p_isCFNumberTrue(proxiesHTTPEnable)) {
|
||||||
|
CFRelease(proxy_dict);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFStringRef proxy_address = (CFStringRef)CFDictionaryGetValue(
|
||||||
|
proxy_dict, kCFNetworkProxiesHTTPProxy);
|
||||||
|
CFNumberRef proxy_port = (CFNumberRef)CFDictionaryGetValue(
|
||||||
|
proxy_dict, kCFNetworkProxiesHTTPPort);
|
||||||
|
|
||||||
|
// the data we need to construct the SocketAddress for the proxy.
|
||||||
|
std::string hostname;
|
||||||
|
int port;
|
||||||
|
if (p_convertHostCFStringRefToCPPString(proxy_address, hostname) &&
|
||||||
|
p_convertCFNumberToInt(proxy_port, &port)) {
|
||||||
|
// We have something enabled, with a hostname and a port.
|
||||||
|
// That's sufficient to set up the proxy info.
|
||||||
|
// Finally, try HTTP proxy. Note that flute doesn't
|
||||||
|
// differentiate between HTTPS and HTTP, hence we are using the
|
||||||
|
// same flute type here, ie. PROXY_HTTPS.
|
||||||
|
proxy->type = PROXY_HTTPS;
|
||||||
|
|
||||||
|
proxy->address.SetIP(hostname);
|
||||||
|
proxy->address.SetPort(port);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We created the dictionary with something that had the
|
||||||
|
// word 'copy' in it, so we have to release it, according
|
||||||
|
// to the Carbon memory management standards.
|
||||||
|
CFRelease(proxy_dict);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif // WEBRTC_IOS
|
||||||
|
|
||||||
bool AutoDetectProxySettings(const char* agent, const char* url,
|
bool AutoDetectProxySettings(const char* agent, const char* url,
|
||||||
ProxyInfo* proxy) {
|
ProxyInfo* proxy) {
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
@ -1195,6 +1250,8 @@ bool GetSystemDefaultProxySettings(const char* agent, const char* url,
|
|||||||
return GetIeProxySettings(agent, url, proxy);
|
return GetIeProxySettings(agent, url, proxy);
|
||||||
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
#elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
||||||
return GetMacProxySettings(proxy);
|
return GetMacProxySettings(proxy);
|
||||||
|
#elif defined(WEBRTC_IOS)
|
||||||
|
return GetiOSProxySettings(proxy);
|
||||||
#else
|
#else
|
||||||
// TODO: Get System settings if browser is not firefox.
|
// TODO: Get System settings if browser is not firefox.
|
||||||
return GetFirefoxProxySettings(url, proxy);
|
return GetFirefoxProxySettings(url, proxy);
|
||||||
|
Loading…
Reference in New Issue
Block a user