Darren Tucker | 0a404b0 | 2013-05-17 20:47:29 +1000 | [diff] [blame] | 1 | # $OpenBSD: portnum.sh,v 1.2 2013/05/17 10:34:30 dtucker Exp $ |
Darren Tucker | a25ab01 | 2009-10-07 11:00:58 +1100 | [diff] [blame] | 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="port number parsing" |
| 5 | |
| 6 | badport() { |
| 7 | port=$1 |
| 8 | verbose "$tid: invalid port $port" |
| 9 | if ${SSH} -F $OBJ/ssh_proxy -p $port somehost true 2>/dev/null ; then |
| 10 | fail "$tid accepted invalid port $port" |
| 11 | fi |
| 12 | } |
| 13 | goodport() { |
| 14 | port=$1 |
| 15 | verbose "$tid: valid port $port" |
Tim Rice | 999aaf4 | 2010-01-16 11:37:53 -0800 | [diff] [blame] | 16 | if ${SSH} -F $OBJ/ssh_proxy -p $port somehost true 2>/dev/null ; then |
| 17 | : |
| 18 | else |
Darren Tucker | a25ab01 | 2009-10-07 11:00:58 +1100 | [diff] [blame] | 19 | fail "$tid rejected valid port $port" |
| 20 | fi |
| 21 | } |
| 22 | |
| 23 | badport 0 |
| 24 | badport 65536 |
| 25 | badport 131073 |
| 26 | badport 2000blah |
| 27 | badport blah2000 |
| 28 | |
| 29 | goodport 1 |
| 30 | goodport 22 |
| 31 | goodport 2222 |
| 32 | goodport 22222 |
| 33 | goodport 65535 |
| 34 | |