Custom host resolver

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Custom host resolver

Postby BeyondDefinition » Tue Feb 23, 2021 5:41 am

Hi, I'm trying to use CEF on Windows to connect to a webserver on a local network that does not have a DNS server. The webserver requires connection by hostname, which I know up front. I don't have access rights to inject DNS into the system. I'd like to inject the hostname into my request from CEF.

I tried to:
  • Wrap CefRequestContext (with CefRequestContext::GetGlobalContext() as wrapped instance) and provide a custom implementation for only ResolveHost.
    Result: Passing this instance to CreateBrowserSync does not trigger any calls to the wrapper request. Browser still works normally.
  • Creating a CefRequest instance with CefRequest::Create() and trying to override the Host header with SetHeaderByName. Then loading the request with GetMainFrame()->LoadRequest(req).
    Result: The Host header in the request is not different then what was parsed from the URL
  • Overriding CefRequestHandler and CefResourceRequestHandler. Then update the Host header with SetHeaderByName in OnBeforeResourceLoad.
    Result: OnBeforeResourceLoad is called, the Host header initially is not present in the header map and setting it does not have any effect.

I am running CEF Version: 87.1.6+g315d248+chromium-87.0.4280.66
How can I achieve this?
BeyondDefinition
Newbie
 
Posts: 2
Joined: Tue Feb 23, 2021 5:05 am

Re: Custom host resolver

Postby magreenblatt » Tue Feb 23, 2021 10:49 am

You can add an entry to the Windows HOSTS file.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Custom host resolver

Postby BeyondDefinition » Tue Feb 23, 2021 12:42 pm

Of course that would work, however we cannot assume (Windows 10) admin rights on the system that runs the browser.
I am looking for a solution that can work without admin rights.
BeyondDefinition
Newbie
 
Posts: 2
Joined: Tue Feb 23, 2021 5:05 am

Re: Custom host resolver

Postby magreenblatt » Tue Feb 23, 2021 1:54 pm

There are many ways to set up DNS resolution on the local network. I suggest looking into one of those options.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 55 guests