Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ebdaaf40
Kaydet (Commit)
ebdaaf40
authored
Nis 14, 2014
tarafından
Eric V. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20480: Add ipaddress.reverse_pointer. Patch by Leon Weber.
üst
6b230880
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
0 deletions
+55
-0
ipaddress.rst
Doc/library/ipaddress.rst
+15
-0
ipaddress.py
Lib/ipaddress.py
+29
-0
test_ipaddress.py
Lib/test/test_ipaddress.py
+8
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/ipaddress.rst
Dosyayı görüntüle @
ebdaaf40
...
...
@@ -146,6 +146,20 @@ write code that handles both IP versions correctly.
the appropriate length (most significant octet first). This is 4 bytes
for IPv4 and 16 bytes for IPv6.
.. attribute:: reverse_pointer
The name of the reverse DNS PTR record for the IP address, e.g.::
>>> ipaddress.ip_address("127.0.0.1").reverse_pointer
'1.0.0.127.in-addr.arpa'
>>> ipaddress.ip_address("2001:db8::1").reverse_pointer
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'
This is the name that could be used for performing a PTR lookup, not the
resolved hostname itself.
.. versionadded:: 3.5
.. attribute:: is_multicast
``True`` if the address is reserved for multicast use. See
...
...
@@ -226,6 +240,7 @@ write code that handles both IP versions correctly.
:class:`IPv4Address` class:
.. attribute:: packed
.. attribute:: reverse_pointer
.. attribute:: version
.. attribute:: max_prefixlen
.. attribute:: is_multicast
...
...
Lib/ipaddress.py
Dosyayı görüntüle @
ebdaaf40
...
...
@@ -435,6 +435,17 @@ class _IPAddressBase(_TotalOrderingMixin):
"""Return the shorthand version of the IP address as a string."""
return
str
(
self
)
@property
def
reverse_pointer
(
self
):
"""The name of the reverse DNS pointer for the IP address, e.g.:
>>> ipaddress.ip_address("127.0.0.1").reverse_pointer
'1.0.0.127.in-addr.arpa'
>>> ipaddress.ip_address("2001:db8::1").reverse_pointer
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'
"""
return
self
.
_reverse_pointer
()
@property
def
version
(
self
):
msg
=
'
%200
s has no version specified'
%
(
type
(
self
),)
...
...
@@ -1221,6 +1232,15 @@ class _BaseV4:
return
True
return
False
def
_reverse_pointer
(
self
):
"""Return the reverse DNS pointer name for the IPv4 address.
This implements the method described in RFC1035 3.5.
"""
reverse_octets
=
str
(
self
)
.
split
(
'.'
)[::
-
1
]
return
'.'
.
join
(
reverse_octets
)
+
'.in-addr.arpa'
@property
def
max_prefixlen
(
self
):
return
self
.
_max_prefixlen
...
...
@@ -1784,6 +1804,15 @@ class _BaseV6:
return
'
%
s/
%
d'
%
(
':'
.
join
(
parts
),
self
.
_prefixlen
)
return
':'
.
join
(
parts
)
def
_reverse_pointer
(
self
):
"""Return the reverse DNS pointer name for the IPv6 address.
This implements the method described in RFC3596 2.5.
"""
reverse_chars
=
self
.
exploded
[::
-
1
]
.
replace
(
':'
,
''
)
return
'.'
.
join
(
reverse_chars
)
+
'.ip6.arpa'
@property
def
max_prefixlen
(
self
):
return
self
.
_max_prefixlen
...
...
Lib/test/test_ipaddress.py
Dosyayı görüntüle @
ebdaaf40
...
...
@@ -1593,6 +1593,14 @@ class IpaddrUnitTest(unittest.TestCase):
addr3
.
exploded
)
self
.
assertEqual
(
'192.168.178.1'
,
addr4
.
exploded
)
def
testReversePointer
(
self
):
addr1
=
ipaddress
.
IPv4Address
(
'127.0.0.1'
)
addr2
=
ipaddress
.
IPv6Address
(
'2001:db8::1'
)
self
.
assertEqual
(
'1.0.0.127.in-addr.arpa'
,
addr1
.
reverse_pointer
)
self
.
assertEqual
(
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.'
+
'b.d.0.1.0.0.2.ip6.arpa'
,
addr2
.
reverse_pointer
)
def
testIntRepresentation
(
self
):
self
.
assertEqual
(
16909060
,
int
(
self
.
ipv4_address
))
self
.
assertEqual
(
42540616829182469433547762482097946625
,
...
...
Misc/ACKS
Dosyayı görüntüle @
ebdaaf40
...
...
@@ -1392,6 +1392,7 @@ Bob Watson
David Watson
Aaron Watters
Henrik Weber
Leon Weber
Corran Webster
Glyn Webster
Phil Webster
...
...
Misc/NEWS
Dosyayı görüntüle @
ebdaaf40
...
...
@@ -37,6 +37,8 @@ Core and Builtins
- Issue #12546: Allow \x00 to be used as a fill character when using str, int,
float, and complex __format__ methods.
- Issue #20480: Add ipaddress.reverse_pointer. Patch by Leon Weber.
Library
-------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment