chill117 / proxy-verifier

NodeJS module to check proxies: if functional, anonymity level, tunneling, supported protocols.
MIT License
76 stars 16 forks source link

How to return result? #27

Open dimonchoo opened 4 years ago

dimonchoo commented 4 years ago

Help me please! I newbie in js. I need to return result of your check but i can`t.

Tried 1:

    let a = await ProxyVerifier.testProtocols(oneProxy,  async function(error, result) {
        return new Promise((resolve) => {
            return resolve(result);
        });
    });

Tried 2:

    let a = await ProxyVerifier.testProtocols(oneProxy,  async function(error, result) {
            return result;
    });

Tried 3:

let/var/const a = null;
    ProxyVerifier.testProtocols(oneProxy,  async function(error, result) {
            a  = result;
    });

Tried 4:

let a = {
    proxy: ProxyVerifier.testProtocols(oneProxy,  async function(error, result) {
            this.value = result;
    }),
   value: null
}

Maybe answer is simple, but i can`t understand how get result.

ghost commented 3 years ago

The result is stored as a json in result for example you could call console.log(result); and get the full json output. And would not recommend to do this in a let

nleiva01 commented 2 years ago

this work for me

async checkProxyTunnel(itemProxy) {
    return new Promise(function (resolve, reject) {
      ProxyVerifier.testAll(itemProxy, function (error, result) {
        resolve({ result, error })
      })
    })
  }

and use:

await checkProxyTunnel(itemProxy)

where itemProxy is

itemProxy = {
   ipAddress: '192.64.13.4'
   port:8080
   protocol:'https'
}