Add an option to generate new I2P destination on every start
This commit is contained in:
parent
b41606ad1f
commit
ae799c295c
|
@ -37,6 +37,7 @@ def parse_arguments():
|
||||||
parser.add_argument('--i2p-tunnel-length', help='Length of I2P tunnels', type=int)
|
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-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-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()
|
args = parser.parse_args()
|
||||||
if args.port:
|
if args.port:
|
||||||
|
@ -82,6 +83,8 @@ def parse_arguments():
|
||||||
shared.i2p_sam_host = args.i2p_sam_host
|
shared.i2p_sam_host = args.i2p_sam_host
|
||||||
if args.i2p_sam_port:
|
if args.i2p_sam_port:
|
||||||
shared.i2p_sam_port = args.i2p_sam_port
|
shared.i2p_sam_port = args.i2p_sam_port
|
||||||
|
if args.i2p_transient:
|
||||||
|
shared.i2p_transient = True
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -150,13 +153,14 @@ def main():
|
||||||
|
|
||||||
dest_priv = b''
|
dest_priv = b''
|
||||||
|
|
||||||
try:
|
if not shared.i2p_transient:
|
||||||
with open(shared.data_directory + 'i2p_dest_priv.key', mode='br') as file:
|
try:
|
||||||
dest_priv = file.read()
|
with open(shared.data_directory + 'i2p_dest_priv.key', mode='br') as file:
|
||||||
logging.debug('Loaded I2P destination private key.')
|
dest_priv = file.read()
|
||||||
except Exception as e:
|
logging.debug('Loaded I2P destination private key.')
|
||||||
logging.warning('Error while loading I2P destination private key.')
|
except Exception as e:
|
||||||
logging.warning(e)
|
logging.warning('Error while loading I2P destination private key.')
|
||||||
|
logging.warning(e)
|
||||||
|
|
||||||
logging.info('Starting I2P Controller and creating tunnels. This may take a while.')
|
logging.info('Starting I2P Controller and creating tunnels. This may take a while.')
|
||||||
i2p_controller = i2p.controller.I2PController(shared.i2p_sam_host, shared.i2p_sam_port, dest_priv)
|
i2p_controller = i2p.controller.I2PController(shared.i2p_sam_host, shared.i2p_sam_port, dest_priv)
|
||||||
|
@ -172,13 +176,14 @@ def main():
|
||||||
i2p_listener = i2p.listener.I2PListener(i2p_controller.nick)
|
i2p_listener = i2p.listener.I2PListener(i2p_controller.nick)
|
||||||
i2p_listener.start()
|
i2p_listener.start()
|
||||||
|
|
||||||
try:
|
if not shared.i2p_transient:
|
||||||
with open(shared.data_directory + 'i2p_dest_priv.key', mode='bw') as file:
|
try:
|
||||||
file.write(i2p_controller.dest_priv)
|
with open(shared.data_directory + 'i2p_dest_priv.key', mode='bw') as file:
|
||||||
logging.debug('Saved I2P destination private key.')
|
file.write(i2p_controller.dest_priv)
|
||||||
except Exception as e:
|
logging.debug('Saved I2P destination private key.')
|
||||||
logging.warning('Error while saving I2P destination private key.')
|
except Exception as e:
|
||||||
logging.warning(e)
|
logging.warning('Error while saving I2P destination private key.')
|
||||||
|
logging.warning(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(shared.data_directory + 'i2p_dest.pub', mode='bw') as file:
|
with open(shared.data_directory + 'i2p_dest.pub', mode='bw') as file:
|
||||||
|
|
|
@ -27,6 +27,7 @@ i2p_dest_obj_type = 0x493250
|
||||||
i2p_dest_obj_version = 1
|
i2p_dest_obj_version = 1
|
||||||
|
|
||||||
i2p_enabled = False
|
i2p_enabled = False
|
||||||
|
i2p_transient = False
|
||||||
i2p_sam_host = '127.0.0.1'
|
i2p_sam_host = '127.0.0.1'
|
||||||
i2p_sam_port = 7656
|
i2p_sam_port = 7656
|
||||||
i2p_tunnel_length = 2
|
i2p_tunnel_length = 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user