def _handle_ConnectionUp(self, event): data_path_id = dpid_to_str(event.dpid) log.debug("Handling the connection up event for DPID : %s" % data_path_id) if (data_path_id == "00-00-00-00-02-01" or data_path_id == "00-00-00-00-02-02"): LearningSwitch(event.connection, False) elif (data_path_id == "00-00-00-00-02-03"): log.debug("Invoking Firewall 1") firewall(event.connection, False, 1)
def _handle_ConnectionUp(self, event): data_path_id = dpid_to_str(event.dpid) log.debug("Handling the connection up event for DPID : %s" %data_path_id) if (data_path_id == "00-00-00-00-02-01" or data_path_id == "00-00-00-00-02-02" or data_path_id == "00-00-00-00-02-03" or data_path_id == "00-00-00-00-02-04" or data_path_id == "00-00-00-00-02-05" or data_path_id == "00-00-00-00-02-08"): LearningSwitch(event.connection, False) elif (data_path_id == "00-00-00-00-02-06"): log.debug("Invoking Firewall 1") firewall(event.connection, False, 1) elif (data_path_id == "00-00-00-00-02-07"): log.debug("Invoking Firewall 2") firewall(event.connection, False, 2)
def wakeup(self): ''' Wakeup net instance ''' self.protocol = protocol.Zoe(core=self.core, name='ZProtocol') self.firewall = firewall.firewall(core=self.core, name='firewall') self.firewall.start() self.transport = udp_transport.UDPPtransport(name='transport', core=self.core) self.transport.start() self.router = router.Router(name='router', port=self.transport.fd_port, core=self.core) self.router.start() # register own in router # this way, two nodes can connect if one of them is a valid presenter data = {} data['ips'] = utils.Net_Utils.get_ips() data['port'] = self.transport.fd_port self.router.update(self.core.my_id, (data['ips'][0], self.transport.fd_port), info=data, volatile=False ) # Consider: # If there is no presenter set assume we ARE a pure presenter and # dont keep refreshing peers self.presenter = self.core.configManager.get('General', 'presenter') if self.presenter: ip, port = self.presenter.split(':') self.router.update('presenter', (ip, int(port)), volatile=False) self.timer(name='publish_net', timer=10, method=self.publish_net) self.subscribe('transport/rx/*', self.attend_rx)
from firewall import firewall from layer import layer with open('input.txt', 'r') as f: known_layers = f.readlines() known_layers = [x.strip() for x in known_layers] layers = [] my_firewall = firewall() for idx, lay in enumerate(known_layers): depth = int(lay.split(":")[0].strip()) layer_range = int(lay.split(":")[1].strip()) is_next_layer = False while (not is_next_layer): if (depth == len(layers)): is_next_layer = True else: my_firewall.add_layer([len(layers)]) layers.append([len(layers)]) my_firewall.add_layer([depth, layer_range]) layers.append([depth, layer_range]) found = False while (not found): found = my_firewall.move_pincosecond()
#------------------------------------------------------------------------------- # AUTHORS: Jakub Cabal <*****@*****.**> # LICENSE: The MIT License, please read LICENSE file #------------------------------------------------------------------------------- from wishbone import wishbone from rmii_mac import rmii_mac from firewall import firewall from sys_module import sys_module print("SUMMARY REPORTS OF RMII FIREWALL FPGA:") print("========================================") wb = wishbone("COM4") sm = sys_module(wb) mac0 = rmii_mac(wb, 0x4000, 0) mac1 = rmii_mac(wb, 0x6000, 1) fw0 = firewall(wb, 0x8000, 0) fw1 = firewall(wb, 0xA000, 1) #sm.report() mac0.rx_mac_report() fw0.firewall_report() mac1.tx_mac_report() mac1.rx_mac_report() fw1.firewall_report() mac0.tx_mac_report() wb.close()
from firewall import firewall fw = firewall("test.csv") print(fw.accept_packet("inbound", "tcp", 80, "192.168.1.2")) print(fw.accept_packet("inbound", "udp", 53, "192.168.2.1")) print(fw.accept_packet("outbound", "tcp", 10234, "192.168.10.11")) print(fw.accept_packet("inbound", "tcp", 81, "192.168.1.2")) print(fw.accept_packet("inbound", "udp", 24, "52.12.48.92")) #checking empty string print(fw.accept_packet("outbound", "tc", 10234, " "))
def config_web(cfg={}): # override Cherrypy's default session behaviour application_conf = { '/' : { 'tools.staticdir.root': _curdir, 'tools.staticdir.on' : True, 'tools.staticdir.dir' : ".", 'tools.sessions.on' : True, 'tools.sessions.storage_type' : "file", 'tools.sessions.storage_path' : "/tmp/", 'tools.sessions.timeout' : 60, 'tools.sessions.locking' : 'explicit', 'tools.auth.on': True, 'tools.encode.on' : True, 'tools.encode.encoding': "utf-8" }, '/favicon.ico' : { 'tools.staticfile.on' : True, 'tools.staticfile.filename' : os.path.join(_curdir,'/image/favicon.ico') }, '/css' : { 'tools.staticdir.on' : True, 'tools.staticdir.dir' : "css" }, '/script' : { 'tools.staticdir.on' : True, 'tools.staticdir.dir' : "script" }, '/image' : { 'tools.staticdir.on' : True, 'tools.staticdir.dir' : "image" }, } #No Root controller as we provided all our own. #cherrypy.tree.mount(root=None, config=config) root = Login() root.logout = AuthController().logout root.xteralink = Interface() root.system = summary() root.system.summary = summary() root.system.dns = dns() root.system.network_header = network_header() root.system.network = network() root.system.wan_detection = wan_detection() root.system.fqdn = fqdn() root.system.ip_group = ip_group() root.system.service_group = service_group() root.system.diagnostic_tools = diagnostic_tools() root.system.arp_table = arp_table() root.system.date_time = date_time() root.system.ddns = ddns() root.system.administration = administration() root.service = dhcp_lan() root.service.dhcp_lan = dhcp_lan() root.service.dhcp_dmz = dhcp_dmz() root.service.virtual_server = virtual_server() root.service.firewall = firewall() root.service.connection_limit = connection_limit() root.service.auto_routing = auto_routing() root.service.nat = nat() root.service.snmp = snmp() root.statistics = stat_bandwidth_utilization() root.statistics.stat_bandwidth_utilization = stat_bandwidth_utilization() root.statistics.stat_wan_detection = stat_wan_detection() root.statistics.stat_dhcp_lan = stat_dhcp_lan() root.statistics.stat_dhcp_dmz = stat_dhcp_dmz() root.statistics.stat_fqdn = stat_fqdn() root.log = view(); root.log.view = view(); root.log.syslog = syslog(); cherrypy.tree.mount(root, "/", config=application_conf) cherrypy.server.unsubscribe() server1 = cherrypy._cpserver.Server() server1.socket_port = 443 server1._socket_host = '0.0.0.0' server1.ssl_certificate = '/usr/local/conf/server.crt' server1.ssl_private_key = '/usr/local/conf/server.key' server1.subscribe() server2 = cherrypy._cpserver.Server() server2.socket_port = 80 server2._socket_host = "0.0.0.0" server2.subscribe()