Example #1
0
    def __init__(self):
        super().__init__()

        self.lock           = Lock()
        self.read_sockets   = {}    # Dictionary<Socket, bool>
        self.write_sockets  = {}    # Dictionary<Socket, bool
        self.error_sockets  = {}    # Dictionary<Socket, bool>
Example #2
0
    def __init__(self):
        super().__init__()

        self.lock = Lock()
        self.sockets = {}  # Dictionary<Socket, NaptSocket>
        self.status = NaptRelayStatus.Stopped
        self.debug = True
Example #3
0
    def __init__(self, client, server):
        Utils.expects_type(socket.socket, client, 'client')
        Utils.expects_type(socket.socket, server, 'server', True)

        self.lock           = Lock()
        self.id             = 0
        self.client         = NaptSocket(self, client, True)
        self.server         = NaptSocket(self, server, False)
        self.is_initial     = True;
        self.is_connecting  = False
        self.is_connected   = False
        self.is_closed      = False
        self.tag            = None
        self.tls            = False
        self.debug          = True
        self.lastrecvtime   = datetime.datetime.now()

        self.connected      = Event()
        self.closed         = Event()
        self.client_closing = Event()
        self.server_closing = Event()
        self.client_closed  = Event()
        self.server_closed  = Event()
        self.client_recieved= Event()
        self.server_recieved= Event()
Example #4
0
    def __init__(self, bindaddr):
        super().__init__()

        self.lock = Lock()
        self.bindaddr = bindaddr
        self.sockets = {}  # Dictionary<int, Socket>
        self.status = NaptListenerStatus.Stopped

        self.accepted = Event('NaptListenerEventArgs')
Example #5
0
    def __init__(self, bindaddr):
        super().__init__()

        self.lock = Lock()
        self.bindaddr = bindaddr
        self.status = NaptListenerStatus.Stopped
        self.ports = {}
        self.parts = []
        self.port_unit = 500 if Utils.is_windows(os.name) else 1000
        self.num_ports = 0

        self.accepted = Event('NaptListenerEventArgs')
Example #6
0
    def __init__(self):
        self.lock           = Lock()
        self.descripters    = {}
        self.fd_map         = {}
        #self.timeout        = 1.0
        self.timeout        = 5.0
        self.thread         = None
        self.running        = False
        self.debug          = True

        self.started        = Event('EventArgs')
        self.stopped        = Event('EventArgs')
        self.idle           = Event('EventArgs')
Example #7
0
    def __init__(self):
        if Utils.is_linux(os.name):
            self.impl = SocketSelectorLinux(self)
        else:
            self.impl = SocketSelectorOther(self)

        self.lock           = Lock()
        self.read_sockets   = []    # List<Socket>
        self.write_sockets  = []    # List<Socket>
        self.error_sockets  = []    # List<Socket>
        self.timeout        = 1.0
        self.thread         = None
        self.running        = False

        self.started        = Event('EventArgs')
        self.stopped        = Event('EventArgs')
Example #8
0
    def __init__(self, logdir, elastic):
        self.lock = Lock()
        self.dir = logdir
        if os.path.exists(self.dir) == False:
            os.mkdir(self.dir)
        if (elastic == True):
            self.elastic = ElasticConnector()
        #self.packet_dir = None
        #self.save_packet= False

        self.geoip_city_reader = geoip2.database.Reader(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'geoip/GeoLite2-City.mmdb'))
        self.geoip_asn_reader = geoip2.database.Reader(
            os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'geoip/GeoLite2-ASN.mmdb'))
Example #9
0
    def __init__(self):
        super().__init__()

        self.lock           = Lock()
        self.poller         = select.epoll()