From aa4a0d9880316ed48d436f58398957e8c7cd2cd1 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Fri, 8 Jul 2022 15:17:47 +0300 Subject: [PATCH] cherry-pick: 4698 Gateway IP in DHCP Lease Closes #4698. Squashed commit of the following: commit 6be0caee58926f8cea1e10650fbde0c8d97d0dac Author: Ildar Kamalov Date: Fri Jul 8 13:41:50 2022 +0300 update translation commit e0370656d05e8463d73ea73568cae81187c6b2e3 Author: Ildar Kamalov Date: Fri Jul 8 13:40:54 2022 +0300 client: validate static lease ip commit 7f4d00f9f3a54dc93ce5d5c45e9c21745f6e39d1 Merge: 2ee79626 77e5e27d Author: Eugene Burkov Date: Fri Jul 8 13:20:15 2022 +0300 Merge branch 'master' into 4698-lease-with-gateway commit 2ee79626a1b0c7b113dbd22ba4ef6e85ea9913ec Merge: 471b96b8 3505ce87 Author: Eugene Burkov Date: Thu Jul 7 19:34:33 2022 +0300 Merge branch 'master' into 4698-lease-with-gateway commit 471b96b81da8920c1e71b7110050154f912677d2 Author: Eugene Burkov Date: Thu Jul 7 16:07:23 2022 +0300 dhcpd: imp docs commit 67dd6c76f7d2df4712a57281e0f40f2ee1a1efa2 Author: Eugene Burkov Date: Thu Jul 7 15:48:47 2022 +0300 dhcpd: restrict gateway ip for lease --- .../Settings/Dhcp/StaticLeases/Form.js | 3 + .../Settings/Dhcp/StaticLeases/Modal.js | 3 + .../Settings/Dhcp/StaticLeases/index.js | 3 + client/src/components/Settings/Dhcp/index.js | 1 + client/src/helpers/validators.js | 11 ++ internal/dhcpd/http.go | 1 - internal/dhcpd/v4.go | 12 +- internal/dhcpd/v4_test.go | 124 ++++++++++++------ 8 files changed, 116 insertions(+), 42 deletions(-) diff --git a/client/src/components/Settings/Dhcp/StaticLeases/Form.js b/client/src/components/Settings/Dhcp/StaticLeases/Form.js index 625e87e2..0525f6a3 100644 --- a/client/src/components/Settings/Dhcp/StaticLeases/Form.js +++ b/client/src/components/Settings/Dhcp/StaticLeases/Form.js @@ -10,6 +10,7 @@ import { validateMac, validateRequiredValue, validateIpv4InCidr, + validateIpGateway, } from '../../../../helpers/validators'; import { FORM_NAME } from '../../../../helpers/constants'; import { toggleLeaseModal } from '../../../../actions'; @@ -57,6 +58,7 @@ const Form = ({ validateRequiredValue, validateIpv4, validateIpv4InCidr, + validateIpGateway, ]} /> @@ -101,6 +103,7 @@ Form.propTypes = { ip: PropTypes.string.isRequired, hostname: PropTypes.string.isRequired, cidr: PropTypes.string.isRequired, + gatewayIp: PropTypes.string, }), pristine: PropTypes.bool.isRequired, handleSubmit: PropTypes.func.isRequired, diff --git a/client/src/components/Settings/Dhcp/StaticLeases/Modal.js b/client/src/components/Settings/Dhcp/StaticLeases/Modal.js index 8ad0f009..0baf487e 100644 --- a/client/src/components/Settings/Dhcp/StaticLeases/Modal.js +++ b/client/src/components/Settings/Dhcp/StaticLeases/Modal.js @@ -13,6 +13,7 @@ const Modal = ({ cidr, rangeStart, rangeEnd, + gatewayIp, }) => { const dispatch = useDispatch(); @@ -42,6 +43,7 @@ const Modal = ({ cidr, rangeStart, rangeEnd, + gatewayIp, }} onSubmit={handleSubmit} processingAdding={processingAdding} @@ -61,6 +63,7 @@ Modal.propTypes = { cidr: PropTypes.string.isRequired, rangeStart: PropTypes.string, rangeEnd: PropTypes.string, + gatewayIp: PropTypes.string, }; export default withTranslation()(Modal); diff --git a/client/src/components/Settings/Dhcp/StaticLeases/index.js b/client/src/components/Settings/Dhcp/StaticLeases/index.js index a63f78cd..2374f044 100644 --- a/client/src/components/Settings/Dhcp/StaticLeases/index.js +++ b/client/src/components/Settings/Dhcp/StaticLeases/index.js @@ -24,6 +24,7 @@ const StaticLeases = ({ cidr, rangeStart, rangeEnd, + gatewayIp, }) => { const [t] = useTranslation(); const dispatch = useDispatch(); @@ -106,6 +107,7 @@ const StaticLeases = ({ cidr={cidr} rangeStart={rangeStart} rangeEnd={rangeEnd} + gatewayIp={gatewayIp} /> ); @@ -119,6 +121,7 @@ StaticLeases.propTypes = { cidr: PropTypes.string.isRequired, rangeStart: PropTypes.string, rangeEnd: PropTypes.string, + gatewayIp: PropTypes.string, }; cellWrap.propTypes = { diff --git a/client/src/components/Settings/Dhcp/index.js b/client/src/components/Settings/Dhcp/index.js index a84e0a93..bd3a45e3 100644 --- a/client/src/components/Settings/Dhcp/index.js +++ b/client/src/components/Settings/Dhcp/index.js @@ -278,6 +278,7 @@ const Dhcp = () => { cidr={cidr} rangeStart={dhcp?.values?.v4?.range_start} rangeEnd={dhcp?.values?.v4?.range_end} + gatewayIp={dhcp?.values?.v4?.gateway_ip} />