function peers::create_client_config() {
  local name="$1"
  local type="$2"
  local ip="$3"
  local allowed_ips="${4:-$(config::allowed_ips_for "split")}"

  local conf
  conf="$(ctx::clients)/${name}.conf"

  if [[ -f "$conf" ]]; then
    log::wg_warning "Client config already exists: ${name}"
    return 1
  fi

  local private_key
  private_key=$(keys::private "$name")

  local server_public_key
  server_public_key=$(config::server_public_key)

  cat > "$conf" <<EOF
[Interface]
PrivateKey = ${private_key}
Address = ${ip}/32
DNS = $(config::dns)

[Peer]
PublicKey = ${server_public_key}
Endpoint = $(config::endpoint)
AllowedIPs = ${allowed_ips}
PersistentKeepalive = 25
EOF

  chmod 600 "$conf"
  log::debug "Created client config: ${name} (${ip})"
}