diff options
author | d3v1150m471c <d3v11@d3v1150m471c.ano> | 2011-07-13 04:21:57 -0500 |
---|---|---|
committer | d3v1150m471c <d3v11@d3v1150m471c.ano> | 2011-07-13 04:21:57 -0500 |
commit | 44916de0b229a39cebe39a3272160cb0291f6388 (patch) | |
tree | 0ff7a7089708f7498f94f6007a79602005150d3e /contrib/peer2anonet | |
parent | 90449a38a3307a0cee261c38c75dad99029f6ab0 (diff) | |
download | resdb-44916de0b229a39cebe39a3272160cb0291f6388.tar.gz resdb-44916de0b229a39cebe39a3272160cb0291f6388.zip |
peer2anonet: added configuration on install to create env variables. see README for details.
Diffstat (limited to 'contrib/peer2anonet')
-rwxr-xr-x | contrib/peer2anonet/DEBIAN/configure | 10 | ||||
-rw-r--r-- | contrib/peer2anonet/Makefile | 2 | ||||
-rw-r--r-- | contrib/peer2anonet/README | 13 | ||||
-rwxr-xr-x | contrib/peer2anonet/configure | 10 | ||||
-rw-r--r-- | contrib/peer2anonet/peer2anonet | 34 |
5 files changed, 47 insertions, 22 deletions
diff --git a/contrib/peer2anonet/DEBIAN/configure b/contrib/peer2anonet/DEBIAN/configure new file mode 100755 index 0000000..6a01c74 --- /dev/null +++ b/contrib/peer2anonet/DEBIAN/configure @@ -0,0 +1,10 @@ +#!/bin/bash +read -p "Enter your anonet network: " P2A_NET +read -p "Enter your anonet router: " P2A_ROUTE +read -p "Enter your anonet asn: " P2A_ASN +read -p "Enter your anonet ip: " P2A_IP + +echo "P2A_NET=\"$P2A_NET\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf +echo "P2A_ROUTE=\"$P2A_ROUTE\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf +echo "P2A_ASN=\"$P2A_ASN\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf +echo "P2A_IP=\"$P2A_IP\"" >>DEBIAN/peer2anonet/etc/peer2anonet/p2a.conf diff --git a/contrib/peer2anonet/Makefile b/contrib/peer2anonet/Makefile index 24d52e7..e040bf5 100644 --- a/contrib/peer2anonet/Makefile +++ b/contrib/peer2anonet/Makefile @@ -11,6 +11,7 @@ install-deb: cp peer2anonet DEBIAN/peer2anonet/usr/bin/peer2anonet chmod +x DEBIAN/peer2anonet/usr/bin/peer2anonet cp LICENSE DEBIAN/peer2anonet/etc/peer2anonet/LICENSE + DEBIAN/configure dpkg-deb --build DEBIAN/peer2anonet dpkg -i DEBIAN/peer2anonet.deb rm -rf DEBIAN/peer2anonet DEBIAN/peer2anonet.deb @@ -20,6 +21,7 @@ install: chmod +x /usr/bin/peer2anonet mkdir /etc/peer2anonet cp LICENSE /etc/peer2anonet/LICENSE + ./configure uninstall: rm -r /usr/bin/peer2anonet /etc/peer2anonet diff --git a/contrib/peer2anonet/README b/contrib/peer2anonet/README index 16291f5..58d3b9a 100644 --- a/contrib/peer2anonet/README +++ b/contrib/peer2anonet/README @@ -71,14 +71,9 @@ USAGE: ================== Not Actual Line on File ============================ anon <--your peer's alias -1.2.3.0 <--your new anonet network address -1.2.3.1 <--your new anonet router address -1.2.3.2 <--your new anonet ip 11.22.33.44 <--your peer's remote ip 3.5.7.9 <--your peer's anonet ip -1001 <--your new anonet client port 3571 <--your peer's client port -1230 <--you new asn 3570 <--your peer's asn 3c6e0b8a9c15224a8228b9a98ca1531d <--your peer's public key ================== Not Actual Line on File ============================ @@ -130,6 +125,14 @@ CHANGES: key pairs so they can be manually created prior to using peer2anonet, for expedience. + Wed Jul 13 04:17:03 CDT 2011 - d3v1150m471c + * added env variables that are configured on installation + * uses env variables for certain settings to uncomplicate the + peering process. A peer now only needs to send you pertinent + data pertaining to his/her system in order for you to + configure a new peering session, or vice versa. + + diff --git a/contrib/peer2anonet/configure b/contrib/peer2anonet/configure new file mode 100755 index 0000000..25aae90 --- /dev/null +++ b/contrib/peer2anonet/configure @@ -0,0 +1,10 @@ +#!/bin/bash +read -p "Enter your anonet network: " P2A_NET +read -p "Enter your anonet router: " P2A_ROUTE +read -p "Enter your anonet asn: " P2A_ASN +read -p "Enter your anonet ip: " P2A_IP + +echo "P2A_NET=\"$P2A_NET\"" >>/etc/peer2anonet/p2a.conf +echo "P2A_ROUTE=\"$P2A_ROUTE\"" >>/etc/peer2anonet/p2a.conf +echo "P2A_ASN=\"$P2A_ASN\"" >>/etc/peer2anonet/p2a.conf +echo "P2A_IP=\"$P2A_IP\"" >>/etc/peer2anonet/p2a.conf diff --git a/contrib/peer2anonet/peer2anonet b/contrib/peer2anonet/peer2anonet index b7759d6..b84d97e 100644 --- a/contrib/peer2anonet/peer2anonet +++ b/contrib/peer2anonet/peer2anonet @@ -7,6 +7,10 @@ if [[ $(id -u) != 0 ]]; then fi ######################################################################### +# We need to source our peer2anonet variables +source /etc/peer2anonet/p2a.conf + +######################################################################### # We need to see if service(s) directories exist: mkdir -p /services mkdir -p /services/bird @@ -15,24 +19,18 @@ mkdir -p /service ######################################################################### # We need to get info for the new peering and BGP session: read -p "Enter your peer's name/interface: " PEERNAME -read -p "Enter your new network address: " YOURNET -read -p "Enter your new network router address: " YOURROUTE -read -p "Enter your new network ip address: " YOURIP read -p "Enter your peer's remote ip: " REMOTEIP read -p "Enter your peer's anonet ip: " PEERIP -read -p "Enter your new local port: " YOURPORT read -p "Enter your peer's remote port: " PEERPORT -read -p "Enter your new asn: " YOURASN read -p "Enter your peer's asn: " PEERASN read -p "Enter your peer's public key: " PUBKEY ######################################################################### # Do some security checks on variables: -TEST[0]=$PEERNAME; TEST[1]=$YOURNET; TEST[2]=$YOURROUTE; TEST[3]=$YOURIP -TEST[4]=$REMOTEIP; TEST[5]=$PEERIP; TEST[6]=$YOURPORT; TEST[7]=$PEERPORT - TEST[8]=$YOURASN; TEST[9]=$PEERASN +TEST[0]=$PEERNAME; TEST[1]=$REMOTEIP; TEST[2]=$PEERIP + TEST[3]=$PEERPORT; TEST[4]=$PEERASN -for((X=0;X<=5;X++)); do +for((X=0;X<=2;X++)); do if [[ $(echo ${TEST[$X]} | tr -d 'a-zA-Z0-9._-' | wc -c) -gt 1 ]]; then echo ${TEST[$X]} | tr -d 'a-zA-Z0-9' | wc -c echo "peer2anonet: fatal error: unacceptable data: ${TEST[$X]} @@ -41,7 +39,7 @@ echo ${TEST[$X]} | tr -d 'a-zA-Z0-9' | wc -c fi done -for((X=6;X<=9;X++)); do +for((X=4;X<=5;X++)); do if [[ $(echo ${TEST[$X]} | tr -d '0-9' | wc -c) -gt 1 ]]; then echo "peer2anonet: fatal error: unacceptable data: ${TEST[$X]} " @@ -55,13 +53,15 @@ if [[ $(echo "$PUBKEY" | tr -d 'a-zA-Z0-9' | wc -c) -gt 1 ]]; then exit 1 fi +ADDPORT="2$(($PEERASN % 10000))" + ######################################################################### # We need to check if base files need to be imported to services for bird: NEW_PROTOCOL=" protocol bgp $PEERNAME'_bgp' { table AnoNet_routes; - local as $YOURASN; + local as $P2A_ASN; neighbor $PEERIP as $PEERASN; - source address $YOURIP; + source address $P2A_IP; import filter only_AnoNet_ebgp; export filter only_AnoNet_ebgp_export; }" @@ -70,7 +70,7 @@ BIRD_RUN='#!/bin/sh exec bird -c bird.conf -d' BIRD_CONF="function n_AnoNet_mine (prefix arg) { - if arg ~ [ $YOURNET/24+ ] then return true; + if arg ~ [ $P2A_NET/24+ ] then return true; return false; }; function n_AnoNet (prefix arg) { @@ -100,7 +100,7 @@ protocol pipe pipe_AnoNet_routes { peer table AnoNet_routes; mode transparent; }; protocol static static_AnoNet_routes { table AnoNet_routes; - route $YOURROUTE/24 drop; + route $P2A_ROUTE/24 drop; } protocol kernel { @@ -136,14 +136,14 @@ mkdir -p /services/"$PEERNAME" echo "#!/bin/sh export REMOTE_ADDRESS=$REMOTEIP export REMOTE_PORT=$PEERPORT -export LOCAL_PORT=$YOURPORT +export LOCAL_PORT=$ADDPORT export PRIVATE_KEY=\"\$(cat seckey)\" export PUBLIC_KEY=$PUBKEY export TUN_MODE=1 export INTERFACE=ppp-$PEERNAME ( sleep 5; - ip addr add $YOURIP peer $PEERIP/32 dev \$INTERFACE scope link - ip addr add $YOURROUTE/32 dev \$INTERFACE scope global + ip addr add $P2A_IP peer $PEERIP/32 dev \$INTERFACE scope link + ip addr add $P2A_ROUTE/32 dev \$INTERFACE scope global ip link set dev \$INTERFACE up ) & exec /usr/sbin/quicktun.nacltai" > /services/"$PEERNAME"/run |