-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: missing field multiple_railguns_allowed
#57
Comments
After encountering this issue, I've ended up switching to a systemd service and I figured I would share, I've made it so that I do not need to manually find the zone and record ids like other example code I found does. Note the customized parts of the domains, the interface (enp2s0), and the api token, which has edit dns permissions on all zones and read permissions on zones. systemd.services.cfdyndns = {
serviceConfig.Type = "oneshot";
after = [ "network.target" ];
path = with pkgs; [curl iproute2 gawk dig jq];
script = ''
declare -a DOMAINS=(
"*.diekvoss.net"
"mc.toyvo.dev"
)
TOKEN=${builtins.readFile ./cfapitoken}
function put_record() {
curl -sS -X PUT \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d "{\"type\":\"A\",\"name\":\"$3\",\"content\":\"$4\",\"ttl\":1,\"proxied\":false}" \
"https://api.cloudflare.com/client/v4/zones/$1/dns_records/$2"
}
function get_ip() {
curl -sS \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
https://api.cloudflare.com/client/v4/zones/$1/dns_records/$2 | jq -r '.result.content'
}
function get_zone() {
curl -sS \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
https://api.cloudflare.com/client/v4/zones?name=$1 | jq -r '.result.[].id'
}
function get_record() {
curl -sS \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
https://api.cloudflare.com/client/v4/zones/$1/dns_records?name=$2 | jq -r '.result.[].id'
}
NEW_IP=$(ip addr show dev enp2s0 | awk '/inet / {print $2}' | cut -d '/' -f1)
echo "The IP Address of this machine is $NEW_IP"
for DOMAIN in "''${DOMAINS[@]}"
do
CURRENT_IP=$(dig +short $DOMAIN)
echo "DNS for $DOMAIN is currently set to $CURRENT_IP"
if [ "$CURRENT_IP" != "$NEW_IP" ]; then
echo "DNS for $DOMAIN Doesn't point to $NEW_IP, checking for confirmation..."
BASE_DOMAIN=$(awk -F'.' '{gsub(/^\*\./, ""); print $(NF-1) "." $NF}' <<< "$DOMAIN")
echo "Base for $DOMAIN is $BASE_DOMAIN"
ZONE=$(get_zone "$BASE_DOMAIN")
echo "Zone ID for $BASE_DOMAIN is $ZONE"
RECORD=$(get_record "$ZONE" "$DOMAIN")
echo "Record ID for $DOMAIN is $RECORD"
CONFIRM_IP=$(get_ip "$ZONE" "$RECORD")
echo "DNS for $DOMAIN is confirmed set to $CONFIRM_IP"
if [ "$CONFIRM_IP" != "$NEW_IP" ]; then
echo "Updating DNS record for $DOMAIN to $NEW_IP"
put_record "$ZONE" "$RECORD" "$DOMAIN" "$NEW_IP"
else
echo "DNS record for $DOMAIN is already set to $NEW_IP, skipping update. Assuming TTL."
fi
else
echo "DNS record for $DOMAIN is $NEW_IP, skipping update."
fi
done
'';
startAt = "*:0/5";
}; Note I did not design this to handle 2tld like .co.uk etc |
This is related to cloudflare/cloudflare-rs#236 |
It sounds as simple as removing a field. I'll take a look upstream later it should be quite a simple crate patch that we can apply quickly 🤞 |
I ended up doing the same as @ToyVo and created a bash script as a replacement to cfdyndns (and it does less requests since it's not restricted by If anyone wants to copy it: I appreciate all the work @nrdxp has done for this project, but it seems cloudflare's crate is giving some headaches at the moment 😅 |
I've made a PR to fix this (#60), and a PR on the upstream cloudflare-rs (cloudflare/cloudflare-rs#240), although considering they haven't yet merged cloudflare/cloudflare-rs#232 yet I don't have high hopes that mine will be merged anytime soon. I'm happy to update the nixpkgs when this gets merged, unless anybody else wants to. For now, you can override the source to point to my repo, as shown in https://nixos.wiki/wiki/Overlays#Overriding_a_version |
Haha yeah I really need to put in the work for sops |
Seems like a change in Cloudflare's API?
Config: https://github.com/diogotcorreia/dotfiles/blob/bf6f0ee0fbf956d0983308f7270d7b7698e8d57d/hosts/bro/default.nix#L76-L80
Keep in mind that I'm using a patch from #56 as well.
cc @nrdxp
The text was updated successfully, but these errors were encountered: