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

added host resolve with custom dns #34

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Fork Changes
As I use this script to send telegram alerts when parts of my infrastructure are unavailable it may coincide with the Pihole DNS server to be offline. When this happens there is no DNS resolution of the Telegram host and no message can be send. To alleviate this issue I have introduced a new flag (`-I`) which resolves the host by using the Google DNS `8.8.8.8` instead of using the usual DNS.

---

Original Readme:

# telegram.sh

## What does it do?
Expand Down
8 changes: 7 additions & 1 deletion telegram
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function help {
echo " -C Sends text as monospace code. Useful when piping command outputs into this tool."
echo " -r Like -C, but if the first line starts with '+ ', it is specially formatted."
echo " -T <TITLE> Sets a title for the message. Printed in bold text if -M or -H is used."
echo " -I Resolves the DNS of the host to be used to mitigate DNS issues."
echo " -l Fetch known chat_ids."
echo " -R Receive a file sent via telegram."
echo " -D Sets disable_web_page_preview parameter to, well, disable the preview for links to webpages."
Expand Down Expand Up @@ -210,7 +211,7 @@ function escapeMarkdown {
echo "$res"
}

while getopts "t:c:i:f:V:MHCrhlvjnRmDNT:" opt; do
while getopts "t:c:i:f:V:MHCrhlvjnRmDNTI:" opt; do
case $opt in
t)
TOKEN="$OPTARG"
Expand Down Expand Up @@ -268,6 +269,11 @@ while getopts "t:c:i:f:V:MHCrhlvjnRmDNT:" opt; do
T)
TITLE="$OPTARG"
;;
I)
TELEGRAM_IP=`dig @8.8.8.8 api.telegram.org | grep "ANSWER SECTION" -A 2 | grep -v -e CNAME -e "ANSWER SECTION" | cut -f5`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using dig api.telegram.org @8.8.8.8 +short? Then there's no need to use grep and cut.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not aware of this option. Please see this PR in which I fixed the issue: #35

I've also closed this one since it was not on purpose for me to update my fork specific readme within your repository.

CURL_OPTIONS="$CURL_OPTIONS --resolve ${URL%/bot}:$TELEGRAM_IP"
;;

?|h)
help
;;
Expand Down