[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2021-10-17 Thread Foster Snowhill


Foster Snowhill  added the comment:

I've stumbled upon this myself, and had a go at fixing it, before looking up 
this issue. My approach ended up being a bit different:

1. I rewrote the existing _reverse_pointer() methods, so that they'd handle 
both addresses and networks, instead of defining separate methods for the 
IPvXNetwork classes.
2. Trying to generate a reverse pointer for a prefix that doesn't align with 
the granularity of reverse pointers (8 bits for IPv4, 4 bits for IPv6) will 
raise an exception instead of returning a more general prefix.

I would like to bring up point 2 for discussion, since it differs from both of 
the other PRs submitted regarding this issue.

For example, let's take an example subnet 127.45.240.0/20. The other solutions 
here propose generating a reverse pointer like "45.127.in-addr.arpa", i.e. 
returning a reverse pointer to a bigger subnet that includes the original one. 
When you convert that reverse pointer back into a network, you get 
127.45.0.0/16. It doesn't match the original network, thus you lose some 
information about it.

I'd like to propose to be more strict about it (or at least, make the strict 
behaviour an option) to avoid unintentional loss of precision when generating 
reverse pointers in these cases.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2021-10-17 Thread Foster Snowhill


Change by Foster Snowhill :


--
pull_requests: +27289
pull_request: https://github.com/python/cpython/pull/29011

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2021-10-13 Thread Foster Snowhill


Change by Foster Snowhill :


--
nosy: +forst

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2021-04-12 Thread Roundup Robot


Change by Roundup Robot :


--
nosy: +python-dev
nosy_count: 6.0 -> 7.0
pull_requests: +24104
pull_request: https://github.com/python/cpython/pull/25371

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2021-04-12 Thread jana


jana  added the comment:

This code does the trick:

ipn = ipaddress.ip_network("2a0c:ac10::/32")
prefix = ipn.prefixlen
if ipn.version == 6:
rest = int((ipn.max_prefixlen - prefix) / 4)
elif ipn.version == 4:
rest = int((ipn.max_prefixlen - prefix) / 8)
return ipn.network_address.reverse_pointer.split(".", rest)[-1]

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2021-04-12 Thread jana


jana  added the comment:

Running into the same problem here. Within the zonefile rfc1035 defines a 
usecase for ipv4, but I can't find anything similar for IPv6. The feature is 
also rather obscure. The zone however is used in the zonefile as origin and in 
bind in the named.conf to refer to which zone is managed where. 

For this you want to provide the reverse network address, minus the irrelevant 
zeros, so 192.168.0.0/24 => 0.168.192.in-addr.arpa and 2001:db8::/32 => 
8.b.d.0.1.0.0.2.ip6.arpa

This would be to me a fitting and convenient interpretation of the function.

--
nosy: +jana
versions: +Python 3.7 -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2018-03-13 Thread Ronald Oussoren

Ronald Oussoren  added the comment:

The "reverse_pointers" attribute is implicitly documented by this phrase in the 
introduction of network objects:

--
All attributes implemented by address objects are implemented by network 
objects as well.
--

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2018-03-13 Thread bbayles

Change by bbayles :


--
nosy: +bbayles

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2018-03-12 Thread Ewoud Kohl van Wijngaarden

Ewoud Kohl van Wijngaarden  added the 
comment:

It's interesting to note that neither IPv4Network[1] nor IPv4Network docs 
mention reverse_pointer. That means it could also remove them (which 
essentially also throws an exception) since they don't make sense for networks. 
It would be useful to have the described functionality under a better name.

[1]: https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Network
[2]: https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv6Network

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2018-02-09 Thread Ronald Oussoren

Ronald Oussoren  added the comment:


 documents that this attribute contains the name of the DNS name that could be 
used to query for PTR record. 

That functionality is not well defined for a network object. It might therefore 
be better to just raise an exception for this attribute on network objects.

--
nosy: +ronaldoussoren

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2018-02-04 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
nosy: +pmoody

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2017-09-17 Thread Ewoud Kohl van Wijngaarden

Ewoud Kohl van Wijngaarden added the comment:

Today I ran into this as well. In the case of IPv6 it's simple to decide what 
should be returned but on the IPv4Network I disagree. My expectation would be 
the domain where I would make the reverse needed. That means for 127.0.0.0/13 
it should be '127.in-addr.arpa'.

I implemented it this way in the linked PR but I'm open to other opinions.

--
nosy: +ekohl

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2017-09-17 Thread Ewoud Kohl van Wijngaarden

Changes by Ewoud Kohl van Wijngaarden :


--
keywords: +patch
pull_requests: +3621
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2017-05-31 Thread Hristo Venev

New submission from Hristo Venev:

`ipaddress.IPv4Network('127.0.0.0/16').reverse_pointer = 
'0/16.0.0.127.in-addr.arpa'` is definitely wrong. I think it should be 
'0.127.in-addr.arpa'.

A funnier case, `ipaddress.IPv6Network('2001:db8::/32').reverse_pointer = 
'2.3./.0.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'`.

For the case where no single reverse pointer exists (e.g. `127.0.0.0/13`), I 
think it should be `None`.

--
components: Library (Lib)
messages: 294854
nosy: h.venev
priority: normal
severity: normal
status: open
title: ipaddress.IPv{4,6}Network.reverse_pointer is broken
type: behavior
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com