Skip to content

Commit d310a37

Browse files
authored
Merge pull request #141 from baranyaib90/fixes-11
Fixes 11
2 parents a63fea9 + b57e163 commit d310a37

File tree

5 files changed

+95
-3
lines changed

5 files changed

+95
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ rules.ninja
1616
log.html
1717
output.xml
1818
report.html
19+
custom_curl/

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,17 @@ endif()
5757
# LIBRARY DEPENDENCIES
5858

5959
find_path(LIBCARES_INCLUDE_DIR ares.h)
60-
find_path(LIBCURL_INCLUDE_DIR curl/curl.h)
6160
find_path(LIBEV_INCLUDE_DIR ev.h)
61+
62+
if(CUSTOM_LIBCURL_INSTALL_PATH)
63+
message(STATUS "Using custom libcurl from: ${CUSTOM_LIBCURL_INSTALL_PATH}")
64+
set(LIBCURL_INCLUDE_DIR "${CUSTOM_LIBCURL_INSTALL_PATH}/include")
65+
link_directories(BEFORE "${CUSTOM_LIBCURL_INSTALL_PATH}/lib")
66+
else()
67+
message(STATUS "Using system libcurl")
68+
find_path(LIBCURL_INCLUDE_DIR curl/curl.h)
69+
endif()
70+
6271
include_directories(
6372
${LIBCARES_INCLUDE_DIR} ${LIBCURL_INCLUDE_DIR}
6473
${LIBEV_INCLUDE_DIR} src)
@@ -86,6 +95,7 @@ set(SRC_LIST ${SRC_LIST})
8695
add_executable(${TARGET_NAME} ${SRC_LIST})
8796
set(LIBS ${LIBS} cares curl ev resolv)
8897
target_link_libraries(${TARGET_NAME} ${LIBS})
98+
set_property(TARGET ${TARGET_NAME} PROPERTY C_STANDARD 11)
8999

90100
define_file_basename_for_sources("https_dns_proxy")
91101

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ $ cmake .
6666
$ make
6767
```
6868

69+
### Build with HTTP/3 support
70+
71+
* If system libcurl supports it by default nothing else has to be done
72+
73+
* If a custom build of libcurl supports HTTP/3 which is installed in a different location, that can be set when running cmake:
74+
```
75+
$ cmake -D CUSTOM_LIBCURL_INSTALL_PATH=/absolute/path/to/custom/libcurl/install .
76+
```
77+
78+
* Just to test HTTP/3 support for development purpose, simply run the following command and wait for a long time:
79+
```
80+
$ ./development_build_with_http3.sh
81+
```
82+
6983
## INSTALL
7084

7185
### Install built program

development_build_with_http3.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
echo
6+
echo "WARNING !!!"
7+
echo
8+
echo "Use only for development and testing!"
9+
echo "It is highly highly not recommended, to use in production!"
10+
echo "This script was based on: https://github.com/curl/curl/blob/curl-7_82_0/docs/HTTP3.md"
11+
echo
12+
13+
sleep 5
14+
15+
INSTALL_DIR=$PWD/custom_curl/install
16+
mkdir -p $INSTALL_DIR
17+
cd custom_curl
18+
19+
###
20+
21+
git clone --depth 1 -b openssl-3.0.0+quic https://github.com/quictls/openssl
22+
cd openssl
23+
./config enable-tls1_3 --prefix=$INSTALL_DIR
24+
make -j build_libs
25+
make install_dev
26+
cd ..
27+
28+
git clone --depth 1 -b v0.3.0 https://github.com/ngtcp2/nghttp3
29+
cd nghttp3
30+
autoreconf -fi
31+
./configure --prefix=$INSTALL_DIR --enable-lib-only
32+
make -j
33+
make install
34+
cd ..
35+
36+
git clone --depth 1 -b v0.3.1 https://github.com/ngtcp2/ngtcp2
37+
cd ngtcp2
38+
autoreconf -fi
39+
./configure PKG_CONFIG_PATH=$INSTALL_DIR/lib64/pkgconfig:$INSTALL_DIR/lib64/pkgconfig LDFLAGS="-Wl,-rpath,$INSTALL_DIR/lib64" --prefix=$INSTALL_DIR --enable-lib-only --with-openssl
40+
make -j
41+
make install
42+
cd ..
43+
44+
git clone --depth 1 -b v1.47.0 https://github.com/nghttp2/nghttp2
45+
cd nghttp2
46+
autoreconf -fi
47+
./configure PKG_CONFIG_PATH=$INSTALL_DIR/lib64/pkgconfig:$INSTALL_DIR/lib64/pkgconfig LDFLAGS="-Wl,-rpath,$INSTALL_DIR/lib64" --prefix=$INSTALL_DIR --enable-lib-only --with-openssl
48+
make -j
49+
make install
50+
cd ..
51+
52+
git clone --depth 1 -b curl-7_82_0 https://github.com/curl/curl
53+
cd curl
54+
autoreconf -fi
55+
LDFLAGS="-Wl,-rpath,$INSTALL_DIR/lib64" ./configure --with-openssl=$INSTALL_DIR --with-nghttp2=$INSTALL_DIR --with-nghttp3=$INSTALL_DIR --with-ngtcp2=$INSTALL_DIR --prefix=$INSTALL_DIR
56+
make -j
57+
make install
58+
cd ..
59+
60+
###
61+
62+
cd ..
63+
cmake -D CUSTOM_LIBCURL_INSTALL_PATH=$INSTALL_DIR .
64+
make -j

src/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,14 @@ int main(int argc, char *argv[]) {
263263
dns_server_init(&dns_server, loop, opt.listen_addr, opt.listen_port,
264264
dns_server_cb, &app);
265265

266+
if (opt.gid != (uid_t)-1 && setgroups(1, &opt.gid)) {
267+
FLOG("Failed to set groups");
268+
}
266269
if (opt.gid != (uid_t)-1 && setgid(opt.gid)) {
267-
FLOG("Failed to set gid.");
270+
FLOG("Failed to set gid");
268271
}
269272
if (opt.uid != (uid_t)-1 && setuid(opt.uid)) {
270-
FLOG("Failed to set uid.");
273+
FLOG("Failed to set uid");
271274
}
272275

273276
if (opt.daemonize) {

0 commit comments

Comments
 (0)