network - Network Utilities
Overview
The network module provides network utilities for interface IP address detection and network operations.
Functions
GetInterfaceIpByName()
Get IP address by interface name.
Parameters:
name- Interface name (e.g., "eth0", "en0")prev6- Prefer IPv6 if true
Returns:
- IP address string
- Empty string if not found
Example:
GetInterfaceIpByAddrs()
Get IP address from interface addresses.
Parameters:
address- Interface addressesprev6- Prefer IPv6 if true
Returns:
- IP address string
- Empty string if not found
Example:
GetListenIp()
Get listen IP address for network interfaces.
Parameters:
prev6- Prefer IPv6 if true (optional)
Returns:
- IP address string
- Empty string if not found
Search Order:
- eth0 interface
- en0 interface
- First available non-loopback interface
Example:
Usage Patterns
Server Configuration
Interface Discovery
Dual Stack Support
Service Discovery
Best Practices
Error Handling
IPv6 Support
Related Documentation
- runtime - Runtime information
- API Documentation
- Module Overview