From 65553a29e915fe0ee62f390c74fe505ec9581f6e Mon Sep 17 00:00:00 2001
From: Ainar Garipov <a.garipov@adguard.com>
Date: Tue, 6 Apr 2021 16:40:05 +0300
Subject: [PATCH] Pull request: dhcpd: do not overwrite dhcpv4 options

Updates #2927.

Squashed commit of the following:

commit b4b0f5928260a7ddada71521e5954eb326d61468
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Apr 6 16:31:01 2021 +0300

    dhcpd: do not overwrite dhcpv4 options
---
 CHANGELOG.md           | 2 ++
 internal/dhcpd/http.go | 1 +
 2 files changed, 3 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91219e09..4d1f9f32 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,7 @@ and this project adheres to
 
 ### Fixed
 
+- Overwriting of DHCPv4 options when using the HTTP API ([#2927]).
 - Assumption that MAC addresses always have the length of 6 octets ([#2828]).
 - Support for more than one `/24` subnet in DHCP ([#2541]).
 - Invalid filenames in the `mobileconfig` API responses ([#2835]).
@@ -60,6 +61,7 @@ and this project adheres to
 [#2828]: https://github.com/AdguardTeam/AdGuardHome/issues/2828
 [#2835]: https://github.com/AdguardTeam/AdGuardHome/issues/2835
 [#2838]: https://github.com/AdguardTeam/AdGuardHome/issues/2838
+[#2927]: https://github.com/AdguardTeam/AdGuardHome/issues/2927
 
 
 
diff --git a/internal/dhcpd/http.go b/internal/dhcpd/http.go
index 2fbf76c0..cf322997 100644
--- a/internal/dhcpd/http.go
+++ b/internal/dhcpd/http.go
@@ -178,6 +178,7 @@ func (s *Server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {
 		s.srv4.WriteDiskConfig4(&c4)
 		v4Conf.notify = c4.notify
 		v4Conf.ICMPTimeout = c4.ICMPTimeout
+		v4Conf.Options = c4.Options
 
 		s4, err = v4Create(v4Conf)
 		if err != nil {