{"id":21744298,"url":"https://github.com/oeo/lan-address-gen","last_synced_at":"2026-02-03T01:38:35.244Z","repository":{"id":257805961,"uuid":"865932819","full_name":"oeo/lan-address-gen","owner":"oeo","description":"deterministic hashing to create static lan ips based on input strings","archived":false,"fork":false,"pushed_at":"2024-12-22T02:02:08.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T01:50:54.828Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/oeo.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}},"created_at":"2024-10-01T11:18:21.000Z","updated_at":"2024-12-22T02:02:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"49dbc80f-8714-4ee1-a181-52d84ff00fa7","html_url":"https://github.com/oeo/lan-address-gen","commit_stats":null,"previous_names":["oeo/lan-address-gen"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oeo/lan-address-gen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Flan-address-gen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Flan-address-gen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Flan-address-gen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Flan-address-gen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oeo","download_url":"https://codeload.github.com/oeo/lan-address-gen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Flan-address-gen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29026417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T00:53:18.321Z","status":"ssl_error","status_checked_at":"2026-02-03T00:51:45.186Z","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":"2024-11-26T07:11:03.863Z","updated_at":"2026-02-03T01:38:35.230Z","avatar_url":"https://github.com/oeo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lan-address-gen\n\nthis tool (and lib) generates lan addresses using deterministic static\nhashing. it maps input strings to ip addresses within private ip ranges,\ndefaulting to 192.168.x.x but supporting other patterns like 10.x.x.x.\n\n*it has no non-native deps to run and only requires jest to run the test suite.*\n\ni use this as part of my homelab toolkit for static ip assignment.\n\n## how it works\n\n1. takes an input string (and optional salt)\n1. creates a sha-256 hash of the string\n1. uses the last 24 bits of the hash to generate a number\n1. maps this number to an ip in the specified range:\n   - 192.168.x.x (default) - 65,536 possible addresses\n   - 10.x.x.x (with --pattern 10) - 16,777,216 possible addresses\n   - 172.16.x.x (with --pattern 172.16) - 65,536 possible addresses\n   - etc.\n\nnote that if the `--ping` option is provided it will attempt to verify\nthat it cannot contact the address via ping before returning the address.\nif it can, it will increment the ip address until it finds an available\naddress and return that.\n\n## collision rates\n\ndue to the different sizes of address spaces, collision rates vary:\n- 192.168.x.x and other /16 ranges: ~7-8% collisions with 10k inputs\n- 10.x.x.x and other /8 ranges: ~0.04% collisions with 10k inputs\n\nif collisions are a concern, you can:\n1. use a larger address space (like 10.x.x.x)\n2. add a salt to your inputs\n3. verify availability with --ping\n\n## installation\n\nglobal install:\n\n```bash\nnpm install -g lan-address-gen\n```\n\nlocal install:\n\n```bash\nnpm install lan-address-gen\n```\n\n## usage\n\n### cli\n\n```bash\nlan-address-gen \u003cinput_string\u003e [options]\n\noptions:\n  --ping          check if the ip is in use and find an available one\n  --verbose       show more details\n  --help          display help\n  --salt \u003csalt\u003e   add some spice to your hash\n  --pattern \u003cpat\u003e ip pattern to use (default: 192.168)\n\npattern examples:\n  192.168   - generates 192.168.x.x addresses (default)\n  10        - generates 10.x.x.x addresses\n  172.16    - generates 172.16.x.x addresses\n```\n\nsimple (using default 192.168.x.x pattern):\n\n```bash\nlan-address-gen proxmox\n\n192.168.140.108\n```\n\nusing 10.x.x.x pattern:\n\n```bash\nlan-address-gen proxmox --pattern 10\n\n10.248.60.218\n```\n\nusing 172.16.x.x pattern:\n\n```bash\nlan-address-gen proxmox --pattern 172.16\n\n172.16.140.108\n```\n\nspecify a custom salt:\n\n```bash\nlan-address-gen proxmox --salt test\n\n192.168.140.108\n```\n\nverbose with ping verification:\n\n```bash\nlan-address-gen proxmox --ping --verbose\n\nGenerated IP: 192.168.140.108\nChecking for an available IP...\nAvailable IP found: 192.168.140.108\n192.168.140.108\n```\n\n### module\n\n```javascript\nconst { stringToIp, ipToString } = require('lan-address-gen');\n\n// default pattern (192.168.x.x)\nconst ip = ipToString(stringToIp('proxmox', 'optional salt'));\nconsole.log(ip); // outputs something like 192.168.45.67\n\n// custom pattern (10.x.x.x)\nconst tenIp = ipToString(stringToIp('proxmox', 'optional salt', '10'));\nconsole.log(tenIp); // outputs something like 10.45.67.89\n\n// custom pattern (172.16.x.x)\nconst corpIp = ipToString(stringToIp('proxmox', 'optional salt', '172.16'));\nconsole.log(corpIp); // outputs something like 172.16.45.67\n```\n\nyou can also set a salt with the LAN_ADDRESS_SALT environment variable\nif you use the module programmatically.\n\n## development\n\nrun tests with:\n\n```bash\nnpm test\n```\n\nhere's what you should see:\n\n```bash\n🚀 testBasicFunctionality passed\nCollision rate (192.168.x.x): 7.56%\nCollision rate (10.x.x.x): 0.04%\n🚀 testCollisions passed\nDistribution range: 108\nMin occurrences: 337, Max occurrences: 445\nAverage occurrences: 390.63\nChi-square value: 281.18\nApproximate p-value: 0.1249\n🚀 testDistribution passed\n🚀 testIncrementIP passed\n🚀 testPatterns passed\nAll tests completed\n```\n\nlooks good, right?\n\n## notes\n\nthis is just for fun. in the real world, think about:\n\n- hash collisions (they happen, especially in smaller ranges)\n- your network's rules\n- security stuff (predictable ips aren't always great)\n\nuse responsibly or irresponsibly\n\n## license\n\nmit\n\n## contrib\n\nprs welcome.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeo%2Flan-address-gen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foeo%2Flan-address-gen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeo%2Flan-address-gen/lists"}