Add an option to generate new I2P destination on every start

This commit is contained in:
TheKysek 2017-07-20 16:12:32 +02:00
parent b41606ad1f
commit ae799c295c
No known key found for this signature in database
GPG Key ID: 50D9AF00D0B1C497
2 changed files with 20 additions and 14 deletions

View File

@ -37,6 +37,7 @@ def parse_arguments():
parser.add_argument('--i2p-tunnel-length', help='Length of I2P tunnels', type=int)
parser.add_argument('--i2p-sam-host', help='Host of I2P SAMv3 bridge')
parser.add_argument('--i2p-sam-port', help='Port of I2P SAMv3 bridge', type=int)
parser.add_argument('--i2p-transient', help='Generate new I2P destination on start', action='store_true')
args = parser.parse_args()
if args.port:
@ -82,6 +83,8 @@ def parse_arguments():
shared.i2p_sam_host = args.i2p_sam_host
if args.i2p_sam_port:
shared.i2p_sam_port = args.i2p_sam_port
if args.i2p_transient:
shared.i2p_transient = True
def main():
@ -150,6 +153,7 @@ def main():
dest_priv = b''
if not shared.i2p_transient:
try:
with open(shared.data_directory + 'i2p_dest_priv.key', mode='br') as file:
dest_priv = file.read()
@ -172,6 +176,7 @@ def main():
i2p_listener = i2p.listener.I2PListener(i2p_controller.nick)
i2p_listener.start()
if not shared.i2p_transient:
try:
with open(shared.data_directory + 'i2p_dest_priv.key', mode='bw') as file:
file.write(i2p_controller.dest_priv)

View File

@ -27,6 +27,7 @@ i2p_dest_obj_type = 0x493250
i2p_dest_obj_version = 1
i2p_enabled = False
i2p_transient = False
i2p_sam_host = '127.0.0.1'
i2p_sam_port = 7656
i2p_tunnel_length = 2