From c2d27b4da2b7ce6de98bbb4f61f89a053fe9c372 Mon Sep 17 00:00:00 2001 From: Hackerprod Date: Sat, 12 Aug 2023 08:37:38 -0400 Subject: [PATCH] Wireguard implementation (#92) * Add files via upload Wireguard peer implementation * Wireguard interface implementation --- .../Interface/InterfaceWireguard.cs | 58 ++++++++++++++++ tik4net.objects/Wireguard/WireguardPeer.cs | 68 +++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 tik4net.objects/Interface/InterfaceWireguard.cs create mode 100644 tik4net.objects/Wireguard/WireguardPeer.cs diff --git a/tik4net.objects/Interface/InterfaceWireguard.cs b/tik4net.objects/Interface/InterfaceWireguard.cs new file mode 100644 index 0000000..aac1712 --- /dev/null +++ b/tik4net.objects/Interface/InterfaceWireguard.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace tik4net.Objects.Interface +{ + /// + /// Wireguard Interface + /// + [TikEntity("/interface/wireguard")] + public class InterfaceWireguard + { + /// + /// .id: primary key of row + /// + [TikProperty(".id", IsReadOnly = true, IsMandatory = true)] + public string Id { get; private set; } + + /// + /// Name of the wireguard interface + /// + [TikProperty("name")] + public string Name { get; set; } + + /// + /// comment: Short description of the Peer. + /// + [TikProperty("comment")] + public string Comment { get; set; } + + /// + /// disabled: Whether peer will be used. + /// + [TikProperty("disabled", DefaultValue = "no")] + public bool Disabled { get; set; } + + /// + /// mtu: Layer3 Maximum transmission unit + /// + /// integer [0..65536] + /// + [TikProperty("mtu", DefaultValue = "1420")] + public int /*integer [0..65536]*/ Mtu { get; set; } + + /// + /// The private key associated with the local device + /// + [TikProperty("private-key")] + public string PrivateKey { get; set; } + + /// + /// Interface listen port + /// + [TikProperty("listen-port", DefaultValue = "13231")] + public int ListenPort { get; set; } + } +} diff --git a/tik4net.objects/Wireguard/WireguardPeer.cs b/tik4net.objects/Wireguard/WireguardPeer.cs new file mode 100644 index 0000000..5527fac --- /dev/null +++ b/tik4net.objects/Wireguard/WireguardPeer.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace tik4net.Objects.Wireguard +{ + /// + /// Specific remote entity or device with which the local device establishes a secure communication tunnel + /// + [TikEntity("/interface/wireguard/peers")] + public class WireguardPeer + { + /// + /// .id: primary key of row + /// + [TikProperty(".id", IsReadOnly = true, IsMandatory = true)] + public string Id { get; private set; } + + /// + /// IP addresses or subnets that are allowed to communicate with that peer + /// + [TikProperty("allowed-address")] + public string AllowedAddress { get; set; } + + /// + /// comment: Short description of the Peer. + /// + [TikProperty("comment")] + public string Comment { get; set; } + + /// + /// disabled: Whether peer will be used. + /// + [TikProperty("disabled", DefaultValue = "no")] + public bool Disabled { get; set; } + + /// + /// Specifies the local network interface that the peer is associated with + /// + [TikProperty("interface", DefaultValue = "")] + public string Interface { get; set; } + + /// + /// shared secret cryptographic key that is preconfigured between two peers + /// + [TikProperty("preshared-key", DefaultValue = "")] + public string PresharedKey { get; set; } + + /// + /// The IP address and port number of the remote endpoint or server that the peer will connect to. + /// + [TikProperty("endpoint-address")] + public string EndpointAddress { get; set; } + + /// + /// Specifies the specific port number on the remote endpoint or server that the peer will connect to. + /// + [TikProperty("endpoint-port")] + public int EndpointPort { get; set; } + + /// + /// The public key associated with the remote peer + /// + [TikProperty("public-key" )] + public string PublicKey { get; set; } + } +}