dyn_dns
This commit is contained in:
@@ -49,11 +49,13 @@ let dns-user = "cloudflare"; in
|
||||
} /* python */ ''
|
||||
import requests
|
||||
import subprocess
|
||||
from time import sleep
|
||||
|
||||
def get_public_ip(ipv6: bool = False) -> str:
|
||||
return subprocess.run(['${pkgs.curl}/bin/curl', '-s', '-6' if ipv6 else '-4', 'https://ifconfig.me'], capture_output=True, text=True).stdout.strip()
|
||||
|
||||
def update_record(record_id: str, record_name: str, ip: str, type: str, proxied: bool, pw: str) -> None:
|
||||
sleep(5)
|
||||
return requests.patch(
|
||||
f'https://api.cloudflare.com/client/v4/zones/${zone_id}/dns_records/{record_id}',
|
||||
headers={
|
||||
|
||||
22
system-modules/nx2site/dyn_dns.nix
Normal file
22
system-modules/nx2site/dyn_dns.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{ config, pkgs, domain, ... }:
|
||||
{
|
||||
sops.secrets = {
|
||||
# "nx2site/namecheap.pw" = { };
|
||||
# "nx2site/cloudflare/api-token-dns-edit" = { };
|
||||
"nx2site/cloudflare/global-api-key-env" = {
|
||||
owner = "root";
|
||||
};
|
||||
};
|
||||
services.cloudflare-dyndns = {
|
||||
enable = true;
|
||||
ipv4 = true;
|
||||
ipv6 = config.networking.enableIPv6;
|
||||
domains = [
|
||||
"${domain}"
|
||||
"*.${domain}"
|
||||
"ssh.${domain}"
|
||||
];
|
||||
proxied = true;
|
||||
apiTokenFile = config.sops.secrets."nx2site/cloudflare/global-api-key-env".path;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user