Browse Source

update reseed list

pull/13/head
R4SAS 5 years ago
parent
commit
0d5a7ac908
  1. 2
      .gitignore
  2. 12
      pyseeder/cli.py
  3. 2
      pyseeder/crypto.py
  4. 6
      pyseeder/server.py
  5. 4
      pyseeder/su3file.py
  6. 15
      pyseeder/transport.py
  7. 6
      pyseeder/transports/git.py
  8. 4
      pyseeder/transports/github.py

2
.gitignore vendored

@ -1,4 +1,6 @@
__pycache__ __pycache__
*.pyc *.pyc
build/
pyseeder.egg-info/
venv/ venv/
transports.ini transports.ini

12
pyseeder/cli.py

@ -9,7 +9,7 @@ import pyseeder.actions
from pyseeder.utils import PyseederException from pyseeder.utils import PyseederException
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--loglevel', default=logging.INFO, help="Log level", parser.add_argument('--loglevel', default=logging.INFO, help="Log level",
@ -24,7 +24,7 @@ def main():
description="Generates keypair for your reseed", description="Generates keypair for your reseed",
usage=""" usage="""
%(prog)s --cert data/user_at_mail.i2p.crt \\ %(prog)s --cert data/user_at_mail.i2p.crt \\
--private-key data/priv_key.pem --signer-id user@mail.i2p""" --private-key data/priv_key.pem --signer-id user@mail.i2p"""
) )
kg_parser.add_argument("--signer-id", required=True, kg_parser.add_argument("--signer-id", required=True,
help="Identifier of certificate (example: user@mail.i2p)") help="Identifier of certificate (example: user@mail.i2p)")
@ -45,13 +45,13 @@ echo $YOUR_PASSWORD | %(prog)s --netdb /path/to/netDb \\
--private-key data/priv_key.pem --outfile output/i2pseeds.su3 \\ --private-key data/priv_key.pem --outfile output/i2pseeds.su3 \\
--signer-id user@mail.i2p""" --signer-id user@mail.i2p"""
) )
rs_parser.add_argument("--signer-id", required=True, rs_parser.add_argument("--signer-id", required=True,
help="Identifier of certificate (example: user@mail.i2p)") help="Identifier of certificate (example: user@mail.i2p)")
rs_parser.add_argument("--private-key", default="data/priv_key.pem", rs_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA 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", rs_parser.add_argument("-o", "--outfile", default="output/i2pseeds.su3",
help="Output file (default: output/i2pseeds.su3)") help="Output file (default: output/i2pseeds.su3)")
rs_parser.add_argument("--netdb", required=True, rs_parser.add_argument("--netdb", required=True,
help="Path to netDb folder (example: ~/.i2pd/netDb)") help="Path to netDb folder (example: ~/.i2pd/netDb)")
rs_parser.add_argument("--no-encryption", action="store_true", rs_parser.add_argument("--no-encryption", action="store_true",
help="Disable private key encryption") help="Disable private key encryption")
@ -102,7 +102,7 @@ echo $YOUR_PASSWORD | %(prog)s --netdb /path/to/netDb \\
help="Port listening for clients (default: 8443)") help="Port listening for clients (default: 8443)")
serve_parser.add_argument("--private-key", default="data/priv_key.pem", serve_parser.add_argument("--private-key", default="data/priv_key.pem",
help="RSA private key (default: data/priv_key.pem)") help="RSA private key (default: data/priv_key.pem)")
serve_parser.add_argument("--cert", required=True, serve_parser.add_argument("--cert", required=True,
help="Certificate (example: data/user_at_mail.i2p.crt)") help="Certificate (example: data/user_at_mail.i2p.crt)")
serve_parser.add_argument("-f", "--file", default="output/i2pseeds.su3", serve_parser.add_argument("-f", "--file", default="output/i2pseeds.su3",
help=".su3 file (default: output/i2pseeds.su3)") help=".su3 file (default: output/i2pseeds.su3)")
@ -111,7 +111,7 @@ echo $YOUR_PASSWORD | %(prog)s --netdb /path/to/netDb \\
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=args.loglevel, logging.basicConfig(level=args.loglevel,
format='%(levelname)-8s %(message)s') format='%(levelname)-8s %(message)s')
if hasattr(args, "func"): if hasattr(args, "func"):

2
pyseeder/crypto.py

@ -1,5 +1,5 @@
import os import os
import random import random
import sys import sys
import datetime import datetime

6
pyseeder/server.py

