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

fix: Double sending webhooks #50

Closed
wants to merge 1 commit into from

Conversation

psycho-neon
Copy link

@psycho-neon psycho-neon commented Jan 6, 2023

Proposed fix for double sending webhooks even if IP Address did not change. What it does is it saves the ip address on a file ".cf-wan_ip_(record_name).txt" and fetches this text file every update making sure that it is comparing a valid IP address.

Proposed fix for double sending webhooks even if IP Address did not change. What it does is it saves the ip address on a file ".cf-wan_ip_<name of record>.txt" and fetches this text file every update making sure that it is comparing a valid IP address.
@psycho-neon psycho-neon changed the title Update cloudflare-template.sh fix: Double sending webhooks Jan 6, 2023
@rossiscool123
Copy link

@psycho-neon
Haven't reviewed the code yet to figure this issue out but if there's no subdomain it doesn't update. If the record name is "test.testingsite.com" it updates and sends an output from the API, if its just "testingsite.com" no output and nothing happens.

@psycho-neon
Copy link
Author

@psycho-neon

Haven't reviewed the code yet to figure this issue out but if there's no subdomain it doesn't update. If the record name is "test.testingsite.com" it updates and sends an output from the API, if its just "testingsite.com" no output and nothing happens.

Are you using global or per site token?

If its global, it should work "test.com" but if per site token, should be empty string ("").

I am using global token tho, i will try to test a per-site/zone token.

@Sailboat265
Copy link
Contributor

Nice catch! So the problem was originated from the IP verifying step all along?

@rossiscool123
Copy link

@psycho-neon
Haven't reviewed the code yet to figure this issue out but if there's no subdomain it doesn't update. If the record name is "test.testingsite.com" it updates and sends an output from the API, if its just "testingsite.com" no output and nothing happens.

Are you using global or per site token?

If its global, it should work "test.com" but if per site token, should be empty string ("").

I am using global token tho, i will try to test a per-site/zone token.

Global token.
I have two domains, one has a subdomain and the other just uses the root domain. The one with the subdomain updates the other doesn't. Weird, I had limited time to test since I was rushed for work but I'll try again tonight.

@psycho-neon
Copy link
Author

.

You can try putting "@" instead of "test.com" for the zone apex. I've checked the cf api documentation and it might work. I don't see any reason on the code to why it doesn't catches the record tho.

@rossiscool123
Copy link

Is there some sort of rate-limit implemented in your pull, it worked fine then stopped submitting requests after 3-5+ updates. I have mine on a CRON job running every minute and I did some trial and error by setting the IP on Cloudflare to 8.8.8.8 then it stopped working suddenly.

@rossiscool123
Copy link

Cloudflare logs are also empty, not update via API on the audit log. Something is stopping the request going through but I'm not sure what it is since there's not much info to go off. @psycho-neon

@psycho-neon
Copy link
Author

Cloudflare logs are also empty, not update via API on the audit log. Something is stopping the request going through but I'm not sure what it is since there's not much info to go off. @psycho-neon

there is no rate limit if i remember correctly. though you have to delete the entry .cf_wan_ip_(record name).txt located at ~/ directory to be able to test some changes. Also one more method to test where it is stopping is to echo every step. at that point you will know which line it is stopping. :-)

@MeiMeiLaiLao
Copy link

@psycho-neon
Just curious, did you actually got the double webhook issue?

Because this appears unusual. I've been running the scripts on five different Linux machines, updating several hostnames every five minutes, and I've never had this problem before.

@rossiscool123
Is it possible that there is a problem with your machine setup or your Internet connection rather than with the code itself?

@MeiMeiLaiLao
Copy link

@rossiscool123
You mentioned that the script stopped working after three to five attempts. Can you run the script with bash -x cloudflare.sh to see what it's doing?

@psycho-neon
Copy link
Author

@psycho-neon Just curious, did you actually got the double webhook issue?

Because this appears unusual. I've been running the scripts on five different Linux machines, updating several hostnames every five minutes, and I've never had this problem before.

