Skip to content

Instantly share code, notes, and snippets.

@searinminecraft
Last active April 23, 2025 02:42
Show Gist options
  • Save searinminecraft/f3c2e1a104be3e39fa54ec9e8a8474b5 to your computer and use it in GitHub Desktop.
Save searinminecraft/f3c2e1a104be3e39fa54ec9e8a8474b5 to your computer and use it in GitHub Desktop.
A script that makes I2P domain registration easy.
"""
INSTRUCTIONS:
To use this script, you will need to download and
compile i2pd-tools, which can be found on:
https://github.com/purplei2p/i2pd-tools
Then you save this file to **the i2pd-tools folder**
and run this script.
"""
import subprocess
import os
def prompt_input(p: str, *, key=False, check=lambda _: True) -> str:
while True:
out = input(p)
if out == "":
continue
if not check(out):
print("Invalid Input")
continue
if key:
if os.path.isdir(out):
print("Is a directory")
continue
if not os.path.exists(out):
print("File does not exist")
continue
try:
subprocess.run(["./keyinfo", out], check=True)
except subprocess.CalledProcessError:
continue
break
return out
print("""
What do u want to do?
1 - Register address
2 - Register subdomain
""")
op = prompt_input("Enter choice > ", check=lambda _: _ in ("1", "2"))
match op:
case "1":
key = prompt_input("Path to key file: ", key=True)
domain = prompt_input("Domain name: ")
subprocess.run(["./regaddr", key, domain], check=True)
print("This is your auth string. You can now register it on http://reg.i2p/add. It may take 24 hours for it to be fully registered.")
case "2":
key = prompt_input("Path to root domain key file: ", key=True)
domain = prompt_input("Root domain name: ")
subdomain_key = prompt_input("Path to subdomain key file: ", key=True)
subdomain = prompt_input("Subdomain name: ")
step1 = subprocess.run(["./regaddr_3ld", "step1", subdomain_key, subdomain], stdout=subprocess.PIPE, check=True)
with open("step1.txt", "w") as f:
f.write(step1.stdout.decode("utf-8"))
step2 = subprocess.run(["./regaddr_3ld", "step2", "step1.txt", key, domain], stdout=subprocess.PIPE, check=True)
with open("step2.txt", "w") as f:
f.write(step2.stdout.decode("utf-8"))
subprocess.run(["./regaddr_3ld", "step3", "step2.txt", subdomain_key])
print("This is your auth string. You can now register it on http://reg.i2p/add. It may take 24 hours for it to be fully registered.")
os.remove("step1.txt")
os.remove("step2.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment