Browse Source

Merge remote-tracking branch 'huig/master'

Nick Mathewson 9 years ago
parent
commit
b19d238e24
3 changed files with 90 additions and 1 deletions
  1. 2 1
      lib/chutney/TorNet.py
  2. 43 0
      tools/hsaddress.sh
  3. 45 0
      tools/warnings.sh

+ 2 - 1
lib/chutney/TorNet.py

@@ -21,6 +21,7 @@ import sys
 import re
 import errno
 import time
+import shutil
 
 import chutney.Templating
 import chutney.Traffic
@@ -753,11 +754,11 @@ class Network(object):
             n.getBuilder().checkConfig(self)
 
     def configure(self):
+        shutil.rmtree(os.path.join(os.getcwd(),'net','nodes'),ignore_errors=True)
         network = self
         altauthlines = []
         bridgelines = []
         builders = [n.getBuilder() for n in self._nodes]
-
         self._checkConfig()
 
         # XXX don't change node names or types or count if anything is

+ 43 - 0
tools/hsaddress.sh

@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Usage: 
+#    cd YOUR-CHUTNEY-DIRECTORY
+#    tools/hsaddress.sh [hs_node]
+# Output: for each HS outputs its onion address. If the argument node is
+#    specified, it only shows the onion address of that node.
+# Examples: tools/hsaddress.sh
+#           tools/hsaddress.sh 025h
+
+NAME=$(basename "$0")
+DEST=net/nodes
+TARGET=hidden_service/hostname
+
+function usage() {
+    echo "Usage: $NAME [hs_node]"
+    exit 1 
+}
+
+function show_address() {
+    cat $1
+}
+
+[ -d $DEST ] || { echo "$NAME: no nodes available"; exit 1; }
+if [ $# -eq 0 ];
+then
+    for dir in $DEST/*h;
+    do
+        FILE=${dir}/$TARGET
+        [ -e $FILE ] || continue
+        echo -n "Node `basename ${dir}`: "
+        show_address $FILE
+    done
+elif [ $# -eq 1 ];
+then
+    [ -d $DEST/$1 ] || { echo "$NAME: $1 not found"; exit 1; }
+    [[ $1 =~ .*h$ ]] || { echo "$NAME: $1 is not a HS"; exit 1; }
+    FILE=$DEST/$1/$TARGET
+    [ -e $FILE ] || { echo "$NAME: $FILE not found"; exit 1; }
+    show_address $FILE
+else
+    usage
+fi

+ 45 - 0
tools/warnings.sh

@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Usage:
+#    cd YOUR-CHUTNEY-DIRECTORY
+#    tools/warnings.sh [node]
+# Output: for each node outputs its warnings and the number of times that
+# warning has ocurred. If the argument node is specified, it only shows
+# the warnings of that node.
+# Examples: tools/warnings.sh 
+#           tools/warnings.sh 000a
+
+function show_warnings() {
+    echo "${GREEN}Node `basename $1`:${NC}"
+    sed -n 's/^.*\[warn\]//p' $1/info.log | sort | uniq -c | \
+    sed -e 's/^\s*//' -e "s/\([0-9][0-9]*\) \(.*\)/${YELLOW}Warning:${NC}\2${YELLOW} Number: \1${NC}/"
+    echo ""
+}
+
+function usage() {
+    echo "Usage: $NAME [node]"
+    exit 1
+}
+
+NC=$(tput sgr0)
+YELLOW=$(tput setaf 3)
+GREEN=$(tput setaf 2)
+CHUTNEY=./chutney
+NAME=$(basename "$0")
+DEST=net/nodes
+
+[ -d net/nodes ] || { echo "$NAME: no logs available"; exit 1; }
+if [ $# -eq 0 ]; 
+then    
+    for dir in $DEST/*;
+    do
+        [ -e ${dir}/info.log ] || continue
+        show_warnings $dir 
+    done
+elif [ $# -eq 1 ];
+then 
+    [ -e $DEST/$1/info.log ] || { echo "$NAME: no log available"; exit 1; }
+    show_warnings $DEST/$1
+else
+    usage
+fi