Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename sender/receiver to client/server #23

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ It is designed to be used behind game clients as well as in front of dedicated g

## Planned Roadmap

- [x] Sender: Configuration with a connection token
- [x] Receiver: Configuration of endpoints with multiple connection token attached, that provide routing
- [ ] 👷 Basic non-transparent UDP forwarding from Sender to Receiver
- [ ] 👷 Basic non-transparent UDP forwarding from Receiver to all endpoints
- [ ] Simple UDP routing via an appended connection ID to UDP packet (sender and receiver implementation)
- [ ] QUIC based security and UDP routing (sender and receiver implementation)
- [x] Client Proxy: Configuration with a connection token
- [x] Server Proxy: Configuration of endpoints with multiple connection token attached, that provide routing
- [ ] 👷 Basic non-transparent UDP forwarding from Client Proxy to Server Proxy
- [ ] 👷 Basic non-transparent UDP forwarding from Server Proxy to all Endpoints
- [ ] Simple UDP routing via an appended connection ID to UDP packet (Client and Server Proxy implementation)
- [ ] QUIC based security and UDP routing (Client and Server Proxy implementation)
- [ ] gRPC configuration management control plane API
- [ ] Add Open Telemetry metrics

Expand All @@ -24,28 +24,28 @@ Not to be used in production systems.

