- follow these instructions here to get the code.
- export CHROMIUM_SRC_ROOT and DEPOT_TOOLS_ROOT to their separate directories,
such as
export CHROMIUM_SRC_ROOT=/root/chromium/src DEPOT_TOOLS_ROOT=/root/depot_tools
- run
checkout-to-tag.sh
to checkout specified tag, for example,102.0.5005.195
. - run
build_cronet.sh [debug|release]
to build native and java bindings, then package intocronet-$BUILD.aar
(BUILD: debug or release).
- Quick Start Guide to Using Cronet, native API, Android API
- Perform network operations using Cronet
- Samples with test: native sample, Android sample, GoogleChromeLabs / cronet_sample
The key point is Cronet_EngineParams_envoy_url_set(engine_params, "ENVOY_URL")
for native
or cronetEngineBuilder.setEnvoyUrl("ENVOY_URL")
for android.
In one format of
https://DOMAIN/PATH
which can be backed up by http servers or even CDN. The full format for this mode isenvoy://?k1=v1&k2=v2
, see Parameters section below for more.socks5://HOST:PORT
which can be any socks5 proxy, and we have a built-in shadowsocks service for the android platform.
keys for envoy://?k1=v1[&<more-pairs>...]
format:
- url: proxy URL, for example, https://allowed.example.com/path/
- header_xxx: HTTP header, header_Host=my-host` will send Host header with value my-host
- address: IP address for domain in proxy URL, to replace IP from DNS resolving
- resolve: resolve map, same as
--host-resolver-rules
command line for chromium, Chromium docs, lighthouse issue #2817, firefox bug #1523367 - disabled_cipher_suites: cipher suites to be disabled, same as
--cipher-suite-blacklist
command line for chromium, chromium bug #58831, Firefox Support Forum - salt: a 16 characters long random string, unique to each combination of app-signing key, user, and device, such ANDROID_ID
All keys except url are optional, for example, only resolve
without url
will just override the DNS setting.
- the simplest form, a simple HTTP/HTTPS URL:
https://allowed.example.com/app1/
- or via socks5 provided by any proxy server or builtin shadowsocks service(go to android/README.md for shadowsocks integration):
socks5://127.0.0.1:1080
. - set host:
envoy://?url=https%3A%2F%2Fexample.com%2Fapp1%2F%3Fk1%3Dv1&header_Host=forbidden.example.com
- only MAP url-host to address:
envoy://?url=https%3A%2F%2Fexample.com%2Fapp1%2F%3Fk1%3Dv1&header_Host=forbidden.example.com&address=1.2.3.4
- custom host override:
envoy://?url=https%3A%2F%2Fexample.com%2Fapp1%2F%3Fk1%3Dv1&header_Host=forbidden.example.com&resolve=MAP%20example.com%201.2.3.4,%20example2.com%201.2.3.5:443
- disable some cipher suites:
envoy://?url=https%3A%2F%2Fallowed.example.com%2Fapp1%2F%3Fk1%3Dv1&header_Host=forbidden.example.com&address=1.2.3.4&disabled_cipher_suites=0xc024,0xc02f
In example 5: allowed.example.com will be TLS SNI, forbidden.example.com will be Host HTTP header, 1.2.3.4 will be IP for allowed.example.com.
The equivalent curl command(see below for nginx conf):
curl --resolve allowed.example.com:443:1.2.3.4 \ --header 'Host: forbidden.example.com' \ --header 'Url-Orig: https://forbidden.example.com' --header 'Host-Orig: forbidden.example.com' \ https://allowed.example.com/app1/ # --ciphers ECDHE-RSA-AES128-GCM-SHA256
Note: _hash=HASH
will be appended to url in all cases for cache invalidation.
Use Nginx as areverse proxy
, see security for more.
location ~ ^/app1/ {
proxy_ssl_server_name on;
proxy_pass $http_url_orig;
proxy_buffering off; # disable buffer for stream
proxy_set_header Host $http_host_orig;
proxy_hide_header Host-Orig;
proxy_hide_header Url-Orig;
proxy_pass_request_headers on;
}
# ... after patching chromium source
export ENVOY_URL=https://example.com/path/
sed -i s#https://example.com/enovy_path/#$ENVOY_URL#g components/cronet/native/sample/main.cc
autoninja -C out/Cronet-Desktop cronet_sample cronet_sample_test
out/Cronet-Desktop/cronet_sample https://ifconfig.co/ip
# ... after patching chromium source
export ENVOY_URL=https://example.com/path/
sed -i s#https://example.com/enovy_path/#$ENVOY_URL#g components/cronet/android/sample/src/org/chromium/cronet_sample_apk/CronetSampleActivity.java
autoninja -C out/Cronet cronet_sample_apk
adb install out/Cronet/apks/CronetSample.apk
-
Update chromium code then run
git ls-files -m|grep -E '.cc|.java' |xargs git cl format # --diff
to format changeset(orgit diff --patch-with-stat
). -
Update api bindings:
if components/cronet/cronet.idl is updated, run
components/cronet/tools/generate_idl_bindings.py
components/cronet/tools/update_api.py --api_jar out/Cronet/lib.java/components/cronet/android/cronet_api_java.jar
Generate xtb translation id
cd tools/grit && python
>>> from grit.extern.tclib import GenerateMessageId
>>> GenerateMessageId("English string to translate")
- JavaCronetEngine.java has no member
envoy_url
.?