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

Discord webhook posting when the IP hasn't changed. #44

Closed
rossiscool123 opened this issue Jul 9, 2022 · 24 comments
Closed

Discord webhook posting when the IP hasn't changed. #44

rossiscool123 opened this issue Jul 9, 2022 · 24 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@rossiscool123
Copy link

Got multiple webhook notifications saying its detected a new IP but the IP is exactly the same, its not consistent but random instead. The script is being ran every minute with CRON. Here's a screenshot for reference.
20220709023627

@rossiscool123
Copy link
Author

@K0p1-Git

@K0p1-Git
Copy link
Owner

I'm currently away, in the mean time @agingorange will you be able to help take a look?

@K0p1-Git K0p1-Git added bug Something isn't working help wanted Extra attention is needed labels Aug 6, 2022
@harukodi
Copy link

Same problem here! Any update on this issue?

@Sailboat265
Copy link
Contributor

Heya! This bug is really hard to track down, but I highly suspect that maybe the issue arises when the script failed to get a valid response at the getting dns_records step.

Am I sure about that? Hell no! At most cases, the credentials used in the script should hardly change, unless someone rotated their passwords or else.

However, there are instances where Cloudflare API servers are having a hard time both in June & July, which will cause API request to be dropped, or failed. But at that time frame, they said only Russia users are affected sooo....... yeah, weird.

Sorry for the essay like comment, but anyways!

Try editing the script's code from line 49, original code looks like

logger "DDNS Updater: Check Initiated"
record=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records?type=A&name=$record_name" \
                      -H "X-Auth-Email: $auth_email" \
                      -H "$auth_header $auth_key" \
                      -H "Content-Type: application/json")

Change it to this

logger "DDNS Updater: Check Initiated"
record=$(curl --write-out "%{http_code}" -s -X GET "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records?type=A&name=$record_name" \
                      -H "X-Auth-Email: $auth_email" \
                      -H "$auth_header $auth_key" \
                      -H "Content-Type: application/json")

record_status=$(echo $record | tail -c 4)

if (( $record_status >= 400 && $record_status <= 530 )); then
  logger -s "DDNS Updater: Error while checking record identifier!"
  exit 1
fi

Since I have no idea when Cloudflare server suffers outages, will it still manage to return a JSON response so we can match it with case in "\"success\":false". So I just changed it to match a range of HTTP Status Code from 400 to 530.

I'm not making a PR for now, because I still don't know if the problem is exactly it or not.
So please, go and change the code, and see if that really fixed the issue.

Thank you for reading the news-alike comment.

@harukodi
Copy link

Thanks for the fast response! I hope this can help a lot of people thanks a lot! 你太棒了!

@rossiscool123
Copy link
Author

So far this fix is looking good @Sailboat265 but its only been running for 3 days, time will tell if it has the same issue. Regardless good fix and hopefully gets pulled into the next release. 👍

@Nevah5
Copy link

Nevah5 commented Oct 31, 2022

image

Same issue. Maybe it could be related to my ISP, but I think this would have been detected by the script.
Very weird. I will try to debug, maybe I'll find something.

@rossiscool123
Copy link
Author

@Nevah5 Have you applied this fix? It has worked for mine.
#44 (comment)

@Nevah5
Copy link

Nevah5 commented Nov 2, 2022

@Nevah5 Have you applied this fix? It has worked for mine.

#44 (comment)

Whoops, I thought I did it, but I might have forgotten to save it. Still weird behaviour though, because it seems like it didn't log anything since a few days ago.

@rossiscool123
Copy link
Author

@Sailboat265
Issue has come back and is still reporting the same IP address.
20221215201620

@harukodi
Copy link

@rossiscool123
Copy link
Author

@harukodi
I don't think they even support Discord webhooks which is why I stuck with this option. The false positives aren't a deal breaker but should be still be considered a bug. Thanks anyway.

@Sailboat265
Copy link
Contributor

Uhhh damn... It's not the problem of dns_records then...?

@rossiscool123 Can you copy and paste your running script here? (Rmb to remove the sensitive credentials info).

@rossiscool123
Copy link
Author

DDNS.txt
Ignore my terrible exiting for the Discord response. 😅
@Sailboat265

@Sailboat265
Copy link
Contributor

Hi, sorry for the late response, uni stuff's catching up a bit...

nahhh, your exiting is alright.
Sorry for asking silly questions but how did you know that the new IP is same as old IP?

@rossiscool123
Copy link
Author

Hi, sorry for the late response, uni stuff's catching up a bit...

nahhh, your exiting is alright. Sorry for asking silly questions but how did you know that the new IP is same as old IP?

Not quire sure what you mean by "how did you know that the new IP is same as old IP?" Here's a screenshot of my issue.
20221220033005

@rossiscool123
Copy link
Author

The issue that's happening is I'm being pinged about my IP changing when it has in fact not changed at all, I can only assume others are experiencing this and just haven't reported it.

@rossiscool123
Copy link
Author

@Sailboat265

@Sailboat265
Copy link
Contributor

@rossiscool123 Thanks for re-explaining it again! I think I need some sleep lmao, been very forgetful about things.

The issue that's happening is I'm being pinged about my IP changing when it has in fact not changed at all, I can only assume others are experiencing this and just haven't reported it.

Hmmm strange, I've not got any notice of this potential bug even though the script has been running on my raspi for months ady

@Sailboat265
Copy link
Contributor

@rossiscool123 Uhhh sorry, can you go try sudo cat /var/log/syslog | grep DDNS

Then, make sure to find the line, that matches exactly the date, and time where the duplicate ping was triggered.

Maybe that could shred some light on what's actually going on...

@rossiscool123
Copy link
Author

image

Hope you don't mind I censored the last bit of my IP and the domains its resolving to. I couldn't get any data further than this and trying to get more data ended up killing my SSH connection.

@rossiscool123
Copy link
Author

@Sailboat265

@Sailboat265
Copy link
Contributor

@rossiscool123 Thanks so much for the screenshot.

Can you send a screenshot of discord message as well? Between Dec 18 00:39 to 00:51.

Ohhh and pls mark the duplicated message again like you did, since only you can see the full IP.

@rossiscool123
Copy link
Author

Fix for now.
#50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants