Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SakuraJensen authored Mar 29, 2018
1 parent 44cf9d9 commit 0fc3c47
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
7 changes: 7 additions & 0 deletions change.log
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ v0.2
as it's only needed for debugging purposes.
- Comment formatting for my OCD :P

v0.3
- Removed $ from range of valid characters as it could be dangerous.
- Fixed mispellings in comments.
- Removed Default setting of 46 as it can be dangerous.
- Removed TTL variable.
- exit Optimizations

To-Do:
Add a bit of redundancy to prevent any error for occuring. Such as double checking vars.
Make --help and -h viable options for bringin up help.
Expand Down
33 changes: 14 additions & 19 deletions ttlset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Author: Sapphiress https://github.com/Sapphiress/ttlset
# Email: [email protected]
# Date: 28/03/2018
# Version: 0.2
# Version: 0.3



Expand All @@ -17,55 +17,50 @@ fi


# Initialize variables
ttl=0 # TTL - The number in which the TTL will be set to.
curttl=0 # Current TTL - Just initializing the variable just to keep all the bases covered.
nan='^[0-9]+$' # Not a Number - A collection of shit to check if argument is a number.
nan='^[0-9]' # Not a Number - A collection of shit to check if argument is a number.


# Set up $tll
# Set up $ttl
if [[ $1 == "" ]]; then
echo "You did not specify a specific TTL, setting to 46"
ttl=46
echo "You did not specify a TTL."
exit 1
elif [[ $1 == "help" ]]; then
echo "Syntax: ttlset [option/ttl]"
echo ""
echo
echo "Options: "
echo ""
echo
echo "help Displays this text."
echo "ttl The number you wish to set your ttl to."
echo ""
echo "You may type ttlset by itself. However, by default it will be set to 46"
echo ""
echo
echo "Examples: "
echo ""
echo
echo "ttlset 65 or ttlset help"
echo ""
echo
exit 0
elif ! [[ $1 =~ $nan ]]; then
echo "What are you doing? YOU MONSTER! That wasn't a number! Your TTL must be a number."
exit 2
exit 1
else
echo "You specified a ttl of $1."
ttl=$1
fi


# Set the TTL while letting the user know what is going on.
echo "Attempting to set the TTL..."
sysctl net.ipv4.ip_default_ttl=$ttl > /dev/null # Don't remove > /dev/null this stops the output.
sysctl net.ipv4.ip_default_ttl=$1 > /dev/null # Don't remove > /dev/null this stops the output.

echo "Checking..."
curttl=$(cat /proc/sys/net/ipv4/ip_default_ttl) # Reads the current ttl and stores it in $curttl.


# Just to confirm that $curttl and $ttl are equal.

# echo "The TTL is $curttl." # For debugging purposes.
if [[ $ttl == $curttl ]]; then
if [[ $1 == $curttl ]]; then
echo "The TTL was set successfully!"
exit 0
else
echo "The TTL did not set correctly. Try again!"
exit 666
exit 1
fi

0 comments on commit 0fc3c47

Please sign in to comment.