From a24c87c5b0b302ae6afbb40d916b50213715b567 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 21 Jun 2020 14:23:46 -0500 Subject: [PATCH] fix lan server test for real this time --- src/lan/server/__init__.py | 2 +- src/runtests/lanservertest.py | 5 +++-- tests/runtime-result.txt | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lan/server/__init__.py b/src/lan/server/__init__.py index 338c7632..1be649cd 100644 --- a/src/lan/server/__init__.py +++ b/src/lan/server/__init__.py @@ -52,7 +52,7 @@ class LANServer: @app.before_request def dns_rebinding_prevention(): 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) if request.host != f'{self.host}:{self.port}': logger.warn('Potential DNS rebinding attack on LAN server:') diff --git a/src/runtests/lanservertest.py b/src/runtests/lanservertest.py index 1d54b5bd..76836c87 100644 --- a/src/runtests/lanservertest.py +++ b/src/runtests/lanservertest.py @@ -20,15 +20,16 @@ def test_lan_server(testmanager): bl3 = insert('test data3') 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: - logger.error('blocks not in blist ' + '-'.join(l), terminal=True) + logger.error('blocks not in blist ' + '-'.join(l)) raise ValueError time = blockmetadb.get_block_date(bl3) - 1 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: - logger.error('Failed to get appopriate time' + '-'.join(l), terminal=True) + logger.error('Failed to get appopriate time' + '-'.join(l)) raise ValueError 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 break diff --git a/tests/runtime-result.txt b/tests/runtime-result.txt index 1123bdb8..8262e8e4 100644 --- a/tests/runtime-result.txt +++ b/tests/runtime-result.txt @@ -1 +1 @@ -1592089969 \ No newline at end of file +1592767265 \ No newline at end of file