[PR #429] [MERGED] Allow Exempting IP Ranges #1296

Closed
opened 2026-05-07 01:01:26 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/429
Author: @karmanyaahm
Created: 10/5/2022
Status: Merged
Merged: 10/8/2022
Merged by: @binwiederhier

Base: mainHead: ip-range-exempt


📝 Commits (7)

  • c2382d2 refactor visitor IPs and allow exempting IP Ranges
  • de2ca33 recommended fixes [1 of 2]
  • 511d3f6 recommended fixes [2 of 2]
  • 3b29294 minor modification to tests involving ips
  • 4edc625 fix lint
  • bc5060b test new config parsing
  • 1672322 test ContainsIP utility

📊 Changes

14 files changed (+164 additions, -60 deletions)

View changed files

📝 cmd/serve.go (+33 -6)
📝 cmd/serve_test.go (+23 -5)
📝 server/config.go (+3 -2)
📝 server/message_cache.go (+11 -4)
📝 server/message_cache_test.go (+13 -7)
📝 server/server.go (+22 -8)
📝 server/server_firebase_test.go (+6 -4)
📝 server/server_matrix_test.go (+4 -2)
📝 server/server_test.go (+13 -11)
📝 server/smtp_sender.go (+1 -1)
📝 server/types.go (+4 -2)
📝 server/visitor.go (+7 -5)
📝 util/util.go (+14 -2)
📝 util/util_test.go (+10 -1)

📄 Description

  • Refactor visitor IPs and allow exempting IP Ranges

    Use netip.Addr instead of storing addresses as strings. This requires
    conversions at the database level and in tests, but is more memory
    efficient and efficient to compare; mainly it facilitates the following.

    Parse rate limit exemptions as netip.Prefix. This allows storing IP
    ranges in the exemption list. Regular IP addresses (entered explicitly
    or resolved from hostnames) are IPV4/32, denoting a range of just that one
    address.

draft still need to add tests and fix bugs.

However, is the change from string IPs to netip.Addr and netip.Prefix acceptable?

Closes #423


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/429 **Author:** [@karmanyaahm](https://github.com/karmanyaahm) **Created:** 10/5/2022 **Status:** ✅ Merged **Merged:** 10/8/2022 **Merged by:** [@binwiederhier](https://github.com/binwiederhier) **Base:** `main` ← **Head:** `ip-range-exempt` --- ### 📝 Commits (7) - [`c2382d2`](https://github.com/binwiederhier/ntfy/commit/c2382d29a1c5e28b4682047f1eeadc78c644d07f) refactor visitor IPs and allow exempting IP Ranges - [`de2ca33`](https://github.com/binwiederhier/ntfy/commit/de2ca33700442c134724a768b94f710555feeaa5) recommended fixes [1 of 2] - [`511d3f6`](https://github.com/binwiederhier/ntfy/commit/511d3f6aafb2c71992751c2204f863929fc64e39) recommended fixes [2 of 2] - [`3b29294`](https://github.com/binwiederhier/ntfy/commit/3b2929467914b910507ae3ae963909c387142ce3) minor modification to tests involving ips - [`4edc625`](https://github.com/binwiederhier/ntfy/commit/4edc625331a5050a5aa6fe8d4a5b318010561178) fix lint - [`bc5060b`](https://github.com/binwiederhier/ntfy/commit/bc5060b218e65d334a79a5c2ea1db2a09f55a8f2) test new config parsing - [`1672322`](https://github.com/binwiederhier/ntfy/commit/1672322fc10d0304080e1e3e866d31c26bb71557) test ContainsIP utility ### 📊 Changes **14 files changed** (+164 additions, -60 deletions) <details> <summary>View changed files</summary> 📝 `cmd/serve.go` (+33 -6) 📝 `cmd/serve_test.go` (+23 -5) 📝 `server/config.go` (+3 -2) 📝 `server/message_cache.go` (+11 -4) 📝 `server/message_cache_test.go` (+13 -7) 📝 `server/server.go` (+22 -8) 📝 `server/server_firebase_test.go` (+6 -4) 📝 `server/server_matrix_test.go` (+4 -2) 📝 `server/server_test.go` (+13 -11) 📝 `server/smtp_sender.go` (+1 -1) 📝 `server/types.go` (+4 -2) 📝 `server/visitor.go` (+7 -5) 📝 `util/util.go` (+14 -2) 📝 `util/util_test.go` (+10 -1) </details> ### 📄 Description - Refactor visitor IPs and allow exempting IP Ranges Use netip.Addr instead of storing addresses as strings. This requires conversions at the database level and in tests, but is more memory efficient and efficient to compare; mainly it facilitates the following. Parse rate limit exemptions as netip.Prefix. This allows storing IP ranges in the exemption list. Regular IP addresses (entered explicitly or resolved from hostnames) are IPV4/32, denoting a range of just that one address. ~~**draft** still need to add tests and fix bugs.~~ However, is the change from string IPs to netip.Addr and netip.Prefix acceptable? Closes #423 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 01:01:26 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1296
No description provided.