2019-12-22 19:42:10 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
|
|
|
|
|
|
|
Test own Onionr node as it is running
|
|
|
|
"""
|
|
|
|
import config
|
|
|
|
from onionrutils import basicrequests
|
|
|
|
from utils import identifyhome
|
|
|
|
from utils import gettransports
|
|
|
|
import logger
|
|
|
|
from onionrutils import localcommand
|
|
|
|
"""
|
|
|
|
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/>.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def test_own_node(test_manager):
|
2020-03-19 06:42:15 +00:00
|
|
|
if config.get('general.security_level', 0) > 0 or not config.get('transports.tor', True):
|
|
|
|
return
|
2019-12-22 19:42:10 +00:00
|
|
|
socks_port = localcommand.local_command('/gettorsocks')
|
|
|
|
if config.get('general.security_level', 0) > 0:
|
|
|
|
return
|
|
|
|
own_tor_address = gettransports.get()[0]
|
|
|
|
if 'this is an onionr node' \
|
2020-01-30 04:56:47 +00:00
|
|
|
not in basicrequests.do_get_request('http://' + own_tor_address,
|
2020-02-08 09:07:07 +00:00
|
|
|
port=socks_port,
|
|
|
|
ignoreAPI=True).lower():
|
|
|
|
logger.warn(f'Own node not reachable in test {own_tor_address}')
|
2019-12-22 19:42:10 +00:00
|
|
|
raise ValueError
|
|
|
|
|
|
|
|
|
|
|
|
def test_tor_adder(test_manager):
|
2020-03-19 06:42:15 +00:00
|
|
|
if config.get('general.security_level', 0) > 0 or not config.get('transports.tor', True):
|
2019-12-22 19:42:10 +00:00
|
|
|
return
|
|
|
|
with open(identifyhome.identify_home() + 'hs/hostname', 'r') as hs:
|
|
|
|
hs = hs.read().strip()
|
|
|
|
if not hs:
|
|
|
|
logger.error('No Tor node address created yet')
|
|
|
|
raise ValueError('No Tor node address created yet')
|
|
|
|
|
|
|
|
if hs not in gettransports.get():
|
|
|
|
logger.error('gettransports Tor not same as file: %s %s' %
|
|
|
|
(hs, gettransports.get()))
|
|
|
|
raise ValueError('gettransports Tor not same as file')
|