mirror of
https://github.com/HelloZeroNet/ZeroNet.git
synced 2023-12-14 04:33:03 +01:00
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 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):
|
||||
|
|
Loading…
Reference in a new issue