[Pkg-privacy-commits] [pyptlib] 02/136: First draft of configuration API

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:24:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository pyptlib.

commit 5a0d91c126e76f3505d8c88e03f042f9ffba3fdd
Author: Brandon Wiley <brandon at blanu.net>
Date:   Wed May 23 17:15:58 2012 -0500

    First draft of configuration API
---
 src/pyptlib/__init__.py |  0
 src/pyptlib/client.py   | 23 ++++++++++++++++
 src/pyptlib/config.py   | 28 +++++++++++++++++++
 src/pyptlib/server.py   | 73 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 124 insertions(+)

diff --git a/src/pyptlib/__init__.py b/src/pyptlib/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/pyptlib/client.py b/src/pyptlib/client.py
new file mode 100644
index 0000000..383de56
--- /dev/null
+++ b/src/pyptlib/client.py
@@ -0,0 +1,23 @@
+class ClientConfig(Config):
+  clientTransports=[] # TOR_PT_CLIENT_TRANSPORTS
+  
+  def __init__(self): # throws EnvError
+    Config.__init__(self)
+    
+  # Returns a list of strings representing the client transports reported by Tor. If present, '*' is stripped from this list and used to set allTransportsEnabled to True.
+  def getClientTransports():
+    return clientTransports
+
+  # Write a message to stdout specifying a supported transport
+  # Takes: str, int, (str, int), [str], [str]
+  def writeMethod(name, socksVersion, address, args, optArgs): # CMETHOD
+    pass
+    
+  # Write a message to stdout specifying that an error occurred setting up the specified method
+  # Takes: str, str
+  def writeMethodError(name, message): # CMETHOD-ERROR
+    pass
+    
+  # Write a message to stdout specifying that the list of supported transports has ended
+  def writeMethodEnd() # CMETHODS DONE
+    pass
diff --git a/src/pyptlib/config.py b/src/pyptlib/config.py
new file mode 100644
index 0000000..dfa9d29
--- /dev/null
+++ b/src/pyptlib/config.py
@@ -0,0 +1,28 @@
+class Config:
+  stateLocation=None     # TOR_PT_STATE_LOCATION
+  managedTransportVer=[] # TOR_PT_MANAGED_TRANSPORT_VER
+  allTransportsEnabled=False
+  
+  def __init__(self): # throws EnvError
+    pass
+    
+  # Returns a string representing the path to the state storage directory (which may not exist, but should be creatable) reported by Tor
+  def getStateLocation():
+    return stateLocation
+
+  # Returns a list of strings representing supported versions as reported by Tor    
+  def getManagedTransportVersions()
+    return managedTransportVer
+    
+  # Checks to see if the specified version is included in those reported by Tor
+  # Returns True if the version is included and False if it is not
+  def checkManagedTransportVersion(version):
+    pass
+
+  # Returns a bool, True if the transport '*' was specified by Tor, otherwise False.
+  def getAllTransportsEnabled():
+    return allTransportsEnabled
+
+# Exception thrown when there is an error parsing the configuration parameters provided by Tor in environment variables    
+class EnvException(Exception):
+  pass
diff --git a/src/pyptlib/server.py b/src/pyptlib/server.py
new file mode 100644
index 0000000..a821ee2
--- /dev/null
+++ b/src/pyptlib/server.py
@@ -0,0 +1,73 @@
+class ServerConfig(Config):
+  extendedServerPort=None # TOR_PT_EXTENDED_SERVER_PORT
+  ORPort=None             # TOR_PT_ORPORT
+  serverBindAddr={}       # TOR_PT_SERVER_BINADDR
+  serverTransports=[]     # TOR_PT_SERVER_TRANSPORTS
+  
+  def __init__(self): # throws EnvError
+    Config.__init__(self)
+    
+  # Returns a tuple (str,int) representing the address of the Tor server port as reported by Tor
+  def getExtendedServerPort():
+    return extendedServerPort
+    
+  # Returns a tuple (str,int) representing the address of the Tor OR port as reported by Tor
+  def getORPort():
+    return ORPort
+    
+  # Returns a dict {str: (str,int)} representing the addresses for each transport as reported by Tor
+  def getServerBindAddresses():
+    return serverBindAddr
+    
+  # Returns a list of strings representing the server transports reported by Tor. If present, '*' is stripped from this list and used to set allTransportsEnabled to True.
+  def getServerTransports():
+    return serverTransports
+
+  # Write a message to stdout specifying that an error parsing the environment variables has occurred
+  # Takes: str
+  def writeEnvError(message): # ENV-ERROR
+    pass
+
+  # Write a message to stdout specifying that the specified configuration protocol version is supported   
+  # Takes: str
+  def writeVersion(version): # VERSION
+    pass
+    
+  # Write a message to stdout specifying a supported transport
+  # Takes: str, (str, int), MethodOptions
+  def writeMethod(name, address, options): # SMETHOD
+    pass
+    
+  # Write a message to stdout specifying that an error occurred setting up the specified method
+  # Takes: str, str
+  def writeMethodError(name, message): # SMETHOD-ERROR
+    pass    
+    
+  # Write a message to stdout specifying that the list of supported transports has ended
+  def writeMethodEnd() # SMETHODS DONE
+    pass
+
+class MethodOptions:
+  forward=False         # FORWARD
+  args={}               # ARGS
+  declare={}            # DECLARE
+  useExtendedPort=False # USE-EXTENDED-PORT
+
+  def __init__(self):
+    pass
+
+  # Sets forward to True    
+  def setForward()
+    pass
+  
+  # Adds a key-value pair to args
+  def addArg(key, value):
+    pass
+
+  # Adds a key-value pair to declare    
+  def addDeclare(key, value):
+    pass
+    
+  # Sets useExtendedPort to True
+  def setUserExtendedPort()
+    pass

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/pyptlib.git



More information about the Pkg-privacy-commits mailing list