コード例 #1
0
    def process_uri_for_mount(
        self,
        d,
        filepath,
        line,
        server,
        port,
        mapping_type,
        d_configurations,
        l_bad_configurations,
    ):

        shared_infrastructure.common_process_uri( 
            lambda: self._root_configuration,
            d, 
            line, 
            server, 
            port,
            mapping_type, 
            l_bad_configurations, 
            'src_'
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'listening_uri_'
        )

        shared_infrastructure.common_process_uri( 
            lambda: self._root_configuration,
            d, 
            line, 
            server, 
            port, 
            mapping_type, 
            l_bad_configurations, 
            'dst_'
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'backed_uri_'
        )

        shared_infrastructure.listen_ssl_process_uri( 
            lambda: self._root_configuration,
            lambda: self._ssl_configuration,
            d, 
            line, 
            server, 
            port, 
            mapping_type,
            l_bad_configurations, 
            'src_'
        )


        def get_ips_for_upstream( host ):

            l_ips = []
            l_ips.extend( [ ip.address for ip in self._resolver.query( host, 'A' ) ] )
            l_ips.extend( [ '[%s]' % ( ip.address ) for ip in self._resolver.query( host, 'AAAA' ) ] )

            if not l_ips:
               l_bad_configurations.append( ( '%s not resolvable' % ( host ), self._root_configuration, server, port, self._mount_filename ) )

            return l_ips

        def get_upstream_name( d ):
            return '%s__%s_%s__%s' % (
                server,
                port,
                d[ 'dst_host' ],
                d[ 'dst_port' ]
        )

        def get_upstream_url( d ):
            uri = ''
            uri += d[ 'dst_scheme' ] + ':'
            uri += '//'
            if  d.get( 'dst_userinfo' ):
                uri += d[ 'dst_userinfo' ] + '@'
            uri += get_upstream_name( d )
            return uri


        def get_proxy_redirect_to_replace_url_with_port( d ):
            uri 	= ''
            uri 	+= d[ 'dst_scheme' ] + ':'
            uri 	+= '//'
            if  d.get( 'dst_userinfo' ):
                uri 	+= d[ 'dst_userinfo' ] + '@'
            uri 	+= d[ 'src_host' ]
            uri 	+= ':%s' % ( d[ 'dst_port' ] )
            uri 	+= d[ 'dst_path' ] or ''
            return uri

        def get_proxy_redirect_to_replace_url_without_port( d ):
            uri 	= ''
            uri 	+= d[ 'dst_scheme' ] + ':'
            uri 	+= '//'
            if  d.get( 'dst_userinfo' ):
                uri 	+= d[ 'dst_userinfo' ] + '@'
            uri 	+= d[ 'src_host' ]
            uri 	+= d[ 'dst_path' ] or ''
            return uri

        AgnosticConfiguration.add_to_configuration( 
            d, 
            lambda d: {
                        'src':
                            shared_infrastructure.str_with_extra(
                                d[ 'src_URI' ],
                                d[ 'listening_uri_extra' ],
   			    ), 
                        'src_scheme':
                            d[ 'src_scheme' ],
                        'src_userinfo':
                            d[ 'src_userinfo' ] or '',
                        'src_host':
                            d[ 'src_host' ],
                        'src_port':
                            str( d[ 'src_port' ] ),
                        'src_path':
                            d[ 'src_path' ] or '',
                        'src_query':
                            d[ 'src_query' ] or '',
                        'dst':
                            shared_infrastructure.str_with_extra(
                                d[ 'dst_URI' ],
                                d[ 'backed_uri_extra' ],
                            ),
                        'dst_scheme':
                            d[ 'dst_scheme' ],
                        'dst_userinfo':
                            d[ 'dst_userinfo' ] or '',
                        'dst_host':
                            d[ 'dst_host' ],
                        'dst_port':
                            str( d[ 'dst_port' ] ),
                        'dst_path':
                            d[ 'dst_path' ] or '',
                        'dst_query':
                            d[ 'dst_query' ] or '',
                        'dst_upstream_name':
                            get_upstream_name( d ),
                        'dst_upstream':
                            get_upstream_url( d ),
                        'dst_upstream_resolved_ips':
                            get_ips_for_upstream( d[ 'dst_host' ] ),
                        'proxy_redirect_to_replace_with_port':
                            get_proxy_redirect_to_replace_url_with_port( d ),
                        'proxy_redirect_to_replace_without_port':
                            get_proxy_redirect_to_replace_url_without_port( d ),
                    }, 
            d_configurations,
            filepath,
            server, 
            port, 
            mapping_type, 
            le_sort	= lambda x: ( x[ 'src' ], x[ 'dst' ] )
        )
