<commit_before>var get_ip = require('..')().get_ip,
    assert = require('assert'),
    request = {'headers': {'connection': {'remoteAddress': '172.16.31.10'}}};


describe('HTTP_X_FORWARDED_FOR Multiple IPs', function() {
  it('should return best matched proxy IP address first', function() {
    request.headers.HTTP_X_FORWARDED_FOR = '192.168.255.182, 10.0.0.0, 127.0.0.1, 172.16.17.32, 192.168.127.12';
    request.headers.HTTP_X_REAL_IP = '172.16.58.3';
    request.headers.REMOTE_ADDR = '172.16.17.32';
    get_ip(request);
    assert.equal(request.clientIp, '172.16.17.32');
    assert.equal(request.clientIpRoutable, true);
  });
});
<commit_msg>added ipv4 tests<commit_after>var get_ip = require('..')().get_ip,
    assert = require('assert'),
    request = {'headers': {'connection': {'remoteAddress': '172.16.31.10'}}};


describe('HTTP_X_FORWARDED_FOR Multiple IPs', function() {
  it('should return best matched proxy IP address first', function() {
    request.headers.HTTP_X_FORWARDED_FOR = '192.168.255.182, 10.0.0.0, 127.0.0.1, 172.16.17.32, 192.168.127.12';
    request.headers.HTTP_X_REAL_IP = '172.16.58.3';
    request.headers.REMOTE_ADDR = '172.16.17.32';
    get_ip(request);
    assert.equal(request.clientIp, '172.16.17.32');
    assert.equal(request.clientIpRoutable, true);
  });
});

describe('HTTP_X_FORWARDED_FOR Multiple IPs with Invalid IP Address', function() {
  it('should return best matched proxy IP address while handling an invalid address', function() {
    request.headers.HTTP_X_FORWARDED_FOR = 'unknown, 192.168.255.182, 10.0.0.0, 127.0.0.1, 172.16.17.32, 192.168.127.12';
    request.headers.HTTP_X_REAL_IP = '172.16.58.3';
    request.headers.REMOTE_ADDR = '172.16.17.32';
    get_ip(request);
    assert.equal(request.clientIp, '172.16.17.32');
    assert.equal(request.clientIpRoutable, true);
  });
});

describe('HTTP_X_FORWARDED_FOR Single IP Address', function() {
  it('should return best matched proxy IP address if only one provided', function() {
    request.headers.HTTP_X_FORWARDED_FOR = '192.168.127.12';
    request.headers.HTTP_X_REAL_IP = '172.16.58.3';
    request.headers.REMOTE_ADDR = '172.16.17.32';
    get_ip(request);
    assert.equal(request.clientIp, '192.168.127.12');
    assert.equal(request.clientIpRoutable, true);
  });
});

describe('HTTP_X_FORWARDED_FOR Single Private IP Address', function() {
  it('should return best matched public ip address if proxy returns a single private ip', function() {
    request.headers.HTTP_X_FORWARDED_FOR = '192.168.255.182';
    request.headers.HTTP_X_REAL_IP = '172.16.58.3';
    request.headers.REMOTE_ADDR = '172.16.17.32';
    get_ip(request);
    assert.equal(request.clientIp, '172.16.58.3');
    assert.equal(request.clientIpRoutable, true);
  });
});

describe('HTTP_X_FORWARDED_FOR Malformed IP Address FallBack on HTTP_X_REAL_IP', function() {
  it('should return the next best match IP if proxy\'s ip is malformed', function() {
    request.headers.HTTP_X_FORWARDED_FOR = 'unknown 192.168.127.12';
    request.headers.HTTP_X_REAL_IP = '172.16.58.3';
    request.headers.REMOTE_ADDR = '172.16.17.32';
    get_ip(request);
    assert.equal(request.clientIp, '172.16.58.3');
    assert.equal(request.clientIpRoutable, true);
  });
});







{'fraction_non_alphanumeric': 0.16462293071735132, 'fraction_numerical': 0.10361741263028816, 'mean_word_length': 4.130503144654088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 38, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2594818', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1172, 'n_words': 208}