コード例 #1
0
ファイル: redirect_server.py プロジェクト: go-magma/magma
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
コード例 #2
0
ファイル: redirect.py プロジェクト: talkhasib/magma
    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
コード例 #3
0
 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)
コード例 #4
0
ファイル: redirect.py プロジェクト: florinasp/magma-1
 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