Coverage for src/bin/ddns/ddns : 91%
        
        
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
| 
 #!/usr/bin/python3 
 # Copyright (C) 2011 Internet Systems Consortium. # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 
 
 
 
 
 
 SOCKET_FILE = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"] + \ "/ddns_socket" else: 
 
 
 '''An exception indicating an error in updating ddns configuration. 
 This exception is raised when the ddns process encounters an error in handling configuration updates. Not all syntax error can be caught at the module-CC layer, so ddns needs to (explicitly or implicitly) validate the given configuration data itself. When it finds an error it raises this exception (either directly or by converting an exception from other modules) as a unified error in configuration. ''' 
 '''An exception raised for some unexpected events during a ddns session. ''' 
 '''Class to handle one DDNS update''' 
 '''Initialize a DDNS Session''' pass 
 ''' Removes the socket file, if it exists. ''' 
 ''' Initialize the DDNS Server. This sets up a ModuleCCSession for the BIND 10 system. Parameters: cc_session: If None (default), a new ModuleCCSession will be set up. If specified, the given session will be used. This is mainly used for testing. ''' else: self._cc = isc.config.ModuleCCSession(SPECFILE_LOCATION, self.config_handler, self.command_handler) 
 # List of the session receivers where we get the requests 
 '''Update config data.''' # TODO: Handle exceptions and turn them to an error response # (once we have any configuration) 
 ''' Handle a CC session command, as sent from bindctl or other BIND 10 modules. ''' # TODO: Handle exceptions and turn them to an error response else: 
 '''Initiate a shutdown sequence. 
 This method is expected to be called in various ways including in the middle of a signal handler, and is designed to be as simple as possible to minimize side effects. Actual shutdown will take place in a normal control flow. 
 ''' 
 ''' Perform any cleanup that is necessary when shutting down the server. Do NOT call this to initialize shutdown, use trigger_shutdown(). 
 Currently, it only causes the ModuleCCSession to send a message that this module is stopping. ''' 
 """ Accept another connection and create the session receiver. """ sock.getpeername()) as e: # These exceptions mean the connection didn't work, but we can # continue with the rest 
 """ This is the place where the actual DDNS processing is done. Other methods are either subroutines of this method or methods doing the uninteresting "accounting" stuff, like accepting socket, initialization, etc. 
 It is called with the request being session as received from SocketSessionReceiver, i.e. tuple (socket, local_address, remote_address, data). """ # TODO: Implement the magic 
 # TODO: Don't propagate most of the exceptions (like datasrc errors), # just drop the packet. pass 
 """ Handle incoming session on the socket with given fileno. """ # No matter why this failed, the connection is in unknown, possibly # broken state. So, we close the socket and remove the receiver. 
 ''' Get and process all commands sent from cfgmgr or other modules. This loops waiting for events until self.shutdown() has been called. ''' # In this event loop, we propagate most of exceptions, which will # subsequently kill the process. We expect the handling functions # to catch their own exceptions which they can recover from # (malformed packets, lost connections, etc). The rationale behind # this is they know best which exceptions are recoverable there # and an exception may be recoverable somewhere, but not elsewhere. 
 select.select([cc_fileno, listen_fileno] + list(self._socksession_receivers.keys()), [], []) # In case it is just interrupted, we continue like nothing # happened else: else: 
 ''' This creates a signal_handler for use in set_signal_handler, which shuts down the given DDNSServer (or any object that has a shutdown() method) ''' ''' Handler for process signals. Since only signals to shut down are sent here, the actual signal is not checked and the server is simply shut down. ''' 
 ''' Sets the signal handler(s). ''' 
 ''' Helper function to set command-line options ''' help="display more about what is going on") 
 ''' The main function. Parameters: ddns_server: If None (default), a DDNSServer object is initialized. If specified, the given DDNSServer will be used. This is mainly used for testing. cc_session: If None (default), a new ModuleCCSession will be set up. If specified, the given session will be used. This is mainly used for testing. ''' print("[b10-ddns] Warning: -v verbose option is ignored at this point.") 
 ddns_server = DDNSServer() 
 main()  |