-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigGenerator.php
More file actions
35 lines (28 loc) · 1.04 KB
/
configGenerator.php
File metadata and controls
35 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
if ($_SERVER['REQUEST_METHOD'] === 'GET') { exit; }
require_once 'standardDefinitions.php';
function generateConfiguration($privilegeLevel,$theIP,$theNetmask,$clientPrivateKey)
{
global $theServerIP;
global $standardServerParameters;
$localServerParameters=$standardServerParameters[$privilegeLevel];
$configurationTemplate = array(
0 => '# Generated by FMI\'s WireguardLDAP',
1 => '# Who to blame if it doesn\'t work: alexandru.kiraly@ubbcluj.ro',
2 => '[Interface]',
3 => 'Address = '.$theIP.'/'.$theNetmask,
4 => 'PrivateKey = '.$clientPrivateKey,
5 => 'DNS = 172.30.0.1',
6 => '[Peer]',
7 => 'PublicKey = '.$localServerParameters['pubKey'],
8 => 'AllowedIPs = '.$localServerParameters['allowedIPs'],
9 => 'Endpoint = '.$theServerIP.':'.$localServerParameters['port'],
10 => 'PersistentKeepalive = 25'
);
$configurationResult = "";
foreach ($configurationTemplate as $configurationLine)
{
$configurationResult = $configurationResult.$configurationLine."\n";
}
return $configurationResult;
}