added reverseBypassEnabled in ProxySettings
This commit is contained in:
parent
6d2408de0e
commit
06ef336c28
|
@ -84,6 +84,9 @@ public class ProxyManager extends ChannelDelegateImpl {
|
||||||
if (settings.removeImplicitRules != null && settings.removeImplicitRules) {
|
if (settings.removeImplicitRules != null && settings.removeImplicitRules) {
|
||||||
proxyConfigBuilder.removeImplicitRules();
|
proxyConfigBuilder.removeImplicitRules();
|
||||||
}
|
}
|
||||||
|
if (settings.reverseBypassEnabled != null && WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE_REVERSE_BYPASS)) {
|
||||||
|
proxyConfigBuilder.setReverseBypassEnabled(settings.reverseBypassEnabled);
|
||||||
|
}
|
||||||
proxyController.setProxyOverride(proxyConfigBuilder.build(), new Executor() {
|
proxyController.setProxyOverride(proxyConfigBuilder.build(), new Executor() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Runnable command) {
|
public void execute(Runnable command) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class ProxySettings implements ISettings<ProxyConfig> {
|
||||||
List<ProxyRuleExt> proxyRules = new ArrayList<>();
|
List<ProxyRuleExt> proxyRules = new ArrayList<>();
|
||||||
Boolean bypassSimpleHostnames = null;
|
Boolean bypassSimpleHostnames = null;
|
||||||
Boolean removeImplicitRules = null;
|
Boolean removeImplicitRules = null;
|
||||||
|
Boolean reverseBypassEnabled = false;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,6 +52,9 @@ public class ProxySettings implements ISettings<ProxyConfig> {
|
||||||
case "removeImplicitRules":
|
case "removeImplicitRules":
|
||||||
removeImplicitRules = (Boolean) value;
|
removeImplicitRules = (Boolean) value;
|
||||||
break;
|
break;
|
||||||
|
case "reverseBypassEnabled":
|
||||||
|
reverseBypassEnabled = (Boolean) value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +74,7 @@ public class ProxySettings implements ISettings<ProxyConfig> {
|
||||||
settings.put("proxyRules", proxyRuleMapList);
|
settings.put("proxyRules", proxyRuleMapList);
|
||||||
settings.put("bypassSimpleHostnames", bypassSimpleHostnames);
|
settings.put("bypassSimpleHostnames", bypassSimpleHostnames);
|
||||||
settings.put("removeImplicitRules", removeImplicitRules);
|
settings.put("removeImplicitRules", removeImplicitRules);
|
||||||
|
settings.put("reverseBypassEnabled", reverseBypassEnabled);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +92,7 @@ public class ProxySettings implements ISettings<ProxyConfig> {
|
||||||
}
|
}
|
||||||
realSettings.put("bypassRules", proxyConfig.getBypassRules());
|
realSettings.put("bypassRules", proxyConfig.getBypassRules());
|
||||||
realSettings.put("proxyRules", proxyRuleMapList);
|
realSettings.put("proxyRules", proxyRuleMapList);
|
||||||
|
realSettings.put("reverseBypassEnabled", proxyConfig.isReverseBypassEnabled());
|
||||||
return realSettings;
|
return realSettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,19 @@ package com.pichillilorenzo.flutter_inappwebview.types;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.webkit.ProxyConfig;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ProxyRuleExt {
|
public class ProxyRuleExt {
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ProxyConfig.ProxyScheme
|
||||||
private String schemeFilter;
|
private String schemeFilter;
|
||||||
@NonNull
|
@NonNull
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
public ProxyRuleExt(@Nullable String schemeFilter, @NonNull String url) {
|
public ProxyRuleExt(@Nullable @ProxyConfig.ProxyScheme String schemeFilter, @NonNull String url) {
|
||||||
this.schemeFilter = schemeFilter;
|
this.schemeFilter = schemeFilter;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,12 +115,24 @@ class ProxySettings {
|
||||||
///Set this to `true` to override the default behavior and force localhost and link-local URLs to be sent through the proxy.
|
///Set this to `true` to override the default behavior and force localhost and link-local URLs to be sent through the proxy.
|
||||||
bool? removeImplicitRules;
|
bool? removeImplicitRules;
|
||||||
|
|
||||||
|
///Reverse the bypass list.
|
||||||
|
///
|
||||||
|
///The default value is `false`, in which case all URLs will use proxy settings except the ones in the bypass list, which will be connected to directly instead.
|
||||||
|
///
|
||||||
|
///If set to `true`, then only URLs in the bypass list will use these proxy settings, and all other URLs will be connected to directly.
|
||||||
|
///
|
||||||
|
///Use [bypassRules] to add bypass rules.
|
||||||
|
///
|
||||||
|
///**NOTE**: available only if [WebViewFeature.PROXY_OVERRIDE_REVERSE_BYPASS] feature is supported.
|
||||||
|
bool reverseBypassEnabled;
|
||||||
|
|
||||||
ProxySettings(
|
ProxySettings(
|
||||||
{this.bypassRules = const [],
|
{this.bypassRules = const [],
|
||||||
this.directs = const [],
|
this.directs = const [],
|
||||||
this.proxyRules = const [],
|
this.proxyRules = const [],
|
||||||
this.bypassSimpleHostnames,
|
this.bypassSimpleHostnames,
|
||||||
this.removeImplicitRules});
|
this.removeImplicitRules,
|
||||||
|
this.reverseBypassEnabled = false});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
|
@ -128,7 +140,8 @@ class ProxySettings {
|
||||||
"directs": directs,
|
"directs": directs,
|
||||||
"proxyRules": proxyRules.map((e) => e.toMap()).toList(),
|
"proxyRules": proxyRules.map((e) => e.toMap()).toList(),
|
||||||
"bypassSimpleHostnames": bypassSimpleHostnames,
|
"bypassSimpleHostnames": bypassSimpleHostnames,
|
||||||
"removeImplicitRules": removeImplicitRules
|
"removeImplicitRules": removeImplicitRules,
|
||||||
|
"reverseBypassEnabled": reverseBypassEnabled
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +154,7 @@ class ProxySettings {
|
||||||
.map((e) => ProxyRule.fromMap(e)) as List<ProxyRule>;
|
.map((e) => ProxyRule.fromMap(e)) as List<ProxyRule>;
|
||||||
settings.bypassSimpleHostnames = map["bypassSimpleHostnames"];
|
settings.bypassSimpleHostnames = map["bypassSimpleHostnames"];
|
||||||
settings.removeImplicitRules = map["removeImplicitRules"];
|
settings.removeImplicitRules = map["removeImplicitRules"];
|
||||||
|
settings.reverseBypassEnabled = map["reverseBypassEnabled"];
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,10 @@ class WebViewFeature_ {
|
||||||
static const PROXY_OVERRIDE =
|
static const PROXY_OVERRIDE =
|
||||||
const WebViewFeature_._internal("PROXY_OVERRIDE");
|
const WebViewFeature_._internal("PROXY_OVERRIDE");
|
||||||
|
|
||||||
|
///This feature covers [ProxySettings.reverseBypassEnabled].
|
||||||
|
static const PROXY_OVERRIDE_REVERSE_BYPASS =
|
||||||
|
const WebViewFeature_._internal("PROXY_OVERRIDE_REVERSE_BYPASS");
|
||||||
|
|
||||||
///
|
///
|
||||||
static const RECEIVE_HTTP_ERROR =
|
static const RECEIVE_HTTP_ERROR =
|
||||||
const WebViewFeature_._internal("RECEIVE_HTTP_ERROR");
|
const WebViewFeature_._internal("RECEIVE_HTTP_ERROR");
|
||||||
|
|
Loading…
Reference in New Issue