Change 'New' command to 'Create'

This commit is contained in:
Erik 2023-03-22 14:54:28 +01:00
parent bff9ce6d85
commit 87cdad3cc2
2 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
curl --header "Content-Type: application/json" \ curl --header "Content-Type: application/json" \
--data '{"command": { --data '{"command": {
"New": { "Create": {
"incoming_port": 5555, "incoming_port": 5555,
"destination_port": 8080, "destination_port": 8080,
"destination_ip": "127.0.0.1", "destination_ip": "127.0.0.1",

View File

@ -29,7 +29,7 @@ impl ProxyCommand {
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
enum Command { enum Command {
New { Create {
incoming_port: u16, incoming_port: u16,
destination_port: u16, destination_port: u16,
destination_ip: IpAddr, destination_ip: IpAddr,
@ -90,7 +90,7 @@ pub async fn process_command(
); );
} }
match payload.command { match payload.command {
Command::New { Command::Create {
incoming_port, incoming_port,
destination_port, destination_port,
destination_ip, destination_ip,
@ -253,11 +253,11 @@ mod tests {
use uuid::uuid; use uuid::uuid;
#[test] #[test]
fn serialize_proxy_command_new() { fn serialize_proxy_command_create() {
let key = SigningKey::from_slice(&[1; 48]).unwrap(); let key = SigningKey::from_slice(&[1; 48]).unwrap();
let signature = key.sign(&[]); // Not a valid signature let signature = key.sign(&[]); // Not a valid signature
let proxy_command = ProxyCommand { let proxy_command = ProxyCommand {
command: Command::New { command: Command::Create {
incoming_port: 5555, incoming_port: 5555,
destination_port: 6666, destination_port: 6666,
destination_ip: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), destination_ip: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
@ -265,7 +265,7 @@ mod tests {
}, },
signature, signature,
}; };
let expected = "{\"command\":{\"New\":{\"incoming_port\":5555,\"destination_port\":6666,\"\ let expected = "{\"command\":{\"Create\":{\"incoming_port\":5555,\"destination_port\":6666,\"\
destination_ip\":\"127.0.0.1\",\"id\":\"67e55044-10b1-426f-9247-bb680e5fe0c8\"}},\ destination_ip\":\"127.0.0.1\",\"id\":\"67e55044-10b1-426f-9247-bb680e5fe0c8\"}},\
\"signature\":\"\ \"signature\":\"\
5C912C4B3BFF2ADB49885DCBDB53D6D3041D0632E498CDFF\ 5C912C4B3BFF2ADB49885DCBDB53D6D3041D0632E498CDFF\
@ -299,7 +299,7 @@ mod tests {
#[test] #[test]
fn verify_signature() { fn verify_signature() {
let command = Command::New { let command = Command::Create {
incoming_port: 4567, incoming_port: 4567,
destination_port: 7654, destination_port: 7654,
destination_ip: IpAddr::V4(Ipv4Addr::new(123, 23, 76, 21)), destination_ip: IpAddr::V4(Ipv4Addr::new(123, 23, 76, 21)),