[Pkg-privacy-commits] [onionbalance] 59/117: Add torrc file creation to oniobalance-config tool
Donncha O'Cearbahill
donncha-guest at moszumanska.debian.org
Wed Dec 16 23:18:47 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 a063e05cb7887eb2c135bf7269ae6489f330a6f3
Author: Donncha O'Cearbhaill <donncha at donncha.is>
Date: Mon Jun 29 13:00:02 2015 +0100
Add torrc file creation to oniobalance-config tool
---
MANIFEST.in | 1 -
data/torrc-server | 12 ----------
{data => onionbalance/data}/config.yaml.example | 0
{data => onionbalance/data}/torrc-instance | 9 +++----
onionbalance/data/torrc-server | 13 ++++++++++
onionbalance/settings.py | 32 +++++++++++++++++--------
setup.py | 30 ++++++++++++-----------
7 files changed, 56 insertions(+), 41 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in
index a9dc1ac..ffef4f6 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,4 +1,3 @@
include README.rst
include COPYING
include requirements.txt
-include data/
diff --git a/data/torrc-server b/data/torrc-server
deleted file mode 100644
index ff802b6..0000000
--- a/data/torrc-server
+++ /dev/null
@@ -1,12 +0,0 @@
-# Sample Tor config for the managment server
-# ---
-# The managment server must be able to access the Tor control port. Alternative
-# the control port can be enabled on the system Tor process.
-
-DataDirectory ./tor-data
-
-ControlPort 9051
-CookieAuthentication 1
-SocksPort 0
-
-# RunAsDaemon 1
diff --git a/data/config.yaml.example b/onionbalance/data/config.yaml.example
similarity index 100%
rename from data/config.yaml.example
rename to onionbalance/data/config.yaml.example
diff --git a/data/torrc-instance b/onionbalance/data/torrc-instance
similarity index 68%
rename from data/torrc-instance
rename to onionbalance/data/torrc-instance
index 655a1c2..a861853 100644
--- a/data/torrc-instance
+++ b/onionbalance/data/torrc-instance
@@ -1,4 +1,4 @@
-# Sample Tor config for the onion service instance servers
+# Tor config for the onion service instance servers
# ---
# The instance servers run standard onion services. In Basic mode the
# control port does not need to be enabled.
@@ -9,8 +9,9 @@ DataDirectory tor-data
# CookieAuthentication 1
SocksPort 0
+# RunAsDaemon 1
+
# Configure each onion service instance with a unique permanent key.
-HiddenServiceDir tor-data/hidden_service/
-HiddenServicePort 80 127.0.0.1:80
+# HiddenServiceDir tor-data/hidden_service/
+# HiddenServicePort 80 127.0.0.1:80
-# RunAsDaemon 1
diff --git a/onionbalance/data/torrc-server b/onionbalance/data/torrc-server
new file mode 100644
index 0000000..4845528
--- /dev/null
+++ b/onionbalance/data/torrc-server
@@ -0,0 +1,13 @@
+# Tor config for the managment server
+# ---
+# The management server must be able to access the Tor control port.
+# Alternatively the control port can be enabled on the system Tor process.
+
+DataDirectory tor-data
+
+ControlPort 9051
+CookieAuthentication 1
+SocksPort 0
+
+# RunAsDaemon 1
+
diff --git a/onionbalance/settings.py b/onionbalance/settings.py
index 4715f7e..0daf391 100644
--- a/onionbalance/settings.py
+++ b/onionbalance/settings.py
@@ -10,6 +10,7 @@ import errno
import argparse
import getpass
import logging
+import pkg_resources
import yaml
import Crypto.PublicKey
@@ -276,6 +277,7 @@ def generate_config():
"key (Not encrypted if no password is specified): ")
master_passphrase = master_passphrase or args.password
+ # Finished reading input, starting to write config files.
master_dir = os.path.join(output_path, 'master')
util.try_make_dir(master_dir)
master_key_file = os.path.join(master_dir,
@@ -295,24 +297,28 @@ def generate_config():
config_yaml = yaml.dump(settings_data, default_flow_style=False)
config_file_path = os.path.join(master_dir, 'config.yaml')
- with open(config_file_path, "w") as config_file:
+ with open(config_file_path, "tw") as config_file:
config_file.write(u"# OnionBalance Config File\n")
config_file.write(config_yaml)
logger.info("Wrote master service config file '%s'.",
os.path.abspath(config_file_path))
+ # Write master service torrc
+ master_torrc_path = os.path.join(master_dir, 'torrc-server')
+ master_torrc_template = pkg_resources.resource_string(__name__,
+ 'data/torrc-server')
+ with open(master_torrc_path, "tw") as master_torrc_file:
+ master_torrc_file.write(master_torrc_template.decode('utf-8'))
+
# Try generate config files for each service instance
for i, (instance_address, instance_key) in enumerate(instances):
# Create a numbered directory for instance
instance_dir = os.path.join(output_path, '{}{}'.format(tag, i+1))
- instance_key_dir = os.path.join(instance_dir,
- '{}'.format(instance_address))
+ instance_key_dir = os.path.join(instance_dir, instance_address)
util.try_make_dir(instance_key_dir)
os.chmod(instance_key_dir, 1472) # chmod 2700 in decimal
- instance_key_file = os.path.join(instance_dir,
- '{}'.format(instance_address),
- 'private_key')
+ instance_key_file = os.path.join(instance_key_dir, 'private_key')
with open(instance_key_file, "wb") as key_file:
os.chmod(instance_key_file, 384) # chmod 0600 in decimal
key_file.write(instance_key.exportKey())
@@ -321,10 +327,16 @@ def generate_config():
# Write torrc file for each instance
instance_torrc = os.path.join(instance_dir, 'instance_torrc')
- with open(instance_torrc, "w") as torrc_file:
- torrc_file.write("SocksPort 0\n")
- torrc_file.write("HiddenServiceDir {}\n".format(instance_address))
- torrc_file.write("{}\n".format(torrc_port_line))
+ instance_torrc_template = pkg_resources.resource_string(
+ __name__, 'data/torrc-instance')
+ with open(instance_torrc, "tw") as torrc_file:
+ torrc_file.write(instance_torrc_template.decode('utf-8'))
+ # The ./ relative path prevents Tor from raising relative
+ # path warnings. The relative path may need to be edited manual
+ # to work on Windows systems.
+ torrc_file.write(u"HiddenServiceDir {}\n".format(
+ instance_address))
+ torrc_file.write(u"{}\n".format(torrc_port_line))
# Output final status message
logger.info("Done! Successfully generated an OnionBalance config and %d "
diff --git a/setup.py b/setup.py
index 078b638..f7d986f 100644
--- a/setup.py
+++ b/setup.py
@@ -22,28 +22,30 @@ def read(*names, **kwargs):
).read()
setup(
- name = "OnionBalance",
- packages = ["onionbalance"],
- entry_points = {
+ name="OnionBalance",
+ packages=["onionbalance"],
+ entry_points={
"console_scripts": [
'onionbalance = onionbalance.manager:main',
'onionbalance-config = onionbalance.settings:generate_config',
]},
- description = "Tool for distributing Tor onion services connections to "
- "multiple backend Tor instances",
- long_description = read('README.rst'),
- version = module_info.get('__version__'),
- author = module_info.get('__author__'),
- author_email = module_info.get('__contact__'),
- url = module_info.get('__url__'),
- license = module_info.get('__license__'),
- keywords = 'tor',
- install_requires = [
+ description="Tool for distributing Tor onion services connections to "
+ "multiple backend Tor instances.",
+ long_description=read('README.rst'),
+ version=module_info.get('__version__'),
+ author=module_info.get('__author__'),
+ author_email=module_info.get('__contact__'),
+ url=module_info.get('__url__'),
+ license=module_info.get('__license__'),
+ keywords='tor',
+ install_requires=[
'stem>=1.4.0-dev',
'PyYAML>=3.11',
'pycrypto>=2.6.1',
'schedule>=0.3.1',
'future>=0.14.0',
],
- tests_require=['tox', 'pytest', 'mock', 'pytest-mock'],
+ tests_require=['tox', 'pytest', 'mock', 'pytest-mock', 'pexpect'],
+ package_data={'onionbalance': ['data/*']},
+ include_package_data=True,
)
--
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