{"id":36444035,"url":"https://github.com/abc-inc/terminus","last_synced_at":"2026-01-11T22:02:29.083Z","repository":{"id":115591408,"uuid":"259119817","full_name":"abc-inc/terminus","owner":"abc-inc","description":"terminus is an IP subnet address calculator","archived":false,"fork":false,"pushed_at":"2023-02-27T13:04:20.000Z","size":47,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T12:34:50.401Z","etag":null,"topics":["address","calculator","go","golang","ip","ipv4-calculator","network","subnet"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abc-inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-04-26T19:50:51.000Z","updated_at":"2022-10-18T19:50:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"ce5030bb-1f4a-4b40-ad0f-0432d4b7847a","html_url":"https://github.com/abc-inc/terminus","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/abc-inc/terminus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abc-inc%2Fterminus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abc-inc%2Fterminus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abc-inc%2Fterminus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abc-inc%2Fterminus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abc-inc","download_url":"https://codeload.github.com/abc-inc/terminus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abc-inc%2Fterminus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28324844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"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":["address","calculator","go","golang","ip","ipv4-calculator","network","subnet"],"created_at":"2026-01-11T22:02:29.001Z","updated_at":"2026-01-11T22:02:29.062Z","avatar_url":"https://github.com/abc-inc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terminus\n\nTerminus is an IPv4 subnet address calculator\n\nIt can be used\n\n- as a standalone tool to output human readable information about a network or address,\n- as a tool suitable to be used by scripts or other programs via [template language](#Template-Language),\n- as well as a library for applications written in Go.\n\n## Why *Terminus*?\n\nIn Roman religion, *Terminus* was the god who protected boundary stones.\nHis name was the Latin word for such a marker.\nTherefore, it is the ideal name of an application, which calculates network boundaries.\n\nBesides, there are a few command-line applications, which output information about IP addresses in human readable form.\nHowever, they lack flexibility when it comes to output format.\n\n## Features\n\nFor a given IPv4 address (and optional prefix length), *Terminus* calculates\n\n- IP / netmask in dot-decimal notation\n- prefix length\n- broadcast address / network address\n- host address range of the subnet\n- maximum number of hosts / IPs in the subnet\n- wildcard mask in dot-decimal notation\n\n## Examples\n\n```shell script\n$ terminus -i eth0\n172.16.57.200\n\n$ terminus -p 10.0.0.138\n8\n\n$ terminus -b 192.168.100.1/24\n192.168.100.255\n\n$ terminus -f -l lo\n127.0.0.1\n127.255.255.254\n\n# using a template expression\n$ terminus -t \"{{.ip}}/{{.prefix}} ({{.network}} - {{.broadcast}})\" tun0\n10.197.63.254/11 (10.192.0.0 - 10.223.255.255)\n```\n\n## Template Language\n\nWhen given a template expression, *Terminus* evaluates it using [Go templates](https://golang.org/pkg/text/template/#pkg-overview).\nThus, all actions, expressions and functions available in a Go template can be used.\n\nFor example, the following statement checks if the environment variable `IP` is a loopback address.\nIf so, it replaces the IP with \"`localhost`\", and it yields a nice URL:\n\n```shell script\n$ export IP=\"127.100.100.1\"\n$ terminus -t \"{{if .ip.IsLoopback}}http://localhost{{else}}https://{{.ip}}{{end}}:8080/\" \"${IP}\"\nhttp://localhost:8080/\n```\n\n### Network Interfaces\n\nIf an IP address or network interface is passed as a command line argument, it is set as the *default interface*.\nIn this way it can be accessed with `.` e.g., `{{.ip}}`.\n\nIn general, all interfaces can be addressed by name via `{{.interfaces.\u003cNAME\u003e}}` e.g., `{{.interfaces.tun0.ip}}`.\nIn other words, the following expressions are equivalent:\n\n```shell script\nterminus -t \"{{.network}} - {{.broadcast}}\" tun0\nterminus -t \"{{.interfaces.tun0.network}} - {{.interfaces.tun0.broadcast}}\"\n```\n\nWhile the short syntax is preferred for retrieving multiple properties of a single network interface,\nthe long syntax can be used for retrieving properties of multiple network interfaces.\n\n```shell script\n$ terminus -t '{{.interfaces.eth0.ip}}{{\"\\n\"}}{{.interfaces.eth1.ip}}'\n172.16.57.200\n192.168.100.1\n```\n\n#### Windows\n\nNetwork adapters can contain whitespaces e.g., \"`Local Area Connection`\".\nTherefore, it is essential to quote them in template expressions.\nThe Windows command interpreter *cmd* requires two double quotes to quote a literal string e.g., `\"\"Local Area Connection\"\"`.\nDue to the nested quotes, the [`index` function](https://golang.org/pkg/text/template/#hdr-Functions) must be used to address properties.\nThis adds additional double quotes to the literals:\n\n```shell script\n\u003eterminus -t \"{{index .interfaces \"\"\"Local Area Connection\"\"\" \"\"\"ip\"\"\"}} {{index .interfaces \"\"\"Local Area Connection\"\"\" \"\"\"netmask\"\"\"}}\"\n192.168.100.200 255.255.255.0\n```\n\n### Network Interface Properties\n\nEvery network interface has the following properties:\n\n```text\nExpression      Example         Type    Description\n{{.broadcast}}  10.0.3.255      net.IP  broadcast address\n{{.first}}      10.0.0.1        net.IP  first usable IP address of the subnet\n{{.ip}}         10.0.0.42       net.IP  IP address\n{{.last}}       10.0.3.254      net.IP  last usable IP address of the subnet\n{{.name}}       eth0            string  name of the network interface\n{{.netmask}}    255.255.252.0   net.IP  subnet mask\n{{.network}}    10.0.0.0        net.IP  network address\n{{.prefix}}     22              int     prefix length\n{{.size}}       1024            int     size of the subnet\n{{.usable}}     1022            int     usable size of the subnet (host count)\n{{.wildcard}}   0.0.3.255       net.IP  wildcard mask\n```\n\nNote that values might be absent if an interface is not up.\n\n### Functions\n\n*terminus* comes with built-in functions for converting IP addresses and netmasks, and for formatting output.\nThe following functions are available:\n\n- `toBinary`: converts an IP address (or netmask) to binary dot-decimal notation\n- `toHex`: converts a netmask (or IP address) to hexadecimal notation\n- `toJson`: converts the input to a valid JSON object/array/string (if possible)\n\n```shell script\n$ terminus -t '{{.ip}} {{.ip | toBinary}}{{\"\\n\"}}{{.netmask}} {{.netmask | toHex}}' eth0\n172.16.57.200 10101100.00010000.00111001.11001000\n255.255.254.0 0xfffffe00\n```\n\nThe following example dumps all properties of the *eth0* interface as JSON object:\n\n```shell script\n$ terminus -t \"{{. | toJson}}\" eth0\n{\"broadcast\":\"172.16.57.255\",\"first\":\"172.16.56.1\",\"ip\":\"172.16.57.200\",\"last\":\"172.16.57.254\",\"name\":\"eth0\",\"netmask\":\"255.255.254.0\",\"network\":\"172.16.56.0\",\"prefix\":23,\"size\":512,\"usable\":510,\"version\":4,\"wildcard\":\"0.0.1.255\"}\n```\n\nThe `toJson` function comes in handy when combined with other tools like *[jq](https://stedolan.github.io/jq/)*.\nFor example, a JSON array of all network interfaces and their properties can be created as follows:\n\n```shell script\n$ terminus -L | cut -f 1 | xargs -n1 terminus -t \"{{. | toJson}}\" | jq -rs \".\"\n[\n  {\n    \"broadcast\": \"172.16.57.255\",\n    \"first\": \"172.16.56.1\",\n    \"ip\": \"172.16.57.200\",\n    \"last\": \"172.16.57.254\",\n    \"name\": \"eth0\",\n    \"netmask\": \"255.255.254.0\",\n    \"network\": \"172.16.56.0\",\n    \"prefix\": 23,\n    \"size\": 512,\n    \"usable\": 510,\n    \"version\": 4,\n    \"wildcard\": \"0.0.1.255\"\n  },\n  ...\n]\n```\n\n## Pipes \u0026 stdin\n\nWhen using *Terminus* in a pipeline, the output of the previous command is appended to the arguments passed to *Terminus*.\nNote that template expressions must be quoted to prevent word splitting.\n\nThe following example reads the template from a file and parametrizes it with the interface *eth0*:\n\n```shell script\n$ cat macOS_format.tmpl\n-t \"inet {{.ip}} netmask {{.netmask | toHex}} broadcast {{.broadcast}}\"\n$ cat macOS_format.tmpl | terminus eth0\ninet 172.16.57.200 netmask 0xfffffe00 broadcast 172.16.57.255\n# equivalent to\n# terminus -t \"inet {{.ip}} netmask {{.netmask | toHex}} broadcast {{.broadcast}}\" eth0\n```\n\nAlso *xargs* can be useful e.g., for iterating over all ethernet adapters and printing their IP addresses:\n\n```shell script\n$ terminus -L | cut -f 1 | grep -E \"^eth\" | xargs -n1 terminus -t '{{.name}}{{\"\\t\"}}{{.ip}}'\neth0  172.16.57.200\neth0:0  127.16.57.100\neth1  192.168.100.1\n```\n\n## Roadmap\n\n- IPv6 support (including conversions)\n- subnet splitting\n\n## Related Projects (in alphabetical order)\n\n- ipcalc: \u003chttps://gitlab.com/ipcalc/ipcalc\u003e\n- netcalc: \u003chttps://github.com/troglobit/netcalc\u003e\n- sipcalc: \u003chttps://github.com/sii/sipcalc\u003e\n- subnetcalc: \u003chttps://github.com/dreibh/subnetcalc\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabc-inc%2Fterminus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabc-inc%2Fterminus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabc-inc%2Fterminus/lists"}