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

Add an ssh connection function #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions network/core/functions
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,21 @@ trace_route() {
complete_trace=$($traceroute -q1 www.google.com 2>&1 | grep -v -e "^[a-z]" -e "^$")
fi
}

connect_to_ssh() {
# these vars will come from the server/xml
remoteport=""
localport=""
sshhost=""
localhost=""
sshusr=""
sshcmd="ssh -fnNq -R $remoteport:$localhost:$localport $sshusr@$sshhost"
if [[ -z $(pgrep -f "$sshcmd") ]]; then
# only set up a connection if it hasn't already been set up
log "$STRING_CONNECT_SSH_Y"
# put everything in /dev/null
eval "nohup $sshcmd &> /dev/null &"
else
log "$STRING_CONNECT_SSH_N"
fi
}
5 changes: 5 additions & 0 deletions network/core/run
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ if [[ "$network__trace_route" == 'y' && -z "$proxy_server" ]]; then
trace_route
add_trace complete_trace "$complete_trace"
fi

if [ true ]; then # [ "$networt__connect_ssh" == 'y' ]
log "$STRING_CONNECT_SSH"
connect_to_ssh
fi
3 changes: 3 additions & 0 deletions network/lang/en
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ STRING_GET_IP=" -- Getting public IP address..."
STRING_GET_LAN_IP=" -- Getting private LAN IP address..."
STRING_GET_WIFI=" -- Getting Wifi info..."
STRING_TRACE=" -- Tracing our complete route to the Internet..."
STRING_CONNECT_SSH=" -- Connecting to SSH server..."
STRING_CONNECT_SSH_Y=" -- SSH: Connecting to server now"
STRING_CONNECT_SSH_N=" -- SSH: Already connected to server"