mirror of
https://github.com/0x5eal/wg-lua.git
synced 2024-12-12 04:40:36 +00:00
chore(examples): include peer example
This commit is contained in:
parent
ca3b9bfb09
commit
cccbfb22bc
1 changed files with 35 additions and 0 deletions
35
examples/peer.luau
Normal file
35
examples/peer.luau
Normal file
|
@ -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()
|
Loading…
Reference in a new issue