From b2f25d7f0aa042ad99252128c4ddd09df9cbb920 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Sun, 20 Jan 2019 16:20:41 +0100 Subject: [PATCH] Store if there was an incoming connection for port open checker --- src/Connection/ConnectionServer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Connection/ConnectionServer.py b/src/Connection/ConnectionServer.py index a79af86d..308cde2b 100644 --- a/src/Connection/ConnectionServer.py +++ b/src/Connection/ConnectionServer.py @@ -1,6 +1,7 @@ import logging import time import sys +import socket from collections import defaultdict import gevent @@ -9,6 +10,7 @@ from gevent.server import StreamServer from gevent.pool import Pool import util +from util import helper from Debug import Debug from Connection import Connection from Config import config @@ -56,6 +58,7 @@ class ConnectionServer(object): self.num_incoming = 0 self.num_outgoing = 0 + self.had_external_incoming = False self.timecorrection = 0.0 @@ -137,6 +140,9 @@ class ConnectionServer(object): ip = ip.replace("::ffff:", "", 1) self.num_incoming += 1 + if not self.had_external_incoming and not helper.isPrivateIp(ip): + self.had_external_incoming = True + # Connection flood protection if ip in self.ip_incoming and ip not in self.whitelist: self.ip_incoming[ip] += 1 @@ -349,6 +355,7 @@ class ConnectionServer(object): self.log.info("Internet online") def onInternetOffline(self): + self.had_external_incoming = False self.log.info("Internet offline") def getTimecorrection(self):