"use strict";constexeca=require("execa");constdb2util="/QOpenSys/pkgs/bin/db2util";constsql="select NEXT_HOP, LOCAL_BINDING_INTERFACE from QSYS2.NETSTAT_ROUTE_INFO where ROUTE_TYPE='DFTROUTE' and NEXT_HOP!='*DIRECT' and CONNECTION_TYPE=?";constparse=stdout=>{letresult;try{constresultObj=JSON.parse(stdout);constgateway=resultObj.records[0].NEXT_HOP;constiface=resultObj.records[0].LOCAL_BINDING_INTERFACE;result={gateway,iface};}catch(err){}if(!result){thrownewError("Unable to determine default gateway");}returnresult;};constpromise=family=>{returnexeca.stdout(db2util,[sql,"-p",family,"-o","json"]).then(stdout=>parse(stdout));};constsync=family=>{const{stdout}=execa.sync(db2util,[sql,"-p",family,"-o","json"]);returnparse(stdout);};module.exports.v4=()=>promise("IPV4");module.exports.v6=()=>promise("IPV6");module.exports.v4.sync=()=>sync("IPV4");module.exports.v6.sync=()=>sync("IPV6");