Browse Source

added setup.py

pull/5/head
l-n-s 8 years ago
parent
commit
e143c70bae
  1. 5
      INSTALL.md
  2. 20
      LICENSE
  3. 21
      README.md
  4. 128
      pyseeder.py
  5. 1
      pyseeder.py
  6. 128
      pyseeder/cli.py
  7. 37
      setup.py

5
INSTALL.md

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
Installation
============
Requirements: python3 and python cryptography package
Requirements: python3 and python cryptography package, requests for transports
Example for Ubuntu/Debian
-------------------------
@ -22,7 +23,7 @@ Configure new python virtual environment: @@ -22,7 +23,7 @@ Configure new python virtual environment:
cd pyseeder
virtualenv --python=python3 venv
. venv/bin/activate
pip3 install -r requirements.txt
pip3 install .
Thats it! Next time you will need to run pyseeder, don't forget to activate

20
LICENSE

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
Copyright (c) 2016-2017 Darknet Villain
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

21
README.md

@ -13,21 +13,26 @@ Reseed transports are implemented so that users can bootstrap their I2P nodes @@ -13,21 +13,26 @@ Reseed transports are implemented so that users can bootstrap their I2P nodes
without needing to connect to "official" I2P reseeds. This makes I2P more
invisible for firewalls.
[Installation instructions](INSTALL.md)
Installation
------------
$ pip3 install https://github.com/PurpleI2P/pyseeder/zipball/master
[Detailed installation instructions](INSTALL.md)
Usage
-----
$ python3 pyseeder.py --help
$ python3 pyseeder.py keygen --help
$ pyseeder --help
$ pyseeder keygen --help
Generating keypair
------------------
$ python3 pyseeder.py keygen --cert data/user_at_mail.i2p.crt --private-key data/priv_key.pem --signer-id user@mail.i2p
$ pyseeder keygen --cert data/user_at_mail.i2p.crt --private-key data/priv_key.pem --signer-id user@mail.i2p
This will generate certificate (user\_at\_mail.i2p.crt) and private RSA key
(priv\_key.pem) in data folder. E-mail is used as certificate identifier.
@ -40,7 +45,7 @@ Generating reseed data @@ -40,7 +45,7 @@ Generating reseed data
$ YOUR_PASSWORD="Pa55w0rd"
$ echo $YOUR_PASSWORD | python3 pyseeder.py reseed --netdb /path/to/netDb --private-key data/priv_key.pem --outfile output/i2pseeds.su3 --signer-id user@mail.i2p
$ echo $YOUR_PASSWORD | pyseeder reseed --netdb /path/to/netDb --private-key data/priv_key.pem --outfile output/i2pseeds.su3 --signer-id user@mail.i2p
This will generate file i2pseeds.su3 in output folder, using user@mail.i2p as
certificate identifier.
@ -52,7 +57,7 @@ is one of the ways to do it (for cron and scripts). @@ -52,7 +57,7 @@ is one of the ways to do it (for cron and scripts).
Download su3 file from official servers
---------------------------------------
$ python3 pyseeder.py transport.pull --urls https://reseed.i2p-projekt.de/ https://reseed.i2p.vzaws.com:8443/ --outfile output/i2pseeds.su3
$ pyseeder transport.pull --urls https://reseed.i2p-projekt.de/ https://reseed.i2p.vzaws.com:8443/ --outfile output/i2pseeds.su3
Note: --urls parameter is optional, defaults are "official" I2P reseeds.
@ -60,7 +65,7 @@ Note: --urls parameter is optional, defaults are "official" I2P reseeds. @@ -60,7 +65,7 @@ Note: --urls parameter is optional, defaults are "official" I2P reseeds.
Upload su3 file with pluggable transports
-----------------------------------------
$ python3 pyseeder.py transport.push --config transports.ini --file output/i2pseeds.su3
$ pyseeder transport.push --config transports.ini --file output/i2pseeds.su3
All parameters are optional. Copy file transports.ini.example to
transports.ini. Edit your settings in this new file.
@ -69,7 +74,7 @@ transports.ini. Edit your settings in this new file. @@ -69,7 +74,7 @@ transports.ini. Edit your settings in this new file.
Run HTTPS reseed server
-----------------------
$ python3 pyseeder.py serve --port 8443 --host 127.0.0.1 --private-key data/priv_key.pem --cert data/user_at_mail.i2p.crt --file output/i2pseeds.su3
$ pyseeder serve --port 8443 --host 127.0.0.1 --private-key data/priv_key.pem --cert data/user_at_mail.i2p.crt --file output/i2pseeds.su3
Note: this server is fine for testing, but for "production" environments please
use nginx webserver.

128
pyseeder.py

