Fix: order IP history by last activity and cap the stored value
The IP list behind "View IP history" was kept in first-seen order: an existing IP only refreshed its timestamp in place, so a host that kept reconnecting for months stayed wherever it originally landed. Updates now move the entry to the front, making the stored list last-active first; the dialog also sorts by the recorded date so legacy lists show the correct order without waiting for every host to reconnect. At the cap, trimming now runs on every update and evicts the tail (the least recently active entry), so a new IP always fits. A 60 KB byte cap protects the single value: the Win32 profile API mishandles a value over ~64 KB (GetPrivateProfileStringA returns only the tail, while WritePrivateProfileStringA appends the whole line again and the file doubles), and the live licenses.ini already carries a 33.5 KB list. Verified: the Release server builds; the value limit was measured against kernel32 - 65,500 bytes round-trips, 66,000 corrupts the file. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
830dcf1672
commit
c9a18856e5
2 files changed
+42
-9
No files matched your search
@@ -906,6 +906,16 @@ void CLicenseDlg::OnLicenseViewIPs()
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
// 按最后活跃时间倒序展示(新的在前);无时间戳/无法解析的记录排在最后。
|
||||
// 存储侧已保证最近上报的条目在前,这里再做一次稳定排序,兼容旧版本写下的
|
||||
// "首次出现倒序" 数据,打开对话框即可看到正确的顺序。
|
||||
std::stable_sort(records.begin(), records.end(),
|
||||
[](const IPRecord& a, const IPRecord& b) {
|
||||
int da = (a.daysAgo < 0) ? 0x7FFFFFFF : a.daysAgo;
|
||||
int db = (b.daysAgo < 0) ? 0x7FFFFFFF : b.daysAgo;
|
||||
return da < db;
|
||||
});
|
||||
|
||||
// 如果有记录被删除,保存更新后的 IP 列表
|
||||
if (removedCount > 0) {
|
||||
// 锁内只做 I/O —— UI 控件更新(SetItemText)放锁外,避免锁内触发
|
||||
|
||||
Reference in new issue
Block a user