wok rev 18036

dropbear/sshx, ppp/pppnc-client: add default route support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 10 12:23:00 2015 +0200 (2015-05-10)
parents 2f76ffd0c441
children 8c87da2c80eb
files dropbear/stuff/sshx ppp/stuff/ppp.cgi ppp/stuff/pppnc-server
line diff
     1.1 --- a/dropbear/stuff/sshx	Sat May 09 21:58:06 2015 +0200
     1.2 +++ b/dropbear/stuff/sshx	Sun May 10 12:23:00 2015 +0200
     1.3 @@ -30,14 +30,18 @@
     1.4  		read -s -t 30 DROPBEAR_PASSWORD && export DROPBEAR_PASSWORD
     1.5  		$ssh $1 true || exit 1
     1.6  	}
     1.7 -	for i in $4 ; do
     1.8 +	extra="$(route -n | awk -vd=${1#*@} \
     1.9 +		'$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')"
    1.10 +	for i in ${4/default/128.0.0.0/1 0.0.0.0/1} ; do
    1.11  		echo "route add -net $i dev \$1"
    1.12  	done > /etc/ppp/ip-up.d/pppssh$$
    1.13 +	[ "$4" ] && echo "route add $extra" >> /etc/ppp/ip-up.d/pppssh$
    1.14  	chmod +x /etc/ppp/ip-up.d/pppssh$$
    1.15  	n=10.$(($$%256)).$(($$/256))
    1.16  	ppp="/usr/sbin/pppd local noauth nodetach"
    1.17  	$ppp ${2:-$n.1:$n.2} passive pty "$ssh $1 $ppp ${3:-proxyarp} notty" \
    1.18  		ipparam pppssh$$
    1.19 +	[ "$4" ] && route del $extra
    1.20  	rm -f /etc/ppp/ip-up.d/pppssh$$
    1.21  }
    1.22  
     2.1 --- a/ppp/stuff/ppp.cgi	Sat May 09 21:58:06 2015 +0200
     2.2 +++ b/ppp/stuff/ppp.cgi	Sun May 10 12:23:00 2015 +0200
     2.3 @@ -269,7 +269,7 @@
     2.4  	</tr>
     2.5  	<tr>
     2.6  		<td>$(_ 'Server routes')</td>
     2.7 -		<td><input type="text" name="routes" size="50" value="${ROUTES:-192.168.10.0/24 192.168.20.0/28}" title="$(_ 'Routes on peer network to import')"/></td>
     2.8 +		<td><input type="text" name="routes" size="50" value="${ROUTES:-192.168.10.0/24 192.168.20.0/28}" title="$(_ 'Routes on peer network to import or "default" to redirect the default route')"/></td>
     2.9  	</tr>
    2.10  	</table>
    2.11  </form>
    2.12 @@ -328,7 +328,7 @@
    2.13  	</tr>
    2.14  	<tr>
    2.15  		<td>$(_ 'Peer routes')</td>
    2.16 -		<td><input type="text" name="routes" size="50" value="${ROUTES:-192.168.10.0/24 192.168.20.0/28}" title="$(_ 'Routes on peer network to import')"/></td>
    2.17 +		<td><input type="text" name="routes" size="50" value="${ROUTES:-192.168.10.0/24 192.168.20.0/28}" title="$(_ 'Routes on peer network to import or "default" to redirect the default route')"/></td>
    2.18  	</tr>
    2.19  	</table>
    2.20  </form>
     3.1 --- a/ppp/stuff/pppnc-server	Sat May 09 21:58:06 2015 +0200
     3.2 +++ b/ppp/stuff/pppnc-server	Sun May 10 12:23:00 2015 +0200
     3.3 @@ -11,9 +11,12 @@
     3.4  esac
     3.5  
     3.6  [ -z "$1" ] && echo "Usage: $0 serverip [port] [routes]" && exit 1
     3.7 -for i in $3 ; do
     3.8 +extra="$(route -n | awk -vd=$1 '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')"
     3.9 +for i in ${3/default/128.0.0.0/1 0.0.0.0/1} ; do
    3.10  	echo "route add -net $i dev \$1"
    3.11  done > $ipupd/pppnc$$
    3.12 +[ "$3" ] && echo "route add $extra" >> $ipupd/pppnc$
    3.13  chmod +x $ipupd/pppnc$$
    3.14  $ppp noipdefault pty "nc $1 ${2:-$port}" ipparam pppnc$$
    3.15 +[ "$3" ] && route del $extra
    3.16  rm -f $ipupd/pppnc$$