phi1618
phi1618

Reputation: 47

How to "Whitelist all ips - allow remote connections for all?

I have been struggling with figuring out how to "allow all remote connections" with a proxy in ChromeDriver in C#.

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.WhitelistedIPAddresses = ""; // NOTE: The idea is to allow all remote 
connections. How to allow all IPs?
service.Port = 9515;
ChromeOptions options = new ChromeOptions();
var proxy = new Proxy();
proxy.Kind = ProxyKind.Manual;
proxy.IsAutoDetect = false;
proxy.HttpProxy = proxyUrl;
proxy.SslProxy = proxyUrl;
options.Proxy = proxy;
options.AddArgument("ignore-certificate-errors");
IWebDriver driver = new ChromeDriver(service, options);
int waitTime = GetRandomWait2to5.getRandom2to5();
driver.Url = "https://whatismyipaddress.com/"; //TEST

============ END ========================= See attached screenshot with "local connections allowed". Passing "chrodriver --whitelisted-ips=''" in CMD works and says "all remote connections allowed". Thanks for the input. (edited)

Upvotes: 2

Views: 1597

Answers (3)

Rohit Agrawal
Rohit Agrawal

Reputation: 371

Incase you were using :

ChromeDriverService service = new ChromeDriverService.Builder().withWhitelistedIps("").build();

This will start throwing

compilation error

as mentioned below because the withWhitelistedIps method of ChromeDriverService is now deprecated and the new method is withAllowedListIps (Refer : https://www.javadoc.io/doc/org.seleniumhq.selenium/selenium-chrome-driver/4.8.2/deprecated-list.html)

[ERROR]   symbol:   method withWhitelistedIps(java.lang.String)
[ERROR]   location: class org.openqa.selenium.chrome.ChromeDriverService.Builder

You now need to use withAllowedListIps in place of withWhitelistedIps and the working code will look like :

ChromeDriverService service = new ChromeDriverService.Builder().withAllowedListIps("").build();

Hope this helps. Let me know in case of any query.

Upvotes: 0

phi1618
phi1618

Reputation: 47

Ok, that was way simpler than i thought: Replace service.WhitelistedIPAddresses = "" with service.WhitelistedIPAddresses = " ". This finally shows "All remote connections are allowed".

Upvotes: 0

Mike93041
Mike93041

Reputation: 387

When you instantiate ChromeDriver a Chrome driver executable is launched, you need to pass --whitelisted-ips='' using options.AddArgument("--whitelisted-ips=''")

In your case:

ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.WhitelistedIPAddresses = ""; // NOTE: The idea is to allow all remote 
connections. How to allow all IPs?
service.Port = 9515;
ChromeOptions options = new ChromeOptions();
var proxy = new Proxy();
proxy.Kind = ProxyKind.Manual;
proxy.IsAutoDetect = false;
proxy.HttpProxy = proxyUrl;
proxy.SslProxy = proxyUrl;
options.Proxy = proxy;
options.AddArgument("ignore-certificate-errors");
options.AddArgument("--whitelisted-ips=''"); // NEW LINE ADDED
IWebDriver driver = new ChromeDriver(service, options);
int waitTime = GetRandomWait2to5.getRandom2to5();
driver.Url = "https://whatismyipaddress.com/"; //TEST

Upvotes: 1

Related Questions