Skip to content

Commit 85c1bc1

Browse files
authored
add ALPS extension with support for new_codepoint (#834)
1 parent 93ae0d4 commit 85c1bc1

File tree

10 files changed

+272
-99
lines changed

10 files changed

+272
-99
lines changed

.github/workflows/CI.yml

Lines changed: 20 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ jobs:
4141
with:
4242
env-vars: "RUST_TOOLCHAIN=${{ matrix.toolchain }}"
4343
key: ${{ matrix.os }}-${{ matrix.toolchain }}
44-
# https://github.com/rust-lang/cmake-rs/pull/259 breaks handling of long Windows paths
45-
# https://github.com/cloudflare/boring/issues/414
46-
# https://github.com/0x676e67/boring/commit/efacedb5bf409d0d773e8ce4f5080cb4b4c10f54
47-
- name: Pin some dependencies, temporary patch for cmake breakage
48-
if: startsWith(matrix.os, 'windows')
49-
run: |
50-
cargo update --package cmake --precise 0.1.54
5144
- name: check
5245
run: |
5346
cargo check --workspace --all-targets --all-features
@@ -89,13 +82,6 @@ jobs:
8982
with:
9083
env-vars: "RUST_TOOLCHAIN=${{ matrix.toolchain }}"
9184
key: ${{ matrix.os }}-${{ matrix.toolchain }}
92-
# https://github.com/rust-lang/cmake-rs/pull/259 breaks handling of long Windows paths
93-
# https://github.com/cloudflare/boring/issues/414
94-
# https://github.com/0x676e67/boring/commit/efacedb5bf409d0d773e8ce4f5080cb4b4c10f54
95-
- name: Pin some dependencies, temporary patch for cmake breakage
96-
if: startsWith(matrix.os, 'windows')
97-
run: |
98-
cargo update --package cmake --precise 0.1.54
9985
- name: clippy
10086
run: |
10187
cargo clippy --workspace --all-targets --all-features
@@ -142,13 +128,6 @@ jobs:
142128
with:
143129
key: ${{ matrix.os }}-${{ matrix.toolchain }}-${{ matrix.target }}
144130
env-vars: "RUST_TOOLCHAIN=${{ matrix.toolchain }}"
145-
# https://github.com/rust-lang/cmake-rs/pull/259 breaks handling of long Windows paths
146-
# https://github.com/cloudflare/boring/issues/414
147-
# https://github.com/0x676e67/boring/commit/efacedb5bf409d0d773e8ce4f5080cb4b4c10f54
148-
- name: Pin some dependencies, temporary patch for cmake breakage
149-
if: startsWith(matrix.os, 'windows')
150-
run: |
151-
cargo update --package cmake --precise 0.1.54
152131
- name: Run tests (cargo test)
153132
run: cargo nextest run --all-features --workspace
154133
- name: Run doc tests (cargo test)
@@ -308,34 +287,39 @@ jobs:
308287
env-vars: "RUST_TOOLCHAIN=${{ matrix.rust }}"
309288
key: ${{ matrix.os }}-${{ matrix.rust }}-${{ matrix.target }}
310289
- run: rustup target add ${{ matrix.target }}
311-
- name: Setup Android NDK
312-
if: endsWith(matrix.thing, '-android')
313-
uses: nttld/setup-ndk@v1
314-
with:
315-
ndk-version: r26d
316290
- name: Configure Android toolchain env
317291
if: endsWith(matrix.thing, '-android')
318292
shell: bash
319293
run: |
320294
ANDROID_API=21
295+
296+
# Normalize NDK env vars
297+
echo "ANDROID_NDK_HOME=${ANDROID_NDK_HOME:-$ANDROID_NDK}" >> "$GITHUB_ENV"
298+
echo "ANDROID_NDK=${ANDROID_NDK:-$ANDROID_NDK_HOME}" >> "$GITHUB_ENV"
299+
321300
TOOLCHAIN="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin"
322301
echo "${TOOLCHAIN}" >> "$GITHUB_PATH"
323302
324303
TRIPLE="${{ matrix.target }}"
325-
326-
# What Cargo expects for the linker env var name
327304
TARGET_UPPER="$(echo "${TRIPLE}" | tr '[:lower:]-' '[:upper:]_')"
328-
329-
# What cc-rs expects for CC_*/CXX_* env var names
330305
TARGET_LOWER_UNDERSCORES="$(echo "${TRIPLE}" | tr '-' '_' | tr '[:upper:]' '[:lower:]')"
331-
332-
# What the NDK clang wrapper is called
333306
NDK_TRIPLE="$(echo "${TRIPLE}" | sed 's/^armv7/armv7a/')"
334307
335-
echo "CARGO_TARGET_${TARGET_UPPER}_LINKER=${TOOLCHAIN}/${NDK_TRIPLE}${ANDROID_API}-clang++" >> "$GITHUB_ENV"
336-
echo "CC_${TARGET_LOWER_UNDERSCORES}=${TOOLCHAIN}/${NDK_TRIPLE}${ANDROID_API}-clang" >> "$GITHUB_ENV"
337-
echo "CXX_${TARGET_LOWER_UNDERSCORES}=${TOOLCHAIN}/${NDK_TRIPLE}${ANDROID_API}-clang++" >> "$GITHUB_ENV"
338-
echo "AR_${TARGET_LOWER_UNDERSCORES}=${TOOLCHAIN}/llvm-ar" >> "$GITHUB_ENV"
308+
CC_PATH="${TOOLCHAIN}/${NDK_TRIPLE}${ANDROID_API}-clang"
309+
CXX_PATH="${TOOLCHAIN}/${NDK_TRIPLE}${ANDROID_API}-clang++"
310+
AR_PATH="${TOOLCHAIN}/llvm-ar"
311+
312+
echo "CARGO_TARGET_${TARGET_UPPER}_LINKER=${CXX_PATH}" >> "$GITHUB_ENV"
313+
314+
# Target specific for cc-rs style
315+
echo "CC_${TARGET_LOWER_UNDERSCORES}=${CC_PATH}" >> "$GITHUB_ENV"
316+
echo "CXX_${TARGET_LOWER_UNDERSCORES}=${CXX_PATH}" >> "$GITHUB_ENV"
317+
echo "AR_${TARGET_LOWER_UNDERSCORES}=${AR_PATH}" >> "$GITHUB_ENV"
318+
319+
# Also set generic vars in case your Config only reads CC/CXX/AR
320+
echo "CC=${CC_PATH}" >> "$GITHUB_ENV"
321+
echo "CXX=${CXX_PATH}" >> "$GITHUB_ENV"
322+
echo "AR=${AR_PATH}" >> "$GITHUB_ENV"
339323
- name: check
340324
env: ${{ matrix.custom_env }}
341325
run: |
@@ -415,13 +399,6 @@ jobs:
415399
with:
416400
key: ${{ matrix.os }}-${{ matrix.toolchain }}
417401
env-vars: "RUST_TOOLCHAIN=${{ matrix.toolchain }}"
418-
# https://github.com/rust-lang/cmake-rs/pull/259 breaks handling of long Windows paths
419-
# https://github.com/cloudflare/boring/issues/414
420-
# https://github.com/0x676e67/boring/commit/efacedb5bf409d0d773e8ce4f5080cb4b4c10f54
421-
- name: Pin some dependencies, temporary patch for cmake breakage
422-
if: startsWith(matrix.os, 'windows')
423-
run: |
424-
cargo update --package cmake --precise 0.1.54
425402
- name: Run tests (--ignored)
426403
run: |
427404
cargo nextest run --all-features --workspace --run-ignored=only
@@ -454,13 +431,6 @@ jobs:
454431
with:
455432
key: ${{ matrix.os }}-${{ matrix.toolchain }}
456433
env-vars: "RUST_TOOLCHAIN=${{ matrix.toolchain }}"
457-
# https://github.com/rust-lang/cmake-rs/pull/259 breaks handling of long Windows paths
458-
# https://github.com/cloudflare/boring/issues/414
459-
# https://github.com/0x676e67/boring/commit/efacedb5bf409d0d773e8ce4f5080cb4b4c10f54
460-
- name: Pin some dependencies, temporary patch for cmake breakage
461-
if: startsWith(matrix.os, 'windows')
462-
run: |
463-
cargo update --package cmake --precise 0.1.54
464434
- name: Run tests in release mode (--ignored)
465435
run: |
466436
cargo nextest run --all-features --release --workspace --run-ignored=only

Cargo.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ quickcheck_macros = "1.1"
173173
quote = "1.0"
174174
radix_trie = "0.3"
175175
rama = { version = "0.3.0-rc1", path = "." }
176-
rama-boring = "0.5.10"
177-
rama-boring-tokio = "0.5.10"
176+
rama-boring = "0.5.12"
177+
rama-boring-tokio = "0.5.12"
178178
rama-core = { version = "0.3.0-rc1", path = "./rama-core" }
179179
rama-crypto = { version = "0.3.0-rc1", path = "./rama-crypto" }
180180
rama-dns = { version = "0.3.0-rc1", path = "./rama-dns" }

docs/thirdparty/fork/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@ as a distant relative.
5959
These are forks made within other code repositories,
6060
but still directly in function of Rama.
6161

62-
- <https://github.com/cloudflare/boring/tree/47c33f64284a905bd1c26dc59c5eec6f5f38bf8b>
62+
- <https://github.com/cloudflare/boring/tree/e71b24328f1cd787f64036d8208a4470ae58e200>
6363
- boring:
6464
- Fork: <https://github.com/plabayo/rama-boring/tree/7b3fb171483c6250dc607520cd7cc71c85843ee1/boring>
6565
- License:
66-
- Original: <https://github.com/cloudflare/boring/blob/47c33f64284a905bd1c26dc59c5eec6f5f38bf8b/boring/LICENSE>
66+
- Original: <https://github.com/cloudflare/boring/blob/e71b24328f1cd787f64036d8208a4470ae58e200/boring/LICENSE>
6767
- Type: Apache 2.0
6868
- Copy: [./licenses/boring](./licenses/boring)
6969
- boring-sys:
7070
- Fork: <https://github.com/plabayo/rama-boring/tree/7b3fb171483c6250dc607520cd7cc71c85843ee1/boring-sys>
7171
- License:
72-
- Original: <https://github.com/cloudflare/boring/blob/47c33f64284a905bd1c26dc59c5eec6f5f38bf8b/boring-sys/LICENSE-MIT>
72+
- Original: <https://github.com/cloudflare/boring/blob/e71b24328f1cd787f64036d8208a4470ae58e200/boring-sys/LICENSE-MIT>
7373
- Type: MIT
7474
- Copy: [./licenses/boring-sys](./licenses/boring-sys)
7575
- tokio-boring:
7676
- Fork: <https://github.com/plabayo/rama-boring/tree/7b3fb171483c6250dc607520cd7cc71c85843ee1/tokio-boring>
7777
- License:
78-
- Original: <https://github.com/cloudflare/boring/blob/47c33f64284a905bd1c26dc59c5eec6f5f38bf8b/tokio-boring/LICENSE-MIT>
78+
- Original: <https://github.com/cloudflare/boring/blob/e71b24328f1cd787f64036d8208a4470ae58e200/tokio-boring/LICENSE-MIT>
7979
- Type: MIT
8080
- Copy: [./licenses/tokio-boring](./licenses/tokio-boring)
8181

rama-cli/src/cmd/serve/fp/data.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,14 @@ pub(super) async fn get_tls_display_info_and_store(
503503
)),
504504
}
505505
}
506-
ClientHelloExtension::ApplicationSettings(v) => TlsDisplayInfoExtension {
507-
id: extension.id().to_string(),
508-
data: Some(TlsDisplayInfoExtensionData::Multi(
509-
v.iter().map(|s| s.to_string()).collect(),
510-
)),
511-
},
506+
ClientHelloExtension::ApplicationSettings { protocols, .. } => {
507+
TlsDisplayInfoExtension {
508+
id: extension.id().to_string(),
509+
data: Some(TlsDisplayInfoExtensionData::Multi(
510+
protocols.iter().map(|s| s.to_string()).collect(),
511+
)),
512+
}
513+
}
512514
ClientHelloExtension::SupportedGroups(v) => TlsDisplayInfoExtension {
513515
id: extension.id().to_string(),
514516
data: Some(TlsDisplayInfoExtensionData::Multi(

rama-net/src/tls/client/hello.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ impl ClientHello {
143143
#[must_use]
144144
pub fn ext_alps(&self) -> Option<&[ApplicationProtocol]> {
145145
for ext in &self.extensions {
146-
if let ClientHelloExtension::ApplicationSettings(alpns) = ext {
147-
return Some(&alpns[..]);
146+
if let ClientHelloExtension::ApplicationSettings { protocols, .. } = ext {
147+
return Some(&protocols[..]);
148148
}
149149
}
150150
None
@@ -239,7 +239,12 @@ pub enum ClientHelloExtension {
239239
/// # Reference
240240
///
241241
/// - <https://www.ietf.org/archive/id/draft-vvv-tls-alps-01.html>
242-
ApplicationSettings(Vec<ApplicationProtocol>),
242+
ApplicationSettings {
243+
/// application protocols supported for settings negotiation
244+
protocols: Vec<ApplicationProtocol>,
245+
/// whether to use the new ALPS extension codepoint (0x44cd) or the old one (0x4469)
246+
new_codepoint: bool,
247+
},
243248
/// used by the client to indicate which versions of TLS it supports
244249
///
245250
/// # Reference
@@ -291,7 +296,13 @@ impl ClientHelloExtension {
291296
Self::ApplicationLayerProtocolNegotiation(_) => {
292297
ExtensionId::APPLICATION_LAYER_PROTOCOL_NEGOTIATION
293298
}
294-
Self::ApplicationSettings(_) => ExtensionId::APPLICATION_SETTINGS,
299+
Self::ApplicationSettings { new_codepoint, .. } => {
300+
if *new_codepoint {
301+
ExtensionId::APPLICATION_SETTINGS
302+
} else {
303+
ExtensionId::OLD_APPLICATION_SETTINGS
304+
}
305+
}
295306
Self::SupportedVersions(_) => ExtensionId::SUPPORTED_VERSIONS,
296307
Self::CertificateCompression(_) => ExtensionId::COMPRESS_CERTIFICATE,
297308
Self::DelegatedCredentials(_) => ExtensionId::DELEGATED_CREDENTIAL,

0 commit comments

Comments
 (0)