Skip to content

Commit

Permalink
Merge branch 'main' into ue4-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rezvaneh committed May 4, 2022
2 parents 6f157b1 + ca19853 commit 03d290a
Show file tree
Hide file tree
Showing 82 changed files with 2,100 additions and 2,469 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test = true
quilkin-macros = { version = "0.4.0-dev", path = "./macros" }

# Crates.io
arc-swap = "1.5.0"
arc-swap = { version = "1.5.0", features = ["serde"] }
base64 = "0.13.0"
base64-serde = "0.6.1"
bytes = { version = "1.1.0", features = ["serde"] }
Expand Down
19 changes: 7 additions & 12 deletions benches/throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,16 @@ const PACKETS: &[&[u8]] = &[
fn run_quilkin(port: u16, endpoint: SocketAddr) {
std::thread::spawn(move || {
let runtime = tokio::runtime::Runtime::new().unwrap();
let config = quilkin::config::Builder::empty()
.with_port(port)
.with_admin(Admin {
let config = quilkin::Server::builder()
.port(port)
.admin(Admin {
address: "[::]:0".parse().unwrap(),
})
.with_static(
vec![],
vec![quilkin::endpoint::Endpoint::new(endpoint.into())],
)
.build();
let server = quilkin::Builder::from(std::sync::Arc::new(config))
.validate()
.unwrap()
.build();
.endpoints(vec![quilkin::endpoint::Endpoint::new(endpoint.into())])
.build()
.unwrap();

let server = quilkin::Server::try_from(config).unwrap();
runtime.block_on(async move {
let (_shutdown_tx, shutdown_rx) = tokio::sync::watch::channel::<()>(());
server.run(shutdown_rx).await.unwrap();
Expand Down
13 changes: 2 additions & 11 deletions build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,10 @@ RUN set -eux && \
apt-get install -y jq wget zip build-essential libssl-dev pkg-config python3-pip && \
pip3 install live-server

# Install Go
WORKDIR /usr/local
ENV GO_VERSION=1.17.2
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
tar -xzf go${GO_VERSION}.linux-amd64.tar.gz && rm go${GO_VERSION}.linux-amd64.tar.gz
ENV PATH /usr/local/go/bin:$PATH

# Install htmltest
WORKDIR /tmp
# TODO (markmandel): replace with official release once a 0.16.0 release is created.
RUN git clone --depth=5 https://github.com/wjdp/htmltest.git && \
cd htmltest && ./build.sh && cp ./bin/htmltest /usr/local/bin/ && \
rm -r /tmp/htmltest
RUN wget -O htmltest.tar.gz https://github.com/wjdp/htmltest/releases/download/v0.16.0/htmltest_0.16.0_linux_amd64.tar.gz && \
tar -xf htmltest.tar.gz && mv ./htmltest /usr/local/bin/ && rm htmltest.tar.gz

# Install Rust
RUN wget https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init && \
Expand Down
27 changes: 13 additions & 14 deletions docs/src/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ As an example, say we would like to perform the following steps in our processin
* Do not forward (drop) the packet if its compressed length is over 512 bytes.

We would create a filter corresponding to each step either by leveraging any [existing filters](#built-in-filters)
that do what we want or [writing one ourselves](./filters/writing_custom_filters.md) and connect them to form the
that do what we want or [writing one ourselves](./filters/writing_custom_filters.md) and connect them to form the
following filter chain:

```bash
Expand Down Expand Up @@ -53,21 +53,20 @@ There are a few things we note here:
# async fn main() {
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.debug.v1alpha1.Debug
config:
id: debug-1
- name: quilkin.filters.local_rate_limit.v1alpha1.LocalRateLimit
config:
max_packets: 10
period: 1
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.debug.v1alpha1.Debug
config:
id: debug-1
- name: quilkin.filters.local_rate_limit.v1alpha1.LocalRateLimit
config:
max_packets: 10
period: 1
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 2);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 2);
# quilkin::Server::try_from(config).unwrap();
# }
```

Expand Down
23 changes: 11 additions & 12 deletions docs/src/filters/capture.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,19 @@ quilkin.filters.capture.v1alpha1.Capture
```rust
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.capture.v1alpha1.Capture
config:
metadataKey: myapp.com/myownkey
prefix:
size: 3
remove: false
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.capture.v1alpha1.Capture
config:
metadataKey: myapp.com/myownkey
prefix:
size: 3
remove: false
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 1);
# quilkin::Server::try_from(config).unwrap();
```

### Configuration Options ([Rust Doc](../../api/quilkin/filters/capture/struct.Config.html))
Expand Down
21 changes: 10 additions & 11 deletions docs/src/filters/compress.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ quilkin.filters.compress.v1alpha1.Compress
```rust
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.compress.v1alpha1.Compress
config:
on_read: COMPRESS
on_write: DECOMPRESS
mode: SNAPPY
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.compress.v1alpha1.Compress
config:
on_read: COMPRESS
on_write: DECOMPRESS
mode: SNAPPY
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 1);
# quilkin::Server::try_from(config).unwrap();
```

The above example shows a proxy that could be used with a typical game client, where the original client data is
Expand Down
21 changes: 10 additions & 11 deletions docs/src/filters/concatenate_bytes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
```rust
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
config:
on_read: APPEND
on_write: DO_NOTHING
bytes: MXg3aWp5Ng==
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.concatenate_bytes.v1alpha1.ConcatenateBytes
config:
on_read: APPEND
on_write: DO_NOTHING
bytes: MXg3aWp5Ng==
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 1);
# quilkin::Server::try_from(config).unwrap();
```

### Configuration Options ([Rust Doc](../../api/quilkin/filters/concatenate_bytes/struct.Config.html))
Expand Down
17 changes: 8 additions & 9 deletions docs/src/filters/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ quilkin.filters.debug_filter.v1alpha1.Debug
```rust
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.debug.v1alpha1.Debug
config:
id: debug-1
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.debug.v1alpha1.Debug
config:
id: debug-1
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 1);
# quilkin::Server::try_from(config).unwrap();
```

### Configuration Options ([Rust Doc](../../api/quilkin/filters/debug/struct.Config.html))
Expand Down
37 changes: 18 additions & 19 deletions docs/src/filters/firewall.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,26 @@ quilkin.filters.firewall.v1alpha1.Firewall
```rust
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.firewall.v1alpha1.Firewall
config:
on_read:
- action: ALLOW
source: 192.168.51.0/24
ports:
- 10
- 1000-7000
on_write:
- action: DENY
source: 192.168.51.0/24
ports:
- 7000
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.firewall.v1alpha1.Firewall
config:
on_read:
- action: ALLOW
source: 192.168.51.0/24
ports:
- 10
- 1000-7000
on_write:
- action: DENY
source: 192.168.51.0/24
ports:
- 7000
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 1);
# quilkin::Server::try_from(config).unwrap();
```

### Configuration Options ([Rust Doc](../../api/quilkin/filters/firewall/struct.Config.html))
Expand Down
17 changes: 8 additions & 9 deletions docs/src/filters/load_balancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ quilkin.filters.load_balancer.v1alpha1.LoadBalancer
# async fn main() {
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.load_balancer.v1alpha1.LoadBalancer
config:
policy: ROUND_ROBIN
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.load_balancer.v1alpha1.LoadBalancer
config:
policy: ROUND_ROBIN
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 1);
# quilkin::Server::try_from(config).unwrap();
# }
```

Expand Down
19 changes: 9 additions & 10 deletions docs/src/filters/local_rate_limit.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@ quilkin.filters.local_rate_limit.v1alpha1.LocalRateLimit
# async fn main() {
# let yaml = "
version: v1alpha1
static:
filters:
- name: quilkin.filters.local_rate_limit.v1alpha1.LocalRateLimit
config:
max_packets: 1000
period: 1
endpoints:
- address: 127.0.0.1:7001
filters:
- name: quilkin.filters.local_rate_limit.v1alpha1.LocalRateLimit
config:
max_packets: 1000
period: 1
endpoints:
- address: 127.0.0.1:7001
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 1);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 1);
# quilkin::Server::try_from(config).unwrap();
# }
```
To configure a rate limiter, we specify the maximum rate at which the proxy is allowed to forward packets. In the example above, we configured the proxy to forward a maximum of 1000 packets per second).
Expand Down
39 changes: 19 additions & 20 deletions docs/src/filters/match.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,28 @@ quilkin.filters.match.v1alpha1.Match
```rust
# let yaml = "
version: v1alpha1
static:
endpoints:
- address: 127.0.0.1:26000
- address: 127.0.0.1:26001
filters:
- name: quilkin.filters.capture_bytes.v1alpha1.CaptureBytes
config:
strategy: PREFIX
endpoints:
- address: 127.0.0.1:26000
- address: 127.0.0.1:26001
filters:
- name: quilkin.filters.capture_bytes.v1alpha1.CaptureBytes
config:
strategy: PREFIX
metadataKey: myapp.com/token
size: 3
remove: false
- name: quilkin.filters.match.v1alpha1.Match
config:
on_read:
metadataKey: myapp.com/token
size: 3
remove: false
- name: quilkin.filters.match.v1alpha1.Match
config:
on_read:
metadataKey: myapp.com/token
branches:
- value: abc
filter: quilkin.filters.pass.v1alpha1.Pass
fallthrough: quilkin.filters.drop.v1alpha1.Drop
branches:
- value: abc
filter: quilkin.filters.pass.v1alpha1.Pass
fallthrough: quilkin.filters.drop.v1alpha1.Drop
# ";
# let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
# assert_eq!(config.source.get_static_filters().unwrap().len(), 2);
# quilkin::Builder::from(std::sync::Arc::new(config)).validate().unwrap();
# assert_eq!(config.filters.load().len(), 2);
# quilkin::Server::try_from(config).unwrap();
```
<!-- ANCHOR_END: example -->

Expand Down
Loading

0 comments on commit 03d290a

Please sign in to comment.