-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathproxy.js
44 lines (36 loc) · 870 Bytes
/
proxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict'
const ProxyAgent = require('proxy-agent')
const HTTP = require('http');
class Proxy {
type;
host;
port;
constructor(type, host, port) {
this.type = type;
this.host = host;
this.port = port;
}
getType() {
return this.type;
}
getHost() {
return this.host;
}
getPort() {
return this.port;
}
async check() {
await HTTP.get({
method: 'GET',
host: 'ifconfig.me',
path: '/',
agent: new ProxyAgent({ protocol: 'socks'+this.getType()+':', host: this.getHost(), port: this.getPort() })
}, (res) => {
if (res.statusCode === 200) {
return true;
}
return false;
});
}
}
module.exports = Proxy;