Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nogweii
my-certificate-alert
Commits
23647655
Commit
23647655
authored
Aug 17, 2021
by
Nogweii
Browse files
run go fmt
parent
f3f3123a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/config.go
View file @
23647655
...
...
@@ -10,6 +10,7 @@ type Configuration struct {
}
var
configuration
Configuration
func
readConfig
()
{
configuration
.
DomainsListPath
=
requireEnvVar
(
"DOMAINS_LIST_PATH"
)
}
...
...
src/main.go
View file @
23647655
package
main
import
(
"strings"
"os"
"bufio"
"os"
"strings"
"github.com/CaliDog/certstream-go"
"github.com/gobwas/glob"
...
...
@@ -32,7 +32,7 @@ func main() {
any_glob_match
:=
false
for
_
,
domain
:=
range
all_domains
{
any_glob_match
=
any_glob_match
||
matchesDomains
(
domain
)
any_glob_match
=
any_glob_match
||
matchesDomains
(
domain
)
}
if
any_glob_match
{
...
...
@@ -54,22 +54,22 @@ func main() {
func
matchesDomains
(
domainName
string
)
bool
{
var
any_match
=
false
for
_
,
glob
:=
range
globs
{
any_match
=
glob
.
Match
(
domainName
)
||
any_match
}
for
_
,
glob
:=
range
globs
{
any_match
=
glob
.
Match
(
domainName
)
||
any_match
}
return
any_match
}
func
readDomainsFromFile
(
filepath
string
)
[]
glob
.
Glob
{
file
,
err
:=
os
.
Open
(
filepath
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
"error"
:
err
})
.
Fatal
(
"Failed to open file "
,
filepath
)
}
defer
file
.
Close
()
scanner
:=
bufio
.
NewScanner
(
file
)
for
scanner
.
Scan
()
{
}
defer
file
.
Close
()
scanner
:=
bufio
.
NewScanner
(
file
)
for
scanner
.
Scan
()
{
text
:=
scanner
.
Text
()
// TODO: skip blank and commented lines
myGlob
,
err
:=
glob
.
Compile
(
text
)
...
...
@@ -77,11 +77,11 @@ func readDomainsFromFile(filepath string) []glob.Glob {
log
.
WithFields
(
log
.
Fields
{
"error"
:
err
})
.
Fatal
(
"Invalid glob "
,
text
)
}
globs
=
append
(
globs
,
myGlob
)
}
if
err
:=
scanner
.
Err
();
err
!=
nil
{
}
if
err
:=
scanner
.
Err
();
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
"error"
:
err
})
.
Fatal
(
"Could not scan through file"
)
}
}
return
globs
}
Write
Preview
Supports
Markdown
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