Add Human-Readable IP Address Support to TON Configuration Files #1723
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Overview
This PR introduces comprehensive human-readable IP address support for TON configuration files, making node configuration more user-friendly while maintaining full backward compatibility with existing numeric IP formats.
🚀 Features Implemented
✨ Human-Readable IPv4 Support
"ip": "192.168.1.100"
)"ip": -1062731775
→192.168.0.1
)"ip": 0
→0.0.0.0
)🔧 Components Enhanced
tl_json.h
with IP address conversion utilities🌐 Configuration Format Support
"ip": "192.168.1.100"
"ip": 3232235876
"ip": -1062731775
"ip": 0
📋 Usage Examples
New Human-Readable Format (Recommended)
Legacy Numeric Format (Still Supported)
Negative IP Format (Fully Compatible)
🧪 Testing Results
✅ Comprehensive Test Suite Passed
validator-engine
anddht-server
compile successfullyvalidator-engine --help
and basic operations work📊 IP Address Conversion Verification
🔍 Test Files Created
test-config-human-readable.json
- Human-readable IP configuration exampletest-config-numeric.json
- Numeric IP configuration exampletest-config-negative-ip.json
- Negative IP configuration exampletest-human-readable-ip.sh
- Comprehensive test script🔧 Technical Implementation
Core Changes
Enhanced JSON Serialization (
tl/tl/tl_json.h
):from_json_ip_address()
function for parsing both string and numeric IP formatsto_json_ip_address()
function for outputting human-readable IP addressesConfiguration Processing (
validator-engine/validator-engine.cpp
):load_config()
with human-readable IP preprocessingwrite_config()
to output human-readable IP formatDHT Server Support (
dht-server/dht-server.cpp
):Conversion Logic
td::IPAddress::get_ipv4_address()
td::IPAddress::ipv4_to_str()
static_cast<td::uint32>(ip)
to preserve bit patterns🎯 Benefits
For Users
For Developers
🛡️ Compatibility & Safety
📚 Migration Guide
For New Deployments
Use the new human-readable format for better maintainability:
For Existing Deployments
No changes required - your current configurations will continue to work:
For Mixed Environments
You can mix both formats in the same configuration file:
🔮 Future Enhancements
This implementation provides a solid foundation for:
This enhancement makes TON node configuration more accessible while maintaining the robustness and compatibility that production environments require. 🚀