summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/hostname_bind_ips.js
blob: d7d87e99ec50173fc8232a4deb83db87d3ad02bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Check that connecting via IPv4 keeps working when
// binding to localhost and enabling IPv6.

(function() {
    'use strict';

    const proc = MongoRunner.runMongod({bind_ip: "localhost", "ipv6": ""});
    assert.neq(proc, null);

    assert.soon(function() {
        try {
            const uri = 'mongodb://127.0.0.1:' + proc.port + '/test';
            const conn = new Mongo(uri);
            assert.commandWorked(conn.adminCommand({ping: 1}));
            return true;
        } catch (e) {
            return false;
        }
    }, "Cannot connect to 127.0.0.1 when bound to localhost", 30 * 1000);
    MongoRunner.stopMongod(proc);
})();