def setup_flask_server(): app = Flask(__name__) url_dict = RedirectDict() def get_redirect_response(src_ip): """ If addr type is IPv4/IPv6 prepend http, if url don't change TODO: not sure what to do with SIP_URI """ if src_ip not in url_dict: return ServerResponse(NOT_FOUND_HTML, HTTP_NOT_FOUND) redirect_addr = url_dict[src_ip].server_address if url_dict[src_ip].address_type == url_dict[src_ip].IPv4: redirect_addr = 'http://' + redirect_addr + '/' elif url_dict[src_ip].address_type == url_dict[src_ip].IPv6: redirect_addr = 'http://[' + redirect_addr + ']/' return ServerResponse(redirect_addr, HTTP_REDIRECT) app.add_url_rule( '/', 'index', flask_redirect, defaults={'get_redirect_response': get_redirect_response}, ) app.add_url_rule( '/<path:path>', 'index', flask_redirect, defaults={'get_redirect_response': get_redirect_response} ) return app
def __init__( self, bridge_ip, logger, main_tbl_num, stats_table, next_table, scratch_table_num, session_rule_version_mapper, ): self._bridge_ip = bridge_ip self.logger = logger self.main_tbl_num = main_tbl_num self.stats_table = stats_table self.next_table = next_table self._scratch_tbl_num = scratch_table_num self._redirect_dict = RedirectDict() self._dns_cache = Memoizer({}) self._redirect_port = get_service_config_value( 'redirectd', 'http_port', 8080, ) self._session_rule_version_mapper = session_rule_version_mapper self._cwf_args_set = False self._mac_rewrite_scratch = None self._internal_ip_allocator = None self._arpd_controller_fut = None self._arp_contoller = None self._egress_table = None self._bridge_mac = None
def __init__(self, bridge_ip, logger, tbl_num, next_table): self._bridge_ip = bridge_ip self.logger = logger self.tbl_num = tbl_num self.next_table = next_table self._redirect_dict = RedirectDict() self._dns_cache = Memoizer({}) self._redirect_port = get_service_config_value( 'redirectd', 'http_port', 8080)
def __init__(self, bridge_ip, logger, main_tbl_num, next_table, scratch_table_num, session_rule_version_mapper): self._bridge_ip = bridge_ip self.logger = logger self.main_tbl_num = main_tbl_num self.next_table = next_table self._scratch_tbl_num = scratch_table_num self._redirect_dict = RedirectDict() self._dns_cache = Memoizer({}) self._redirect_port = get_service_config_value( 'redirectd', 'http_port', 8080) self._session_rule_version_mapper = session_rule_version_mapper