[Pkg-privacy-commits] [onionbalance] 08/117: Adds extra error checking and fixes typos, closes #2
Donncha O'Cearbahill
donncha-guest at moszumanska.debian.org
Wed Dec 16 23:18:41 UTC 2015
This is an automated email from the git hooks/post-receive script.
donncha-guest pushed a commit to branch debian/sid
in repository onionbalance.
commit 75d7511542144452bf902c80b07449d5b087b733
Author: Ivan Markin <mark-in at users.noreply.github.com>
Date: Wed Apr 8 00:45:53 2015 +0300
Adds extra error checking and fixes typos, closes #2
---
README.md | 6 +++++-
onion-balance/descriptor.py | 6 +++++-
onion-balance/manager.py | 12 ++++++++++--
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index ae2ea7f..6dfa2de 100644
--- a/README.md
+++ b/README.md
@@ -48,9 +48,10 @@ and upload HS descriptors. Until these features are merged into Tor, you can
use my patched Tor branch.
$ git clone https://github.com/DonnchaC/tor.git
+ $ cd tor
$ git checkout hs-fetch-and-post-cmds
-The `docs/torrc` contains a sample Tor config file which is suitable for the
+The `doc/torrc` contains a sample Tor config file which is suitable for the
management server.
##### Install the management server
@@ -67,6 +68,9 @@ be install using pip.
For onion service descriptor parsing you need a version of stem >= `1.3.0-dev`.
+ $ git clone https://git.torproject.org/stem.git
+ $ sudo python stem/setup.py install
+
## Configuration
Each load balancing Tor instance is listed by it's unique onion address.
diff --git a/onion-balance/descriptor.py b/onion-balance/descriptor.py
index 4dbae17..c00bf8c 100644
--- a/onion-balance/descriptor.py
+++ b/onion-balance/descriptor.py
@@ -9,6 +9,7 @@ import stem
import util
import log
+import sys
logger = log.get_logger()
@@ -176,6 +177,9 @@ def fetch_descriptor(controller, onion_address, hsdir=None):
response = controller.msg("HSFETCH %s" % (onion_address))
(response_code, divider, response_content) = response.content()[0]
if not response.is_ok():
+ if response_code == "510":
+ logger.error("This version of Tor does not support HSFETCH command")
+ sys.exit(1)
if response_code == "552":
raise stem.InvalidRequest(response_code, response_content)
else:
@@ -207,5 +211,5 @@ def upload_descriptor(controller, signed_descriptor, hsdirs=None):
if response_code == "552":
raise stem.InvalidRequest(response_code, response_content)
else:
- raise stem.ProtocolError("+HSPOST returned unexpected response "
+ raise stem.ProtocolError("HSPOST returned unexpected response "
"code: %s" % response_code)
diff --git a/onion-balance/manager.py b/onion-balance/manager.py
index b0282df..b2b6d05 100755
--- a/onion-balance/manager.py
+++ b/onion-balance/manager.py
@@ -78,7 +78,15 @@ def main():
logger.setLevel(logging.__dict__[args.verbosity.upper()])
# Create a connection to the Tor control port
- controller = Controller.from_port(address=args.ip, port=args.port)
+ try:
+ controller = Controller.from_port(address=args.ip, port=args.port)
+ except stem.SocketError as exc:
+ logger.error("Unable to connect to Tor control port: %s"
+ % exc)
+ sys.exit(1)
+ else:
+ logger.debug("Successfully connected to the Tor control port")
+
try:
controller.authenticate()
except stem.connection.AuthenticationFailure as exc:
@@ -86,7 +94,7 @@ def main():
% exc)
sys.exit(1)
else:
- logger.debug("Successfully connected to the Tor control port")
+ logger.debug("Successfully authenticated to the Tor control port")
# Load the keys and configuration for each hidden service
for service in config.cfg.config.get("services"):
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionbalance.git
More information about the Pkg-privacy-commits
mailing list