Skip to content

Refactor CloudFlare IP updater to eliminate temporary files - #8

Merged
gpas45 merged 1 commit into
mainfrom
claude/cf-ip-updater-bpbar7
Jun 12, 2026
Merged

Refactor CloudFlare IP updater to eliminate temporary files#8
gpas45 merged 1 commit into
mainfrom
claude/cf-ip-updater-bpbar7

Conversation

@gpas45

@gpas45 gpas45 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Refactored the CloudFlare IP address list updater script to eliminate temporary file operations and improve reliability. The script now downloads the IP list directly into memory and validates entries before updating the address list, preventing the list from becoming empty during updates.

Key Changes

  • Removed temporary file handling: Replaced file-based download with direct memory storage using /tool fetch with output=user as-value parameter
  • Eliminated file system operations: Removed file creation, deletion, and timeout waiting logic (~40 lines of code)
  • Improved update atomicity: Validates all downloaded entries before modifying the address list, preventing empty state during updates
  • Enhanced error handling: Simplified error detection by checking response status and content size directly
  • Better IPv6 filtering: Explicitly skips IPv6 entries (containing colons) during parsing
  • Cleaner code structure: Reduced script from 129 to 97 lines while improving readability
  • Updated documentation:
    • Changed minimum RouterOS version requirement from 6.x to 6.43+
    • Fixed scheduler configuration example to use proper syntax
    • Clarified that script downloads current IPv4 networks (not just addresses)

Implementation Details

  • Downloads response directly into $content variable, bypassing file system
  • Pre-validates all entries into $newList array before updating address-list
  • Maintains backward compatibility with existing address-list structure
  • Preserves logging for debugging and monitoring purposes
  • Removed unnecessary delays and file existence checks

https://claude.ai/code/session_015PYMYtCPwvUpUqkfFD5UL6

@gpas45
gpas45 merged commit 146f259 into main Jun 12, 2026
2 checks passed
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.

2 participants