@ -1,128 +0,0 @@ @@ -1,128 +0,0 @@
#! /usr/bin/env python3
import os
import sys
import argparse
import logging
import pyseeder.transport
import pyseeder.actions
from pyseeder.utils import PyseederException
log = logging.getLogger(__name__)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--loglevel', default=logging.INFO, help="Log level",
choices=[logging.CRITICAL, logging.ERROR, logging.WARNING,
logging.INFO, logging.DEBUG])
subparsers = parser.add_subparsers(title="actions",
help="Command to execute")
kg_parser = subparsers.add_parser(
"keygen",
description="Generates keypair for your reseed",
usage="""
%(prog)s --cert data/user_at_mail.i2p.crt \\
--private-key data/priv_key.pem --signer-id user@mail.i2p"""
)
kg_parser.add_argument("--signer-id", required=True,
help="Identifier of certificate (example: user@mail.i2p)")
kg_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA private key (default: data/priv_key.pem)")
kg_parser.add_argument("--cert", default=None,
help="Certificate (example: data/user_at_mail.i2p.crt)")
kg_parser.add_argument("--no-encryption", action="store_true",
help="Disable private key encryption")
kg_parser.set_defaults(func=pyseeder.actions.keygen)
rs_parser = subparsers.add_parser(
"reseed",
description="Creates su3 reseed file",
usage="""
echo $YOUR_PASSWORD | %(prog)s --netdb /path/to/netDb \\
--private-key data/priv_key.pem --outfile output/i2pseeds.su3 \\
--signer-id user@mail.i2p"""
)
rs_parser.add_argument("--signer-id", required=True,
help="Identifier of certificate (example: user@mail.i2p)")
rs_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA private key (default: data/priv_key.pem)")
rs_parser.add_argument("-o", "--outfile", default="output/i2pseeds.su3",
help="Output file (default: output/i2pseeds.su3)")
rs_parser.add_argument("--netdb", required=True,
help="Path to netDb folder (example: ~/.i2pd/netDb)")
rs_parser.add_argument("--no-encryption", action="store_true",
help="Disable private key encryption")
rs_parser.set_defaults(func=pyseeder.actions.reseed)
tpull_parser = subparsers.add_parser(
"transport.pull",
description="Download su3 file from random reseed server",
usage="""
%(prog)s --urls https://reseed.i2p-projekt.de/ \\
https://reseed.i2p.vzaws.com:8443/ \\
--outfile output/i2pseeds.su3"""
)
tpull_parser.add_argument("--urls", default=pyseeder.transport.RESEED_URLS,
nargs="*", help="""Reseed URLs separated by space, default are
mainline I2P (like https://reseed.i2p-projekt.de/)""")
tpull_parser.add_argument("-o", "--outfile", default="output/i2pseeds.su3",
help="Output file (default: output/i2pseeds.su3)")
tpull_parser.set_defaults(func=pyseeder.actions.transport_pull)
tpush_parser = subparsers.add_parser(
"transport.push",
description="Upload su3 file with transports",
usage="%(prog)s --config transports.ini --file output/i2pseeds.su3"
)
tpush_parser.add_argument("--config", default="transports.ini",
help="Transports config file (default: transports.ini)")
tpush_parser.add_argument("-f", "--file", default="output/i2pseeds.su3",
help=".su3 file (default: output/i2pseeds.su3)")
tpush_parser.set_defaults(func=pyseeder.actions.transport_push)
serve_parser = subparsers.add_parser(
"serve",
description="""Run HTTPS reseeding server
(in production use nginx instead, please).
Will ask for a private key password""",
usage="""%(prog)s --port 8443 --host 127.0.0.1 \\
--private-key data/priv_key.pem \\
--cert data/user_at_mail.i2p.crt \\
--file output/i2pseeds.su3"""
)
serve_parser.add_argument("--host", default="0.0.0.0",
help="Host listening for clients (default: 0.0.0.0)")
serve_parser.add_argument("--port", default=8443,
help="Port listening for clients (default: 8443)")
serve_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA private key (default: data/priv_key.pem)")
serve_parser.add_argument("--cert", required=True,
help="Certificate (example: data/user_at_mail.i2p.crt)")
serve_parser.add_argument("-f", "--file", default="output/i2pseeds.su3",
help=".su3 file (default: output/i2pseeds.su3)")
serve_parser.set_defaults(func=pyseeder.actions.serve)
args = parser.parse_args()
logging.basicConfig(level=args.loglevel,
format='%(levelname)-8s %(message)s')
if hasattr(args, "func"):
try:
args.func(args)
except PyseederException as pe:
log.critical("Pyseeder error: {}".format(pe))
sys.exit(1)
else:
parser.print_help()
if __name__ == "__main__":
main()

1
pyseeder.py

@ -0,0 +1 @@ @@ -0,0 +1 @@
pyseeder/cli.py

128
pyseeder/cli.py

