You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module is used to detect the IP address if an IP address is a proxy IP address.
It will store the proxy IP address in a MongoDB database and a Redis database.
Redis is used to store only IP addresses and fast access and MongoDB is used to store the IP address and other information as a permanent record.
The module will check the IP address on the following default ports: 8000, 443, 8080, 8081, 1194, 3128.
The module will try to connect (TCP CONNECT) to the IP address on the above ports, if it is successful, it will be considered as a proxy IP address.
The module will also check if the IP address is a TOR node, if it is, it will be considered as a proxy IP address. ( DNSEL Service will be used to check if the IP address is a TOR node )
Before checking the IP address, it will be checked in the Redis database, if it is not in the Redis database, it will be checked.
When the module is initialized, IP addresses are stored in MongoDB, will be transferred to Redis.
Full Lookup time is about 500ms, even if the IP address is not a proxy IP address.
MongoDB Schema to store IP address and other information
IP address stored in Redis
Installation
yarn add proxy-detect-module
Exposed Methods
// initialize the module with the following parametersproxyDetect.init({host: 'redis-domain.com',port: 19831,// Redis portpassword: 'redispassword',username: 'default',// Redis usernameports: [8000,443,8080,8081,1194,3128],// Ports to checkmongoUri:
'mongodb+srv://DetectService:fgfg'// MongoDB connection string});// get all proxy ip stored in mongoDBproxyDetect.GetProxyList(page: number,limit: number,search: string) : Promise<ProxyIp[]>;//peform a check on a single ip address, if it is a proxy ip address, it will be stored in mongoDB and redisproxyDetect.IsProxy(ip: string) : Promise<boolean>;//remove a proxy ip address from mongoDB and redisproxyDetect.DeleteProxyIP(id: string) : Promise<{resultM : boolean,resultR : boolean}>;
Usage ( NestJS API Example )
// importing the moduleimport{ProxyDetect}from'proxy-detect-module';exportclassDetectService{// initialize the module with the following parametersprivateproxyDetect=newProxyDetect();constructor(){this.proxyDetect.init({host: 'redis-domain.com',port: 19831,// Redis portpassword: 'redispassword',username: 'default',// Redis usernameports: [8000,443,8080,8081,1194,3128],// Ports to checkmongoUri:
'mongodb+srv://DetectService:Asdfv8dsfds8q@clusternt.jdryd3.mongodb.net/ProxyIpDB?retryWrites=true&w=majority',});}// get all proxy ip stored in mongoDBasyncfindAll(page: number,limit: number,search: string){returnawaitthis.proxyDetect.GetProxyList(page,limit,search);}//peform a check on a single ip address, if it is a proxy ip address, it will be stored in mongoDB and redisasyncfindOne(ip: string){console.log('findOne service',ip);constres=awaitthis.proxyDetect.IsProxy(ip);return{ ip, res };}//remove a proxy ip address from mongoDB and redisasyncremove(id: string){returnawaitthis.proxyDetect.DeleteProxyIP(id);}}