<commit_before>var bencode = require('bencode');
var _ = require('lodash');

var common = require('./../helpers/common');
var Peer = require('./../helpers/peer');
var PeerInfo = require('./../helpers/peerInfo');
var Response = require('./../helpers/response');

var database = {};

var generatePeer = function(req) {
    var info_hash = common.descramble(req.param('info_hash'));
    var peer_id = common.descramble(req.param('peer_id'));
    var ip = req.param('ip') || req.connection.remoteAddress;
    var ipv6 = req.param('ipv6');
    var port = parseInt(req.param('port'));
    var compact = parseInt(req.param('compact')) || 1;
    var no_peer_id = parseInt(req.param('no_peer_id')) || 0;
    var numwant = parseInt(req.param('numwant')) || 50;
    var uploaded = req.param('uploaded') || 0;
    var downloaded = req.param('downloaded') || 0;
    var left = req.param('left');

    if (numwant > 200) {
        numwant = 200;
    }

    var peer_info = new PeerInfo(uploaded, downloaded, left);<commit_msg>check if IP is IP!<commit_after>var bencode = require('bencode');
var _ = require('lodash');
var net = require('net');

var common = require('./../helpers/common');
var Peer = require('./../helpers/peer');
var PeerInfo = require('./../helpers/peerInfo');
var Response = require('./../helpers/response');

var database = {};

var generatePeer = function(req) {
    var info_hash = common.descramble(req.param('info_hash'));
    var peer_id = common.descramble(req.param('peer_id'));
    var ip = req.param('ip') || req.connection.remoteAddress;
    ip = net.isIPv4(ip) ? ip : null;

    var ipv6 = req.param('ipv6');
    ipv6 = net.isIPv6(ipv6) ? ipv6 : null;

    var port = parseInt(req.param('port'));
    var compact = parseInt(req.param('compact')) || 1;
    var no_peer_id = parseInt(req.param('no_peer_id')) || 0;
    var numwant = parseInt(req.param('numwant')) || 50;
    var uploaded = req.param('uploaded') || 0;
    var downloaded = req.param('downloaded') || 0;
    var left = req.param('left');

    if (numwant > 200) {
        numwant = 200;
    }

    var peer_info = new PeerInfo(uploaded, downloaded, left);
{'fraction_non_alphanumeric': 0.18671034160037436, 'fraction_numerical': 0.01544220870379036, 'mean_word_length': 3.657952069716776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3195357', 'n_tokens_mistral': 731, 'n_tokens_neox': 699, 'n_words': 158}