parameters: ()
docstring: Initialize and check whether the routing information is correct.
docstring_summary: Initialize and check whether the routing information is correct.
docstring_tokens: Initialize and check whether the routing information is correct .
function: def init_routing():
      """Initialize and check whether the routing information is correct."""
      interfaces = set()
  
      # Check if all configured VPNs exist and are up and enable NAT on
      # each VPN interface.
      if config("routing:vpn:enabled"):
          for name in config("routing:vpn:vpns"):
              entry = config2("routing", name)
              if not rooter("nic_available", entry.interface):
                  raise CuckooStartupError(
                      "The network interface that has been configured for "
                      "VPN %s is not available." % entry.name
                  )
  
              if not rooter("rt_available", entry.rt_table):
                  raise CuckooStartupError(
                      "The routing table that has been configured for "
                      "VPN %s is not available." % entry.name
                  )
  
              interfaces.add((entry.rt_table, entry.interface))
  
      standard_routes = "none", "drop", "internet", "inetsim", "tor"
  
      # Check whether the default VPN exists if specified.
      if config("routing:routing:route") not in standard_routes:
          if config("routing:routing:route") not in config("routing:vpn:vpns"):
              raise CuckooStartupError(
                  "The default routing target (%s) has not been configured in "
                  "routing.conf, is it supposed to be a VPN?" %
                  config("routing:routing:route")
              )
  
          if not config("routing:vpn:enabled"):
              raise CuckooStartupError(
                  "The default route configured is a VPN, but VPNs have "
                  "not been enabled in routing.conf."
              )
  
      # Check whether the dirty line exists if it has been defined.
      if config("routing:routing:internet") != "none":
          if not rooter("nic_available", config("routing:routing:internet")):
              raise CuckooStartupError(
                  "The network interface that has been configured as dirty "
                  "line is not available."
              )
  
          if not rooter("rt_available", config("routing:routing:rt_table")):
              raise CuckooStartupError(
                  "The routing table that has been configured for dirty "
                  "line interface is not available."
              )
  
          interfaces.add((
              config("routing:routing:rt_table"),
              config("routing:routing:internet")
          ))
  
      for rt_table, interface in interfaces:
          # Disable & enable NAT on this network interface. Disable it just
          # in case we still had the same rule from a previous run.
          rooter("disable_nat", interface)
          rooter("enable_nat", interface)
  
          # Populate routing table with entries from main routing table.
          if config("routing:routing:auto_rt"):
              rooter("flush_rttable", rt_table)
              rooter("init_rttable", rt_table, interface)
function_tokens: def init_routing ( ) : interfaces = set ( ) # Check if all configured VPNs exist and are up and enable NAT on # each VPN interface. if config ( "routing:vpn:enabled" ) : for name in config ( "routing:vpn:vpns" ) : entry = config2 ( "routing" , name ) if not rooter ( "nic_available" , entry . interface ) : raise CuckooStartupError ( "The network interface that has been configured for " "VPN %s is not available." % entry . name ) if not rooter ( "rt_available" , entry . rt_table ) : raise CuckooStartupError ( "The routing table that has been configured for " "VPN %s is not available." % entry . name ) interfaces . add ( ( entry . rt_table , entry . interface ) ) standard_routes = "none" , "drop" , "internet" , "inetsim" , "tor" # Check whether the default VPN exists if specified. if config ( "routing:routing:route" ) not in standard_routes : if config ( "routing:routing:route" ) not in config ( "routing:vpn:vpns" ) : raise CuckooStartupError ( "The default routing target (%s) has not been configured in " "routing.conf, is it supposed to be a VPN?" % config ( "routing:routing:route" ) ) if not config ( "routing:vpn:enabled" ) : raise CuckooStartupError ( "The default route configured is a VPN, but VPNs have " "not been enabled in routing.conf." ) # Check whether the dirty line exists if it has been defined. if config ( "routing:routing:internet" ) != "none" : if not rooter ( "nic_available" , config ( "routing:routing:internet" ) ) : raise CuckooStartupError ( "The network interface that has been configured as dirty " "line is not available." ) if not rooter ( "rt_available" , config ( "routing:routing:rt_table" ) ) : raise CuckooStartupError ( "The routing table that has been configured for dirty " "line interface is not available." ) interfaces . add ( ( config ( "routing:routing:rt_table" ) , config ( "routing:routing:internet" ) ) ) for rt_table , interface in interfaces : # Disable & enable NAT on this network interface. Disable it just # in case we still had the same rule from a previous run. rooter ( "disable_nat" , interface ) rooter ( "enable_nat" , interface ) # Populate routing table with entries from main routing table. if config ( "routing:routing:auto_rt" ) : rooter ( "flush_rttable" , rt_table ) rooter ( "init_rttable" , rt_table , interface )