yes i did stumble upon it a few days back. Then I sorted it out just by caching the actual ip on a file instead of getting it from cloudflare. I do not understand it either why it is happening. Though when I use my custom python script, it isn't doing this double/resending of webhooks. Could be a bad http request or timeout. But I like bash more, its native, so stayed on this script.

@rossiscool123
Copy link

@MeiMeiLaiLao @psycho-neon
Just from the output of bash -x cloudflare.sh I can see what's happening. Didn't realise it was writing the last IP to a file and using that to compare in the event of a disconnect or bad connection, which explains why it was working 3-5 times in my situation because I was actually resetting my IP then editing it on Cloudflare to test the webhook. I appreciate the help anyway. :)

@K0p1-Git
Copy link
Owner

Hi, have this fixed been tested? @psycho-neon

@psycho-neon
Copy link
Author

Hi, have this fixed been tested? @psycho-neon

Yes, I've tested this myself and using it daily. Never fails.

@rossiscool123 can confirm also. He is using it I believe.

@Sailboat265
Copy link
Contributor

_this is a repost because i forget to censor my ip lmao_

Alright, thanks for the insights from @rossiscool123, and @psycho-neon.

I did some digging and I think we have a more throughout understanding of this mysterious bug now.

As mentioned by @psycho-neon, this bug is most likely triggered by HTTP timeout, and I have the info to back up that.

It's important to take note of these points in mind first:


  1. The bug most likely wouldn't have occurred during the getting public IP step, because we have this code to check the IP format:
[[ ! $ip =~ ^$ipv4_regex$ ]]
  1. I used ip route add default via FAKE_GATEWAY_IP to effectively stimulate an internet loss situation. Then I found out that curl will fail with a 000 response code if, according to Google, No valid HTTP response code is received.
  2. curl command has a default timeout of around 200+ seconds (different distros may have a different default value)
  3. Note that Cloudflare logs won't be helpful because it only logs upon request in which an operation is executed successfully.
  4. We don't have a valid IP checking procedure on the old_ip which is extracted from the record HTTP response.

Now, I think what happened is most likely this:

  1. The script was running perfectly fine. It can get the machine's current public IP blah blah blah.
  2. Then, the network dropped when it was trying to get detailed info for the DNS record.
  3. Because of the default timeout, the curl command waited around 3 mins for a valid HTTP response.
  4. Since we need to do three curl HTTP requests, that brings us to a window timeframe of 9 mins possibility of network recovery
  5. Because of a network outage, curl returned 000 on the record HTTP request.
  6. After that, we still have a time window of 6 mins for the network to recover. If the network has recovered at any point within 6 mins. the curl command will of course complete all HTTP requests, including the discord webhook one.

Below shown is the script's logs after trying to get the record HTTP request:
image(1)

Then, the bug came up
image

I suggest we implement multiple fixes for this:


  1. Use the fix proposed by @psycho-neon to cache and check old_ip from a file
  2. Always check the validity of old_ip by reusing this code
# Use regex to check for proper IPv4 format.
if [[ ! $ip =~ ^$ipv4_regex$ ]]; then
    logger -s "DDNS Updater: Failed to find a valid IP."
    exit 2
fi
  1. It's worth mentioning even that case $update in *"\"success\":false"*) isn't properly catching failed IP update requests too. Maybe we can add an additional error-catching procedure by using the code below
update=curl --write-out "%{http_code}" <...>
update_code=$(echo $update | tail -c 4)
# If else logic to match client and server side HTTP code
<...>

TL: DR;

The webhook message duplication bug is most likely caused by a client-side network error. The network outage occurred somewhere before or while the script is getting the detailed info of a DNS record. If curl didn't get a valid HTTP response within 3 to 4 mins, a response of 000 will be returned. Sadly, the script isn't coded to deal with the 000 data response. When the script compared new_ip with old_ip, you know what happens next. In conclusion, the bug will occur if a network outage happened before the getting DNS record step is completed and lasted longer than 3 mins timeout frame. Thus the script to thinks that an IP change update is needed, hence causing webhook message duplication.

Again, this may or may not be the exact problem but it should give us an idea of what happened.

@psycho-neon
Copy link
Author

Also, we can use infinite for-loop to check the dns record constantly until it returns a valid one.

@K0p1-Git
Copy link
Owner

@Sailboat265 Great insights on this strange bug that existed for so long. I think we can proceed with a patch and see if it fixes the problem.

@psycho-neon Having an infinite loop might cause bottle neck or issues down the line. I think we can look into other means to check dns validity.

@ghost
Copy link

ghost commented Jan 20, 2023

@Sailboat265 your wrong af. The insights given are not close even to actual. Issue was the request dropped, just so simple.

@psycho-neon why have you decided to save it to a file? Why the hassle? Best use my fix #51 simple quick nice

@K0p1-Git please merge my #51 asap tq

@psycho-neon
Copy link
Author

psycho-neon commented Jan 20, 2023

@Sailboat265 your wrong af. The insights given are not close even to actual. Issue was the request dropped, just so simple.

@psycho-neon why have you decided to save it to a file? Why the hassle? Best use my fix #51 simple quick nice

@K0p1-Git please merge my #51 asap tq

Lol, he did mention about the dropped request. The f you talking about?

Doubling the request doesn't fix the issue. Your fix doesn't make any sense at all. It can still drop at any point.

@ghost
Copy link

ghost commented Jan 20, 2023

@psycho-neon failed curl request doesnot equal to request dropped. They is not the same thing

My fix use send two http request so if the first one failed then i got second one still ready. Ez fix

@ghost
Copy link

ghost commented Jan 20, 2023

@psycho-neon they wont drop together not a chance. So it the best solution

@K0p1-Git please review and merge asap

@Sailboat265
Copy link
Contributor

@MohairVomNipa Sure thing there, smart guy. Why don't you explain to us, in details, what caused the "request dropped" error huh?

@ndrone
Copy link
Contributor

ndrone commented Jan 22, 2023

It seems like this change to store the ip address in a file is over complicating the entire script. This should be simple and just fetch the ip address and update it Cloudflare. If you are hitting max attempts maybe fix your cron to not flood it so much? Fix the problem not apply a band-aid.

@Sailboat265
Copy link
Contributor

Sailboat265 commented Jan 22, 2023

Well in that case, we still can use regex to verify and make sure the extracted IPs are all valid before continuing to the next step.

It's worth mentioning that I don't think this issue is related to API rate limiting.

Cloudflare's Global API rate limit is 1200 requests per five minutes. It will also return a HTTP 429 if we ever actually cross that limit.

However, during some testings, I have never seen HTTP 429 being returned. Even up until now, I have only got 000 return code from curl.

Additionally, here are some information you should know:

  1. The bug is seemingly only present on IPv4 only requests. That means if you use IPv6 or dual-stack, you have no problem.
  2. The curl response code is 000 while exit_code is 28 which means OPERATION_TIMEOUT.
  3. By using curl -v, it seems that TLS handshakes, everything are fine. The bug stuck at Operation timed out after 10000 milliseconds with 0 out of 0 bytes received

@ghost
Copy link

ghost commented Jan 23, 2023

@psycho-neon put me finger bottom emijo haha my code better than you you cry. Imagine losing to 13 yo lmao
@Sailboat265 ok i explain simple to your small brain. The script send wifi to router router send Wi-Fi to server, then server rejects Wi-Fi. Then the bug is appears.

@ndrone dude i agree with u so much storing to a file is too small pepe and brain. U go see my code,I send request again if first fail. More economic efficiency and nice code. I ran my code using ./cloudflsare.sh then it work ok. No issue

@ghost
Copy link

ghost commented Jan 23, 2023

@K0p1-Git why u so busy? Please ceck and merge my code asap. If not merge fast then got many bug out again

@psycho-neon
Copy link
Author

@psycho-neon put me finger bottom emijo haha my code better than you you cry. Imagine losing to 13 yo lmao @Sailboat265 ok i explain simple to your small brain. The script send wifi to router router send Wi-Fi to server, then server rejects Wi-Fi. Then the bug is appears.

Not really dude. Could you please explain to me this? What's your reason behind doubling these clauses?
image
image


Next I'm going to teach you some manners:

  1. Never ever force someone to pull your PR. Let alone the contributors/owner/reviewers to review/check your code and wait. How many times have you pinged the owner? Jeez, if it's working for you then so be it. We are here to discuss all possibilities of fixing this issue, not doubling or tripling requests without explanation.

@K0p1-Git
Copy link
Owner

@MohairVomNipa I am looking into the crux of the issue, at this point it leading towards the request being drop/failed/limited as the script uses existing tools it makes it difficult to pinpoint. However, doubling the request sent is not a valid way of fixing this issue. Like @ndrone mentioned, we are not looking for a band-aid fix.

I am indeed busy, soldier first, developer second. I am grateful for those that help maintain and optimize this script that is now used by many. I will however not tolerate negative behavior, please watch yourself and be respectful when it comes to discussion.

@ndrone
Copy link
Contributor

ndrone commented Jan 23, 2023

Well in that case, we still can use regex to verify and make sure the extracted IPs are all valid before continuing to the next step.

It's worth mentioning that I don't think this issue is related to API rate limiting.

Cloudflare's Global API rate limit is 1200 requests per five minutes. It will also return a HTTP 429 if we ever actually cross that limit.

However, during some testings, I have never seen HTTP 429 being returned. Even up until now, I have only got 000 return code from curl.

Additionally, here are some information you should know:

  1. The bug is seemingly only present on IPv4 only requests. That means if you use IPv6 or dual-stack, you have no problem.
  2. The curl response code is 000 while exit_code is 28 which means OPERATION_TIMEOUT.
  3. By using curl -v, it seems that TLS handshakes, everything are fine. The bug stuck at Operation timed out after 10000 milliseconds with 0 out of 0 bytes received

Sorry I have not been following this change close enough. But I believe you are probably on the right path here. We probably should be validating the curl command is successful before continuing any further. And have a regex to validate IPv4 and IPv6.

@K0p1-Git
Copy link
Owner

Looking through, a good fix as of now will be:

  1. Exception handling > Fixes immediate issue for fail / dropped request. i.e expectation for HTTP 000/429
  2. Rate limiting via Cron to see if there's a causal relationship between the rate of request sent and error observed
  3. Alternate ways of obtaining public address if curl was indeed the issue

Adding a local file for IP imo is redundant, and might be over complicating the script.

@ghost
Copy link

ghost commented Jan 23, 2023

@psycho-neon @psycho-neon @K0p1-Git

i dont know why is all you so angry at me. I already solve the bug and all you keep yelling.

please see and try my code u will see it work
do before talking pls

#!/bin/bash

change to "bin/sh" when necessary

auth_email="" # The email used to login 'https://dash.cloudflare.com'
auth_method="token" # Set to "global" for Global API Key or "token" for Scoped API Token
auth_key="" # Your API Token or Global API Key
zone_identifier="" # Can be found in the "Overview" tab of your domain
record_name="" # Which record you want to be synced
ttl="3600" # Set the DNS TTL (seconds)
proxy="false" # Set the proxy to true or false
sitename="" # Title of site "Example Site"
slackchannel="" # Slack Channel #example
slackuri="" # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx"
discorduri="" # URI for Discord WebHook "https://discordapp.com/api/webhooks/xxxxx"

###########################################

Check if we have a public IP

###########################################

exit 0

ipv4_regex='([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])'
ip=$(curl -s -4 https://cloudflare.com/cdn-cgi/trace | grep -E '^ip'); ret=$?
if [[ ! $ret == 0 ]]; then # In the case that cloudflare failed to return an ip.
# Attempt to get the ip from other websites.
ip=$(curl -s https://api.ipify.org || curl -s https://ipv4.icanhazip.com)
else
# Extract just the ip from the ip line from cloudflare.
ip=$(echo $ip | sed -E "s/^ip=($ipv4_regex)$/\1/")
fi

Use regex to check for proper IPv4 format.

if [[ ! $ip =~ ^$ipv4_regex$ ]]; then
logger -s "DDNS Updater: Failed to find a valid IP."
exit 2
fi

###########################################

Check and set the proper auth header

###########################################
if [[ "${auth_method}" == "global" ]]; then
auth_header="X-Auth-Key:"
else
auth_header="Authorization: Bearer"
fi

###########################################

Seek for the A record

###########################################

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")

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")

###########################################

Check if the domain has an A record

###########################################
if [[ $record == ""count":0" ]]; then
logger -s "DDNS Updater: Record does not exist, perhaps create one first? (${ip} for ${record_name})"
exit 1
fi

if [[ $record == ""count":0" ]]; then
logger -s "DDNS Updater: Record does not exist, perhaps create one first? (${ip} for ${record_name})"
exit 1
fi

###########################################

Get existing IP

###########################################
old_ip=$(echo "$record" | sed -E 's/."content":"(([0-9]{1,3}.){3}[0-9]{1,3})"./\1/')

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

old_ip=$(echo "$record" | sed -E 's/."content":"(([0-9]{1,3}.){3}[0-9]{1,3})"./\1/')

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

###########################################

Set the record identifier from result

###########################################
record_identifier=$(echo "$record" | sed -E 's/."id":"(\w+)"./\1/')

###########################################

Change the IP@Cloudflare using the API

###########################################
update=$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$record_identifier"
-H "X-Auth-Email: $auth_email"
-H "$auth_header $auth_key"
-H "Content-Type: application/json"
--data "{"type":"A","name":"$record_name","content":"$ip","ttl":"$ttl","proxied":${proxy}}")

###########################################

Report the status

###########################################
case "$update" in
""success":false")
echo -e "DDNS Updater: $ip $record_name DDNS failed for $record_identifier ($ip). DUMPING RESULTS:\n$update" | logger -s
if [[ $slackuri != "" ]]; then
curl -L -X POST $slackuri
--data-raw '{
"channel": "'$slackchannel'",
"text" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
}'
fi
if [[ $discorduri != "" ]]; then
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST
--data-raw '{
"content" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
}' $discorduri
fi
exit 1;;
*)
logger "DDNS Updater: $ip $record_name DDNS updated."
if [[ $slackuri != "" ]]; then
curl -L -X POST $slackuri
--data-raw '{
"channel": "'$slackchannel'",
"text" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
}'
fi
if [[ $discorduri != "" ]]; then
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST
--data-raw '{
"content" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
}' $discorduri
fi
exit 0;;
esac

@ghost
Copy link

ghost commented Jan 23, 2023

i dont know why cannot text become beautiful code just now






#!/bin/bash
## change to "bin/sh" when necessary

auth_email=""                                       # The email used to login 'https://dash.cloudflare.com'
auth_method="token"                                 # Set to "global" for Global API Key or "token" for Scoped API Token
auth_key=""                                         # Your API Token or Global API Key
zone_identifier=""                                  # Can be found in the "Overview" tab of your domain
record_name=""                                      # Which record you want to be synced
ttl="3600"                                          # Set the DNS TTL (seconds)
proxy="false"                                       # Set the proxy to true or false
sitename=""                                         # Title of site "Example Site"
slackchannel=""                                     # Slack Channel #example
slackuri=""                                         # URI for Slack WebHook "https://hooks.slack.com/services/xxxxx"
discorduri=""                                       # URI for Discord WebHook "https://discordapp.com/api/webhooks/xxxxx"


###########################################
## Check if we have a public IP
###########################################


exit 0


