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

Revert "Fix #281 - Render supernet table by smallest prefix first" #383

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion frontend/src/components/asnQuery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class ASNQuery extends Component {
reducedColour={reducedColour}
filterWarningError={filterWarningError}
apiCallUrl={this.state.apiCallUrl}
defaultSortSmallestFirst={true}
/>
<h2 className="h3 mt-4">
Included in the following AS sets:
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/prefixQuery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class PrefixQuery extends Component {
apiCallUrl={leastSpecificOverlapPrefixes.apiCallUrl}
reducedColour={reducedColour}
filterWarningError={filterWarningError}
defaultSortSmallestFirst={true}
/>
</>}
</>
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/prefixTable/prefixTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class PrefixTable extends Component {
}

updateState() {
const defaultKey = this.props.defaultSortSmallestFirst ? 'prefixSmallestFirst' : 'prefix';
this.setState({
sortedPrefixesData: sortPrefixesDataBy(this.props.prefixesData, defaultKey),
sortedPrefixesData: sortPrefixesDataBy(this.props.prefixesData, 'prefix'),
irrSourceColumns: findIrrSourceColumns(this.props.prefixesData),
});

Expand Down Expand Up @@ -92,7 +91,6 @@ PrefixTable.propTypes = {
reducedColour: PropTypes.bool,
filterWarningError: PropTypes.bool,
apiCallUrl: PropTypes.string,
defaultSortSmallestFirst: PropTypes.bool,
};


Expand Down
3 changes: 1 addition & 2 deletions frontend/src/utils/prefixData.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export function findLeastSpecific(queryPrefix, prefixesData) {
}

export function sortPrefixesDataBy(prefixesData, key, order = 'asc') {
if (key === 'prefix') key = 'prefixSortKeyIpPrefix';
if (key === 'prefixSmallestFirst') key = 'prefixSortKeyReverseNetworklenIp';
if (key === 'prefix') key = 'prefixSortKey';
if (key === 'bgpOrigins') key = 'bgpOrigins.0';
if (key === 'rpkiRoutes') key = 'rpkiRoutes.0.asn';
if (key.startsWith('irrRoutes')) key += '.0.asn';
Expand Down
7 changes: 2 additions & 5 deletions irrexplorer/api/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,14 @@ class PrefixSummary:
# category_overall converted into a number for sorting
goodness_overall: Optional[int] = 0
# Numerical IP plus prefix length. Used as sorting key in the frontend.
prefix_sort_key_ip_prefix: Optional[str] = None
# (128 - prefix length) plus numerical IP. Used as sorting key in the frontend.
prefix_sort_key_reverse_networklen_ip: Optional[str] = None
prefix_sort_key: Optional[str] = None

def finalise_status(self):
"""
Set a few properties that depend on others.
Should be called before returning to the user.
"""
self.prefix_sort_key_ip_prefix = f"{self.prefix.network_address._ip}/{self.prefix.prefixlen}"
self.prefix_sort_key_reverse_networklen_ip = f"{128 - self.prefix.prefixlen}-{self.prefix.network_address._ip}"
self.prefix_sort_key = f"{self.prefix.network_address._ip}/{self.prefix.prefixlen}"
if not self.messages:
self.success("Everything looks good")

Expand Down
3 changes: 1 addition & 2 deletions irrexplorer/api/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def test_report_good():
assert summary.messages == [
ReportMessage(category=MessageCategory.SUCCESS, text="Everything looks good"),
]
assert summary.prefix_sort_key_ip_prefix == "42540766411282592856903984951653826560/48"
assert summary.prefix_sort_key_reverse_networklen_ip == "80-42540766411282592856903984951653826560"
assert summary.prefix_sort_key == "42540766411282592856903984951653826560/48"


def test_report_no_origin():
Expand Down
9 changes: 3 additions & 6 deletions irrexplorer/tests/test_prefixes_asn.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ async def test_asn_valid(client, httpserver):
"directOrigin": [
{
"prefix": "192.0.2.0/24",
"prefixSortKeyIpPrefix": "3221225984/24",
"prefixSortKeyReverseNetworklenIp": "104-3221225984",
"prefixSortKey": "3221225984/24",
"goodnessOverall": 0,
"categoryOverall": "danger",
"bgpOrigins": [64500],
Expand Down Expand Up @@ -109,8 +108,7 @@ async def test_asn_valid(client, httpserver):
"overlaps": [
{
"prefix": "192.0.2.128/25",
"prefixSortKeyIpPrefix": "3221226112/25",
"prefixSortKeyReverseNetworklenIp": "103-3221226112",
"prefixSortKey": "3221226112/25",
"goodnessOverall": 0,
"categoryOverall": "danger",
"bgpOrigins": [64501],
Expand Down Expand Up @@ -146,8 +144,7 @@ async def test_asn_no_irr_data(client, httpserver):
"directOrigin": [
{
"prefix": "192.0.2.0/24",
"prefixSortKeyIpPrefix": "3221225984/24",
"prefixSortKeyReverseNetworklenIp": "104-3221225984",
"prefixSortKey": "3221225984/24",
"goodnessOverall": 0,
"categoryOverall": "danger",
"bgpOrigins": [64500],
Expand Down
9 changes: 3 additions & 6 deletions irrexplorer/tests/test_prefixes_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ async def test_prefix_valid(client, httpserver):
expected = [
{
"prefix": "192.0.2.0/24",
"prefixSortKeyIpPrefix": "3221225984/24",
"prefixSortKeyReverseNetworklenIp": "104-3221225984",
"prefixSortKey": "3221225984/24",
"goodnessOverall": 0,
"categoryOverall": "danger",
"bgpOrigins": [64500],
Expand Down Expand Up @@ -145,8 +144,7 @@ async def test_prefix_valid_rpki_as0(client, httpserver):
expected = [
{
"prefix": "192.0.2.0/24",
"prefixSortKeyIpPrefix": "3221225984/24",
"prefixSortKeyReverseNetworklenIp": "104-3221225984",
"prefixSortKey": "3221225984/24",
"goodnessOverall": 0,
"categoryOverall": "danger",
"bgpOrigins": [],
Expand Down Expand Up @@ -187,8 +185,7 @@ async def test_prefix_no_data(client, httpserver):
expected = [
{
"prefix": "192.0.2.0/24",
"prefixSortKeyIpPrefix": "3221225984/24",
"prefixSortKeyReverseNetworklenIp": "104-3221225984",
"prefixSortKey": "3221225984/24",
"goodnessOverall": 0,
"categoryOverall": "danger",
"bgpOrigins": [64500],
Expand Down