@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
41 lines • 1.86 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAddressObject = exports.getProtocolVersionLabel = exports.getShownProtocolVersions = exports.showProtocolVersion = exports.showIpv6 = exports.showIpv4 = void 0;
const ip_address_1 = require("ip-address");
const dataTypes_1 = require("./dataTypes");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const showIpv4 = (protocolType) => {
//always true untill we allow only ipv6
return true;
};
exports.showIpv4 = showIpv4;
const showIpv6 = (protocolType) => {
return protocolType === 'dualStack';
};
exports.showIpv6 = showIpv6;
const showProtocolVersion = (protocolType, protocolVersion) => {
if (protocolVersion === dataTypes_1.ProtocolVersion.ipv4) {
return (0, exports.showIpv4)(protocolType);
}
return (0, exports.showIpv6)(protocolType);
};
exports.showProtocolVersion = showProtocolVersion;
const getShownProtocolVersions = (protocolType) => {
return protocolType === 'dualStack'
? [dataTypes_1.ProtocolVersion.ipv4, dataTypes_1.ProtocolVersion.ipv6]
: [dataTypes_1.ProtocolVersion.ipv4];
};
exports.getShownProtocolVersions = getShownProtocolVersions;
const getProtocolVersionLabel = (protocolVersion) => protocolVersion === dataTypes_1.ProtocolVersion.ipv4 ? 'IPv4' : 'IPv6';
exports.getProtocolVersionLabel = getProtocolVersionLabel;
const getAddressObject = (ip, protocolVersion) => {
if (protocolVersion === dataTypes_1.ProtocolVersion.ipv4 && ip_address_1.Address4.isValid(ip)) {
return new ip_address_1.Address4(ip);
}
if (protocolVersion === dataTypes_1.ProtocolVersion.ipv6 && ip_address_1.Address6.isValid(ip)) {
return new ip_address_1.Address6(ip);
}
return null;
};
exports.getAddressObject = getAddressObject;
//# sourceMappingURL=protocolVersion.js.map
;