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

Be more lenient in reading maintenance.ip addresses #3634

Merged
merged 8 commits into from
Nov 13, 2023

Conversation

loekvangool
Copy link
Contributor

@loekvangool loekvangool commented Nov 8, 2023

Currently, only commas are accepted to split IPs, and no spaces are allowed (only at the start/end of the file, not after the comma).

Event this input is currently invalid: 1.1.1.1, 1.1.1.2 because it will not trim the space.

This preg_split() allows splitting on spaces, commas, or new lines, such that these contents for maintenance.ip are valid:

1.1.1.1, 1.1.1.2  1.1.1.3
1.1.1.4


1.1.1.5,1.1.1.6

Result:

array ( 0 => '1.1.1.1', 1 => '1.1.1.2', 2 => '1.1.1.3', 3 => '1.1.1.4', 4 => '1.1.1.5', 5 => '1.1.1.6', )

Currently, only commas are accepted to split IPs, and no spaces are allowed (only at the start/end of the file, not after the comma).

This `preg_split()` allows splitting on spaces, commas, or new lines, such that these contents for `maintenance.ip` are valid:

```
1.1.1.1, 1.1.1.2  1.1.1.3
1.1.1.4


1.1.1.5, 1.1.1.6
```

Result:
```php
array ( 0 => '1.1.1.1', 1 => '1.1.1.2', 2 => '1.1.1.3', 3 => '1.1.1.4', 4 => '1.1.1.5', 5 => '1.1.1.6', )
```
Copy link
Contributor

@m-overlund m-overlund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great!
(Would love better IPv6 prefix support too)

index.php Outdated Show resolved Hide resolved
index.php Outdated Show resolved Hide resolved
loekvangool and others added 2 commits November 10, 2023 13:31
Co-authored-by: Sven Reichel <github-sr@hotmail.com>
@loekvangool
Copy link
Contributor Author

loekvangool commented Nov 10, 2023

Made some changes. Didn't make much sense to foreach...in_array() it so turned it around a bit. Pulled the === in front of the filter_var().

index.php Outdated Show resolved Hide resolved
@loekvangool
Copy link
Contributor Author

Agreed. Rewritten.

@loekvangool
Copy link
Contributor Author

@m-overlund anything to add for IPv6? I have no aspiration towards it tbh

@m-overlund
Copy link
Contributor

@loekvangool I'm not able to contribute sorry.
But the issue is, that with IPv6 you have privacy addresses, so, as i understand, you would have to be able to insert a subset of IPs like: 1234.1234.1234.0::/48
Because your IP changes daily.

index.php Outdated Show resolved Hide resolved
Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
@sreichel
Copy link
Contributor

Can we keep the comment?

@fballiano
Copy link
Contributor

the comment is still there but modified, how would you like that?

@sreichel
Copy link
Contributor

Either its too late, or too early 😎

Missed that. Sry.

@loekvangool
Copy link
Contributor Author

But the issue is, that with IPv6 you have privacy addresses, so, as i understand, you would have to be able to insert a subset of IPs like: 1234.1234.1234.0::/48

Could be done in a follow up PR by introducing a lib like symfony ip utils.

@fballiano fballiano merged commit bd00d61 into OpenMage:main Nov 13, 2023
17 checks passed
@loekvangool loekvangool deleted the patch-4 branch November 13, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants