Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
  • Loading branch information
khulnasoft-bot committed Sep 27, 2024
1 parent cb3a5e5 commit 0184c70
Show file tree
Hide file tree
Showing 205 changed files with 1,615 additions and 488 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c90e4ce2596840c60b5ff1737e2141447e5953e1
761f676b044dcf0d34205f96921e3385ffac7810
7 changes: 4 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ module built on top of or for use with Bongonet and encourage you to pursue that

**You do not need to file an issue for small fixes.** What counts as a "small" or trivial fix is a
judgment call, so here's a few examples to clarify:

- fixing a typo
- refactoring a bit of code
- most documentation or comment edits

Still, _sometimes_ we may review your PR and ask you to file an issue if we expect there are larger
Still, *sometimes* we may review your PR and ask you to file an issue if we expect there are larger
design decisions to be made.

## Making a PR

After you've filed an issue, you can make your PR referencing that issue number. Once you open your
PR, it will be labelled _Needs Review_. A maintainer will review your PR as soon as they can. The
reviewer may ask for changes - they will mark the PR as _Changes Requested_ and will give you
PR, it will be labelled *Needs Review*. A maintainer will review your PR as soon as they can. The
reviewer may ask for changes - they will mark the PR as *Changes Requested* and will give you
details about the requested changes. Feel free to ask lots of questions! The maintainers are there
to help you.

Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Bug Report
about: Report an issue to help us improve
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---

## Describe the bug
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
bongonet:
strategy:
matrix:
toolchain: [nightly, 1.72, 1.79]
toolchain: [nightly, 1.72, 1.80.0]
runs-on: ubuntu-latest
# Only run on "pull_request" event for external PRs. This is to avoid
# duplicate builds for PRs created from internal branches.
Expand Down Expand Up @@ -46,8 +46,8 @@ jobs:

- name: Run cargo clippy
run: |
[[ ${{ matrix.toolchain }} == nightly ]] || cargo clippy --all-targets --all -- --allow=unknown-lints --deny=warnings
[[ ${{ matrix.toolchain }} != 1.80 ]] || cargo clippy --all-targets --all -- --allow=unknown-lints --deny=warnings
- name: Run cargo audit
run: |
[[ ${{ matrix.toolchain }} == nightly ]] || (cargo install cargo-audit && cargo audit)
[[ ${{ matrix.toolchain }} != 1.80.0 ]] || (cargo install cargo-audit && cargo audit)
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
on:
workflow_dispatch:
push:
branches:
- master
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
pull_request: {}
workflow_dispatch: {}
push:
branches:
- main
- master
schedule:
- cron: "0 0 * * *"
name: Semgrep config
jobs:
semgrep:
name: semgrep/ci
runs-on: ubuntu-latest
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
SEMGREP_URL: https://khulnasoft.semgrep.dev
SEMGREP_APP_URL: https://khulnasoft.semgrep.dev
SEMGREP_VERSION_CHECK_URL: https://khulnasoft.semgrep.dev/api/check-version
container:
image: returntocorp/semgrep
steps:
- uses: actions/checkout@v4
- run: semgrep ci
108 changes: 108 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,109 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.3.0](https://github.com/khulnasoft/bongonet/compare/0.2.0...0.3.0) - 2024-07-12

### 🚀 Features

- Add support for HTTP modules. This feature allows users to import modules written by 3rd parties.
- Add `request_body_filter`. Now request body can be inspected and modified.
- Add H2c support.
- Add TCP fast open support.
- Add support for server side TCP keep-alive.
- Add support to get TCP_INFO.
- Add support to set DSCP.
- Add `or_err()`/`or_err_with` API to convert `Options` to `bongonet::Error`.
- Add `or_fail()` API to convert `impl std::error::Error` to `bongonet::Error`.
- Add the API to track socket read and write pending time.
- Compression: allow setting level per algorithm.

### 🐛 Bug Fixes

- Fixed a panic when using multiple H2 streams in the same H2 connection to upstreams.
- Bongonet now respects the `Connection` header it sends to upstream.
- Accept-Ranges header is now removed when response is compressed.
- Fix ipv6_only socket flag.
- A new H2 connection is opened now if the existing connection returns GOAWAY with graceful shutdown error.
- Fix a FD mismatch error when 0.0.0.0 is used as the upstream IP

### ⚙️ Changes and Miscellaneous Tasks

- Dependency: replace `structopt` with `clap`
- Rework the API of HTTP modules
- Optimize remove_header() API call
- UDS parsing now requires the path to have `unix:` prefix. The support for the path without prefix is deprecated and will be removed on the next release.
- Other minor API changes

## [0.2.0](https://github.com/khulnasoft/bongonet/compare/0.1.1...0.2.0) - 2024-05-10

### 🚀 Features

- Add support for downstream h2 trailers and add an upstream h2 response trailer filter
- Add the ability to set TCP recv buf size
- Add a convenience function to retrieve Session digest
- Add `body_bytes_read()` method to Session
- Add `cache_not_modified_filter`
- Add `SSLKEYLOG` support for tls upstream
- Add `Service<HttpProxy<T>>` constructor for providing name
- Add `purge_response` callback
- Make `pop_closed` pub, to simplify DIY drains

### 🐛 Bug Fixes

- Fixed gRPC trailer proxying
- Fixed `response_body_filter` `end_of_stream` always being false
- Fixed compile error in Rust <= 1.73
- Fixed non linux build
- Fixed the counting problem of used_weight data field in `LruUnit<T>`
- Fixed `cargo run --example server` missing cert
- Fixed error log string interpolation outside of proper context
- Fixed tinylfu test flake

### ⚙️ Changes and Miscellaneous Tasks

- API change: `Server::run_forever` now takes ownership and ensures exit semantics
- API change: `cleanup()` method of `ServerApp` trait is now async
- Behavior change: Always return `HttpTask::Body` on body done instead of `HttpTask::done`
- Behavior change: HTTP/1 reason phrase is now parsed and proxied
- Updated `h2` dependency for RUSTSEC-2024-0332
- Updated zstd dependencies
- Code optimization and refactor in a few crates
- More examples and docs

## [0.1.1](https://github.com/khulnasoft/bongonet/compare/0.1.0...0.1.1) - 2024-04-05

### 🚀 Features

- `Server::new` now accepts `Into<Option<T>>`
- Implemented client `HttpSession::get_keepalive_values` for Keep-Alive parsing
- Expose `ListenFds` and `Fds` to fix a voldemort types issue
- Expose config options in `ServerConf`, provide new `Server` constructor
- `upstream_response_filter` now runs on upstream 304 responses during cache revalidation
- Added `server_addr` and `client_addr` APIs to `Session`
- Allow body modification in `response_body_filter`
- Allow configuring grace period and graceful shutdown timeout
- Added TinyUFO sharded skip list storage option

### 🐛 Bug Fixes

- Fixed build failures with the `boringssl` feature
- Fixed compile warnings with nightly Rust
- Fixed an issue where Upgrade request bodies might not be handled correctly
- Fix compilation to only include openssl or boringssl rather than both
- Fix OS read errors so they are reported as `ReadError` rather than `ReadTimeout` when reading http/1.1 response headers

### ⚙️ Miscellaneous Tasks

- Performance improvements in `bongonet-ketama`
- Added more TinyUFO benchmarks
- Added tests for `bongonet-cache` purge
- Limit buffer size for `InvalidHTTPHeader` error logs
- Example code: improvements in bongonet client, new LB cluster example
- Typo fixes and clarifications across comments and docs

## [0.1.0] - 2024-02-28

### Highlights

- First Public Release of Bongonet 🎉
62 changes: 36 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
# Bongonet

## What is Bongonet

Bongonet is a Rust framework to [build fast, reliable and programmable networked systems](https://blog.khulnasoft.com/bongonet-open-source).

Bongonet is battle tested as it has been serving more than 40 million Internet requests per second for [more than a few years](https://blog.khulnasoft.com/how-we-built-bongonet-the-proxy-that-connects-khulnasoft-to-the-internet).

## Feature highlights
* Async Rust: fast and reliable
* HTTP 1/2 end to end proxy
* TLS over OpenSSL or BoringSSL
* gRPC and websocket proxying
* Graceful reload
* Customizable load balancing and failover strategies
* Support for a variety of observability tools

- Async Rust: fast and reliable
- HTTP 1/2 end to end proxy
- TLS over OpenSSL or BoringSSL
- gRPC and websocket proxying
- Graceful reload
- Customizable load balancing and failover strategies
- Support for a variety of observability tools

## Reasons to use Bongonet
* **Security** is your top priority: Bongonet is a more memory safe alternative for services that are written in C/C++
* Your service is **performance-sensitive**: Bongonet is fast and efficient
* Your service requires extensive **customization**: The APIs Bongonet proxy framework provides are highly programmable

- **Security** is your top priority: Bongonet is a more memory safe alternative for services that are written in C/C++
- Your service is **performance-sensitive**: Bongonet is fast and efficient
- Your service requires extensive **customization**: The APIs Bongonet proxy framework provides are highly programmable

# Getting started

Expand All @@ -25,22 +31,24 @@ Our [user guide](./docs/user_guide/index.md) covers more topics such as how to c
API docs are also available for all the crates.

# Notable crates in this workspace
* Bongonet: the "public facing" crate to build networked systems and proxies
* Bongonet-core: this crate defines the protocols, functionalities and basic traits
* Bongonet-proxy: the logic and APIs to build HTTP proxies
* Bongonet-error: the common error type used across Bongonet crates
* Bongonet-http: the HTTP header definitions and APIs
* Bongonet-openssl & bongonet-boringssl: SSL related extensions and APIs
* Bongonet-ketama: the [Ketama](https://github.com/RJ/ketama) consistent algorithm
* Bongonet-limits: efficient counting algorithms
* Bongonet-load-balancing: load balancing algorithm extensions for bongonet-proxy
* Bongonet-memory-cache: Async in-memory caching with cache lock to prevent cache stampede
* Bongonet-timeout: A more efficient async timer system
* TinyUfo: The caching algorithm behind bongonet-memory-cache

- Bongonet: the "public facing" crate to build networked systems and proxies
- Bongonet-core: this crate defines the protocols, functionalities and basic traits
- Bongonet-proxy: the logic and APIs to build HTTP proxies
- Bongonet-error: the common error type used across Bongonet crates
- Bongonet-http: the HTTP header definitions and APIs
- Bongonet-openssl & bongonet-boringssl: SSL related extensions and APIs
- Bongonet-ketama: the [Ketama](https://github.com/RJ/ketama) consistent algorithm
- Bongonet-limits: efficient counting algorithms
- Bongonet-load-balancing: load balancing algorithm extensions for bongonet-proxy
- Bongonet-memory-cache: Async in-memory caching with cache lock to prevent cache stampede
- Bongonet-timeout: A more efficient async timer system
- TinyUfo: The caching algorithm behind bongonet-memory-cache

# System requirements

## Systems

Linux is our tier 1 environment and main focus.

We will try our best for most code to compile for Unix environments. This is for developers and users to have an easier time developing with Bongonet in Unix-like environments like macOS (though some features might be missing)
Expand All @@ -58,14 +66,16 @@ Our current MSRV is 1.72.
Some of the crates in this repository have dependencies on additional tools and
libraries that must be satisfied in order to build them:

* Make sure that [Clang] is installed on your system (for boringssl)
* Make sure that [Perl 5] is installed on your system (for openssl)
- Make sure that [Clang] is installed on your system (for boringssl)
- Make sure that [Perl 5] is installed on your system (for openssl)

[Clang]:https://clang.llvm.org/
[Perl 5]:https://www.perl.org/
[Clang]: https://clang.llvm.org/
[Perl 5]: https://www.perl.org/

# Contributing

Please see our [contribution guidelines](./.github/CONTRIBUTING.md).

# License

This project is Licensed under [Apache License, Version 2.0](./LICENSE).
2 changes: 1 addition & 1 deletion bongonet-boringssl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bongonet-boringssl"
version = "0.3.0"
authors = ["KhulnaSoft DevOps <info@khulnasoft.com>"]
authors = ["Yuchen Wu <yuchen@khulnasoft.com>"]
license = "Apache-2.0"
edition = "2021"
repository = "https://github.com/khulnasoft/bongonet"
Expand Down
2 changes: 1 addition & 1 deletion bongonet-boringssl/src/boring_tokio.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-boringssl/src/ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-boringssl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 2 additions & 1 deletion bongonet-cache/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bongonet-cache"
version = "0.3.0"
authors = ["KhulnaSoft DevOps <info@khulnasoft.com>"]
authors = ["Yuchen Wu <yuchen@khulnasoft.com>"]
license = "Apache-2.0"
edition = "2021"
repository = "https://github.com/khulnasoft/bongonet"
Expand Down Expand Up @@ -43,6 +43,7 @@ lru = { workspace = true }
ahash = { workspace = true }
hex = "0.4"
httparse = { workspace = true }
strum = { version = "0.26", features = ["derive"] }

[dev-dependencies]
tokio-test = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/benches/lru_memory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/benches/lru_serde.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/benches/simple_lru_memory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions bongonet-cache/src/cache_control.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,8 +51,8 @@ impl DirectiveValue {
/// A [DirectiveValue] without quotes (`"`).
pub fn parse_as_bytes(&self) -> &[u8] {
self.0
.strip_prefix(b"\"")
.and_then(|bytes| bytes.strip_suffix(b"\""))
.strip_prefix(&[b'"'])
.and_then(|bytes| bytes.strip_suffix(&[b'"']))
.unwrap_or(&self.0[..])
}

Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/eviction/lru.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/eviction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/eviction/simple_lru.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/filters.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Khulnasoft, Ltd.
// Copyright 2024 KhulnaSoft, Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 0184c70

Please sign in to comment.