예제 #1
0
파일: NAT.py 프로젝트: kkovaacs/zorp
 def mapAddress(self, addr, from_domain, to_domain, nat_type):
     """
             <method internal="yes">
               <summary>
                 Function to map an address to another subnet.
               </summary>
               <description>
                 <para>
                   This function maps the address 'addr' in the domain
                   'from_domain' to another domain 'to_domain'.
                   Returns a SockAddrInet in the destination domain or None
                 </para>
               </description>
               <metainfo>
                 <arguments>
                   <argument maturity="stable">
                     <name>from_domain</name>
                     <type></type>
                     <description>source domain</description>
                   </argument>
                   <argument maturity="stable">
                     <name>to_domain</name>
                     <type></type>
                     <description>destination domain</description>
                   </argument>
                   <argument maturity="stable">
                     <name>nat_type</name>
                     <type></type>
                     <description>specifies the NAT type</description>
                   </argument>
                 </arguments>
               </metainfo>
             </method>
             """
     if addr < from_domain:
         ip = (addr.ip & ~to_domain.mask) + (to_domain.ip & to_domain.mask)
         if nat_type == NAT_SNAT:
             return SockAddrInet(inet_ntoa(ip), 0)
         elif nat_type == NAT_DNAT:
             return SockAddrInet(inet_ntoa(ip), addr.port)
예제 #2
0
파일: NAT.py 프로젝트: kkovaacs/zorp
	def mapAddress(self, addr, from_domain, to_domain, nat_type):
		"""
                <method internal="yes">
                  <summary>
                    Function to map an address to another subnet.
                  </summary>
                  <description>
                    <para>
                      This function maps the address 'addr' in the domain
                      'from_domain' to another domain 'to_domain'.
                      Returns a SockAddrInet in the destination domain or None
                    </para>
                  </description>
                  <metainfo>
                    <arguments>
                      <argument maturity="stable">
                        <name>from_domain</name>
                        <type></type>
                        <description>source domain</description>
                      </argument>
                      <argument maturity="stable">
                        <name>to_domain</name>
                        <type></type>
                        <description>destination domain</description>
                      </argument>
                      <argument maturity="stable">
                        <name>nat_type</name>
                        <type></type>
                        <description>specifies the NAT type</description>
                      </argument>
                    </arguments>
                  </metainfo>
                </method>
                """
                if addr < from_domain:
                        ip = (addr.ip & ~to_domain.mask) + (to_domain.ip & to_domain.mask)
                        if nat_type == NAT_SNAT:
                                return SockAddrInet(inet_ntoa(ip), 0)
                        elif nat_type == NAT_DNAT:
                                return SockAddrInet(inet_ntoa(ip), addr.port)
예제 #3
0
파일: Domain.py 프로젝트: pfeiffersz/zorp
	def __str__(self):
		"""
                <method internal="yes">
                  <summary>Function returning the string representation of this instance.</summary>
                  <description>
                    This function returns the string representation of this
                    instance in the form address/mask.                   
                  </description>
                  <metainfo>
                    <arguments/>
                  </metainfo>
                </method>
                """
                return "%s/%u" % (inet_ntoa(self.ip), self.mask_bits)
예제 #4
0
파일: Domain.py 프로젝트: kkovaacs/zorp
 def __str__(self):
     """
             <method internal="yes">
               <summary>Function returning the string representation of this instance.</summary>
               <description>
                 This function returns the string representation of this
                 instance in the form address/mask.                   
               </description>
               <metainfo>
                 <arguments/>
               </metainfo>
             </method>
             """
     return "%s/%u" % (inet_ntoa(self.ip), self.mask_bits)