From 6090400ea00f2ea4b97cac780ad54c271e466376 Mon Sep 17 00:00:00 2001
From: Simon Zolin <s.zolin@adguard.com>
Date: Mon, 10 Aug 2020 12:43:38 +0300
Subject: [PATCH] * GET /control/dhcp/interfaces: remove 'mtu'; add
 'gateway_ip'

---
 AGHTechDoc.md        | 2 +-
 dhcpd/dhcp_http.go   | 5 ++---
 openapi/openapi.yaml | 6 ++----
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/AGHTechDoc.md b/AGHTechDoc.md
index 76e1171c..8661e39c 100644
--- a/AGHTechDoc.md
+++ b/AGHTechDoc.md
@@ -442,10 +442,10 @@ Response:
 	{
 		"iface_name":{
 			"name":"iface_name",
-			"mtu":1500,
 			"hardware_address":"...",
 			"ipv4_addresses":["ipv4 addr", ...],
 			"ipv6_addresses":["ipv6 addr", ...],
+			"gateway_ip":"...",
 			"flags":"up|broadcast|multicast"
 		}
 		...
diff --git a/dhcpd/dhcp_http.go b/dhcpd/dhcp_http.go
index f85c00b4..34e833ec 100644
--- a/dhcpd/dhcp_http.go
+++ b/dhcpd/dhcp_http.go
@@ -200,7 +200,7 @@ func (s *Server) handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {
 
 type netInterfaceJSON struct {
 	Name         string   `json:"name"`
-	MTU          int      `json:"mtu"`
+	GatewayIP    string   `json:"gateway_ip"`
 	HardwareAddr string   `json:"hardware_address"`
 	Addrs4       []string `json:"ipv4_addresses"`
 	Addrs6       []string `json:"ipv6_addresses"`
@@ -233,7 +233,6 @@ func (s *Server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
 
 		jsonIface := netInterfaceJSON{
 			Name:         iface.Name,
-			MTU:          iface.MTU,
 			HardwareAddr: iface.HardwareAddr.String(),
 		}
 
@@ -259,9 +258,9 @@ func (s *Server) handleDHCPInterfaces(w http.ResponseWriter, r *http.Request) {
 			}
 		}
 		if len(jsonIface.Addrs4)+len(jsonIface.Addrs6) != 0 {
+			jsonIface.GatewayIP = getGatewayIP(iface.Name)
 			response[iface.Name] = jsonIface
 		}
-
 	}
 
 	err = json.NewEncoder(w).Encode(response)
diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml
index ef288f04..bd56fe7c 100644
--- a/openapi/openapi.yaml
+++ b/openapi/openapi.yaml
@@ -1619,10 +1619,6 @@ components:
                 hardware_address:
                     type: string
                     example: 52:54:00:11:09:ba
-                mtu:
-                    type: integer
-                    format: int32
-                    example: 1500
                 name:
                     type: string
                     example: eth0
@@ -1634,6 +1630,8 @@ components:
                     type: array
                     items:
                         type: string
+                gateway_ip:
+                    type: string
         AddressInfo:
             type: object
             description: Port information