Fix IP sorting: use multiplication to avoid signed integer overflow

This commit is contained in:
remotetohome 2026-02-05 01:39:19 -06:00
parent 5ea1393a16
commit 698e910466
1 changed files with 2 additions and 1 deletions

View File

@ -37,7 +37,8 @@ Connected Peers
// Extract IP from formats like "10.9.0.132/32" or "99.92.101.230:56078"
const match = (ip || '').trim().match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/);
if (!match) return null; // Empty/invalid IPs will be sorted to bottom
return (parseInt(match[1]) << 24) + (parseInt(match[2]) << 16) + (parseInt(match[3]) << 8) + parseInt(match[4]);
// Use multiplication instead of bit shifting to avoid signed 32-bit integer issues
return (parseInt(match[1]) * 16777216) + (parseInt(match[2]) * 65536) + (parseInt(match[3]) * 256) + parseInt(match[4]);
}
function getSortValue(cell, sortType) {