Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f24ba9d3
Commit
f24ba9d3
authored
Apr 15, 2024
by
linxin
Committed by
Brad Davidson
May 24, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate resolv.conf for presence of nameserver entries
Co-authored-by:
Brad Davidson
<
brad@oatmail.org
>
Signed-off-by:
linxin
<
linxin@geedgenetworks.com
>
parent
2669d67a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
config.go
pkg/agent/config/config.go
+4
-1
No files found.
pkg/agent/config/config.go
View file @
f24ba9d3
...
@@ -316,19 +316,22 @@ func isValidResolvConf(resolvConfFile string) bool {
...
@@ -316,19 +316,22 @@ func isValidResolvConf(resolvConfFile string) bool {
nameserver
:=
regexp
.
MustCompile
(
`^nameserver\s+([^\s]*)`
)
nameserver
:=
regexp
.
MustCompile
(
`^nameserver\s+([^\s]*)`
)
scanner
:=
bufio
.
NewScanner
(
file
)
scanner
:=
bufio
.
NewScanner
(
file
)
foundNameserver
:=
false
for
scanner
.
Scan
()
{
for
scanner
.
Scan
()
{
ipMatch
:=
nameserver
.
FindStringSubmatch
(
scanner
.
Text
())
ipMatch
:=
nameserver
.
FindStringSubmatch
(
scanner
.
Text
())
if
len
(
ipMatch
)
==
2
{
if
len
(
ipMatch
)
==
2
{
ip
:=
net
.
ParseIP
(
ipMatch
[
1
])
ip
:=
net
.
ParseIP
(
ipMatch
[
1
])
if
ip
==
nil
||
!
ip
.
IsGlobalUnicast
()
{
if
ip
==
nil
||
!
ip
.
IsGlobalUnicast
()
{
return
false
return
false
}
else
{
foundNameserver
=
true
}
}
}
}
}
}
if
err
:=
scanner
.
Err
();
err
!=
nil
{
if
err
:=
scanner
.
Err
();
err
!=
nil
{
return
false
return
false
}
}
return
true
return
foundNameserver
}
}
func
locateOrGenerateResolvConf
(
envInfo
*
cmds
.
Agent
)
string
{
func
locateOrGenerateResolvConf
(
envInfo
*
cmds
.
Agent
)
string
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment