Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace IPy with ipaddress #385

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mirrormanager2/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# pylint: disable=W0232


import ipaddress
import re

import wtforms
Expand All @@ -40,7 +41,6 @@
except ImportError:
from flask_wtf import Form as FlaskForm

import IPy
from flask import current_app, g

COUNTRY_REGEX = "^[a-zA-Z][a-zA-Z]$"
Expand Down Expand Up @@ -140,17 +140,17 @@ def validate_netblocks(form, field):
emsg += " can only be created by mirrormanager administrators."
emsg += " Please ask the mirrormanager administrators for assistance."

ipv4_block = IPy.IP(f"10.0.0.0{max_ipv4_netblock_size}")
ipv6_block = IPy.IP(f"fec0::{max_ipv6_netblock_size}")
ipv4_block = ipaddress.IPv4Network(f"10.0.0.0{max_ipv4_netblock_size}", strict=False)
ipv6_block = ipaddress.IPv6Network(f"fec0::{max_ipv6_netblock_size}", strict=False)

try:
ip = IPy.IP(field.data, make_net=True)
ip = ipaddress.ip_network(field.data, strict=False)
except ValueError:
# also accept DNS hostnames
return
if (
(ip.version() == 4 and ip.len() > ipv4_block.len())
or (ip.version() == 6 and ip.len() > ipv6_block.len())
(ip.version == 4 and ip.prefixlen < ipv4_block.prefixlen)
or (ip.version == 6 and ip.prefixlen < ipv6_block.prefixlen)
) and not g.is_mirrormanager_admin:
raise wtforms.validators.ValidationError(emsg)

Expand Down
12 changes: 1 addition & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ flask-oidc = "^2.0.0"
flask-xml-rpc-re = "^0.1.4"
flask-wtf = "^1.1.1"
wtforms = {extras = ["email"], version = "^3.0.1"}
ipy = "^1.1"
backoff = "^2.2.1"
fedora-messaging = "^3.3.0"
sqlalchemy-helpers = "^1.0.0"
Expand Down
8 changes: 7 additions & 1 deletion utility/mirrormanager2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ BuildRequires: python%{python_pkgversion}-flask-oidc >= 2.0.0
BuildRequires: python%{python_pkgversion}-flask-xml-rpc
BuildRequires: python%{python_pkgversion}-flask-wtf
BuildRequires: python%{python_pkgversion}-wtforms
BuildRequires: python%{python_pkgversion}-IPy
BuildRequires: python%{python_pkgversion}-backoff
BuildRequires: python%{python_pkgversion}-fedora-messaging
BuildRequires: python%{python_pkgversion}-sqlalchemy-helpers
Expand Down Expand Up @@ -70,7 +69,14 @@ Summary: Library to interact with MirrorManager's database
BuildArch: noarch

Requires: %{name}-filesystem = %{version}-%{release}
<<<<<<< HEAD
Requires: python%{python_pkgversion}-IPy
||||||| parent of 0216c75 (Replace IPy with ipaddress)
Requires: python%{python_pkgversion}-IPy
Requires: python%{python_pkgversion}-dns
=======
Requires: python%{python_pkgversion}-dns
>>>>>>> 0216c75 (Replace IPy with ipaddress)
Requires: python%{python_pkgversion}-pyrpmmd

%description lib
Expand Down
Loading