Skip to content

Commit

Permalink
Merge branch 'main' into docs/agent-relay-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky authored Oct 10, 2023
2 parents 136b378 + 98af104 commit b4e254f
Show file tree
Hide file tree
Showing 22 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion agones/src/sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {
let config = r#"
version: v1alpha1
filters:
- name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
- name: quilkin.filters.concatenate.v1alpha1.Concatenate
config:
on_read: APPEND
on_write: DO_NOTHING
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"proto/quilkin/config/v1alpha1/config.proto",
"proto/quilkin/filters/capture/v1alpha1/capture.proto",
"proto/quilkin/filters/compress/v1alpha1/compress.proto",
"proto/quilkin/filters/concatenate_bytes/v1alpha1/concatenate_bytes.proto",
"proto/quilkin/filters/concatenate/v1alpha1/concatenate.proto",
"proto/quilkin/filters/debug/v1alpha1/debug.proto",
"proto/quilkin/filters/drop/v1alpha1/drop.proto",
"proto/quilkin/filters/firewall/v1alpha1/firewall.proto",
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ substitutions:
artifacts:
images:
- ${_REPOSITORY}quilkin
logsBucket: "gs://quilkin-build-logs"
# logsBucket: "gs://quilkin-build-logs"
2 changes: 1 addition & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- [Filters](./services/proxy/filters.md)
- [Capture](./services/proxy/filters/capture.md)
- [Compress](./services/proxy/filters/compress.md)
- [Concatenate Bytes](./services/proxy/filters/concatenate_bytes.md)
- [Concatenate](./services/proxy/filters/concatenate.md)
- [Debug](./services/proxy/filters/debug.md)
- [Drop](./services/proxy/filters/drop.md)
- [Firewall](./services/proxy/filters/firewall.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/deployment/quickstarts/agones-xonotic-relay.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ quilkin-proxies LoadBalancer 10.109.0.12 35.246.94.14 7000:30174/UDP
We have a [Quilkin config yaml](https://github.com/googleforgames/quilkin/blob/{{GITHUB_REF_NAME}}/examples/agones-xonotic-relay/client-token.yaml)
file all ready for you, that is configured to append the routing token `456` to each
packet that passes through it, via the power of a
[ConcatenateBytes](../../services/proxy/filters/concatenate_bytes.md) Filter.
[Concatenate](../../services/proxy/filters/concatenate.md) Filter.

Download `client-token.yaml` locally, so you can edit it:

Expand Down
2 changes: 1 addition & 1 deletion docs/src/deployment/quickstarts/agones-xonotic-xds.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ quilkin-proxies LoadBalancer 10.109.0.12 35.246.94.14 7000:30174/UDP
We have a [Quilkin config yaml](https://github.com/googleforgames/quilkin/blob/{{GITHUB_REF_NAME}}/examples/agones-xonotic-xds/client-token.yaml)
file all ready for you, that is configured to append the routing token `456` to each
packet that passes through it, via the power of a
[ConcatenateBytes](../../services/proxy/filters/concatenate_bytes.md) Filter.
[Concatenate](../../services/proxy/filters/concatenate.md) Filter.

Download `client-token.yaml` locally, so you can edit it:

Expand Down
4 changes: 2 additions & 2 deletions docs/src/services/proxy/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ Quilkin includes several filters out of the box.
|----------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| [Capture] | Capture specific bytes from a packet and store them in [filter dynamic metadata](#filter-dynamic-metadata). |
| [Compress](./filters/compress.md) | Compress and decompress packets data. |
| [ConcatenateBytes](./filters/concatenate_bytes.md) | Add authentication tokens to packets. |
| [Debug](./filters/concatenate_bytes.md) | Logs every packet. |
| [Concatenate](./filters/concatenate.md) | Add authentication tokens to packets. |
| [Debug](./filters/debug.md) | Logs every packet. |
| [Drop](./filters/drop.md) | Drop all packets |
| [Firewall](./filters/firewall.md) | Allowing/blocking traffic by IP and port. |
| [LoadBalancer](./filters/load_balancer.md) | Distributes downstream packets among upstream endpoints. |
Expand Down
2 changes: 1 addition & 1 deletion docs/src/services/proxy/filters/capture.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The `Capture` filter's job is to find a series of bytes within a packet, and cap
down the chain.

This is often used as a way of retrieving authentication tokens from a packet, and used in combination with
[ConcatenateBytes](concatenate_bytes.md) and
[Concatenate](concatenate.md) and
[TokenRouter](token_router.md) filter to provide common packet routing utilities.

## Capture strategies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# ConcatenateBytes
# Concatenate

The `ConcatenateBytes` filter's job is to add a byte packet to either the beginning or end of each UDP packet that passes
The `Concatenate` filter's job is to add a byte packet to either the beginning or end of each UDP packet that passes
through. This is commonly used to provide an auth token to each packet, so they can be routed appropriately.

## Filter name
```text
quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
quilkin.filters.concatenate.v1alpha1.Concatenate
```

## Configuration Examples
```rust
# let yaml = "
version: v1alpha1
filters:
- name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
- name: quilkin.filters.concatenate.v1alpha1.Concatenate
config:
on_read: APPEND
on_write: DO_NOTHING
Expand All @@ -26,8 +26,8 @@ clusters:
# assert_eq!(config.filters.load().len(), 1);
```

## Configuration Options ([Rust Doc](../../../../api/quilkin/filters/concatenate_bytes/struct.Config.html))
## Configuration Options ([Rust Doc](../../../../api/quilkin/filters/concatenate/struct.Config.html))

```yaml
{{#include ../../../../../target/quilkin.filters.concatenate_bytes.v1alpha1.yaml}}
{{#include ../../../../../target/quilkin.filters.concatenate.v1alpha1.yaml}}
```
2 changes: 1 addition & 1 deletion docs/src/services/proxy/filters/token_router.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ clusters:
# assert_eq!(config.filters.load().len(), 2);
```

On the game client side the [ConcatenateBytes](concatenate_bytes.md) filter could also be used to add authentication
On the game client side the [Concatenate](concatenate.md) filter could also be used to add authentication
tokens to outgoing packets.

[filter-dynamic-metadata]: ../filters.md#filter-dynamic-metadata
Expand Down
2 changes: 1 addition & 1 deletion examples/agones-xonotic-relay/client-token.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

version: v1alpha1
filters:
- name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
- name: quilkin.filters.concatenate.v1alpha1.Concatenate
config:
on_read: APPEND
on_write: DO_NOTHING
Expand Down
2 changes: 1 addition & 1 deletion examples/agones-xonotic-xds/client-token.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

version: v1alpha1
filters:
- name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
- name: quilkin.filters.concatenate.v1alpha1.Concatenate
config:
on_read: APPEND
on_write: DO_NOTHING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

syntax = "proto3";

package quilkin.filters.concatenate_bytes.v1alpha1;
package quilkin.filters.concatenate.v1alpha1;

message ConcatenateBytes {
message Concatenate {
enum Strategy {
DoNothing = 0;
Append = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod write;

pub mod capture;
pub mod compress;
pub mod concatenate_bytes;
pub mod concatenate;
pub mod debug;
pub mod drop;
pub mod firewall;
Expand All @@ -53,7 +53,7 @@ pub mod prelude {
pub use self::{
capture::Capture,
compress::Compress,
concatenate_bytes::ConcatenateBytes,
concatenate::Concatenate,
debug::Debug,
drop::Drop,
error::{ConvertProtoConfigError, CreationError, FilterError},
Expand Down
22 changes: 11 additions & 11 deletions src/filters/concatenate_bytes.rs → src/filters/concatenate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
* limitations under the License.
*/

crate::include_proto!("quilkin.filters.concatenate_bytes.v1alpha1");
crate::include_proto!("quilkin.filters.concatenate.v1alpha1");

mod config;

use crate::filters::prelude::*;

use self::quilkin::filters::concatenate_bytes::v1alpha1 as proto;
use self::quilkin::filters::concatenate::v1alpha1 as proto;
pub use config::{Config, Strategy};

/// The `ConcatenateBytes` filter's job is to add a byte packet to either the
/// The `Concatenate` filter's job is to add a byte packet to either the
/// beginning or end of each UDP packet that passes through. This is commonly
/// used to provide an auth token to each packet, so they can be
/// routed appropriately.
pub struct ConcatenateBytes {
pub struct Concatenate {
on_read: Strategy,
on_write: Strategy,
bytes: Vec<u8>,
}

impl ConcatenateBytes {
impl Concatenate {
pub fn new(config: Config) -> Self {
ConcatenateBytes {
Concatenate {
on_read: config.on_read,
on_write: config.on_write,
bytes: config.bytes,
Expand All @@ -44,7 +44,7 @@ impl ConcatenateBytes {
}

#[async_trait::async_trait]
impl Filter for ConcatenateBytes {
impl Filter for Concatenate {
async fn read(&self, ctx: &mut ReadContext) -> Result<(), FilterError> {
match self.on_read {
Strategy::Append => {
Expand Down Expand Up @@ -74,12 +74,12 @@ impl Filter for ConcatenateBytes {
}
}

impl StaticFilter for ConcatenateBytes {
const NAME: &'static str = "quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes";
impl StaticFilter for Concatenate {
const NAME: &'static str = "quilkin.filters.concatenate.v1alpha1.Concatenate";
type Configuration = Config;
type BinaryConfiguration = proto::ConcatenateBytes;
type BinaryConfiguration = proto::Concatenate;

fn try_from_config(config: Option<Self::Configuration>) -> Result<Self, CreationError> {
Ok(ConcatenateBytes::new(Self::ensure_config_exists(config)?))
Ok(Concatenate::new(Self::ensure_config_exists(config)?))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum Strategy {
DoNothing,
}

impl From<Strategy> for proto::concatenate_bytes::Strategy {
impl From<Strategy> for proto::concatenate::Strategy {
fn from(strategy: Strategy) -> Self {
match strategy {
Strategy::Append => Self::Append,
Expand All @@ -41,25 +41,25 @@ impl From<Strategy> for proto::concatenate_bytes::Strategy {
}
}

impl From<proto::concatenate_bytes::Strategy> for Strategy {
fn from(strategy: proto::concatenate_bytes::Strategy) -> Self {
impl From<proto::concatenate::Strategy> for Strategy {
fn from(strategy: proto::concatenate::Strategy) -> Self {
match strategy {
proto::concatenate_bytes::Strategy::Append => Self::Append,
proto::concatenate_bytes::Strategy::Prepend => Self::Prepend,
proto::concatenate_bytes::Strategy::DoNothing => Self::DoNothing,
proto::concatenate::Strategy::Append => Self::Append,
proto::concatenate::Strategy::Prepend => Self::Prepend,
proto::concatenate::Strategy::DoNothing => Self::DoNothing,
}
}
}

impl From<Strategy> for proto::concatenate_bytes::StrategyValue {
impl From<Strategy> for proto::concatenate::StrategyValue {
fn from(strategy: Strategy) -> Self {
Self {
value: proto::concatenate_bytes::Strategy::from(strategy) as i32,
value: proto::concatenate::Strategy::from(strategy) as i32,
}
}
}

/// Config represents a `ConcatenateBytes` filter configuration.
/// Config represents a `Concatenate` filter configuration.
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, JsonSchema)]
#[non_exhaustive]
pub struct Config {
Expand All @@ -77,7 +77,7 @@ pub struct Config {
pub bytes: Vec<u8>,
}

impl From<Config> for proto::ConcatenateBytes {
impl From<Config> for proto::Concatenate {
fn from(config: Config) -> Self {
Self {
on_read: Some(config.on_read.into()),
Expand All @@ -87,8 +87,8 @@ impl From<Config> for proto::ConcatenateBytes {
}
}

impl From<proto::ConcatenateBytes> for Config {
fn from(p: proto::ConcatenateBytes) -> Self {
impl From<proto::Concatenate> for Config {
fn from(p: proto::Concatenate) -> Self {
let on_read = p
.on_read
.map(|p| p.value())
Expand Down
4 changes: 2 additions & 2 deletions src/filters/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub type FilterMap = std::collections::HashMap<&'static str, Arc<DynFilterFactor
/// Current default filters:
/// - [`debug`][filters::debug]
/// - [`local_rate_limit`][filters::local_rate_limit]
/// - [`concatenate_bytes`][filters::concatenate_bytes]
/// - [`concatenate`][filters::concatenate]
/// - [`load_balancer`][filters::load_balancer]
/// - [`capture`][filters::capture]
/// - [`token_router`][filters::token_router]
Expand All @@ -46,7 +46,7 @@ impl FilterSet {
[
filters::Capture::factory(),
filters::Compress::factory(),
filters::ConcatenateBytes::factory(),
filters::Concatenate::factory(),
filters::Debug::factory(),
filters::Drop::factory(),
filters::Firewall::factory(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mod external_doc_tests {
#![doc = include_str!("../docs/src/services/proxy/filters.md")]
#![doc = include_str!("../docs/src/services/proxy/filters/capture.md")]
#![doc = include_str!("../docs/src/services/proxy/filters/compress.md")]
#![doc = include_str!("../docs/src/services/proxy/filters/concatenate_bytes.md")]
#![doc = include_str!("../docs/src/services/proxy/filters/concatenate.md")]
#![doc = include_str!("../docs/src/services/proxy/filters/debug.md")]
#![doc = include_str!("../docs/src/services/proxy/filters/firewall.md")]
#![doc = include_str!("../docs/src/services/proxy/filters/load_balancer.md")]
Expand Down
8 changes: 4 additions & 4 deletions src/xds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ mod tests {
tokio::time::sleep(std::time::Duration::from_millis(500)).await;

let filters = crate::filters::FilterChain::try_from(vec![
ConcatenateBytes::as_filter_config(concatenate_bytes::Config {
on_read: concatenate_bytes::Strategy::Append,
Concatenate::as_filter_config(concatenate::Config {
on_read: concatenate::Strategy::Append,
on_write: <_>::default(),
bytes: b1.as_bytes().to_vec(),
})
.unwrap(),
ConcatenateBytes::as_filter_config(concatenate_bytes::Config {
on_read: concatenate_bytes::Strategy::Append,
Concatenate::as_filter_config(concatenate::Config {
on_read: concatenate::Strategy::Append,
on_write: <_>::default(),
bytes: b2.as_bytes().to_vec(),
})
Expand Down
6 changes: 3 additions & 3 deletions tests/concatenate_bytes.rs → tests/concatenate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ use tokio::time::{timeout, Duration};
use quilkin::{
config::Filter,
endpoint::Endpoint,
filters::{ConcatenateBytes, StaticFilter},
filters::{Concatenate, StaticFilter},
test_utils::{AddressType, TestHelper},
};

#[tokio::test]
async fn concatenate_bytes() {
async fn concatenate() {
let mut t = TestHelper::default();
let yaml = "
on_read: APPEND
Expand All @@ -45,7 +45,7 @@ bytes: YWJj #abc
.modify(|clusters| clusters.insert_default([Endpoint::new(echo.clone())].into()));
server_config.filters.store(
quilkin::filters::FilterChain::try_from(vec![Filter {
name: ConcatenateBytes::factory().name().into(),
name: Concatenate::factory().name().into(),
label: None,
config: serde_yaml::from_str(yaml).unwrap(),
}])
Expand Down
6 changes: 3 additions & 3 deletions tests/filter_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tokio::time::{timeout, Duration};
use quilkin::{
config::Filter,
endpoint::Endpoint,
filters::{Compress, ConcatenateBytes, StaticFilter},
filters::{Compress, Concatenate, StaticFilter},
test_utils::{AddressType, TestHelper},
};

Expand Down Expand Up @@ -65,12 +65,12 @@ on_write: DECOMPRESS
server_config.filters.store(
quilkin::filters::FilterChain::try_from(vec![
Filter {
name: ConcatenateBytes::factory().name().into(),
name: Concatenate::factory().name().into(),
label: None,
config: serde_yaml::from_str(yaml_concat_read).unwrap(),
},
Filter {
name: ConcatenateBytes::factory().name().into(),
name: Concatenate::factory().name().into(),
label: None,
config: serde_yaml::from_str(yaml_concat_write).unwrap(),
},
Expand Down
Loading

0 comments on commit b4e254f

Please sign in to comment.