Skip to content

Commit 4dcec0f

Browse files
authored
Merge pull request #351 from Tencent/release/v1.0.0
Release/v1.0.0
2 parents 1a68d04 + 6d782ae commit 4dcec0f

22 files changed

+502
-97
lines changed

.github/workflows/rust.yml

+23
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@ jobs:
5353
. "$HOME/.cargo/env"
5454
cargo build --all -F ffi --verbose && cargo test
5555
56+
build_windows:
57+
name: Build for Windows
58+
runs-on: windows-2022
59+
env:
60+
TARGET: "x86_64-pc-windows-msvc"
61+
steps:
62+
- uses: actions/checkout@v4
63+
with:
64+
submodules: 'recursive'
65+
- name: Install rust toolchain
66+
uses: dtolnay/rust-toolchain@master
67+
with:
68+
toolchain: stable
69+
targets: ${{ env.TARGET }}
70+
- name: Install dependencies
71+
uses: crazy-max/ghaction-chocolatey@v3
72+
with:
73+
args: install nasm
74+
- name: Build TQUIC library and tools
75+
run: cargo build --all -F ffi --verbose && cargo test
76+
5677
build_ios:
5778
name: Build for iOS
5879
runs-on: macos-latest
@@ -119,6 +140,8 @@ jobs:
119140
typos -c ./typos.toml
120141
- name: Code lint check
121142
run: cargo clippy --all -- -D warnings
143+
- name: Code lint check (FFI)
144+
run: cargo clippy --all -F ffi -- -D warnings
122145

123146
unit_testing:
124147
name: Unit testing

.github/workflows/tquic-benchmark.yml

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
benchmark_impls: ${{ steps.set-implements.outputs.benchmark_impls }}
1818
benchmark_rounds: ${{ steps.set-rounds.outputs.benchmark_rounds }}
1919
benchmark_duration: ${{ steps.set-duration.outputs.benchmark_duration }}
20+
if: ${{ ( github.event_name == 'schedule' && github.repository == 'tencent/tquic' ) || github.event_name == 'workflow_dispatch' }}
2021
steps:
2122
- name: Set date
2223
id: set-benchmark-date
@@ -43,6 +44,7 @@ jobs:
4344
build_tquic:
4445
name: Build tquic
4546
runs-on: ubuntu-latest
47+
needs: config
4648
steps:
4749
- uses: actions/checkout@v4
4850
with:
@@ -74,6 +76,7 @@ jobs:
7476
build_lsquic:
7577
name: Build lsquic
7678
runs-on: ubuntu-latest
79+
needs: config
7780
steps:
7881
- uses: actions/checkout@v4
7982
with:
@@ -107,6 +110,7 @@ jobs:
107110
gen_cert:
108111
name: Generate cert
109112
runs-on: ubuntu-latest
113+
needs: config
110114
steps:
111115
- name: Generate cert
112116
run: |
@@ -121,6 +125,7 @@ jobs:
121125
gen_files:
122126
name: Generate files
123127
runs-on: ubuntu-latest
128+
needs: config
124129
steps:
125130
- name: Generate files
126131
run: |

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1212

1313

14+
## [v1.0.0] - 2024-08-01
15+
16+
### Added
17+
- Support building on Windows
18+
- Optimize the initial RTT of the newly validated path
19+
- Add API for deferring idle timeout
20+
21+
### Changed
22+
- Rename PathStats to quic_path_stats_t in FFI
23+
- Change prototype of quic_set_logger in FFI
24+
25+
1426
## [v0.15.0] - 2024-07-18
1527

1628
### Added
@@ -276,6 +288,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
276288
- Provide example clients and servers.
277289

278290

291+
[v1.0.0]: https://github.com/tencent/tquic/compare/v0.15.0...v1.0.0
279292
[v0.15.0]: https://github.com/tencent/tquic/compare/v0.14.0...v0.15.0
280293
[v0.14.0]: https://github.com/tencent/tquic/compare/v0.13.0...v0.14.0
281294
[v0.13.0]: https://github.com/tencent/tquic/compare/v0.12.0...v0.13.0

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tquic"
3-
version = "0.15.0"
3+
version = "1.0.0"
44
edition = "2021"
55
rust-version = "1.70.0"
66
license = "Apache-2.0"
@@ -51,6 +51,9 @@ hex = "0.4"
5151
priority-queue = "1.3.2"
5252
sfv = { version = "0.9" }
5353

54+
[target."cfg(windows)".dependencies]
55+
winapi = { version = "0.3", features = ["wincrypt", "ws2def", "ws2ipdef", "ws2tcpip"] }
56+
5457
[dev-dependencies]
5558
env_logger = "0.10.0"
5659
mio = { version = "0.8", features = ["net", "os-poll"] }