## Proposed Architecture
```
+ +
| |
Internet Private
| Network
| +-------------+ | +----------------+
| |Quilkin Proxy| | | Dedicated Game |
| +-->+(Receiver) +---------+------> Server |
+---------+ +-------------+ | | | | | | | |
| Game | |Quilkin Proxy+------+ --------------+ | | +----------------+
| Client +------>+(Sender) | | | | |
+---------+ +-------------+ | | +-------------+ | | +----------------+
| | |Quilkin Proxy| | | | Dedicated Game |
| +-->+(Receiver) +---------+ | Server |
| | | | | |
| +-------------+ | +----------------+
| |
| +-------------+ | +----------------+
| |Quilkin Proxy| | | Dedicated Game |
| |(Receiver) | | | Server |
| | | | | |
| +-------------+ | +----------------+
+ +
+ +
+ |
Internet Private
+ Network
| +----------------+ + +----------------+
| | Quilkin | | | Dedicated |
| +--> (Server Proxy) +-------+------> Game Server |
+---------+ +----------------+ | | | | | | | |
| Game | | Quilkin +-------+ +----------------+ | | +----------------+
| Client +------+ (Client Proxy) | | | | |
+---------+ +----------------+ | | +----------------+ | | +----------------+
| | | Quilkin | | | | Dedicated |
| +--> (Server Proxy) +-------+ | Game Server |
| | | | | |
| +----------------+ | +----------------+
| |
| +----------------+ | +----------------+
| | Quilkin | | | Dedicated |
| | (Server Proxy) | | | Game Server |
| | | | | |
| +----------------+ | +----------------+
+ +
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions examples/sender.yaml → examples/client-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#

#
# Example configuration for a game client sender
# Example configuration for a Quilkin Proxy that sits behind a game clients
#

local:
port: 7000 # the port to receive traffic to locally
sender_config:
client:
address: 127.0.0.1:7001 # the address to send traffic to
connection_id: 1x7ijy6 # the connection string to attach to the traffic
4 changes: 2 additions & 2 deletions examples/reciever.yaml → examples/server-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#

#
# Example configuration for Game server receivers
# Example configuration for a Quilkin Proxy that sits in front of dedicated game servers
#

local:
port: 7001 # the port to receive traffic to locally
receiver_config:
server:
endpoints: # array of potential endpoints to send on traffic to
- name: Game Server No. 1
address: 127.0.0.1:26000
Expand Down
67 changes: 33 additions & 34 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use serde::{Deserialize, Serialize};
use serde_yaml::Error;
use std::collections::HashMap;

// SENDER_ENDPOINT is because we need a name for the sender config
const SENDER_ENDPOINT: &str = "address";
// CLIENT_ENDPOINT is because we need a name for the client endpoint configuration
const CLIENT_ENDPOINT: &str = "address";

/// Config is the configuration for either a sender or a receiver
/// Config is the configuration for either a Client or Server proxy
#[derive(Debug, Deserialize, Serialize)]
pub struct Config {
pub local: Local,
Expand All @@ -33,19 +33,19 @@ pub struct Config {
}

impl Config {
/// get_endpoints get a list of all endpoints as a HashMap. For a Sender,
/// the key is "address", for the Receiver the key is the name provided.
/// get_endpoints get a list of all endpoints as a HashMap. For a Client proxy,
/// the key is "address", for a Server proxy the key is the name provided.
pub fn get_endpoints(&self) -> HashMap<String, SocketAddr> {
return match &self.connections {
ConnectionConfig::Sender {
ConnectionConfig::Client {
address,
connection_id: _,
} => {
let mut map: HashMap<String, SocketAddr> = HashMap::new();
map.insert(String::from(SENDER_ENDPOINT), *address);
map.insert(String::from(CLIENT_ENDPOINT), *address);
return map;
}
ConnectionConfig::Receiver { endpoints } => {
ConnectionConfig::Server { endpoints } => {
endpoints.iter().fold(HashMap::new(), |mut m, entrypoint| {
m.insert(entrypoint.name.clone(), entrypoint.address);
return m;
Expand All @@ -61,20 +61,19 @@ pub struct Local {
pub port: u16,
}

/// ConnectionConfig is the configuration for either a sender or receivers
/// ConnectionConfig is the configuration for either a Client or Server proxy
#[derive(Debug, Deserialize, Serialize)]
pub enum ConnectionConfig {
/// SenderConfig is the configuration for the sender, such as when sitting behind a game client.
#[serde(rename = "sender_config")]
Sender {
/// Client is the configuration for a client proxy, for sitting behind a game client.
#[serde(rename = "client")]
Client {
address: SocketAddr,
connection_id: String,
},

/// Receiver is the configuration for a recievers, such as a proxy that sits in front of a
/// set of Dedicated Game Servers.
#[serde(rename = "receiver_config")]
Receiver { endpoints: Vec<EndPoint> },
/// Server is the configuration for a Dedicated Game Server proxy
#[serde(rename = "server")]
Server { endpoints: Vec<EndPoint> },
}

/// A singular endpoint, to pass on UDP packets to.
Expand All @@ -93,14 +92,14 @@ pub fn from_reader<R: io::Read>(input: R) -> Result<Config, Error> {

#[cfg(test)]
mod tests {
use crate::config::{from_reader, Config, ConnectionConfig, EndPoint, Local, SENDER_ENDPOINT};
use crate::config::{from_reader, Config, ConnectionConfig, EndPoint, Local, CLIENT_ENDPOINT};
use std::collections::HashMap;

#[test]
fn deserialise_sender() {
fn deserialise_client() {
let config = Config {
local: Local { port: 7000 },
connections: ConnectionConfig::Sender {
connections: ConnectionConfig::Client {
address: "127.0.0.1:25999".parse().unwrap(),
connection_id: String::from("1234"),
},
Expand All @@ -110,10 +109,10 @@ mod tests {
}

#[test]
fn deserialise_receiver() {
fn deserialise_server() {
let config = Config {
local: Local { port: 7000 },
connections: ConnectionConfig::Receiver {
connections: ConnectionConfig::Server {
endpoints: vec![
EndPoint {
name: String::from("No.1"),
Expand All @@ -133,34 +132,34 @@ mod tests {
}

#[test]
fn parse_sender() {
fn parse_client() {
let yaml = "
local:
port: 7000
sender_config:
client:
address: 127.0.0.1:25999
connection_id: 1x7ijy6";
let config = from_reader(yaml.as_bytes()).unwrap();
assert_eq!(7000, config.local.port);
match config.connections {
ConnectionConfig::Sender {
ConnectionConfig::Client {
address,
connection_id,
} => {
assert_eq!("1x7ijy6", connection_id);
assert_eq!("127.0.0.1:25999", address.to_string())
}
ConnectionConfig::Receiver { .. } => panic!("Should not be a receiver"),
ConnectionConfig::Server { .. } => panic!("Should not be a receiver"),
}
}

#[test]
fn parse_receiver() {
fn parse_server() {
let yaml = "
---
local:
port: 7000
receiver_config:
server:
endpoints:
- name: Game Server No. 1
address: 127.0.0.1:26000
Expand All @@ -174,8 +173,8 @@ receiver_config:
let config = from_reader(yaml.as_bytes()).unwrap();
assert_eq!(7000, config.local.port);
match config.connections {
ConnectionConfig::Sender { .. } => panic!("Should not be a sender"),
ConnectionConfig::Receiver { endpoints } => {
ConnectionConfig::Client { .. } => panic!("Should not be a Client"),
ConnectionConfig::Server { endpoints } => {
let expected = vec![
EndPoint {
name: String::from("Game Server No. 1"),
Expand All @@ -194,28 +193,28 @@ receiver_config:
}

#[test]
fn get_endpoints_sender() {
fn get_endpoints_client() {
let expected_addr = "127.0.0.1:8080".parse().unwrap();
let config = Config {
local: Local { port: 0 },
connections: ConnectionConfig::Sender {
connections: ConnectionConfig::Client {
address: expected_addr,
connection_id: "".to_string(),
},
};

let mut expected = HashMap::new();
expected.insert(String::from(SENDER_ENDPOINT), expected_addr);
expected.insert(String::from(CLIENT_ENDPOINT), expected_addr);
assert_eq!(expected, config.get_endpoints());
}

#[test]
fn get_endpoints_receiver() {
fn get_endpoints_server() {
let yaml = "
---
local:
port: 7000
receiver_config:
server:
endpoints:
- name: Game Server No. 1
address: 127.0.0.1:26000
Expand Down
12 changes: 6 additions & 6 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ impl Server {
fn log_config(&self, config: &Arc<Config>) {
info!(self.log, "Starting on port {}", config.local.port);
match &config.connections {
ConnectionConfig::Sender { address, .. } => {
info!(self.log, "Sender configuration"; "address" => address)
ConnectionConfig::Client { address, .. } => {
info!(self.log, "Client proxy configuration"; "address" => address)
}
ConnectionConfig::Receiver { endpoints } => {
info!(self.log, "Receiver configuration"; "endpoints" => endpoints.len())
ConnectionConfig::Server { endpoints } => {
info!(self.log, "Server proxy configuration"; "endpoints" => endpoints.len())
}
};
}
Expand Down Expand Up @@ -288,7 +288,7 @@ mod tests {
async fn server_bind() {
let config = Config {
local: Local { port: 12345 },
connections: ConnectionConfig::Receiver {
connections: ConnectionConfig::Server {
endpoints: Vec::new(),
},
};
Expand All @@ -306,7 +306,7 @@ mod tests {

let config = Arc::new(Config {
local: Local { port: 0 },
connections: ConnectionConfig::Sender {
connections: ConnectionConfig::Client {
address: local_addr,
connection_id: String::from(""),
},
Expand Down