Block UDP 53 in test_bootstrap_tor using subprocess call of iptables
This commit is contained in:
parent
ebdcc363b1
commit
29dd235872
|
@ -18,6 +18,7 @@ import unittest
|
||||||
|
|
||||||
import protocol
|
import protocol
|
||||||
import state
|
import state
|
||||||
|
import subprocess
|
||||||
import helper_sent
|
import helper_sent
|
||||||
import helper_addressbook
|
import helper_addressbook
|
||||||
|
|
||||||
|
@ -263,9 +264,22 @@ class TestCore(unittest.TestCase):
|
||||||
def test_bootstrap_tor(self):
|
def test_bootstrap_tor(self):
|
||||||
"""test bootstrapping with tor"""
|
"""test bootstrapping with tor"""
|
||||||
BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'SOCKS5')
|
BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'SOCKS5')
|
||||||
|
iptables_rule = [
|
||||||
|
'OUTPUT', '-p', 'udp', '--dport', '53', '-j', 'REJECT']
|
||||||
|
try:
|
||||||
|
subprocess.call(['sudo', 'iptables', '-A'] + iptables_rule)
|
||||||
|
except OSError:
|
||||||
|
print('Failed to use iptables ):')
|
||||||
|
else:
|
||||||
|
with self.assertRaises(socket.gaierror):
|
||||||
|
socket.getaddrinfo('bootstrap8080.bitmessage.org', 8444)
|
||||||
self._initiate_bootstrap()
|
self._initiate_bootstrap()
|
||||||
self._check_connection()
|
self._check_connection()
|
||||||
self._check_knownnodes()
|
self._check_knownnodes()
|
||||||
|
try:
|
||||||
|
subprocess.call(['sudo', 'iptables', '-D'] + iptables_rule)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
@unittest.skipIf(tor_port_free, 'no running tor detected')
|
@unittest.skipIf(tor_port_free, 'no running tor detected')
|
||||||
def test_onionservicesonly(self):
|
def test_onionservicesonly(self):
|
||||||
|
|
Reference in New Issue
Block a user