@ -14,7 +14,7 @@ class ReseedHandler(http.server.SimpleHTTPRequestHandler):
if path == "/i2pseeds.su3": if path == "/i2pseeds.su3":
self.send_response(200) self.send_response(200)
self.send_header("Content-Type", "application/octet-stream") self.send_header("Content-Type", "application/octet-stream")
self.send_header("Content-Length", self.send_header("Content-Length",
os.path.getsize(self.i2pseeds_file)) os.path.getsize(self.i2pseeds_file))
self.end_headers() self.end_headers()
with open(self.i2pseeds_file, 'rb') as f: with open(self.i2pseeds_file, 'rb') as f:
@ -25,10 +25,10 @@ class ReseedHandler(http.server.SimpleHTTPRequestHandler):
def run_server(host, port, priv_key, cert, i2pseeds_file): def run_server(host, port, priv_key, cert, i2pseeds_file):
"""Start HTTPS server""" """Start HTTPS server"""
Handler = ReseedHandler Handler = ReseedHandler
Handler.i2pseeds_file = i2pseeds_file Handler.i2pseeds_file = i2pseeds_file
httpd = http.server.HTTPServer((host, int(port)), Handler) httpd = http.server.HTTPServer((host, int(port)), Handler)
httpd.socket = ssl.wrap_socket(httpd.socket, server_side=True, httpd.socket = ssl.wrap_socket(httpd.socket, server_side=True,
keyfile=priv_key, certfile=cert, ssl_version=ssl.PROTOCOL_TLSv1) keyfile=priv_key, certfile=cert, ssl_version=ssl.PROTOCOL_TLSv1)
try: try:

4
pyseeder/su3file.py

@ -1,6 +1,6 @@
import os import os
import time, datetime import time, datetime
import random import random
import io import io
from zipfile import ZipFile, ZIP_DEFLATED from zipfile import ZipFile, ZIP_DEFLATED
@ -68,7 +68,7 @@ class SU3File:
dat_files = random.sample(dat_files, 75) dat_files = random.sample(dat_files, 75)
with ZipFile(zip_file, "w", compression=ZIP_DEFLATED) as zf: with ZipFile(zip_file, "w", compression=ZIP_DEFLATED) as zf:
for f in dat_files: for f in dat_files:
zf.write(f, arcname=os.path.split(f)[1]) zf.write(f, arcname=os.path.split(f)[1])
self.FILE_TYPE = 0x00 self.FILE_TYPE = 0x00

15
pyseeder/transport.py

@ -12,14 +12,13 @@ log = logging.getLogger(__name__)
RESEED_URLS = [ RESEED_URLS = [
"https://reseed.i2p-projekt.de/", "https://reseed.i2p-projekt.de/",
"https://i2p.mooo.com/netDb/", "https://i2p.mooo.com/netDb/",
"https://netdb.i2p2.no/", "https://reseed.i2p2.no/",
"https://us.reseed.i2p2.no:444/", "https://reseed-fr.i2pd.xyz/",
"https://uk.reseed.i2p2.no:444/", "https://reseed.memcpy.io/",
"https://i2p.manas.ca:8443/", "https://reseed.onion.im/",
"https://i2p-0.manas.ca:8443/", "https://i2pseed.creativecowpat.net:8443/",
"https://reseed.i2p.vzaws.com:8443/", "https://reseed.i2pgit.org/",
"https://user.mx24.eu/", "https://i2p.novg.net/",
"https://download.xxlspeed.com/",
] ]
def download(url, filename): def download(url, filename):

6
pyseeder/transports/git.py

@ -6,11 +6,11 @@ from pyseeder.utils import TransportException
TRANSPORT_NAME = "git" TRANSPORT_NAME = "git"
# Push to github repo witout prompting password. # Push to github repo witout prompting password.
# Set up SSH keys or change origin URL like that: # Set up SSH keys or change origin URL like that:
# git remote set-url origin https://$USERNAME:$PASSWORD@github.com/$USERNAME/$REPO.git # git remote set-url origin https://$USERNAME:$PASSWORD@github.com/$USERNAME/$REPO.git
def run(filename, config): def run(filename, config):
if "folder" not in config: if "folder" not in config:
raise TransportException("git: No folder specified in config") raise TransportException("git: No folder specified in config")
else: else:
@ -28,7 +28,7 @@ def run(filename, config):
copyfile(filename, os.path.join(REPO_FOLDER, REPO_FILE)) copyfile(filename, os.path.join(REPO_FOLDER, REPO_FILE))
commands = [ commands = [
"git add {}".format(REPO_FILE), "git add {}".format(REPO_FILE),
"git commit -m 'update'", "git commit -m 'update'",
"git push origin master" "git push origin master"
] ]

4
pyseeder/transports/github.py

@ -34,14 +34,14 @@ def run(filename, config):
r = requests.delete(x["url"], auth=creds) r = requests.delete(x["url"], auth=creds)
if r.status_code is not 204: if r.status_code is not 204:
raise TransportException("Failed to delete asset from GitHub") raise TransportException("Failed to delete asset from GitHub")
# upload new asset # upload new asset
upload_url = resp.json()["upload_url"].split("{")[0] # wat upload_url = resp.json()["upload_url"].split("{")[0] # wat
headers = {'Content-Type': content_type} headers = {'Content-Type': content_type}
params = {'name': asset_name} params = {'name': asset_name}
data = open(filename, 'rb').read() data = open(filename, 'rb').read()
r = requests.post(upload_url, headers=headers, params=params, auth=creds, r = requests.post(upload_url, headers=headers, params=params, auth=creds,
data=data) data=data)
if r.status_code is not 201: if r.status_code is not 201:

Loading…
Cancel
Save