Skip to content
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

Ensure Cloudflare is returning a valid IP address before comparing old_ip to current IP #73

Open
octopop opened this issue Nov 3, 2023 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@octopop
Copy link

octopop commented Nov 3, 2023

Cloudflare API is down today and as a result at random returns the following instead of the IP address:
{"success":false,"errors":[{"code":10000,"message":"Internal authentication error: internal server error"}]}

The causes $old_ip == $ip to fail and force a IP update.

FIX:
Sanitize and ensure that the returned string from the API call is actually an IP before comparing. Suggested snippet below adds a comparison to ensure $old_ip is a valid IP first:

if [[ $old_ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then # <== NEW

        # Compare if they're the same
        if [[ $ip == $old_ip ]]; then
        logger "DDNS Updater: IP ($ip) for ${record_name} has not changed."
        exit 0
        fi
fi
@K0p1-Git K0p1-Git added the enhancement New feature or request label Nov 3, 2023
@K0p1-Git
Copy link
Owner

K0p1-Git commented Nov 3, 2023

Hi if possible, please submit a pull request!

@K0p1-Git K0p1-Git added the bug Something isn't working label Nov 3, 2023
@Sailboat265
Copy link
Contributor

Interesting. So Cloudflare will return an JSON response if it's down, and seemingly with a HTTP response code of 200.

Ahhhh I see, that's why my patch fix of catching the HTTP response code didn't work last time on issue #44.

Anyways, just wanna say that ensuring $old_ip is valid should effectively clear out the infamous double Discord webhook bug here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants