Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

How to set proxy settings ... especially tor network

User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to set proxy settings ... especially tor network

Post by salvadordf »

ASoraru wrote: Tue Jan 02, 2018 11:51 am i tried some stuff but that does not effect that ... there is a timeout switch but that doesnt seem to work ... so when the problem is in the CEF3 or CE ... do you report that to them or should i do? do you have a contact person in the other projects?
Anyone can do it but you must be able to replicate the same error with their client app and report the problem as a bug in their client.

For example, if you want to report a bug in the chromium project, you need to replicate the same error in Chrome or in Chromium.

But before creating a new issue in Chromium, try this in Chrome :
https://tor.stackexchange.com/questions ... to-use-tor

It seems that you need to add another command switch to disable DNS prefetching too :

Code: Select all

/path/to/Chrome.exe --proxy-server="socks5://127.0.0.1:9050" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE 127.0.0.1"
The comments in stackexchange indicate that this works in Chrome.

You would only need to add GlobalCEFApp.AddCustomCommandLine('--host-resolver-rules', 'MAP * 0.0.0.0 , EXCLUDE 127.0.0.1'); before GlobalCEFApp.StartMainProcess to test this in CEF4Delphi.

More information here :
http://www.chromium.org/developers/desi ... ocks-proxy
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to set proxy settings ... especially tor network

Post by salvadordf »

I edited my last message several times. If you were reading at that time refresh the page in your browser
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to set proxy settings ... especially tor network

Post by salvadordf »

Hi,

I finally installed the tor browser in a virtual machine and made some tests with the minibrowser.

I added the "host-resolver-rules" command switch and I used these settings :

Code: Select all

type : fixed servers
address scheme : socks 5
address : 127.0.0.1
port : 9150  // <-- notice that I used 9150 and not 9050 
Using those settings I could open several 'onion' sites. The speed was extremely slow but all the sites were loaded eventually.

I tried ansotec.de in the minibrowser but it timed out. Just to be sure, I also tried ansotec.de in the tor browser and it also timed out! :shock:
Without the proxy settings ansotec.de was loaded successfully very fast.

This means that there's some problem with the Tor network or the ansotec.de server refuses to open connections with the exit nodes from the Tor network to avoid hacker attacks.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: How to set proxy settings ... especially tor network

Post by snoop »

Hello! I updated to latest version. Now browsers are initializing. I have 4 browsers in my project. 2 on main form, 2 on other 2 forms. Im using proxies in my app. And now I have a problem. changing proxies works on 2 bworsers on my main form. But it doesnt on other forms. I receive 407 authorization required error. Seems like changeing ip and type works (also I can turn off proxy and it works everywhere), but not password. I tried to change it few times later in code on other forms, but still doesnt work
worked fine in previous versions
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to set proxy settings ... especially tor network

Post by salvadordf »

Hi,

The proxy settings are updated in the request context used by each TChromium.

If you need different proxy settings in some of your browsers you need to create a new request context when you create the TChromium component.
All TChromium components that share the same request context will also share the proxy settings.

The code to update the proxy settings was recently modified to support SOCKS4 and SOCKS5 proxy servers but that should not affect you. The modified function was TChromium.UpdateProxyPrefs and I only added 'socks4://' and 'socks5://' to the server string.

Please check that the proxy servers that you are using don't have some sort of limitation : number of connections, bandwidth used, etc.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: How to set proxy settings ... especially tor network

Post by snoop »

I tested for a day, then I tried to run it few times again. It worked once, but then I had white screen or 407 error again... White screen is ok, browser initialized. setting proxy off works. I came up with that deleting CACHE folder helps. IT works correct after deleting it, app works fine once, then its white screens/407 for additional browsers. There is definetely still something wrong with new versions, you must check it I don't know how, but look in initializing browsers and proxy utils. I think you've made some changes in proxies and initializing and... why??? To discover new bugs and problems...
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: How to set proxy settings ... especially tor network