cbindgen.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ cpp_compat = true
1515
documentation = true
1616

1717
# A list of headers to #include (with quotes)
18-
sys_includes = ["sys/socket.h", "sys/types.h"]
1918
includes = ["openssl/ssl.h", "tquic_def.h"]
2019

2120
[export]
@@ -31,6 +30,7 @@ exclude = ["MIN_CLIENT_INITIAL_LEN", "VINT_MAX"]
3130
"PacketOutSpec" = "quic_packet_out_spec_t"
3231
"PacketInfo" = "quic_packet_info_t"
3332
"PathAddress" = "quic_path_address_t"
33+
"PathStats" = "quic_path_stats_t"
3434
"FourTupleIter" = "quic_path_address_iter_t"
3535
"Shutdown" = "quic_shutdown"
3636
"TransportHandler" = "quic_transport_handler_t"

include/tquic.h

+34-17
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <stdbool.h>
88
#include <stdint.h>
99
#include <stdlib.h>
10-
#include <sys/socket.h>
11-
#include <sys/types.h>
1210
#include "openssl/ssl.h"
1311
#include "tquic_def.h"
1412

@@ -278,7 +276,7 @@ typedef struct quic_path_address_t {
278276
/**
279277
* Statistics about path
280278
*/
281-
typedef struct PathStats {
279+
typedef struct quic_path_stats_t {
282280
/**
283281
* The number of QUIC packets received.
284282
*/
@@ -303,14 +301,14 @@ typedef struct PathStats {
303301
* The number of lost bytes.
304302
*/
305303
uint64_t lost_bytes;
306-
/**
307-
* Total number of bytes acked.
308-
*/
309-
uint64_t acked_bytes;
310304
/**
311305
* Total number of packets acked.
312306
*/
313307
uint64_t acked_count;
308+
/**
309+
* Total number of bytes acked.
310+
*/
311+
uint64_t acked_bytes;
314312
/**
315313
* Initial congestion window in bytes.
316314
*/
@@ -367,7 +365,7 @@ typedef struct PathStats {
367365
* Pacing rate estimated by congestion control algorithm.
368366
*/
369367
uint64_t pacing_rate;
370-
} PathStats;
368+
} quic_path_stats_t;
371369

372370
/**
373371
* Statistics about a QUIC connection.
@@ -968,6 +966,21 @@ void quic_conn_session(struct quic_conn_t *conn, const uint8_t **out, size_t *ou
968966
*/
969967
int quic_conn_early_data_reason(struct quic_conn_t *conn, const uint8_t **out, size_t *out_len);
970968

969+
/**
970+
* Send a Ping frame on the active path(s) for keep-alive.
971+
*/
972+
int quic_conn_ping(struct quic_conn_t *conn);
973+
974+
/**
975+
* Send a Ping frame on the specified path for keep-alive.
976+
* The API is only applicable to multipath quic connections.
977+
*/
978+
int quic_conn_ping_path(struct quic_conn_t *conn,
979+
const struct sockaddr *local,
980+
socklen_t local_len,
981+
const struct sockaddr *remote,
982+
socklen_t remote_len);
983+
971984
/**
972985
* Add a new path on the client connection.
973986
*/
@@ -1020,11 +1033,11 @@ bool quic_conn_active_path(const struct quic_conn_t *conn, struct quic_path_addr
10201033
/**
10211034
* Return the latest statistics about the specified path.
10221035
*/
1023-
const struct PathStats *quic_conn_path_stats(struct quic_conn_t *conn,
1024-
const struct sockaddr *local,
1025-
socklen_t local_len,
1026-
const struct sockaddr *remote,
1027-
socklen_t remote_len);
1036+
const struct quic_path_stats_t *quic_conn_path_stats(struct quic_conn_t *conn,
1037+
const struct sockaddr *local,
1038+
socklen_t local_len,
1039+
const struct sockaddr *remote,
1040+
socklen_t remote_len);
10281041

10291042
/**
10301043
* Return statistics about the connection.
@@ -1105,6 +1118,7 @@ void quic_conn_set_keylog(struct quic_conn_t *conn, void (*cb)(const uint8_t *da
11051118

11061119
/**
11071120
* Set keylog file.
1121+
* Note: The API is not applicable for Windows.
11081122
*/
11091123
void quic_conn_set_keylog_fd(struct quic_conn_t *conn, int fd);
11101124

@@ -1122,6 +1136,7 @@ void quic_conn_set_qlog(struct quic_conn_t *conn,
11221136

11231137
/**
11241138
* Set qlog file.
1139+
* Note: The API is not applicable for Windows.
11251140
*/
11261141
void quic_conn_set_qlog_fd(struct quic_conn_t *conn, int fd, const char *title, const char *desc);
11271142

@@ -1403,13 +1418,15 @@ int http3_take_priority_update(struct http3_conn_t *conn,
14031418
/**
14041419
* Set logger.
14051420
* `cb` is a callback function that will be called for each log message.
1406-
* `data` is a '\n' terminated log message and `argp` is user-defined data that will be passed to
1407-
* the callback.
1408-
* `level` represents the log level.
1421+
* `data` is a '\n' terminated log message and `argp` is user-defined data that
1422+
* will be passed to the callback.
1423+
* `level` is a case-insensitive string used for specifying the log level. Valid
1424+
* values are "OFF", "ERROR", "WARN", "INFO", "DEBUG", and "TRACE". If its value
1425+
* is NULL or invalid, the default log level is "OFF".
14091426
*/
14101427
void quic_set_logger(void (*cb)(const uint8_t *data, size_t data_len, void *argp),
14111428
void *argp,
1412-
quic_log_level level);
1429+
const char *level);
14131430

14141431
#ifdef __cplusplus
14151432
} // extern "C"

include/tquic_def.h

+12-30
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,18 @@
11
#ifndef _TQUIC_DEF_H_
22
#define _TQUIC_DEF_H_
33

4-
/**
5-
* An enum representing the available verbosity level filters of the logger.
6-
*/
7-
typedef enum quic_log_level {
8-
/**
9-
* A level lower than all log levels.
10-
*/
11-
QUIC_LOG_LEVEL_OFF,
12-
/**
13-
* Corresponds to the `Error` log level.
14-
*/
15-
QUIC_LOG_LEVEL_ERROR,
16-
/**
17-
* Corresponds to the `Warn` log level.
18-
*/
19-
QUIC_LOG_LEVEL_WARN,
20-
/**
21-
* Corresponds to the `Info` log level.
22-
*/
23-
QUIC_LOG_LEVEL_INFO,
24-
/**
25-
* Corresponds to the `Debug` log level.
26-
*/
27-
QUIC_LOG_LEVEL_DEBUG,
28-
/**
29-
* Corresponds to the `Trace` log level.
30-
*/
31-
QUIC_LOG_LEVEL_TRACE,
32-
} quic_log_level;
33-
4+
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
5+
#include <winsock2.h>
6+
#include <ws2tcpip.h>
7+
typedef SSIZE_T ssize_t;
8+
struct iovec {
9+
void *iov_base; // starting address
10+
size_t iov_len; // number of bytes to transfer
11+
};
12+
#else
13+
#include <sys/socket.h>
14+
#include <sys/types.h>
15+
#endif
3416

3517
typedef enum http3_error {
3618
HTTP3_NO_ERROR = 0,

src/build.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,29 @@ fn new_boringssl_cmake_config() -> cmake::Config {
107107
boringssl_cmake
108108
}
109109

110+
/// Return the build sub-dir for boringssl.
111+
fn get_boringssl_build_sub_dir() -> &'static str {
112+
if !cfg!(target_env = "msvc") {
113+
return "";
114+
}
115+
116+
// Note: MSVC outputs static libs in a sub-directory.
117+
let debug = std::env::var("DEBUG").expect("DEBUG not set");
118+
let opt_level = std::env::var("OPT_LEVEL").expect("OPT_LEVEL not set");
119+
120+
match &opt_level[..] {
121+
"1" | "2" | "3" => {
122+
if &debug[..] == "true" {
123+
"RelWithDebInfo"
124+
} else {
125+
"Release"
126+
}
127+
}
128+
"s" | "z" => "MinSizeRel",
129+
_ => "Debug",
130+
}
131+
}
132+
110133
fn main() {
111134
if let Ok(boringssl_lib_dir) = std::env::var("BORINGSSL_LIB_DIR") {
112135
// Build with static boringssl lib.
@@ -121,7 +144,8 @@ fn main() {
121144
cfg.build_target("ssl").build();
122145
cfg.build_target("crypto").build().display().to_string()
123146
};
124-
let build_dir = format!("{boringssl_dir}/build/");
147+
let sub_dir = get_boringssl_build_sub_dir();
148+
let build_dir = format!("{boringssl_dir}/build/{sub_dir}");
125149
println!("cargo:rustc-link-search=native={build_dir}");
126150
}
127151

0 commit comments

Comments
 (0)