当前位置: 首页>>代码示例>>Python>>正文


Python Zone.lookup方法代码示例

本文整理汇总了Python中Zone.Zone.lookup方法的典型用法代码示例。如果您正苦于以下问题:Python Zone.lookup方法的具体用法?Python Zone.lookup怎么用?Python Zone.lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zone.Zone的用法示例。


在下文中一共展示了Zone.lookup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setTargetAddress

# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import lookup [as 别名]
    def setTargetAddress(self, addr):
        """
        <method internal="yes">
          <summary>
            Set the target server address.
          </summary>
          <description>
            <para>
              This is a compatibility function for proxies that
              override the routed target.
            </para>
          </description>
          <metainfo>
            <arguments>
              <argument maturity="stable">
                <name>addr</name>
                <type></type>
                <description>Server address</description>
              </argument>
            </arguments>
          </metainfo>
        </method>
        """
        # NOTE: handling SockAddr types is a compatibility hack, as
        # proxies might call setServer with a SockAddr instance
        # instead of a tuple of SockAddrs

        if isinstance(addr, SockAddrType):
            self.target_address = (addr,)
        else:
            self.target_address = addr

        self.target_zone = [Zone.lookup(a) for a in self.target_address]
开发者ID:magwas,项目名称:zorp,代码行数:35,代码来源:Session.py

示例2: setServerAddress

# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import lookup [as 别名]
 def setServerAddress(self, addr):
     """
     <method internal="yes">
       <summary>
         Sets the server address and looks up the server zone and sets the server_zone property.
       </summary>
     </method>
     """
     self.server_address = addr
     self.server_zone = Zone.lookup(addr)
开发者ID:matepeter90,项目名称:zorp,代码行数:12,代码来源:Session.py

示例3: __init__

# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import lookup [as 别名]
    def __init__(self, client_stream, client_local, client_listen, client_address):
        """<method internal="yes">"""
        self.client_stream = client_stream
        self.client_local = client_local
        self.client_listen = client_listen
        self.client_address = client_address

        if client_address is not None:
            try:
                self.client_zone = Zone.lookup(client_address)
            except ZoneException:
                self.client_zone = None
        else:
            self.client_zone = None
开发者ID:matepeter90,项目名称:zorp,代码行数:16,代码来源:Session.py

示例4: __init__

# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import lookup [as 别名]
    def __init__(self, service, client_stream, client_local, client_listen, client_address, **kwargs):
        """
        <method internal="yes">
          <summary>
            Constructor to initialize a MasterSession instance.
          </summary>
          <description>
            <para>
              This constructor initializes a new MasterSession instance
              based on its arguments.
            </para>
          </description>
          <metainfo>
            <arguments/>
          </metainfo>
        </method>
        """
        if client_address is None and hasattr(kwargs, 'client_zone') is True:
            raise AttributeError

        super(MasterSession, self).__init__()

        self.service = service
        self.client_stream = client_stream
        self.client_local = client_local
        self.client_listen = client_listen
        self.client_address = client_address
        self.client_zone = getattr(kwargs, 'client_zone', None)
        self.rule_id = getattr(kwargs, 'rule_id', None)
        self.server_address = getattr(kwargs, "server_address", None)
        self.server_zone = getattr(kwargs, "server_zone", None)
        self.server_local = None

        self.target_address = getattr(kwargs, "target_address", ())
        self.target_local = getattr(kwargs, "target_local", None)
        self.target_zone = getattr(kwargs, "target_zone", ())

        self.instance_id = kwargs.pop("instance_id", 0)
        for arg_name,value in kwargs.items():
            setattr(self, arg_name, value)
            log(None, CORE_DEBUG, 8,
                "Added value to the session; name='%s', value='%s'" % (arg_name, value))

        if self.client_address is not None and self.client_zone is None:
            try:
                self.client_zone = Zone.lookup(client_address)
            except ZoneException:
                self.client_zone = None

        if self.server_address is not None and self.server_zone is None:
            try:
                self.server_zone = Zone.lookup(server_address)
            except ZoneException:
                self.server_zone = None

        # these are set by the router to indicate how target address
        # selection should work based on the type of the router used
        self.target_address_inband = FALSE
        self.target_local_loose = TRUE
        self.target_local_random = FALSE

        self.proxy = None
        self.started = 0

        self.auth_user = ""
        self.auth_groups = ()
        self.authorized = FALSE

        self.protocol = self.client_listen.protocol
        self.protocol_name = get_protocol_name(self.protocol)

        self.base_session_id = 'svc'
        self.session_id = "%s/%s/%s:%d" % (self.base_session_id, Globals.virtual_instance_name, self.service.name, self.instance_id)
        self.master_session_id = self.session_id
        self.verdict = ConnectionVerdict(ConnectionVerdict.ACCEPTED)
开发者ID:magwas,项目名称:zorp,代码行数:77,代码来源:Session.py

示例5: setServerAddress

# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import lookup [as 别名]
 def setServerAddress(self, addr):
     self.server_address = addr
     self.server_zone = Zone.lookup(addr)
开发者ID:VPetyaa,项目名称:zorp,代码行数:5,代码来源:Session.py

示例6: setClientAddress

# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import lookup [as 别名]
 def setClientAddress(self, addr):
     self.client_address = addr
     self.client_zone = Zone.lookup(addr)
开发者ID:VPetyaa,项目名称:zorp,代码行数:5,代码来源:Session.py

示例7: _getSession

# 需要导入模块: from Zone import Zone [as 别名]
# 或者: from Zone.Zone import lookup [as 别名]
    def _getSession(self, client_stream, client_local, client_listen, client_address):
        """
        <method internal="yes">
          <summary>Virtual function which returns the service to be ran</summary>
          <description>
            <para>
              This function is called by our base class to find out the
              service to be used for the current client_info. It uses the
              client and the server zone name to decide which service to
              use.
            </para>
          </description>
          <metainfo>
            <arguments>
              <argument maturity="stable">
                <name>client_info</name>
                <type></type>
                <description>Session information</description>
              </argument>
            </arguments>
          </metainfo>
        </method>
        """
        dest_zone = Zone.lookup(client_local)
        client_zone = Zone.lookup(client_address)
        cache_ndx = (client_zone.getName(), dest_zone.getName())

        cached = self.cache.lookup(cache_ndx)
        if cached == 0:
            ## LOG ##
            # This message indicates that no applicable service was found for this client zone in the services cache.
            # It is likely that there is no applicable service configured in this CSZoneListener/Receiver at all.
            # Check your CSZoneListener/Receiver service configuration.
            # @see: Listener.CSZoneListener
            # @see: Receiver.CSZoneReceiver
            ##
            log(None, CORE_POLICY, 2, "No applicable service found for this client & server zone (cached); bindto='%s', client_zone='%s', server_zone='%s'", (self.bindto, client_zone, dest_zone))
        elif cached:
            return MasterSession(cached, client_stream, client_local, client_listen, client_address, client_zone = client_zone, instance_id=getInstanceId(cached.name))

        src_hierarchy = {}
        dst_hierarchy = {}
        if self.follow_parent:
            z = client_zone
            level = 0
            while z:
                src_hierarchy[z.getName()] = level
                z = z.admin_parent
                level = level + 1
            src_hierarchy['*'] = level
            max_level = level + 1
            z = dest_zone
            level = 0
            while z:
                dst_hierarchy[z.getName()] = level
                z = z.admin_parent
                level = level + 1
            dst_hierarchy['*'] = level
            max_level = max(max_level, level + 1)
        else:
            src_hierarchy[client_zone.getName()] = 0
            src_hierarchy['*'] = 1
            dst_hierarchy[dest_zone.getName()] = 0
            dst_hierarchy['*'] = 1
            max_level = 10

        best = None
        for spec in self.services.keys():
            try:
                src_level = src_hierarchy[spec[0]]
                dst_level = dst_hierarchy[spec[1]]
            except KeyError:
                src_level = max_level
                dst_level = max_level

            if not best or                                                  \
               (best_src_level > src_level) or                              \
               (best_src_level == src_level and best_dst_level > dst_level):
                best = self.services[spec]
                best_src_level = src_level
                best_dst_level = dst_level

        service = None
        if best is not None and best_src_level < max_level and best_dst_level < max_level:
            try:
                service = Globals.services[best]
            except KeyError:
                log(None, CORE_POLICY, 2, "No such service; service='%s'", (best))
        else:
            ## LOG ##
            # This message indicates that no applicable service was found for this client zone.
            # Check your CSZoneListener/Receiver service configuration.
            # @see: Listener.CSZoneListener
            # @see: Receiver.CSZoneReceiver
            ##
            log(None, CORE_POLICY, 2, "No applicable service found for this client & server zone; bindto='%s', client_zone='%s', server_zone='%s'", (self.bindto, client_zone, dest_zone))

        if service is None:
            return None

#.........这里部分代码省略.........
开发者ID:mochrul,项目名称:zorp,代码行数:103,代码来源:Dispatch.py


注:本文中的Zone.Zone.lookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。