Skip to content

Commit 988ea61

Browse files
committed
Add http/3 support
1 parent 1e04cdf commit 988ea61

6 files changed

Lines changed: 193 additions & 221 deletions

File tree

.github/workflows/build-and-test-make.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616
contents: write
1717

1818
env:
19-
BORING_SSL_COMMIT: 23768dca563c4e62d48bb3675e49e34955dced12
19+
BORING_SSL_COMMIT: 673e61fc215b178a90c0e67858bbf162c8158993
2020

2121
jobs:
2222
build-and-test-linux:

.github/workflows/build-win.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
ZLIB_COMMIT: 09155eaa2f9270dc4ed1fa13e2b4b2613e6e4851
1919
ZSTD_COMMIT: 794ea1b0afca0f020f4e57b6732332231fb23c70
2020
BROTLI_COMMIT: ed738e842d2fbdf2d6459e39267a633c4a9b2f5d
21-
BORINGSSL_COMMIT: 23768dca563c4e62d48bb3675e49e34955dced12
21+
BORINGSSL_COMMIT: 673e61fc215b178a90c0e67858bbf162c8158993
2222
CURL_COMMIT: de7b3e89218467159a7af72d58cea8425946e97d
2323
NGHTTP2_COMMIT: 8f44147c385fb1ed93a6f39911eeb30279bfd2dd
2424

Makefile.in

Lines changed: 86 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ SHELL := bash
1010
SUBJOBS := 4
1111

1212
BROTLI_VERSION := 1.1.0
13-
# In case this is changed, update build-and-test-make.yml as well
14-
BORING_SSL_COMMIT := 23768dca563c4e62d48bb3675e49e34955dced12
15-
NGHTTP2_VERSION := nghttp2-1.63.0
16-
NGHTTP2_URL := https://github.com/nghttp2/nghttp2/releases/download/v1.63.0/nghttp2-1.63.0.tar.bz2
13+
# Chrome 135.0.7049.41
14+
# In case this is changed, update build-and-test-make.yml and build-win as well
15+
BORING_SSL_COMMIT := 673e61fc215b178a90c0e67858bbf162c8158993
16+
NGHTTP2_VERSION := 1.63.0
17+
NGHTTP2_URL := https://github.com/nghttp2/nghttp2/releases/download/v$(NGHTTP2_VERSION)/nghttp2-$(NGHTTP2_VERSION).tar.bz2
18+
NGTCP2_VERSION := 1.11.0
19+
NGTCP2_URL := https://github.com/ngtcp2/ngtcp2/releases/download/v$(NGTCP2_VERSION)/ngtcp2-$(NGTCP2_VERSION).tar.bz2
20+
NGHTTP3_VERSION := 1.9.0
21+
NGHTTP3_URL := https://github.com/ngtcp2/nghttp3/releases/download/v$(NGHTTP3_VERSION)/nghttp3-$(NGHTTP3_VERSION).tar.bz2
1722
CURL_VERSION := curl-8_13_0
1823

1924
# https://github.com/google/brotli/commit/641bec0e30bea648b3da1cd90fc6b44deb429f71
@@ -22,11 +27,15 @@ brotli_static_libs := $(brotli_install_dir)/lib/libbrotlicommon.a $(brotli_insta
2227
boringssl_dir := $(abspath boringssl-$(BORING_SSL_COMMIT))
2328
boringssl_install_dir := $(boringssl_dir)/build
2429
boringssl_static_libs := $(boringssl_dir)/lib/libssl.a $(boringssl_dir)/lib/libcrypto.a
25-
nghttp2_install_dir := $(abspath $(NGHTTP2_VERSION)/installed)
30+
nghttp2_install_dir := $(abspath nghttp2-$(NGHTTP2_VERSION)/installed)
2631
nghttp2_static_libs := $(nghttp2_install_dir)/lib/libnghttp2.a
32+
ngtcp2_install_dir := $(abspath ngtcp2-$(NGTCP2_VERSION)/installed)
33+
ngtcp2_static_libs := $(ngtcp2_install_dir)/lib/libngtcp2.a
34+
nghttp3_install_dir := $(abspath nghttp3-$(NGHTTP3_VERSION)/installed)
35+
nghttp3_static_libs := $(nghttp3_install_dir)/lib/libnghttp3.a
2736

2837
# Dependencies needed to compile the Chrome version
29-
chrome_libs := $(brotli_static_libs) $(boringssl_static_libs) $(nghttp2_static_libs)
38+
chrome_libs := $(brotli_static_libs) $(boringssl_static_libs) $(nghttp2_static_libs) $(ngtcp2_static_libs) $(nghttp3_static_libs)
3039

3140
# The following variables will be set by the configure script.
3241
prefix = @prefix@
@@ -59,7 +68,7 @@ help: ## Show this help message
5968
.PHONY: help
6069
.DEFAULT_GOAL := help
6170

62-
build: $(CURL_VERSION)/.chrome ## Build the Chrome version of curl-impersonate
71+
build: $(CURL_VERSION)/.chrome
6372
cd $(CURL_VERSION)
6473
# Don't pass this Makefile's MAKEFLAGS
6574
$(MAKE) MAKEFLAGS=-j$(SUBJOBS)
@@ -79,7 +88,7 @@ else
7988
endif
8089
.PHONY: checkbuild
8190

82-
install: ## Install the Chrome version of curl-impersonate after build
91+
install:
8392
cd $(CURL_VERSION)
8493
$(MAKE) install-exec MAKEFLAGS=
8594
# Wrapper scripts for the cli shortcut (e.g. 'curl_chrome99')
@@ -106,7 +115,9 @@ clean:
106115
## Remove all build artifacts, including dependencies
107116
rm -Rf brotli-$(BROTLI_VERSION).tar.gz brotli-$(BROTLI_VERSION)
108117
rm -Rf boringssl-$(BORING_SSL_COMMIT).zip boringssl-$(BORING_SSL_COMMIT)
109-
rm -Rf $(NGHTTP2_VERSION).tar.bz2 $(NGHTTP2_VERSION)
118+
rm -Rf nghttp2-$(NGHTTP2_VERSION).tar.bz2 nghttp2-$(NGHTTP2_VERSION)
119+
rm -Rf ngtcp2-$(NGTCP2_VERSION).tar.bz2 ngtcp2-$(NGTCP2_VERSION)
120+
rm -Rf nghttp3-$(NGHTTP3_VERSION).tar.bz2 nghttp3-$(NGHTTP3_VERSION)
110121
rm -Rf $(CURL_VERSION).tar.gz $(CURL_VERSION)
111122
.PHONY: clean
112123

@@ -200,12 +211,12 @@ $(boringssl_static_libs): boringssl-$(BORING_SSL_COMMIT).zip boringssl-$(BORING_
200211
cp crypto/libcrypto.a $(boringssl_dir)/lib
201212

202213

203-
$(NGHTTP2_VERSION).tar.bz2:
204-
curl -L $(NGHTTP2_URL) -o $(NGHTTP2_VERSION).tar.bz2
214+
nghttp2-$(NGHTTP2_VERSION).tar.bz2:
215+
curl -L $(NGHTTP2_URL) -o nghttp2-$(NGHTTP2_VERSION).tar.bz2
205216

206-
$(nghttp2_static_libs): $(NGHTTP2_VERSION).tar.bz2
207-
tar -xf $(NGHTTP2_VERSION).tar.bz2
208-
cd $(NGHTTP2_VERSION)
217+
$(nghttp2_static_libs): nghttp2-$(NGHTTP2_VERSION).tar.bz2
218+
tar -xf nghttp2-$(NGHTTP2_VERSION).tar.bz2
219+
cd nghttp2-$(NGHTTP2_VERSION)
209220

210221
# Set up the configure flags to nghttp2.
211222
# If the user provided the --host flag to our configure script
@@ -223,6 +234,58 @@ $(nghttp2_static_libs): $(NGHTTP2_VERSION).tar.bz2
223234
$(MAKE) MAKEFLAGS=-j$(SUBJOBS)
224235
$(MAKE) install MAKEFLAGS=
225236

237+
ngtcp2-$(NGTCP2_VERSION).tar.bz2:
238+
curl -L $(NGTCP2_URL) -o ngtcp2-$(NGTCP2_VERSION).tar.bz2
239+
240+
$(ngtcp2_static_libs): ngtcp2-$(NGTCP2_VERSION).tar.bz2 $(boringssl_static_libs)
241+
tar -xf ngtcp2-$(NGTCP2_VERSION).tar.bz2
242+
cd ngtcp2-$(NGTCP2_VERSION)
243+
autoreconf -i
244+
245+
# Set up the configure flags to ngtcp2.
246+
# If the user provided the --host flag to our configure script
247+
# (for cross compilation), then pass it on to ngtcp2.
248+
# PKG_CONFIG_PATH=<somewhere1>/lib/pkgconfig:<somewhere2>/lib/pkgconfig LDFLAGS="-Wl,-rpath,<somewhere1>/lib"
249+
{ \
250+
config_flags="--prefix=$(ngtcp2_install_dir)"; \
251+
config_flags="$$config_flags --with-pic --enable-lib-only"; \
252+
config_flags="$$config_flags --disable-shared --disable-python-bindings"; \
253+
if test -n "$(host_alias)"; then \
254+
config_flags="$$config_flags --host=$(host_alias)"; \
255+
fi; \
256+
}
257+
258+
./configure PKG_CONFIG_PATH=$(nghttp3_install_dir)/lib/pkgconfig \
259+
BORINGSSL_LIBS="-L$(boringssl_install_dir)/ssl -lssl -L$(boringssl_install_dir)/crypto -lcrypto" \
260+
BORINGSSL_CFLAGS="-I$(boringssl_dir)/include" \
261+
--with-boringssl \
262+
$$config_flags
263+
$(MAKE) MAKEFLAGS=-j$(SUBJOBS)
264+
$(MAKE) install MAKEFLAGS=
265+
266+
nghttp3-$(NGHTTP3_VERSION).tar.bz2:
267+
curl -L $(NGHTTP3_URL) -o nghttp3-$(NGHTTP3_VERSION).tar.bz2
268+
269+
$(nghttp3_static_libs): nghttp3-$(NGHTTP3_VERSION).tar.bz2
270+
tar -xf nghttp3-$(NGHTTP3_VERSION).tar.bz2
271+
cd nghttp3-$(NGHTTP3_VERSION)
272+
273+
# Set up the configure flags to nghttp2.
274+
# If the user provided the --host flag to our configure script
275+
# (for cross compilation), then pass it on to nghttp2.
276+
{ \
277+
config_flags="--prefix=$(nghttp3_install_dir)"; \
278+
config_flags="$$config_flags --with-pic --enable-lib-only"; \
279+
config_flags="$$config_flags --disable-shared --disable-python-bindings"; \
280+
if test -n "$(host_alias)"; then \
281+
config_flags="$$config_flags --host=$(host_alias)"; \
282+
fi; \
283+
}
284+
285+
./configure $$config_flags
286+
$(MAKE) MAKEFLAGS=-j$(SUBJOBS)
287+
$(MAKE) install MAKEFLAGS=
288+
226289
$(CURL_VERSION).tar.gz:
227290
curl -L "https://github.com/curl/curl/archive/$(CURL_VERSION).tar.gz" \
228291
-o "$(CURL_VERSION).tar.gz"
@@ -250,16 +313,18 @@ $(CURL_VERSION)/.chrome: $(chrome_libs) $(CURL_VERSION).tar.gz $(CURL_VERSION)/.
250313
# https://daniel.haxx.se/blog/2024/01/10/psl-in-curl/
251314
{ \
252315
config_flags="--prefix=@prefix@"; \
253-
config_flags="$$config_flags --with-nghttp2=$(nghttp2_install_dir)"; \
254316
config_flags="$$config_flags --with-brotli=$(brotli_install_dir)"; \
317+
config_flags="$$config_flags --with-nghttp2=$(nghttp2_install_dir)"; \
318+
config_flags="$$config_flags --with-ngtcp2=$(ngtcp2_install_dir)"; \
319+
config_flags="$$config_flags --with-nghttp3=$(nghttp3_install_dir)"; \
255320
config_flags="$$config_flags --with-openssl=$(boringssl_dir)"; \
256321
config_flags="$$config_flags --without-libpsl"; \
257322
config_flags="$$config_flags --enable-websockets"; \
258323
config_flags="$$config_flags --enable-ech"; \
259324
config_flags="$$config_flags --enable-ipv6"; \
260325
config_flags="$$config_flags USE_CURL_SSLKEYLOGFILE=true"; \
261326
if test "$(static_build)" = "yes"; then \
262-
config_flags="$$config_flags --enable-static --disable-shared";
327+
config_flags="$$config_flags --enable-static --disable-shared"; \
263328
fi; \
264329
if test -n "$(host_alias)"; then \
265330
config_flags="$$config_flags --host=$(host_alias)"; \
@@ -285,7 +350,11 @@ $(CURL_VERSION)/.chrome: $(chrome_libs) $(CURL_VERSION).tar.gz $(CURL_VERSION)/.
285350

286351
echo "Configuring curl with: $$config_flags"
287352

288-
CXXFLAGS="-stdlib=libc++" LDFLAGS="-lc++" ./configure $$config_flags LIBS="$$add_libs"
353+
CXXFLAGS="-stdlib=libc++" LDFLAGS="-lc++ -Wl,-rpath,$(ngtcp2_install_dir)/lib" \
354+
./configure \
355+
$$config_flags \
356+
LIBS="$$add_libs" \
357+
PKG_CONFIG_PATH="$(ngtcp2_install_dir)/crypto/boringssl/"
289358

290359
# Remove possible leftovers from a previous compilation
291360
$(MAKE) clean MAKEFLAGS=

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([curl-impersonate], [0.9.0], [infinitesheldon@gmail.com])
1+
AC_INIT([curl-impersonate], [1.0.0], [infinitesheldon@gmail.com])
22

33
AC_CANONICAL_BUILD
44
AC_CANONICAL_HOST

0 commit comments

Comments
 (0)