Skip to content
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
fix(32bit): drop darsyn/ip dependency
Parse IPv6 addresses directly using built-in functions.

Signed-off-by: Richard Steinmetz <[email protected]>
  • Loading branch information
st3iny authored and backportbot[bot] committed Feb 14, 2024
commit 30771bb95621038b0423b0451990f239daa1b631
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"require": {
"amphp/amp": "^2.6.2",
"amphp/parallel": "^1.4.3",
"darsyn/ip": "^4.1.0",
"rubix/ml": "dev-chore/bump-flysystem-v2.1.1"
},
"license": "AGPLv3",
Expand Down
61 changes: 1 addition & 60 deletions composer.lock

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

11 changes: 8 additions & 3 deletions lib/Service/IpV6Strategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @copyright 2019 Christoph Wurst <[email protected]>
*
* @author 2019 Christoph Wurst <[email protected]>
* @author Richard Steinmetz <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
Expand All @@ -25,7 +26,7 @@

namespace OCA\SuspiciousLogin\Service;

use Darsyn\IP\Version\IPv6;
use InvalidArgumentException;
use OCA\SuspiciousLogin\Db\LoginAddressAggregatedMapper;
use OCA\SuspiciousLogin\Service\MLP\Config;
use function array_map;
Expand All @@ -50,8 +51,12 @@ public function findHistoricAndRecent(LoginAddressAggregatedMapper $loginAddress
}

protected function ipToVec(string $ip): array {
$addr = IPv6::factory($ip);
$hex = bin2hex($addr->getBinary());
$addr = inet_pton($ip);
if ($addr === false) {
throw new InvalidArgumentException('Invalid IPv6 address');
}

$hex = bin2hex($addr);
$padded = str_pad($hex, 32, '0', STR_PAD_LEFT);
$binString = implode('', array_map(function (string $h) {
return str_pad(base_convert($h, 16, 2), 4, '0', STR_PAD_LEFT);
Expand Down