Store if there was an incoming connection for port open checker
This commit is contained in:
parent
30b71328b9
commit
b2f25d7f0a
1 changed files with 7 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
|
import socket
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
import gevent
|
import gevent
|
||||||
|
@ -9,6 +10,7 @@ from gevent.server import StreamServer
|
||||||
from gevent.pool import Pool
|
from gevent.pool import Pool
|
||||||
|
|
||||||
import util
|
import util
|
||||||
|
from util import helper
|
||||||
from Debug import Debug
|
from Debug import Debug
|
||||||
from Connection import Connection
|
from Connection import Connection
|
||||||
from Config import config
|
from Config import config
|
||||||
|
@ -56,6 +58,7 @@ class ConnectionServer(object):
|
||||||
|
|
||||||
self.num_incoming = 0
|
self.num_incoming = 0
|
||||||
self.num_outgoing = 0
|
self.num_outgoing = 0
|
||||||
|
self.had_external_incoming = False
|
||||||
|
|
||||||
self.timecorrection = 0.0
|
self.timecorrection = 0.0
|
||||||
|
|
||||||
|
@ -137,6 +140,9 @@ class ConnectionServer(object):
|
||||||
ip = ip.replace("::ffff:", "", 1)
|
ip = ip.replace("::ffff:", "", 1)
|
||||||
self.num_incoming += 1
|
self.num_incoming += 1
|
||||||
|
|
||||||
|
if not self.had_external_incoming and not helper.isPrivateIp(ip):
|
||||||
|
self.had_external_incoming = True
|
||||||
|
|
||||||
# Connection flood protection
|
# Connection flood protection
|
||||||
if ip in self.ip_incoming and ip not in self.whitelist:
|
if ip in self.ip_incoming and ip not in self.whitelist:
|
||||||
self.ip_incoming[ip] += 1
|
self.ip_incoming[ip] += 1
|
||||||
|
@ -349,6 +355,7 @@ class ConnectionServer(object):
|
||||||
self.log.info("Internet online")
|
self.log.info("Internet online")
|
||||||
|
|
||||||
def onInternetOffline(self):
|
def onInternetOffline(self):
|
||||||
|
self.had_external_incoming = False
|
||||||
self.log.info("Internet offline")
|
self.log.info("Internet offline")
|
||||||
|
|
||||||
def getTimecorrection(self):
|
def getTimecorrection(self):
|
||||||
|
|
Loading…
Reference in a new issue