Пример #1
0
  /**
   * Fethces the source ref and outputs it to STDOUT
   * @param {string} source
   */
  static fetch(source, username, password, gitBlobID) {
    var agent = null;
    if (process.env.HTTPS_PROXY) {
      agent = HttpsProxyAgent(process.env.HTTPS_PROXY);
    } else if (process.env.https_proxy) {
      agent = HttpsProxyAgent(process.env.https_proxy);
    }

    const octokit = new Octokit({
      userAgent: packageJson.name + '/' + packageJson.version,
      baseUrl: 'https://api.github.com',
      request: {
        agent: agent,
        timeout: 5000
      },
    });

    // authorization
    if (username != '' && password !== '') {
      octokit.authenticate({
        type: 'basic',
        username,
        password
      });
    }

    if (gitBlobID !== 'undefined') {
      const args = {
        owner: this.parseUrl(source).owner,
        repo: this.parseUrl(source).repo,
        file_sha: gitBlobID,
      };

      // @see https://octokit.github.io/rest.js/#api-Git-getBlob
      octokit.gitdata.getBlob(args)
        .then((res) => {
          const ret = {
            data: Buffer.from(res.data.content, 'base64').toString(),
            gitBlobID: res.data.sha,
          };
          process.stdout.write(JSON.stringify(ret));
        })
        .catch(err => GithubReader.processError(err, source));

      return;
    }

    // @see https://developer.github.com/v3/repos/contents/#get-contents
    octokit.repos.getContents(this.parseUrl(source))
      .then((res) => {
        const ret = {
          data: Buffer.from(res.data.content, 'base64').toString(),
          gitBlobID: res.data.sha,
        };
        process.stdout.write(JSON.stringify(ret));
      })
      .catch(err => GithubReader.processError(err, source));
  }
Пример #2
0
function startFeederBotOnProxies() {

    for (proxy_line in lines) {

        if(lines[proxy_line].trim() == "#HTTP"){
            proxy_mode = "HTTP";
        }else if(lines[proxy_line].trim() == "#SOCKS4"){
            proxy_mode = "SOCKS4";
        }else if(lines[proxy_line].trim() == "#SOCKS5"){
            proxy_mode = "SOCKS5";
        }

        if (lines[proxy_line][0] == "#" || lines[proxy_line].length < 3) {
            continue;
        }

        //usefull for testing single proxies
        if (process.argv[3] != null && proxy_line != process.argv[3]) {
            continue;
        }

        proxy = "http://" + lines[proxy_line];
        proxy_single = lines[proxy_line];
        console.log(proxy_mode + " ; " + proxy_single);

        try {

            var opts = url.parse(proxy);

            if (proxy != null) {
                if(proxy_mode=="HTTP"){
                    agent = HttpsProxyAgent(opts);
                }else if(proxy_mode=="SOCKS4"){
                    agent = createAgent(lines[proxy_line],4);
                }else if(proxy_mode=="SOCKS5"){
                    agent = createAgent(lines[proxy_line],5);
                }

            } else {
                var agent = null;
            }

            if (lines[proxy_line] == "NOPROXY") {
                agent = null;
            }

            console.log("Attempting connection to " + game_server_ip);
            for (i = 0; i < config.botsPerIp; i++) {
				if(bot_count<config.maxBots){
					bot_count++;
					bots[bot_count] = new FeederBot(bot_count, agent, bot_count, game_server_ip);
				}
            }

        } catch (e) {
            console.log('Error occured on startup: ' + e);
        }
    }
}