Skip to content

Commit

Permalink
Move Tor related functions to birb_funcs
Browse files Browse the repository at this point in the history
This way the same functions can be used by birbd if needed
  • Loading branch information
Toasterbirb committed Nov 15, 2023
1 parent ac9ec35 commit 86be7be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
21 changes: 0 additions & 21 deletions birb
Original file line number Diff line number Diff line change
Expand Up @@ -508,27 +508,6 @@ add_package_to_nest()
fi
}

# Check if the package has a source URL that points to an .onion address
# Args: [url]
onion_check()
{
grep -q "http://[A-Za-z2-7]*d.onion" <<< "$1"
}

# Check if tor is installed and running. Also make sure that torsocks is installed
tor_check()
{
println "Checking if Tor is installed and running..."
[ ! -f /usr/bin/tor ] && println ERROR "Tor isn't installed! Birb cannot download packages from .onion addresses without it (>﹏<)" && exit 1
[ ! -f /usr/bin/torsocks ] && println ERROR "torsocks isn't installed! Birb cannot download packages from .onion addresses without it (」><)」" && exit 1

if ! pgrep -x tor &>/dev/null
then
println ERROR "Tor isn't running! Birb cannot download packages from .onion addresses without it (ノω・、)"
exit 1
fi
}

install_package()
{
root_check
Expand Down
24 changes: 24 additions & 0 deletions birb_funcs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,27 @@ major_version()
{
echo "$1" | cut -d'.' -f1
}


# Tor related functions

# Check if the package has a source URL that points to an .onion address
# Args: [url]
onion_check()
{
grep -q "http://[A-Za-z2-7]*d.onion" <<< "$1"
}

# Check if tor is installed and running. Also make sure that torsocks is installed
tor_check()
{
println "Checking if Tor is installed and running..."
[ ! -f /usr/bin/tor ] && println ERROR "Tor isn't installed! Birb cannot download packages from .onion addresses without it (>﹏<)" && exit 1
[ ! -f /usr/bin/torsocks ] && println ERROR "torsocks isn't installed! Birb cannot download packages from .onion addresses without it (」><)」" && exit 1

if ! pgrep -x tor &>/dev/null
then
println ERROR "Tor isn't running! Birb cannot download packages from .onion addresses without it (ノω・、)"
exit 1
fi
}

0 comments on commit 86be7be

Please sign in to comment.