jstests/sharding/proxy_protocol_connect.js
// Test that you can't connect to the load balancer port without being proxied.
Test that you can't connect to the load balancer port without being proxied.
Test that you can ' t connect to the load balancer port without being proxied .
function testProxyProtocolConnectFailure(lbPort, sendLoadBalanced) {
    'use strict';
    let st = new ShardingTest(
        {shards: 1, mongos: 1, mongosOptions: {setParameter: {"loadBalancerPort": lbPort}}});
    const hostName = st.s.host.substring(0, st.s.host.indexOf(":"));
    const uri = `mongodb://${hostName}:${lbPort}/?loadBalanced=${sendLoadBalanced}`;
    try {
        var conn = new Mongo(uri);
        assert(false, 'Client was unable to connect to the load balancer port');
    } catch (err) {
        assert(checkLog.checkContainsOnceJsonStringMatch(
                   st.s, 6067900, "msg", "Error while parsing proxy protocol header"),
               "Connection failed for some reason other than lacking a proxy protocol header");
    }
    st.stop();
}
function testProxyProtocolConnectFailure ( lbPort , sendLoadBalanced ) { 'use strict' ; let st = new ShardingTest ( { shards : 1 , mongos : 1 , mongosOptions : { setParameter : { "loadBalancerPort" : lbPort } } } ) ; const hostName = st . s . host . substring ( 0 , st . s . host . indexOf ( ":" ) ) ; const uri = ` ${ hostName } ${ lbPort } ${ sendLoadBalanced } ` ; try { var conn = new Mongo ( uri ) ; assert ( false , 'Client was unable to connect to the load balancer port' ) ; } catch ( err ) { assert ( checkLog . checkContainsOnceJsonStringMatch ( st . s , 6067900 , "msg" , "Error while parsing proxy protocol header" ) , "Connection failed for some reason other than lacking a proxy protocol header" ) ; } st . stop ( ) ; }
Test that you can't connect to the load balancer port without being proxied.
Test that you can ' t connect to the load balancer port without being proxied .