2019-03-09 06:37:57 +00:00
|
|
|
'''
|
2019-06-12 20:12:56 +00:00
|
|
|
Onionr - Private P2P Communication
|
2019-03-09 01:57:44 +00:00
|
|
|
|
2019-03-09 06:37:57 +00:00
|
|
|
add keys (transport and pubkey)
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
'''
|
2019-03-09 18:01:57 +00:00
|
|
|
import sys
|
|
|
|
import logger
|
2019-03-09 01:57:44 +00:00
|
|
|
def add_peer(o_inst):
|
|
|
|
try:
|
|
|
|
newPeer = sys.argv[2]
|
2019-03-09 18:01:57 +00:00
|
|
|
except IndexError:
|
2019-03-09 01:57:44 +00:00
|
|
|
pass
|
|
|
|
else:
|
2019-06-25 08:21:36 +00:00
|
|
|
if newPeer in o_inst.onionrCore.listPeers():
|
2019-06-20 00:59:05 +00:00
|
|
|
logger.info('We already have that key', terminal=True)
|
2019-03-09 01:57:44 +00:00
|
|
|
return
|
2019-06-20 00:59:05 +00:00
|
|
|
logger.info("Adding peer: " + logger.colors.underline + newPeer, terminal=True)
|
2019-03-09 01:57:44 +00:00
|
|
|
try:
|
|
|
|
if o_inst.onionrCore.addPeer(newPeer):
|
2019-06-20 00:59:05 +00:00
|
|
|
logger.info('Successfully added key', terminal=True)
|
2019-03-09 01:57:44 +00:00
|
|
|
except AssertionError:
|
2019-06-20 00:59:05 +00:00
|
|
|
logger.error('Failed to add key', terminal=True)
|
2019-03-09 01:57:44 +00:00
|
|
|
|
|
|
|
def add_address(o_inst):
|
|
|
|
try:
|
|
|
|
newAddress = sys.argv[2]
|
|
|
|
newAddress = newAddress.replace('http:', '').replace('/', '')
|
2019-03-09 18:01:57 +00:00
|
|
|
except IndexError:
|
2019-03-09 01:57:44 +00:00
|
|
|
pass
|
|
|
|
else:
|
2019-06-20 00:59:05 +00:00
|
|
|
logger.info("Adding address: " + logger.colors.underline + newAddress, terminal=True)
|
2019-03-09 06:37:57 +00:00
|
|
|
if o_inst.onionrCore.addAddress(newAddress):
|
2019-06-20 00:59:05 +00:00
|
|
|
logger.info("Successfully added address.", terminal=True)
|
2019-03-09 01:57:44 +00:00
|
|
|
else:
|
2019-06-20 00:59:05 +00:00
|
|
|
logger.warn("Unable to add address.", terminal=True)
|