コード例 #2
0
    def process_uri_for_unmount(
        self,
        d,
        filepath,
        line,
        server,
        port,
        mapping_type,
        d_configurations,
        l_bad_configurations,
    ):
        shared_infrastructure.common_process_uri( 
            lambda: self._root_configuration,
            d, 
            line, 
            server, 
            port,
            mapping_type, 
            l_bad_configurations, 
            ''
        )

        shared_infrastructure.listen_ssl_process_uri( 
            lambda: self._root_configuration,
            lambda: self._ssl_configuration,
            d, 
            line, 
            server, 
            port, 
            mapping_type,
            l_bad_configurations, 
            '' 
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'listening_uri_',
        )

        AgnosticConfiguration.add_to_configuration( 
            d, 
            lambda m: { 
                'uri'	:
                    shared_infrastructure.str_with_extra(
                        d[ 'URI' ],
                        d[ 'listening_uri_extra' ],
                    ),
            },
            d_configurations,
            filepath,
            server,
            port,
            mapping_type,
            le_sort     = lambda x: ( x[ 'uri' ] )
        )
コード例 #3
0
    def process_uri_for_redirect(
        self,
        d,
        filepath,
        line,
        server,
        port,
        mapping_type,
        d_configurations,
        l_bad_configurations,
    ):
        shared_infrastructure.common_process_uri( 
            lambda: self._root_configuration,
            d, 
            line, 
            server, 
            port,
            mapping_type, 
            l_bad_configurations, 
            'src_'
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'listening_uri_',
        )

        shared_infrastructure.common_process_uri( 
            lambda: self._root_configuration,
            d, 
            line, 
            server, 
            port, 
            mapping_type, 
            l_bad_configurations, 
            'dst_' 
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'redirected_uri_',
        )

        shared_infrastructure.listen_ssl_process_uri( 
            lambda: self._root_configuration,
            lambda: self._ssl_configuration,
            d, 
            line, 
            server, 
            port, 
            mapping_type,
            l_bad_configurations, 
            'src_' 
        )

        AgnosticConfiguration.add_to_configuration( 
            d, 
            lambda d: {
                        'src'		:
                             shared_infrastructure.str_with_extra(
                                 d[ 'src_URI' ],
                                 d[ 'listening_uri_extra' ],
                 	     ),
                        'dst'		:
                             shared_infrastructure.str_with_extra(
                                 d[ 'dst_URI' ],
                                 d[ 'redirected_uri_extra' ],
            		     ), 
                    }, 
            d_configurations,
            filepath,
            server,
            port,
            mapping_type,
            le_sort     = lambda x: ( x[ 'src' ], x[ 'dst' ] )
        )
コード例 #4
0
    def process_uri_for_url2entity(
        self,
        d,
        filepath,
        line,
        server,
        port,
        mapping_type,
        d_configurations,
        l_bad_configurations,
    ):
        shared_infrastructure.common_process_uri( 
            lambda: self._root_configuration,
            d, 
            line, 
            server, 
            port,
            mapping_type, 
            l_bad_configurations, 
            '',
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'listening_uri_',
        )

        shared_infrastructure.listen_ssl_process_uri( 
            lambda: self._root_configuration,
            lambda: self._ssl_configuration,
            d, 
            line, 
            server, 
            port, 
            mapping_type,
            l_bad_configurations, 
            '',
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'appcode_',
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'env_',
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'aera_',
        )

        shared_infrastructure.common_process_extra(
            lambda: self._root_configuration,
            d,
            line,
            server,
            port,
            mapping_type,
            l_bad_configurations,
            lambda: self._extra_from_distrib,
            'virtual_ngv_num_',
        )


        URL2EntityConfiguration.add_to_configuration( 
            d, 
            lambda d: {
                        'uri'			:
                            shared_infrastructure.str_with_extra(
                                d[ 'URI' ],
                                d[ 'listening_uri_extra' ],
                            ),
                        'appcode'		:
                            shared_infrastructure.str_with_extra(
                                d[ 'appcode' ],
                                d[ 'appcode_extra' ],
                            ),
                        'env'			:
                            shared_infrastructure.str_with_extra(
                                d[ 'env' ],
                                d[ 'env_extra' ],
                            ),
                        'aera'			:
                            shared_infrastructure.str_with_extra(
                                d[ 'aera' ],
                                d[ 'aera_extra' ],
                            ),
                        'virtual_ngv_num'	:
                            shared_infrastructure.str_with_extra(
                                d[ 'virtual_ngv_num' ],
                                d[ 'virtual_ngv_num_extra' ],
                            ),
                    }, 
            d_configurations,
            filepath,
            server, 
            port, 
            mapping_type,
            le_sort     = lambda x: ( x[ 'uri' ] )
        )