fix lan server test for real this time

This commit is contained in:
Kevin Froman 2020-06-21 14:23:46 -05:00
parent 3ed2ac2d63
commit a24c87c5b0
3 changed files with 5 additions and 4 deletions

View File

@ -52,7 +52,7 @@ class LANServer:
@app.before_request @app.before_request
def dns_rebinding_prevention(): def dns_rebinding_prevention():
if request.remote_addr in lan_ips or ipaddress.ip_address(request.remote_addr).is_loopback: if request.remote_addr in lan_ips or ipaddress.ip_address(request.remote_addr).is_loopback:
if time.time() - _start_time < 600: if time.time() - _start_time > 600:
abort(403) abort(403)
if request.host != f'{self.host}:{self.port}': if request.host != f'{self.host}:{self.port}':
logger.warn('Potential DNS rebinding attack on LAN server:') logger.warn('Potential DNS rebinding attack on LAN server:')

View File

@ -20,15 +20,16 @@ def test_lan_server(testmanager):
bl3 = insert('test data3') bl3 = insert('test data3')
l = requests.get(f"http://{best_ip}:{i}/blist/0").text.split('\n') l = requests.get(f"http://{best_ip}:{i}/blist/0").text.split('\n')
if bl not in l or bl2 not in l or bl3 not in l: if bl not in l or bl2 not in l or bl3 not in l:
logger.error('blocks not in blist ' + '-'.join(l), terminal=True) logger.error('blocks not in blist ' + '-'.join(l))
raise ValueError raise ValueError
time = blockmetadb.get_block_date(bl3) - 1 time = blockmetadb.get_block_date(bl3) - 1
l = requests.get(f"http://{best_ip}:{i}/blist/{time}").text.split('\n') l = requests.get(f"http://{best_ip}:{i}/blist/{time}").text.split('\n')
if (bl in l and bl2 in l and bl3 in l) or len(l) == 0: if (bl in l and bl2 in l and bl3 in l) or len(l) == 0:
logger.error('Failed to get appopriate time' + '-'.join(l), terminal=True) logger.error('Failed to get appopriate time' + '-'.join(l))
raise ValueError raise ValueError
if onionrblockapi.Block(bl).raw != requests.get(f"http://{best_ip}:{i}/get/{bl}", stream=True).raw.read(6000000): if onionrblockapi.Block(bl).raw != requests.get(f"http://{best_ip}:{i}/get/{bl}", stream=True).raw.read(6000000):
logger.error('Block doesn\'t match')
raise ValueError raise ValueError
break break

View File

@ -1 +1 @@
1592089969 1592767265