cmd/ctrld: optimizing set/reset DNS

Currently, when reset DNS, ctrld always find the net.Interface by
interface name. This may produce unexpected error because the interface
table may be cleared at the time ctrld is being stopped.

Instead, we can get the net interface only once, and use that interface
for restoring the DNS before shutting down.

While at it, also making logging message clearer.
This commit is contained in:
Cuong Manh Le
2023-01-24 13:55:43 +07:00
committed by Cuong Manh Le
parent b0dc96aa01
commit c82a0e2562
4 changed files with 66 additions and 39 deletions
+2
View File
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"io"
"net"
"os"
"path/filepath"
"time"
@@ -35,6 +36,7 @@ var (
cdUID string
iface string
netIface *net.Interface
ifaceStartStop string
)