Skip to content

Commit

Permalink
Merge pull request #351 from Tencent/release/v1.0.0
Browse files Browse the repository at this point in the history
Release/v1.0.0
  • Loading branch information
iyangsj authored Aug 1, 2024
2 parents 1a68d04 + 6d782ae commit 4dcec0f
Show file tree
Hide file tree
Showing 22 changed files with 502 additions and 97 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ jobs:
. "$HOME/.cargo/env"
cargo build --all -F ffi --verbose && cargo test
build_windows:
name: Build for Windows
runs-on: windows-2022
env:
TARGET: "x86_64-pc-windows-msvc"
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ env.TARGET }}
- name: Install dependencies
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install nasm
- name: Build TQUIC library and tools
run: cargo build --all -F ffi --verbose && cargo test

build_ios:
name: Build for iOS
runs-on: macos-latest
Expand Down Expand Up @@ -119,6 +140,8 @@ jobs:
typos -c ./typos.toml
- name: Code lint check
run: cargo clippy --all -- -D warnings
- name: Code lint check (FFI)
run: cargo clippy --all -F ffi -- -D warnings

unit_testing:
name: Unit testing
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/tquic-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
benchmark_impls: ${{ steps.set-implements.outputs.benchmark_impls }}
benchmark_rounds: ${{ steps.set-rounds.outputs.benchmark_rounds }}
benchmark_duration: ${{ steps.set-duration.outputs.benchmark_duration }}
if: ${{ ( github.event_name == 'schedule' && github.repository == 'tencent/tquic' ) || github.event_name == 'workflow_dispatch' }}
steps:
- name: Set date
id: set-benchmark-date
Expand All @@ -43,6 +44,7 @@ jobs:
build_tquic:
name: Build tquic
runs-on: ubuntu-latest
needs: config
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -74,6 +76,7 @@ jobs:
build_lsquic:
name: Build lsquic
runs-on: ubuntu-latest
needs: config
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -107,6 +110,7 @@ jobs:
gen_cert:
name: Generate cert
runs-on: ubuntu-latest
needs: config
steps:
- name: Generate cert
run: |
Expand All @@ -121,6 +125,7 @@ jobs:
gen_files:
name: Generate files
runs-on: ubuntu-latest
needs: config
steps:
- name: Generate files
run: |
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [v1.0.0] - 2024-08-01

### Added
- Support building on Windows
- Optimize the initial RTT of the newly validated path
- Add API for deferring idle timeout

### Changed
- Rename PathStats to quic_path_stats_t in FFI
- Change prototype of quic_set_logger in FFI


## [v0.15.0] - 2024-07-18

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


[v1.0.0]: https://github.com/tencent/tquic/compare/v0.15.0...v1.0.0
[v0.15.0]: https://github.com/tencent/tquic/compare/v0.14.0...v0.15.0
[v0.14.0]: https://github.com/tencent/tquic/compare/v0.13.0...v0.14.0
[v0.13.0]: https://github.com/tencent/tquic/compare/v0.12.0...v0.13.0
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tquic"
version = "0.15.0"
version = "1.0.0"
edition = "2021"
rust-version = "1.70.0"
license = "Apache-2.0"
Expand Down Expand Up @@ -51,6 +51,9 @@ hex = "0.4"
priority-queue = "1.3.2"
sfv = { version = "0.9" }

[target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = ["wincrypt", "ws2def", "ws2ipdef", "ws2tcpip"] }

[dev-dependencies]
env_logger = "0.10.0"
mio = { version = "0.8", features = ["net", "os-poll"] }
Expand Down
2 changes: 1 addition & 1 deletion cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ cpp_compat = true
documentation = true

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

[export]
Expand All @@ -31,6 +30,7 @@ exclude = ["MIN_CLIENT_INITIAL_LEN", "VINT_MAX"]
"PacketOutSpec" = "quic_packet_out_spec_t"
"PacketInfo" = "quic_packet_info_t"
"PathAddress" = "quic_path_address_t"
"PathStats" = "quic_path_stats_t"
"FourTupleIter" = "quic_path_address_iter_t"
"Shutdown" = "quic_shutdown"
"TransportHandler" = "quic_transport_handler_t"
Expand Down
51 changes: 34 additions & 17 deletions include/tquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include "openssl/ssl.h"
#include "tquic_def.h"