Post by snoop »

Hey Salvador, any news? I really need to update chromium with correct proxies. Please!
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to set proxy settings ... especially tor network

Post by salvadordf »

I tried to find a public proxy server protected by a username and password but it seems that all public servers don't need a password.

I tested the MDIBrowser adding the proxy settings in the TChildForm.FormShow procedure like this :

Code: Select all

procedure TChildForm.FormShow(Sender: TObject);
var
  TempContext : ICefRequestContext;
begin
  // The new request context overrides several GlobalCEFApp properties like :
  // cache, AcceptLanguageList, PersistSessionCookies, PersistUserPreferences,
  // IgnoreCertificateErrors and EnableNetSecurityExpiration

  // If you use an empty cache path, CEF will use in-memory cache.

  if MainForm.NewContextChk.Checked then
    TempContext := TCefRequestContextRef.New('', '', False, False, False, False)
   else
    TempContext := nil;

  Chromium1.ProxyType := CEF_PROXYTYPE_FIXED_SERVERS;
  Chromium1.ProxyScheme := psSOCKS5;
  Chromium1.ProxyServer := '189.102.74.134';
  Chromium1.ProxyPort := 33601;
  Chromium1.ProxyUsername := '';
  Chromium1.ProxyPassword := '';

  // In case you used a custom cookies path in the GlobalCEFApp you can
  // override it in the TChromium.CreateBrowser function
  Chromium1.CreateBrowser(CEFWindowParent1, '', TempContext);
end;
I compiled and run MDIBrowser. Then I opened several child windows and visited some websites that show your IP. All of them told me that I was using an IP from Brazil, not from Spain.

Please check this in your application :
  • Set the proxy settings in all your browsers. If you get a 407, set a breakpoint at the TChromium.doOnGetAuthCredentials procedure and check that the callback.cont function is called with the right username and password.
  • Check that the proxy server that shows a 407 error allows you to have multiple sessions with the same username and password.
  • Browsers with different request contexts can't share the same cache and cookies directory.
  • Many public proxy servers limit the number of connections, used bandwidth, etc.
snoop
Posts: 75
Joined: Mon Jul 10, 2017 12:06 pm

Re: How to set proxy settings ... especially tor network

Post by snoop »

Hello
Im using private and not free proxies. very fast and no problems with many connections
There is something wrong in new browsers initialization or in proxy settings
My browsers are sharing context, so Im making Createbrowser(window) function. no other parameters
You did not notice that I said deleting cache is helping everytime. After that application runs once correct.
Also, if I get 407 error, sometimes I manage to set proxy in runtime. I managed once when I first set up no proxy (direct), then I set up proxy with wrong password(!), then I tried correct and it worked! Very strange...
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to set proxy settings ... especially tor network

Post by salvadordf »

snoop wrote: Fri Jan 26, 2018 4:05 pm Hello
Im using private and not free proxies. very fast and no problems with many connections
There is something wrong in new browsers initialization or in proxy settings
My browsers are sharing context, so Im making Createbrowser(window) function. no other parameters
You did not notice that I said deleting cache is helping everytime. After that application runs once correct.
Also, if I get 407 error, sometimes I manage to set proxy in runtime. I managed once when I first set up no proxy (direct), then I set up proxy with wrong password(!), then I tried correct and it worked! Very strange...
Do you call Chromium1.UpdatePreferences; after you modify the proxy settings at runtime ?

The MiniBrowser has all the necessary code to update the proxy settings at runtime in the TMiniBrowserFrm.Preferences1Click procedure.

If you don't call Chromium1.UpdatePreferences the browser will update them automatically in the TChromium.doOnBeforeBrowse procedure but this procedure is only called when you visit a different website.

Please, test the MDIBrowser demo with your proxy settings and the code I sent you in the previous message. Let me know if the MDIBrowser gives you the same problem.
Post Reply