Utoljára aktív 1 month ago

nuno gist felülvizsgálása 1 month ago. Revízióhoz ugrás

1 file changed, 36 insertions

gistfile1.txt(fájl létrehozva)

@@ -0,0 +1,36 @@
1 + function peers::create_client_config() {
2 + local name="$1"
3 + local type="$2"
4 + local ip="$3"
5 + local allowed_ips="${4:-$(config::allowed_ips_for "split")}"
6 +
7 + local conf
8 + conf="$(ctx::clients)/${name}.conf"
9 +
10 + if [[ -f "$conf" ]]; then
11 + log::wg_warning "Client config already exists: ${name}"
12 + return 1
13 + fi
14 +
15 + local private_key
16 + private_key=$(keys::private "$name")
17 +
18 + local server_public_key
19 + server_public_key=$(config::server_public_key)
20 +
21 + cat > "$conf" <<EOF
22 + [Interface]
23 + PrivateKey = ${private_key}
24 + Address = ${ip}/32
25 + DNS = $(config::dns)
26 +
27 + [Peer]
28 + PublicKey = ${server_public_key}
29 + Endpoint = $(config::endpoint)
30 + AllowedIPs = ${allowed_ips}
31 + PersistentKeepalive = 25
32 + EOF
33 +
34 + chmod 600 "$conf"
35 + log::debug "Created client config: ${name} (${ip})"
36 + }
Újabb Régebbi