{"_id":"@abrifq/tor-detector-with-dns","name":"@abrifq/tor-detector-with-dns","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@abrifq/tor-detector-with-dns","version":"1.0.0","description":"Detects if given IP is a TOR exit node with the old ip list strategy and new DNS query strategy.","main":"index.js","scripts":{"test":"node --test"},"repository":{"type":"git","url":"git+https://github.com/Abrifq/tor-detector-js.git"},"keywords":["tor","exit","ip","censor","dark","deep","web","net","dns","dnsel","list"],"author":{"name":"Abrifq"},"license":"MIT","bugs":{"url":"https://github.com/Abrifq/tor-detector-js/issues"},"homepage":"https://github.com/Abrifq/tor-detector-js#readme","engines":{"node":"^20"},"devDependencies":{"@types/node":"^20.7.0"},"_id":"@abrifq/tor-detector-with-dns@1.0.0","gitHead":"c3d1afe475326a20c008ac235f3c81e921297a9a","_nodeVersion":"20.7.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-GrinJl089s/WZHQn5OorX9Xo5kCQlxrIH1/Y/jdpYilo47w+wcqOGHbRZgYfZgWUWZn3DtznufJ9u1FWs6QqiQ==","shasum":"c7d74f37573f06db760f2a223269057faa38acee","tarball":"https://registry.npmjs.org/@abrifq/tor-detector-with-dns/-/tor-detector-with-dns-1.0.0.tgz","fileCount":7,"unpackedSize":7315,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHRpSq2afMaZFY/Z3k16LLYStnPr7lJBAzBGnIIXB3o8AiEApUqFEDFb1L9X8VoZZey8fm1EA5X0K1Z5evWrfBO2nPQ="}]},"_npmUser":{"name":"abrifq","email":"melezorus34@gmail.com"},"directories":{},"maintainers":[{"name":"abrifq","email":"melezorus34@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/tor-detector-with-dns_1.0.0_1700363762322_0.6767917892594106"},"_hasShrinkwrap":false}},"time":{"created":"2023-11-19T03:16:01.858Z","1.0.0":"2023-11-19T03:16:02.510Z","modified":"2023-11-19T03:16:02.803Z"},"maintainers":[{"name":"abrifq","email":"melezorus34@gmail.com"}],"description":"Detects if given IP is a TOR exit node with the old ip list strategy and new DNS query strategy.","homepage":"https://github.com/Abrifq/tor-detector-js#readme","keywords":["tor","exit","ip","censor","dark","deep","web","net","dns","dnsel","list"],"repository":{"type":"git","url":"git+https://github.com/Abrifq/tor-detector-js.git"},"author":{"name":"Abrifq"},"bugs":{"url":"https://github.com/Abrifq/tor-detector-js/issues"},"license":"MIT","readme":"# tor-detector-with-dns\n\nWhy this name? I ran out of good names. Most of them are taken.\n\nCheck if a request you received is routed via tor.\n\n- `FileBasedChecker` uses the traditional ip file strategy\n- `DNSBasedChecker` uses [the new (2020) DNS query strategy](https://lists.torproject.org/pipermail/tor-project/2020-March/002759.html#DNS-Exit-List\n) (less waste!)\n\n## Usage\n\nDepending on your usage, use either `tor-detector/dns-checker.js` to check via DNS queries or `tor-detector/local-checker.js` to check with TOR's own auto-published list.\n\nFor example, use dns checker for realtime detection and local checker for when you got a list of IPs to skim through.\n\nBoth classes have the same function signature:\n\n- `check(ip: string): Promise<boolean>`, takes in an IPv4 address, returns a boolean promise.\n\n```ts\nimport { DNSBasedChecker as TorChecker } from \"tor-checker/dns-checker\"\nimport * as requestIP from \"request-ip\";\nimport { NextFunction, Request, Response } from \"express\"\n\nconst torChecker = new TorChecker();\n\nasync function handleIPMiddleware(req: Request, res: Response, next: NextFunction) {\n    if (await torChecker.check(requestIP.getClientIp(req)))\n        handleTorUser(req, res);\n    return next();\n}\n\n//handle tor users differently. for example, put a banner on top of the template\nfunction handleTorUser(req: Request, res: Response) {\n    return res.redirect(\"/tor-welcome\")\n}\n```\n\n### Advanced Usage\n\n- IP List files get updated \"around every 40 minutes\", this project fetches the IP list file again if an hour passed since the last request.\n  You can change this behavior in `FileBasedChecker` class' constructor by giving it a new Time To Live time, in milliseconds.\n\n- IP List url may get changed or you may have found a more accurate provider, fear not!\n  You can change the IP list link url by providing the new url to `FileBasedChecker` class' constructor.\n\n- The DNS Query system may get updated and change how the DNS query is formed. (Or maybe you are using a different provider, who knows)\n  You can change the default query constructor with your own one, in `DNSBasedChecker` class' constructor.\n","readmeFilename":"README.md"}