summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJameson Rollins <jrollins@finestructure.net>2010-10-29 20:56:25 -0400
committerJameson Rollins <jrollins@finestructure.net>2010-10-30 02:31:08 -0400
commit88f98d02aee070c96f3b975ec797754efa3e32d7 (patch)
tree7f1db4c080a91a070610834a321f0a0ea935c88e
parent343e9b41962e508e777d0ead2e6e5e3a725cfb3a (diff)
clean up ssh_proxycommand function (no functional change)
-rw-r--r--src/share/m/ssh_proxycommand94
1 files changed, 49 insertions, 45 deletions
diff --git a/src/share/m/ssh_proxycommand b/src/share/m/ssh_proxycommand
index 110309e..3ac70e1 100644
--- a/src/share/m/ssh_proxycommand
+++ b/src/share/m/ssh_proxycommand
@@ -15,6 +15,55 @@
# established. Can be added to ~/.ssh/config as follows:
# ProxyCommand monkeysphere ssh-proxycommand %h %p
+# the ssh proxycommand function itself
+ssh_proxycommand() {
+ local connect='true'
+ local HOST
+ local PORT
+ local HOSTP
+ local URI
+
+ if [[ "$1" == '--no-connect' ]] ; then
+ connect='false'
+ shift 1
+ fi
+
+ HOST="$1"
+ PORT="$2"
+
+ if [ -z "$HOST" ] ; then
+ log error "Host not specified."
+ usage
+ exit 255
+ fi
+ if [ -z "$PORT" ] ; then
+ PORT=22
+ fi
+
+ # set the host URI
+ if [ "$PORT" != '22' ] ; then
+ HOSTP="${HOST}:${PORT}"
+ else
+ HOSTP="${HOST}"
+ fi
+ URI="ssh://${HOSTP}"
+
+ # passed HOST/PORT/HOSTP/URI
+ validate_monkeysphere
+
+ # exec a netcat passthrough to host for the ssh connection
+ if [[ "$connect" == 'true' ]] ; then
+ if (type nc &>/dev/null); then
+ exec nc "$HOST" "$PORT"
+ elif (type socat &>/dev/null); then
+ exec socat STDIO "TCP:$HOST:$PORT"
+ else
+ echo "Neither netcat nor socat found -- could not complete monkeysphere-ssh-proxycommand connection to $HOST:$PORT" >&2
+ exit 255
+ fi
+ fi
+}
+
validate_monkeysphere() {
local hostKey
@@ -266,48 +315,3 @@ EOF
-------------------- ssh continues below --------------------
EOF
}
-
-
-# the ssh proxycommand function itself
-ssh_proxycommand() {
-
-if [ "$1" = '--no-connect' ] ; then
- NO_CONNECT='true'
- shift 1
-fi
-
-HOST="$1"
-PORT="$2"
-
-if [ -z "$HOST" ] ; then
- log error "Host not specified."
- usage
- exit 255
-fi
-if [ -z "$PORT" ] ; then
- PORT=22
-fi
-
-# set the host URI
-if [ "$PORT" != '22' ] ; then
- HOSTP="${HOST}:${PORT}"
-else
- HOSTP="${HOST}"
-fi
-URI="ssh://${HOSTP}"
-
-validate_monkeysphere
-
-# exec a netcat passthrough to host for the ssh connection
-if [ -z "$NO_CONNECT" ] ; then
- if (type nc &>/dev/null); then
- exec nc "$HOST" "$PORT"
- elif (type socat &>/dev/null); then
- exec socat STDIO "TCP:$HOST:$PORT"
- else
- echo "Neither netcat nor socat found -- could not complete monkeysphere-ssh-proxycommand connection to $HOST:$PORT" >&2
- exit 255
- fi
-fi
-
-}