-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
37 lines (33 loc) · 940 Bytes
/
main.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
var check = function ({
url: z,
type: t,
proxy: p
}) {
if(!z) throw new Error('Missing url!')
if(!t) throw new Error('Missing type!')
if(!p) throw new Error('Missing proxy!')
x = ['http', 'https', 'socks4', 'socks5']
if(!x.includes(t)) throw new Error('The type does not exist')
return new Promise((resolve) => {
const r = require('request')
r.get(z, {
proxy: String(t + '://' + p)
}, (err, res) => {
if (err) resolve({
proxy: String(t + '://' + p),
code: 500,
type: t,
err: err
})
if(!res) return;
if (res.statusCode == 200) resolve({
proxy: String(t + '://' + p),
type: t,
code: res.statusCode
})
})
})
}
module.exports = {
check: check
}