@ -0,0 +1,128 @@ @@ -0,0 +1,128 @@
#! /usr/bin/env python3
import os
import sys
import argparse
import logging
import pyseeder.transport
import pyseeder.actions
from pyseeder.utils import PyseederException
log = logging.getLogger(__name__)
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--loglevel', default=logging.INFO, help="Log level",
choices=[logging.CRITICAL, logging.ERROR, logging.WARNING,
logging.INFO, logging.DEBUG])
subparsers = parser.add_subparsers(title="actions",
help="Command to execute")
kg_parser = subparsers.add_parser(
"keygen",
description="Generates keypair for your reseed",
usage="""
%(prog)s --cert data/user_at_mail.i2p.crt \\
--private-key data/priv_key.pem --signer-id user@mail.i2p"""
)
kg_parser.add_argument("--signer-id", required=True,
help="Identifier of certificate (example: user@mail.i2p)")
kg_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA private key (default: data/priv_key.pem)")
kg_parser.add_argument("--cert", default=None,
help="Certificate (example: data/user_at_mail.i2p.crt)")
kg_parser.add_argument("--no-encryption", action="store_true",
help="Disable private key encryption")
kg_parser.set_defaults(func=pyseeder.actions.keygen)
rs_parser = subparsers.add_parser(
"reseed",
description="Creates su3 reseed file",
usage="""
echo $YOUR_PASSWORD | %(prog)s --netdb /path/to/netDb \\
--private-key data/priv_key.pem --outfile output/i2pseeds.su3 \\
--signer-id user@mail.i2p"""
)
rs_parser.add_argument("--signer-id", required=True,
help="Identifier of certificate (example: user@mail.i2p)")
rs_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA private key (default: data/priv_key.pem)")
rs_parser.add_argument("-o", "--outfile", default="output/i2pseeds.su3",
help="Output file (default: output/i2pseeds.su3)")
rs_parser.add_argument("--netdb", required=True,
help="Path to netDb folder (example: ~/.i2pd/netDb)")
rs_parser.add_argument("--no-encryption", action="store_true",
help="Disable private key encryption")
rs_parser.set_defaults(func=pyseeder.actions.reseed)
tpull_parser = subparsers.add_parser(
"transport.pull",
description="Download su3 file from random reseed server",
usage="""
%(prog)s --urls https://reseed.i2p-projekt.de/ \\
https://reseed.i2p.vzaws.com:8443/ \\
--outfile output/i2pseeds.su3"""
)
tpull_parser.add_argument("--urls", default=pyseeder.transport.RESEED_URLS,
nargs="*", help="""Reseed URLs separated by space, default are
mainline I2P (like https://reseed.i2p-projekt.de/)""")
tpull_parser.add_argument("-o", "--outfile", default="output/i2pseeds.su3",
help="Output file (default: output/i2pseeds.su3)")
tpull_parser.set_defaults(func=pyseeder.actions.transport_pull)
tpush_parser = subparsers.add_parser(
"transport.push",
description="Upload su3 file with transports",
usage="%(prog)s --config transports.ini --file output/i2pseeds.su3"
)
tpush_parser.add_argument("--config", default="transports.ini",
help="Transports config file (default: transports.ini)")
tpush_parser.add_argument("-f", "--file", default="output/i2pseeds.su3",
help=".su3 file (default: output/i2pseeds.su3)")
tpush_parser.set_defaults(func=pyseeder.actions.transport_push)
serve_parser = subparsers.add_parser(
"serve",
description="""Run HTTPS reseeding server
(in production use nginx instead, please).
Will ask for a private key password""",
usage="""%(prog)s --port 8443 --host 127.0.0.1 \\
--private-key data/priv_key.pem \\
--cert data/user_at_mail.i2p.crt \\
--file output/i2pseeds.su3"""
)
serve_parser.add_argument("--host", default="0.0.0.0",
help="Host listening for clients (default: 0.0.0.0)")
serve_parser.add_argument("--port", default=8443,
help="Port listening for clients (default: 8443)")
serve_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA private key (default: data/priv_key.pem)")
serve_parser.add_argument("--cert", required=True,
help="Certificate (example: data/user_at_mail.i2p.crt)")
serve_parser.add_argument("-f", "--file", default="output/i2pseeds.su3",
help=".su3 file (default: output/i2pseeds.su3)")
serve_parser.set_defaults(func=pyseeder.actions.serve)
args = parser.parse_args()
logging.basicConfig(level=args.loglevel,
format='%(levelname)-8s %(message)s')
if hasattr(args, "func"):
try:
args.func(args)
except PyseederException as pe:
log.critical("Pyseeder error: {}".format(pe))
sys.exit(1)
else:
parser.print_help()
if __name__ == "__main__":
main()

37
setup.py

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
#!/usr/bin/env python
from setuptools import setup
with open("README.md") as readme:
long_description = readme.read()
with open("requirements.txt") as f:
install_requires = f.read().split()
setup(
name='pyseeder',
version='0.0.1',
description='Python reseed utilities for I2P',
long_description=long_description,
author='Darnet Villain',
author_email='supervillain@riseup.net',
url='https://github.com/PurpleI2P/pyseeder/',
keywords='i2p reseed',
license='MIT',
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
packages=['pyseeder', 'pyseeder.transports'],
install_requires=install_requires,
entry_points={
'console_scripts': [
'pyseeder=pyseeder.cli:main',
],
}
)
Loading…
Cancel
Save