{"id":35049891,"url":"https://github.com/getevo/network","last_synced_at":"2026-05-19T13:12:41.980Z","repository":{"id":317846193,"uuid":"1043994625","full_name":"getevo/network","owner":"getevo","description":"Network Configuration Package","archived":false,"fork":false,"pushed_at":"2025-08-25T03:07:30.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-28T23:18:45.973Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getevo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-25T03:06:52.000Z","updated_at":"2025-08-25T03:08:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b09de6e-8278-4263-badc-27a79ffc54c6","html_url":"https://github.com/getevo/network","commit_stats":null,"previous_names":["getevo/network"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/getevo/network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getevo%2Fnetwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getevo%2Fnetwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getevo%2Fnetwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getevo%2Fnetwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getevo","download_url":"https://codeload.github.com/getevo/network/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getevo%2Fnetwork/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33218004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T07:54:09.561Z","status":"ssl_error","status_checked_at":"2026-05-19T07:54:08.508Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-27T09:11:41.239Z","updated_at":"2026-05-19T13:12:41.957Z","avatar_url":"https://github.com/getevo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Network Configuration Package\n\nA Go package for retrieving network configuration information across different operating systems (Windows and Linux).\n\n## Features\n\n- **Cross-platform support**: Works on both Windows and Linux\n- **Thread-safe singleton pattern**: Ensures consistent configuration access\n- **Comprehensive network information**: Retrieves IP addresses, DNS servers, gateways, and more\n- **Network diagnostics**: Ping hosts with RTT and packet loss statistics\n- **DNS operations**: NSLookup and comprehensive DNS record resolution\n- **Error handling**: Robust error handling with detailed error messages\n- **Security**: Protection against command injection and safe command execution\n\n## Installation\n\n```bash\ngo get github.com/getevo/network\n```\n\n## Usage\n\n### Basic Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \"github.com/getevo/network\"\n)\n\nfunc main() {\n    // Get network configuration\n    config, err := network.GetConfig()\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Print network information\n    fmt.Println(config.String())\n    \n    // Access individual fields\n    fmt.Printf(\"Local IP: %s\\n\", config.LocalIP)\n    fmt.Printf(\"Interface: %s\\n\", config.InterfaceName)\n    fmt.Printf(\"MAC Address: %s\\n\", config.HardwareAddress)\n}\n```\n\n### Refresh Configuration\n\n```go\n// Refresh network configuration (useful after network changes)\nnewConfig, err := network.RefreshConfig()\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n### Ping a Host\n\n```go\n// Ping with default options\nresult, err := network.Ping(\"google.com\", nil)\nif err != nil {\n    log.Fatal(err)\n}\n\nfmt.Printf(\"Packet Loss: %.1f%%\\n\", result.PacketLoss)\nfmt.Printf(\"Average RTT: %v\\n\", result.AvgRTT)\n\n// Ping with custom options\noptions := \u0026network.PingOptions{\n    Count:   10,\n    Timeout: 5 * time.Second,\n    Size:    64,\n}\nresult, err = network.Ping(\"8.8.8.8\", options)\nfmt.Println(result.String())\n```\n\n### DNS Lookup\n\n```go\n// Simple NS lookup - get IP addresses for a domain\nips, err := network.NSLookup(\"google.com\")\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Printf(\"IP addresses: %v\\n\", ips)\n\n// Comprehensive DNS resolution - get all DNS records\nrecords, err := network.Resolve(\"example.com\")\nif err != nil {\n    log.Fatal(err)\n}\nfmt.Println(records.String())\n\n// Access specific record types\nfor _, mx := range records.MX {\n    fmt.Printf(\"Mail server: %s (priority %d)\\n\", mx.Host, mx.Priority)\n}\n```\n\n## API Reference\n\n### Types\n\n#### Network Struct\n\n```go\ntype Network struct {\n    LocalIP                       net.IP\n    DNS                           []string\n    SubnetMask                    net.IP\n    DefaultGateway                net.IP\n    DefaultGatewayHardwareAddress net.HardwareAddr\n    InterfaceName                 string\n    HardwareAddress               net.HardwareAddr\n    Suffix                        string\n    Interface                     *net.Interface\n}\n```\n\n#### PingResult Struct\n\n```go\ntype PingResult struct {\n    Host         string\n    Sent         int\n    Received     int\n    Lost         int\n    PacketLoss   float64       // Percentage\n    MinRTT       time.Duration\n    MaxRTT       time.Duration\n    AvgRTT       time.Duration\n    StdDevRTT    time.Duration\n    Success      bool\n    ErrorMessage string\n}\n```\n\n#### DNSRecords Struct\n\n```go\ntype DNSRecords struct {\n    Domain string\n    A      []string    // IPv4 addresses\n    AAAA   []string    // IPv6 addresses\n    CNAME  []string    // Canonical names\n    MX     []MXRecord  // Mail exchange records\n    NS     []string    // Name servers\n    TXT    []string    // Text records (includes SPF)\n    SOA    *SOARecord  // Start of Authority\n    PTR    []string    // Pointer records\n}\n```\n\n### Functions\n\n#### GetConfig() (*Network, error)\n\nReturns the singleton instance of the network configuration. Thread-safe and returns the same instance on subsequent calls.\n\n```go\nconfig, err := network.GetConfig()\n```\n\n#### RefreshConfig() (*Network, error)\n\nForces a refresh of the network configuration, creating a new instance.\n\n```go\nconfig, err := network.RefreshConfig()\n```\n\n#### String() string\n\nReturns a formatted string representation of the network configuration.\n\n```go\nfmt.Println(config.String())\n```\n\n#### Ping(host string, options *PingOptions) (*PingResult, error)\n\nSends ICMP echo requests to a host and returns detailed statistics including RTT and packet loss.\n\n```go\nresult, err := network.Ping(\"google.com\", nil)\n```\n\n#### NSLookup(domain string) ([]string, error)\n\nConverts a domain name to a list of IP addresses.\n\n```go\nips, err := network.NSLookup(\"google.com\")\n```\n\n#### Resolve(domain string) (*DNSRecords, error)\n\nReturns comprehensive DNS records for a domain including A, AAAA, CNAME, MX, NS, TXT, SOA, and PTR records.\n\n```go\nrecords, err := network.Resolve(\"example.com\")\n```\n\n## Platform-Specific Behavior\n\n### Windows\n- Uses `ipconfig` and `arp` commands to gather network information\n- Retrieves DNS servers from Windows network configuration\n\n### Linux\n- Uses `ip`, `ifconfig`, and `arp` commands\n- Reads DHCP lease files for DNS information\n- Automatically searches for commands in common locations\n\n## Error Handling\n\nThe package includes comprehensive error handling for:\n- Missing network commands\n- Invalid network configurations\n- Command execution failures\n- Parsing errors\n\n## Thread Safety\n\nThe package uses mutex locks to ensure thread-safe access to the singleton instance. Multiple goroutines can safely call `GetConfig()` concurrently.\n\n## Testing\n\nRun the test suite:\n\n```bash\ngo test -v\n```\n\nRun benchmarks:\n\n```bash\ngo test -bench=.\n```\n\n## Security Considerations\n\n- Command injection protection for user-supplied interface names\n- Safe parsing of command outputs with bounds checking\n- Nil pointer protection throughout the codebase\n\n## Requirements\n\n- Go 1.20 or higher\n- Administrative privileges may be required on some systems\n- Linux systems need standard networking tools (`ip`, `ifconfig`, `arp`)\n- Windows systems need standard Windows networking commands\n\n## License\n\nPlease check the repository for license information.\n\n## Contributing\n\nContributions are welcome! Please ensure all tests pass and add new tests for any new functionality.\n\n## Known Limitations\n\n- Some network information may not be available in containerized environments\n- VPN connections may affect the detected network configuration\n- Some Linux distributions may have networking tools in non-standard locations","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetevo%2Fnetwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetevo%2Fnetwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetevo%2Fnetwork/lists"}