Adding proxy support to Cronet

373 views
Skip to first unread message

Lucas Moauro

unread,
Feb 27, 2024, 11:10:57 AMFeb 27
to net...@chromium.org
Hello,

I'm working on an open source library that will provide python bindings for libcronet and an important feature is to support proxies so that I can provide similar features to requests or httpx.

I see that there's an open issue for that at the moment: https://issues.chromium.org/issues/40716285

I would like to work on that issue and I'm wondering if there are any high level suggestions on how to approach the problem from an experienced chromium dev. Also I'm interested in implementing it to be configurable per request and not just a single proxy for the Cronet engine.

Lucas

Sebastian Poreba

unread,
Feb 27, 2024, 12:16:53 PMFeb 27
to Lucas Moauro, net...@chromium.org
libcronet does not have a stable interface, and we suggest you do not create additional bindings to it, as no guarantees exist that we would not break you in the future. We only support libcronet on Android, and only via CronetEngine.

We also don't have an ETA for proxy support, or per-request configuration in CronetEngine - we are currently considering both of these features.


-- 

  •  Sebastian Poręba
  •  Engineering Manager
  •  spo...@google.com
 


--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAJ3O4-P%3DN4CzVVwerM8ejF5dGy1NsnjABUg%3DK3owRBsXO64jDA%40mail.gmail.com.

Lucas Moauro

unread,
Feb 27, 2024, 2:01:59 PMFeb 27
to Sebastian Poreba, net...@chromium.org
The bindings won't be too tied to the API internals so I can update them if cronet changes. I think it's a very useful library to use outside of Android and it's more lightweight than running headless chrome if you just need to run chrome's network stack.

I have been testing how to set the proxy and it looks like it's not too difficult to do it per cronet engine. Per request it seems difficult.

I added a class like the following one:

class ProxyConfigServiceSingle : public net::ProxyConfigService {
 public:
  // ProxyConfigServiceSingle implementation:
  void AddObserver(Observer* observer) override {}
  void RemoveObserver(Observer* observer) override {}
  ConfigAvailability GetLatestProxyConfig(
      net::ProxyConfigWithAnnotation* config) override {
   
    auto proxy_config = net::ProxyConfig();
    proxy_config.proxy_rules().ParseFromString("http://localhost:8080");
    auto annotation = net::DefineNetworkTrafficAnnotation("test", "test");
    *config = net::ProxyConfigWithAnnotation(proxy_config, annotation);
    return CONFIG_VALID;
  }
};

and then modified CreateProxyConfigService to use it.

Reply all
Reply to author
Forward
0 new messages