Skip to content

Commit 933d4dc

Browse files
authored
Factor out curl (#4)
1 parent 00cc088 commit 933d4dc

3 files changed

Lines changed: 74 additions & 64 deletions

File tree

curl/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ECH-enabled `curl`
2+
3+
This is a custom build of `curl` with ECH support from the [DEfO project](https://github.com/defo-project). It is useful for manually testing ECH functionality against specific web servers.
4+
5+
## Prerequisites (for building on macOS)
6+
7+
* Homebrew
8+
* `automake`
9+
* `libtool`
10+
* `pkg-config`
11+
* `libpsl`
12+
13+
## Building
14+
15+
A helper script, `build-curl.sh`, is provided to automate the build process for `curl` and its dependency, `openssl`.
16+
17+
To build the ECH-enabled `curl`, run the script from the `greasereport` directory and provide an output path:
18+
19+
```sh
20+
./curl/build-curl.sh <output_directory>
21+
```
22+
23+
For example, to build `curl` and place the output in the `workspace` directory:
24+
25+
```sh
26+
./curl/build-curl.sh ./workspace
27+
```
28+
29+
The script will download the source code for `openssl` and `curl`, build them, and install the final binaries in the specified output directory.
30+
31+
For more details on how to use `curl` with ECH, see the [official documentation](https://github.com/defo-project/curl/blob/master/docs/ECH.md).
32+
33+
## Verifying the build
34+
35+
To test that your custom `curl` build is working correctly, run it against the DEfO test server:
36+
37+
```sh
38+
./workspace/output/bin/curl" --ech=true --doh-url https://1.1.1.1/dns-query 'https://test.defo.ie/echstat.php?format=json' | jq
39+
```
40+
41+
Example output:
42+
```json
43+
{
44+
"SSL_ECH_OUTER_SNI": "public.test.defo.ie",
45+
"SSL_ECH_INNER_SNI": "test.defo.ie",
46+
"SSL_ECH_STATUS": "success",
47+
"date": "2025-11-06T19:36:47+00:00",
48+
"config": "min-ng.test.defo.ie"
49+
}
50+
```
51+
52+
You may need to specify the `LD_LIBRARY_PATH` on Linux:
53+
54+
```sh
55+
LD_LIBRARY_PATH="$(pwd)/workspace/lib" ./workspace/bin/curl --version
56+
```
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,30 @@
1616

1717
set -e
1818

19-
if [ -z "$1" ]; then
19+
if [[ -z "$1" ]]; then
2020
echo "Usage: $0 <output_dir>"
2121
exit 1
2222
fi
2323

2424
OUTPUT_DIR=$(realpath "$1")
25-
WORKSPACE_DIR=$(mktemp -d)
25+
mkdir -p "${OUTPUT_DIR}/tmp"
26+
TEMP_DIR=$(mktemp -d -p "${OUTPUT_DIR}/tmp")
2627

27-
echo "Using workspace directory: ${WORKSPACE_DIR}"
28+
echo "Using workspace directory: ${TEMP_DIR}"
2829
echo "Using output directory: ${OUTPUT_DIR}"
2930

3031
echo "Cloning OpenSSL..."
31-
git clone --filter=blob:none https://github.com/defo-project/openssl "${WORKSPACE_DIR}/openssl"
32-
cd "${WORKSPACE_DIR}/openssl"
32+
git clone --filter=blob:none https://github.com/defo-project/openssl "${TEMP_DIR}/openssl"
33+
cd "${TEMP_DIR}/openssl"
3334

3435
echo "Configuring and building OpenSSL..."
3536
./config --libdir=lib --prefix="${OUTPUT_DIR}"
36-
make -j$(nproc)
37+
make "-j$(nproc)"
3738
make install_sw
3839

3940
echo "Cloning curl..."
40-
git clone --filter=blob:none https://github.com/defo-project/curl "${WORKSPACE_DIR}/curl"
41-
cd "${WORKSPACE_DIR}/curl"
41+
git clone --filter=blob:none https://github.com/defo-project/curl "${TEMP_DIR}/curl"
42+
cd "${TEMP_DIR}/curl"
4243

4344
echo "Configuring and building curl..."
4445
autoreconf -fi
@@ -47,6 +48,6 @@ make
4748
make install
4849

4950
echo "Cleaning up workspace..."
50-
rm -rf "${WORKSPACE_DIR}"
51+
rm -rf "${TEMP_DIR}"
5152

5253
echo "Done. curl with ECH support is installed in ${OUTPUT_DIR}/bin"

greasereport/README.md

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
## `greasereport`
1+
# ECH GREASE Report Generation
22

33
This tool, located in the `greasereport/` directory, issues HEAD requests to a list of domains with and without ECH GREASE to test for compatibility. It uses a custom-built ECH-enabled `curl` binary for these requests.
44

5+
## Requirements
6+
7+
You need to build the ECH-enabled `curl` and place it in the workspace directory. See [instructions](../curl/README.md).
8+
9+
## Running
10+
511
To run the tool, use the `go run` command from the `ech-test` directory:
612

713
```sh
@@ -41,60 +47,7 @@ The tool generates a CSV file (`workspace/grease-results-top<N>.csv`) with the f
4147
* `total_time_ms`: The total duration of the request.
4248
* `http_status`: The HTTP status code of the response.
4349

44-
---
45-
46-
## ECH-enabled `curl`
47-
48-
This is a custom build of `curl` with ECH support from the [DEfO project](https://github.com/defo-project). It is useful for manually testing ECH functionality against specific web servers.
49-
50-
### Prerequisites (for building on macOS)
51-
52-
* Homebrew
53-
* `automake`
54-
* `libtool`
55-
* `pkg-config`
56-
* `libpsl`
57-
58-
### Building
59-
60-
A helper script, `build-curl.sh`, is provided to automate the build process for `curl` and its dependency, `openssl`.
61-
62-
To build the ECH-enabled `curl`, run the script from the `greasereport` directory and provide an output path:
63-
64-
```sh
65-
./build-curl.sh <output_directory>
66-
```
67-
68-
For example, to build `curl` and place the output in the `workspace` directory:
69-
70-
```sh
71-
./build-curl.sh ../workspace
72-
```
73-
74-
The script will download the source code for `openssl` and `curl`, build them, and install the final binaries in the specified output directory.
75-
76-
For more details on how to use `curl` with ECH, see the [official documentation](https://github.com/defo-project/curl/blob/master/docs/ECH.md).
77-
78-
### Verifying the build
79-
80-
To test that your custom `curl` build is working correctly, run it against the DEfO test server:
81-
82-
```sh
83-
"$(pwd)/workspace/output/bin/curl" --ech=true --doh-url https://1.1.1.1/dns-query 'https://test.defo.ie/echstat.php?format=json' | jq
84-
```
85-
86-
Example output:
87-
```json
88-
{
89-
"SSL_ECH_OUTER_SNI": "public.test.defo.ie",
90-
"SSL_ECH_INNER_SNI": "test.defo.ie",
91-
"SSL_ECH_STATUS": "success",
92-
"date": "2025-11-06T19:36:47+00:00",
93-
"config": "min-ng.test.defo.ie"
94-
}
95-
```
96-
97-
### Report
50+
## Report
9851

9952
After running the `greasereport` tool, a `report` subdirectory is created within the `greasereport` directory. This directory contains:
10053

0 commit comments

Comments
 (0)