gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14510 - gauger


From: gnunet
Subject: [GNUnet-SVN] r14510 - gauger
Date: Thu, 24 Feb 2011 04:05:37 +0100

Author: bartpolot
Date: 2011-02-24 04:05:37 +0100 (Thu, 24 Feb 2011)
New Revision: 14510

Modified:
   gauger/README
   gauger/gauger-cli.py
   gauger/gauger.py
Log:
Added configurable port


Modified: gauger/README
===================================================================
--- gauger/README       2011-02-24 02:38:18 UTC (rev 14509)
+++ gauger/README       2011-02-24 03:05:37 UTC (rev 14510)
@@ -48,13 +48,18 @@
  * gauger.conf: Server configuration
   Should be placed in same directory as gauger.py. Should contain two 
sections, 
   one with directories and one for authentication.
+  * Section net
+   Should contain the port on which to listen for incoming connections, 
default=10111
   * Section dir
    Should contain a path where to put the data logged from clients
   * Section hosts
    Should contain "username,password" and the desired hostname for each
    machine authorized to log data to the server, one per line. Username and
    password should be separated by a comma and contain no blank spaces.
-  Example:  
+  Example:
+  [net]
+  port=10111  
+
   [dir]
   data=my_data_directory
 
@@ -63,11 +68,11 @@
   user2,pass=testhost
 
  * gauger-cli.conf: Client configuration
-  Should contain one line with the server hostname, user and password.
+  Should contain one line with the server hostname[:port], user and password.
   Should be placed in the same directory as gauger-cli.py or in the user's
   home, as ~/.gauger-cli.conf
   Example:
-  server.tld user 123456
+  server.tld:10112 user 123456
 
 
 Usage
@@ -82,7 +87,7 @@
  * Client
    * Command line
     invoke with ./gauger-cli.py -n COUNTER_NAME -d COUNTER_VALUE -u unit [-i 
ID]
-    Run ./gauger-cli.py -h for help
+    Run ./gauger-cli.py -h for full help
    * C program
      * Include "gauger.h"
      * Call the macro GAUGER("COUNTER_NAME", COUNTER_VALUE, "COUNTER_UNIT")

Modified: gauger/gauger-cli.py
===================================================================
--- gauger/gauger-cli.py        2011-02-24 02:38:18 UTC (rev 14509)
+++ gauger/gauger-cli.py        2011-02-24 03:05:37 UTC (rev 14510)
@@ -49,6 +49,8 @@
         help="value of the data itself")
     parser.add_argument('-u', '--unit',
         help="unit in which the data is expressed")
+    parser.add_argument('-p', '--port', type=int,
+        help="port on which to connect")
     args = parser.parse_args()
     return args
 
@@ -80,9 +82,16 @@
 if(args.unit):
     args.name = args.name + "_" + args.unit
 
+port = 10111
+if (remotehost.count(':') == 1):
+    remotehost,port = remotehost.split(':')
+    port = int(port)
+if (args.port != None):
+    port = args.port
+
 s1 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 try:
-  s1.connect((remotehost, 10111))
+  s1.connect((remotehost, port))
 except:
   print "ERROR: Couldn't connect to", remotehost
   exit(1)

Modified: gauger/gauger.py
===================================================================
--- gauger/gauger.py    2011-02-24 02:38:18 UTC (rev 14509)
+++ gauger/gauger.py    2011-02-24 03:05:37 UTC (rev 14510)
@@ -34,6 +34,7 @@
     import argparse as arg_parser
 
 DATADIR="data/"
+PORT=10111
 
 def check_dir(path):
     path = path.strip("/")
@@ -55,6 +56,7 @@
 
 def process_configuration():
     global DATADIR
+    global PORT
     parser = ConfigParser.ConfigParser()
     parser.read(["gauger.conf"])
     try:
@@ -66,6 +68,7 @@
             print "ERROR: data dir not accessible"
             exit (1)
         print "Using datadir:", DATADIR
+        PORT=parser.getint('net', 'port')
     except ConfigParser.NoSectionError:
         pass
     except ConfigParser.NoOptionError:
@@ -220,7 +223,7 @@
 
 s1 = socket(AF_INET, SOCK_STREAM)
 s1.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
-s1.bind(("0.0.0.0", 10111))
+s1.bind(("0.0.0.0", PORT))
 s1.listen(5)
 while(True):
   s2, address = s1.accept()




reply via email to

[Prev in Thread] Current Thread [Next in Thread]