From cccbfb22bc741f28e6e13bfdd0d40ee883fafc97 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Thu, 28 Mar 2024 16:52:55 +0530 Subject: [PATCH] chore(examples): include peer example --- examples/peer.luau | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/peer.luau diff --git a/examples/peer.luau b/examples/peer.luau new file mode 100644 index 0000000..234eb00 --- /dev/null +++ b/examples/peer.luau @@ -0,0 +1,35 @@ +local wg = require("../out").wireguard + +local CODEGEN_TEMPLATE = [[[NetDev] +Name=wg0 +Kind=wireguard + +[WireGuard] +PrivateKey = %s +# PublicKey = %s +ListenPort = 51820 + +[WireGuardPeer] +PublicKey = %s +AllowedIPs = 0.0.0.0/0 +PersistentKeepalive = 25]] + +function main() + local bob = wg:generateKeypair() + local alice = wg:generateKeypair() + + local bob_config = CODEGEN_TEMPLATE:format(bob.privateKey, bob.publicKey, alice.publicKey) + local alice_config = CODEGEN_TEMPLATE:format(alice.privateKey, alice.publicKey, bob.publicKey) + + print("########################## BOB'S CONFIG ##########################") + print(bob_config) + print("##################################################################") + + print() + + print("######################### ALICE'S CONFIG #########################") + print(alice_config) + print("##################################################################") +end + +return main()