ipv4_regex='([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])'
ip=$(curl -s -4 https://cloudflare.com/cdn-cgi/trace | grep -E '^ip'); ret=$?
if [[ ! $ret == 0 ]]; then # In the case that cloudflare failed to return an ip.
    # Attempt to get the ip from other websites.
    ip=$(curl -s https://api.ipify.org || curl -s https://ipv4.icanhazip.com)
else
    # Extract just the ip from the ip line from cloudflare.
    ip=$(echo $ip | sed -E "s/^ip=($ipv4_regex)$/\1/")
fi

# Use regex to check for proper IPv4 format.
if [[ ! $ip =~ ^$ipv4_regex$ ]]; then
    logger -s "DDNS Updater: Failed to find a valid IP."
    exit 2
fi

###########################################
## Check and set the proper auth header
###########################################
if [[ "${auth_method}" == "global" ]]; then
  auth_header="X-Auth-Key:"
else
  auth_header="Authorization: Bearer"
fi

###########################################
## Seek for the A record
###########################################

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")

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")

###########################################
## Check if the domain has an A record
###########################################
if [[ $record == *"\"count\":0"* ]]; then
  logger -s "DDNS Updater: Record does not exist, perhaps create one first? (${ip} for ${record_name})"
  exit 1
fi

if [[ $record == *"\"count\":0"* ]]; then
  logger -s "DDNS Updater: Record does not exist, perhaps create one first? (${ip} for ${record_name})"
  exit 1
fi

###########################################
## Get existing IP
###########################################
old_ip=$(echo "$record" | sed -E 's/.*"content":"(([0-9]{1,3}\.){3}[0-9]{1,3})".*/\1/')
# 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

old_ip=$(echo "$record" | sed -E 's/.*"content":"(([0-9]{1,3}\.){3}[0-9]{1,3})".*/\1/')
# 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

###########################################
## Set the record identifier from result
###########################################
record_identifier=$(echo "$record" | sed -E 's/.*"id":"(\w+)".*/\1/')

###########################################
## Change the IP@Cloudflare using the API
###########################################
update=$(curl -s -X PATCH "https://api.cloudflare.com/client/v4/zones/$zone_identifier/dns_records/$record_identifier" \
                     -H "X-Auth-Email: $auth_email" \
                     -H "$auth_header $auth_key" \
                     -H "Content-Type: application/json" \
                     --data "{\"type\":\"A\",\"name\":\"$record_name\",\"content\":\"$ip\",\"ttl\":\"$ttl\",\"proxied\":${proxy}}")

###########################################
## Report the status
###########################################
case "$update" in
*"\"success\":false"*)
  echo -e "DDNS Updater: $ip $record_name DDNS failed for $record_identifier ($ip). DUMPING RESULTS:\n$update" | logger -s 
  if [[ $slackuri != "" ]]; then
    curl -L -X POST $slackuri \
    --data-raw '{
      "channel": "'$slackchannel'",
      "text" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
    }'
  fi
  if [[ $discorduri != "" ]]; then
    curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST \
    --data-raw '{
      "content" : "'"$sitename"' DDNS Update Failed: '$record_name': '$record_identifier' ('$ip')."
    }' $discorduri
  fi
  exit 1;;
*)
  logger "DDNS Updater: $ip $record_name DDNS updated."
  if [[ $slackuri != "" ]]; then
    curl -L -X POST $slackuri \
    --data-raw '{
      "channel": "'$slackchannel'",
      "text" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
    }'
  fi
  if [[ $discorduri != "" ]]; then
    curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST \
    --data-raw '{
      "content" : "'"$sitename"' Updated: '$record_name''"'"'s'""' new IP Address is '$ip'"
    }' $discorduri
  fi
  exit 0;;
esac



ok now u can see my code

`

@ghost
Copy link

ghost commented Jan 23, 2023

@psycho-neon u nid to copy paste the code ok then save to file ok? u then run then can work fine program no error

@psycho-neon
Copy link
Author

@psycho-neon u nid to copy paste the code ok then save to file ok? u then run then can work fine program no error

Dude, just stop please? If its working for you, fine. I already saw what you did and asked you questions, yet you didn't answer them. What's the point then?

@psycho-neon
Copy link
Author

I will make a new PR consisting of the following:

  1. We will keep the way we fetch the ip address using cloudflare api.
  2. I will add additional checks if the return response is valid. I will also check if the returned IP address is in valid format such A.B.C.D exists.

If all of these criteria failed, then we will just exit the script completely and wait for the next cron sched.

@K0p1-Git
Copy link
Owner

User has been reported

Repository owner deleted a comment Jan 24, 2023
@K0p1-Git K0p1-Git added the bug Something isn't working label Jan 24, 2023
@K0p1-Git K0p1-Git closed this Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants