2019-02-04 14:13:59 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2019-02-06 14:32:32 +00:00
|
|
|
import { getIpList, getDnsAddress, getWebAddress } from '../../helpers/helpers';
|
2019-03-29 13:24:59 +00:00
|
|
|
import { ALL_INTERFACES_IP } from '../../helpers/constants';
|
2019-02-04 14:13:59 +00:00
|
|
|
|
2020-08-19 15:23:05 +00:00
|
|
|
const renderItem = ({
|
|
|
|
ip, port, isDns,
|
|
|
|
}) => {
|
|
|
|
const webAddress = getWebAddress(ip, port);
|
|
|
|
const dnsAddress = getDnsAddress(ip, port);
|
|
|
|
|
|
|
|
return <li key={ip}>{isDns
|
|
|
|
? <strong>{dnsAddress}</strong>
|
2020-12-08 15:47:47 +00:00
|
|
|
: <a href={webAddress} target="_blank" rel="noopener noreferrer">{webAddress}</a>
|
2019-02-04 14:13:59 +00:00
|
|
|
}
|
2020-08-19 15:23:05 +00:00
|
|
|
</li>;
|
2019-02-04 14:13:59 +00:00
|
|
|
};
|
|
|
|
|
2020-08-19 15:23:05 +00:00
|
|
|
const AddressList = ({
|
|
|
|
address,
|
|
|
|
interfaces,
|
|
|
|
port,
|
|
|
|
isDns,
|
|
|
|
}) => <ul className="list-group pl-4">{
|
|
|
|
address === ALL_INTERFACES_IP
|
|
|
|
? getIpList(interfaces)
|
|
|
|
.map((ip) => renderItem({
|
|
|
|
ip,
|
|
|
|
port,
|
|
|
|
isDns,
|
|
|
|
}))
|
|
|
|
: renderItem({
|
|
|
|
ip: address,
|
|
|
|
port,
|
|
|
|
isDns,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</ul>;
|
|
|
|
|
2019-02-04 14:13:59 +00:00
|
|
|
AddressList.propTypes = {
|
|
|
|
interfaces: PropTypes.object.isRequired,
|
|
|
|
address: PropTypes.string.isRequired,
|
|
|
|
port: PropTypes.oneOfType([
|
|
|
|
PropTypes.string,
|
|
|
|
PropTypes.number,
|
|
|
|
]),
|
|
|
|
isDns: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
2020-08-19 15:23:05 +00:00
|
|
|
renderItem.propTypes = {
|
|
|
|
ip: PropTypes.string.isRequired,
|
|
|
|
port: PropTypes.string.isRequired,
|
|
|
|
isDns: PropTypes.bool.isRequired,
|
|
|
|
};
|
|
|
|
|
2019-02-04 14:13:59 +00:00
|
|
|
export default AddressList;
|