Expand Down Expand Up @@ -278,7 +276,7 @@ typedef struct quic_path_address_t {
/**
* Statistics about path
*/
typedef struct PathStats {
typedef struct quic_path_stats_t {
/**
* The number of QUIC packets received.
*/
Expand All @@ -303,14 +301,14 @@ typedef struct PathStats {
* The number of lost bytes.
*/
uint64_t lost_bytes;
/**
* Total number of bytes acked.
*/
uint64_t acked_bytes;
/**
* Total number of packets acked.
*/
uint64_t acked_count;
/**
* Total number of bytes acked.
*/
uint64_t acked_bytes;
/**
* Initial congestion window in bytes.
*/
Expand Down Expand Up @@ -367,7 +365,7 @@ typedef struct PathStats {
* Pacing rate estimated by congestion control algorithm.
*/
uint64_t pacing_rate;
} PathStats;
} quic_path_stats_t;

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

/**
* Send a Ping frame on the active path(s) for keep-alive.
*/
int quic_conn_ping(struct quic_conn_t *conn);

/**
* Send a Ping frame on the specified path for keep-alive.
* The API is only applicable to multipath quic connections.
*/
int quic_conn_ping_path(struct quic_conn_t *conn,
const struct sockaddr *local,
socklen_t local_len,
const struct sockaddr *remote,
socklen_t remote_len);

/**
* Add a new path on the client connection.
*/
Expand Down Expand Up @@ -1020,11 +1033,11 @@ bool quic_conn_active_path(const struct quic_conn_t *conn, struct quic_path_addr
/**
* Return the latest statistics about the specified path.
*/
const struct PathStats *quic_conn_path_stats(struct quic_conn_t *conn,
const struct sockaddr *local,
socklen_t local_len,
const struct sockaddr *remote,
socklen_t remote_len);
const struct quic_path_stats_t *quic_conn_path_stats(struct quic_conn_t *conn,
const struct sockaddr *local,
socklen_t local_len,
const struct sockaddr *remote,
socklen_t remote_len);

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

/**
* Set keylog file.
* Note: The API is not applicable for Windows.
*/
void quic_conn_set_keylog_fd(struct quic_conn_t *conn, int fd);

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

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

Expand Down Expand Up @@ -1403,13 +1418,15 @@ int http3_take_priority_update(struct http3_conn_t *conn,
/**
* Set logger.
* `cb` is a callback function that will be called for each log message.
* `data` is a '\n' terminated log message and `argp` is user-defined data that will be passed to
* the callback.
* `level` represents the log level.
* `data` is a '\n' terminated log message and `argp` is user-defined data that
* will be passed to the callback.
* `level` is a case-insensitive string used for specifying the log level. Valid
* values are "OFF", "ERROR", "WARN", "INFO", "DEBUG", and "TRACE". If its value
* is NULL or invalid, the default log level is "OFF".
*/
void quic_set_logger(void (*cb)(const uint8_t *data, size_t data_len, void *argp),
void *argp,
quic_log_level level);
const char *level);

#ifdef __cplusplus
} // extern "C"
Expand Down
42 changes: 12 additions & 30 deletions include/tquic_def.h
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
#ifndef _TQUIC_DEF_H_
#define _TQUIC_DEF_H_

/**
* An enum representing the available verbosity level filters of the logger.
*/
typedef enum quic_log_level {
/**
* A level lower than all log levels.
*/
QUIC_LOG_LEVEL_OFF,
/**
* Corresponds to the `Error` log level.
*/
QUIC_LOG_LEVEL_ERROR,
/**
* Corresponds to the `Warn` log level.
*/
QUIC_LOG_LEVEL_WARN,
/**
* Corresponds to the `Info` log level.
*/
QUIC_LOG_LEVEL_INFO,
/**
* Corresponds to the `Debug` log level.
*/
QUIC_LOG_LEVEL_DEBUG,
/**
* Corresponds to the `Trace` log level.
*/
QUIC_LOG_LEVEL_TRACE,
} quic_log_level;

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#include <winsock2.h>
#include <ws2tcpip.h>
typedef SSIZE_T ssize_t;
struct iovec {
void *iov_base; // starting address
size_t iov_len; // number of bytes to transfer
};
#else
#include <sys/socket.h>
#include <sys/types.h>
#endif

typedef enum http3_error {
HTTP3_NO_ERROR = 0,
Expand Down
26 changes: 25 additions & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,29 @@ fn new_boringssl_cmake_config() -> cmake::Config {
boringssl_cmake
}

/// Return the build sub-dir for boringssl.
fn get_boringssl_build_sub_dir() -> &'static str {
if !cfg!(target_env = "msvc") {
return "";
}

// Note: MSVC outputs static libs in a sub-directory.
let debug = std::env::var("DEBUG").expect("DEBUG not set");
let opt_level = std::env::var("OPT_LEVEL").expect("OPT_LEVEL not set");

match &opt_level[..] {
"1" | "2" | "3" => {
if &debug[..] == "true" {
"RelWithDebInfo"
} else {
"Release"
}
}
"s" | "z" => "MinSizeRel",
_ => "Debug",
}
}

fn main() {
if let Ok(boringssl_lib_dir) = std::env::var("BORINGSSL_LIB_DIR") {
// Build with static boringssl lib.
Expand All @@ -121,7 +144,8 @@ fn main() {
cfg.build_target("ssl").build();
cfg.build_target("crypto").build().display().to_string()
};
let build_dir = format!("{boringssl_dir}/build/");
let sub_dir = get_boringssl_build_sub_dir();
let build_dir = format!("{boringssl_dir}/build/{sub_dir}");
println!("cargo:rustc-link-search=native={build_dir}");
}

Expand Down
Loading

0 comments on commit 4dcec0f

Please sign in to comment.