2019-12-19 10:34:19 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
2019-06-14 18:02:02 +00:00
|
|
|
|
2019-12-19 10:34:19 +00:00
|
|
|
Command to delete the Tor data directory if its safe to do so
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import logger
|
|
|
|
from onionrutils import localcommand
|
|
|
|
from utils import identifyhome
|
|
|
|
"""
|
2019-06-14 18:02:02 +00:00
|
|
|
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-12-19 10:34:19 +00:00
|
|
|
"""
|
|
|
|
|
2019-06-23 17:41:07 +00:00
|
|
|
|
2019-09-01 09:13:46 +00:00
|
|
|
def __delete(directory):
|
|
|
|
tor_dir = '%s/%s/' % (identifyhome.identify_home(), directory)
|
2019-06-14 18:02:02 +00:00
|
|
|
if os.path.exists(tor_dir):
|
2019-07-19 04:59:44 +00:00
|
|
|
if localcommand.local_command('/ping') == 'pong!':
|
2019-12-19 10:34:19 +00:00
|
|
|
logger.warn(
|
|
|
|
'Cannot delete Tor data while Onionr is running',
|
|
|
|
terminal=True)
|
2019-06-14 18:02:02 +00:00
|
|
|
else:
|
2019-09-01 09:13:46 +00:00
|
|
|
shutil.rmtree(tor_dir)
|
|
|
|
logger.info('Tor reset', terminal=True)
|
|
|
|
|
2019-12-19 10:34:19 +00:00
|
|
|
|
2019-09-01 09:13:46 +00:00
|
|
|
def reset_tor():
|
2019-12-19 10:34:19 +00:00
|
|
|
"""Delete tor data directory."""
|
2019-09-01 09:13:46 +00:00
|
|
|
__delete('tordata')
|
|
|
|
|
2019-12-19 10:34:19 +00:00
|
|
|
|
|
|
|
reset_tor.onionr_help = "Deletes Onionr's Tor data directory. " # type: ignore
|
|
|
|
reset_tor.onionr_help += "Only do this as a last resort if " # type: ignore
|
|
|
|
reset_tor.onionr_help += "you have serious Tor issues." # type: ignore
|
|
|
|
|
2019-09-21 05:06:49 +00:00
|
|
|
|
2019-09-01 09:13:46 +00:00
|
|
|
def reset_tor_key_pair():
|
2019-12-19 10:34:19 +00:00
|
|
|
"""Delete Tor HS key pair for our node."""
|
2019-09-01 09:13:46 +00:00
|
|
|
__delete('hs')
|
2019-09-21 05:06:49 +00:00
|
|
|
|
2019-12-19 10:34:19 +00:00
|
|
|
|
|
|
|
reset_tor_key_pair.onionr_help = "Delete's your Tor " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "node address permanently. " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "Note that through " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "fingerprinting attackers " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "may be able to know that " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "your new generated node " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "address belongs to " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "the same node " # type: ignore
|
|
|
|
reset_tor_key_pair.onionr_help += "as the deleted one." # type: ignore
|