@@ -57,6 +57,12 @@ public class ChromeDriverService extends DriverService {
57
57
public static final String CHROME_DRIVER_SILENT_OUTPUT_PROPERTY =
58
58
"webdriver.chrome.silentOutput" ;
59
59
60
+ /**
61
+ * System property that defines comma-separated list of remote IPv4 addresses which are
62
+ * allowed to connect to ChromeDriver.
63
+ */
64
+ public final static String CHROME_DRIVER_WHITELISTED_IPS_PROPERTY = "webdriver.chrome.whitelistedIps" ;
65
+
60
66
/**
61
67
*
62
68
* @param executable The chromedriver executable.
@@ -90,6 +96,7 @@ public static class Builder extends DriverService.Builder<
90
96
91
97
private boolean verbose = Boolean .getBoolean (CHROME_DRIVER_VERBOSE_LOG_PROPERTY );
92
98
private boolean silent = Boolean .getBoolean (CHROME_DRIVER_SILENT_OUTPUT_PROPERTY );
99
+ private String whitelistedIps = System .getProperty (CHROME_DRIVER_WHITELISTED_IPS_PROPERTY );
93
100
94
101
/**
95
102
* Configures the driver server verbosity.
@@ -113,6 +120,18 @@ public Builder withSilent(boolean silent) {
113
120
return this ;
114
121
}
115
122
123
+ /**
124
+ * Configures the comma-separated list of remote IPv4 addresses which are allowed to connect
125
+ * to the driver server.
126
+ *
127
+ * @param whitelistedIps comma-separated list of remote IPv4 addresses
128
+ * @return A self reference.
129
+ */
130
+ public Builder withWhitelistedIps (String whitelistedIps ) {
131
+ this .whitelistedIps = whitelistedIps ;
132
+ return this ;
133
+ }
134
+
116
135
@ Override
117
136
protected File findDefaultExecutable () {
118
137
return findExecutable ("chromedriver" , CHROME_DRIVER_EXE_PROPERTY ,
@@ -140,6 +159,9 @@ protected ImmutableList<String> createArgs() {
140
159
if (silent ) {
141
160
argsBuilder .add ("--silent" );
142
161
}
162
+ if (whitelistedIps != null ) {
163
+ argsBuilder .add (String .format ("--whitelisted-ips=%s" , whitelistedIps ));
164
+ }
143
165
144
166
return argsBuilder .build ();
145
167
}
0 commit comments