Commit 9af13dfc authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[1454] Accept implemented

parent e7b1c03c
...@@ -23,6 +23,7 @@ from isc.dns import * ...@@ -23,6 +23,7 @@ from isc.dns import *
from isc.config.ccsession import * from isc.config.ccsession import *
from isc.cc import SessionError, SessionTimeout from isc.cc import SessionError, SessionTimeout
import isc.util.process import isc.util.process
import isc.util.io.socketsession
import select import select
from isc.log_messages.ddns_messages import * from isc.log_messages.ddns_messages import *
...@@ -86,7 +87,7 @@ class DDNSServer: ...@@ -86,7 +87,7 @@ class DDNSServer:
self._config_data = self._cc.get_full_config() self._config_data = self._cc.get_full_config()
self._cc.start() self._cc.start()
self._shutdown = False self._shutdown = False
# List of the sessions where we get the packets to handle # List of the sessions where we get the packets
self._socket_sessions = {} self._socket_sessions = {}
def config_handler(self, new_config): def config_handler(self, new_config):
...@@ -132,7 +133,10 @@ class DDNSServer: ...@@ -132,7 +133,10 @@ class DDNSServer:
""" """
Accept another connection and create the session receiver. Accept another connection and create the session receiver.
""" """
pass socket = self._listen_socket.accept()
fileno = socket.fileno()
session = isc.util.io.socketsession.SocketSessionReceiver(socket)
self._socket_sessions[fileno] = (socket, session)
def run(self): def run(self):
''' '''
......
...@@ -20,6 +20,7 @@ import isc ...@@ -20,6 +20,7 @@ import isc
import ddns import ddns
import isc.config import isc.config
import select import select
import isc.util.io.socketsession
class FakeSocket: class FakeSocket:
""" """
...@@ -29,6 +30,8 @@ class FakeSocket: ...@@ -29,6 +30,8 @@ class FakeSocket:
self.__fileno = fileno self.__fileno = fileno
def fileno(self): def fileno(self):
return self.__fileno return self.__fileno
def accept(self):
return FakeSocket(self.__fileno + 1)
class FakeSession: class FakeSession:
""" """
...@@ -102,6 +105,8 @@ class TestDDNSServer(unittest.TestCase): ...@@ -102,6 +105,8 @@ class TestDDNSServer(unittest.TestCase):
def tearDown(self): def tearDown(self):
ddns.select.select = select.select ddns.select.select = select.select
ddns.isc.util.io.socketsession.SocketSessionReceiver = \
isc.util.io.socketsession.SocketSessionReceiver
def test_config_handler(self): def test_config_handler(self):
# Config handler does not do anything yet, but should at least # Config handler does not do anything yet, but should at least
...@@ -186,6 +191,7 @@ class TestDDNSServer(unittest.TestCase): ...@@ -186,6 +191,7 @@ class TestDDNSServer(unittest.TestCase):
Test that we can accept a new connection. Test that we can accept a new connection.
""" """
# There's nothing before the accept # There's nothing before the accept
ddns.isc.util.io.socketsession.SocketSessionReceiver = FakeSession
self.assertEqual({}, self.ddns_server._socket_sessions) self.assertEqual({}, self.ddns_server._socket_sessions)
self.ddns_server.accept() self.ddns_server.accept()
# Now the new session socket receiver is stored in the dict # Now the new session socket receiver is stored in the dict
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment