wok-6.x annotate ppp/stuff/pppnc-server @ rev 18102
ppp/pppnc: udp instead of tcp
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Jun 01 10:13:14 2015 +0200 (2015-06-01) |
parents | e726e3214807 |
children | 1ae2567134a8 |
rev | line source |
---|---|
pascal@15968 | 1 #!/bin/sh |
pascal@15968 | 2 |
pascal@15968 | 3 ppp="/usr/sbin/pppd local noauth nodetach" |
pascal@15968 | 4 port=1111 |
pascal@15968 | 5 ipupd=/etc/ppp/ip-up.d |
pascal@15968 | 6 |
pascal@15968 | 7 case "$0" in |
pascal@15968 | 8 *server) # Usage: pppnc-server [port] [localip:remoteip] |
pascal@15968 | 9 n=10.$(($$%256)).$(($$/256)) |
pascal@18102 | 10 exec $ppp ${2:-$n.1:$n.2} passive proxyarp pty "nc -ulp ${1:-$port}" |
pascal@15968 | 11 esac |
pascal@15968 | 12 |
pascal@15968 | 13 [ -z "$1" ] && echo "Usage: $0 serverip [port] [routes]" && exit 1 |
pascal@18042 | 14 extra="$(route -n | awk -vd=$(nslookup ${1#*@} | sed \ |
pascal@18042 | 15 '$!d;s/.*: \([^ ]*\).*/\1/') '$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')" |
pascal@18036 | 16 for i in ${3/default/128.0.0.0/1 0.0.0.0/1} ; do |
pascal@15968 | 17 echo "route add -net $i dev \$1" |
pascal@15968 | 18 done > $ipupd/pppnc$$ |
pascal@18042 | 19 [ "$3" ] && echo "route add $extra" >> $ipupd/pppnc$$ |
pascal@15968 | 20 chmod +x $ipupd/pppnc$$ |
pascal@18102 | 21 $ppp noipdefault pty "nc -u $1 ${2:-$port}" ipparam pppnc$$ |
pascal@18036 | 22 [ "$3" ] && route del $extra |
pascal@15968 | 23 rm -f $ipupd/pppnc$$ |