changeset 550:4964136d5043 draft

peer2anonet: added configuration on install to create env variables. see README for details.
author d3v1150m471c <d3v11@d3v1150m471c.ano>
date Wed, 13 Jul 2011 04:21:57 -0500
parents 5b5b29f8d8c7
children 4dc5e973698f 04f1dbdc5e47
files contrib/peer2anonet/DEBIAN/configure contrib/peer2anonet/Makefile contrib/peer2anonet/README contrib/peer2anonet/configure contrib/peer2anonet/peer2anonet
diffstat 5 files changed, 47 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/peer2anonet/DEBIAN/configure	Wed Jul 13 04:21:57 2011 -0500
@@ -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
--- a/contrib/peer2anonet/Makefile	Sun Jul 10 22:41:54 2011 -0500
+++ b/contrib/peer2anonet/Makefile	Wed Jul 13 04:21:57 2011 -0500
@@ -11,6 +11,7 @@
 	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 @@
 	chmod +x /usr/bin/peer2anonet
 	mkdir /etc/peer2anonet
 	cp LICENSE /etc/peer2anonet/LICENSE
+	./configure
 
 uninstall:
 	rm -r /usr/bin/peer2anonet /etc/peer2anonet
--- a/contrib/peer2anonet/README	Sun Jul 10 22:41:54 2011 -0500
+++ b/contrib/peer2anonet/README	Wed Jul 13 04:21:57 2011 -0500
@@ -71,14 +71,9 @@
 
 ================== 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 @@
         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.
+
+
 
 
       
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/peer2anonet/configure	Wed Jul 13 04:21:57 2011 -0500
@@ -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
--- a/contrib/peer2anonet/peer2anonet	Sun Jul 10 22:41:54 2011 -0500
+++ b/contrib/peer2anonet/peer2anonet	Wed Jul 13 04:21:57 2011 -0500
@@ -7,6 +7,10 @@
 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 @@
 #########################################################################
 # 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 @@
 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 @@
  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 @@
 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 static static_AnoNet_routes { table AnoNet_routes;
- route $YOURROUTE/24 drop;
+ route $P2A_ROUTE/24 drop;
 }
 
 protocol kernel {
@@ -136,14 +136,14 @@
 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