diff --git a/assets/html/file-not-found.tplt b/assets/html/file-not-found.tplt
new file mode 100644
index 0000000..ccf7693
--- /dev/null
+++ b/assets/html/file-not-found.tplt
@@ -0,0 +1,40 @@
+
+
+
+
+ {{ .Title }}
+
+
+
+
+ {{ printf "%d" .ErrorCode }}
+
+
\ No newline at end of file
diff --git a/assets/html/human.txt b/assets/html/human.txt
new file mode 100644
index 0000000..b665466
--- /dev/null
+++ b/assets/html/human.txt
@@ -0,0 +1,16 @@
+/* TEAM */
+ Owner: Nicolaas Hyatt
+ Mastodon: https://mastodon.c.smoothnet.org/@nhyatt
+
+/* CREDIT */
+
+ Original Concept: Jan Schaumann
+ Twitter: https://twitter.com/jschauma
+ Site: https://istheinternetonfire.com
+
+/* SITE */
+ Last update: 2024-01-23
+ Language: English
+ Doctype: HTML5, GoLang
+ IDE: VSCodium
+ Source Code: https://gitea.smoothnet.org/nhyatt/istheinternetonfire
diff --git a/assets/html/site.txt.tplt b/assets/html/site.txt.tplt
new file mode 100644
index 0000000..f8436d9
--- /dev/null
+++ b/assets/html/site.txt.tplt
@@ -0,0 +1,10 @@
+Site: https://istheinternetonfire.app
+{{ if gt (len .CVEs) 0 }}
+Is the internet on fire: Yes!
+{{ range .CVEs }}
+{{ .CveID | ToUpper }} - {{ .Product }}
+ {{ .ShortDescription }}
+{{ end }}
+{{ else }}
+Is the internet on fire: No
+{{ end }}
\ No newline at end of file
diff --git a/assets/html/txt.tplt b/assets/html/txt.tplt
deleted file mode 100644
index a44a5b3..0000000
--- a/assets/html/txt.tplt
+++ /dev/null
@@ -1,3 +0,0 @@
-{{- range .CVEs }}
-{{ .CveID | ToUpper }} - {{ .Product }} - {{ .ShortDescription }}
-{{- end }}
\ No newline at end of file
diff --git a/internal/webserver/httpServer.go b/internal/webserver/httpServer.go
index 34d7909..dfd5f0c 100644
--- a/internal/webserver/httpServer.go
+++ b/internal/webserver/httpServer.go
@@ -38,6 +38,7 @@ var validFiles map[string]string = map[string]string{
"/favicon-16x16.png": TYPE_IMAGE_PNG,
"/favicon-32x32.png": TYPE_IMAGE_PNG,
"/favicon.ico": TYPE_IMAGE_PNG,
+ "/human.txt": TYPE_TEXT_PLAIN,
"/js/bootstrap.bundle.min.js.map": TYPE_APPLICATION_JSON,
"/js/bootstrap.bundle.min.js": TYPE_TEXT_JS,
"/js/jquery.min.js": TYPE_TEXT_JS,
@@ -140,7 +141,7 @@ func webJSON(w http.ResponseWriter, r *http.Request) {
cves := cisa.Read()
if len(cves.Vulnerabilities) == 0 {
- w.Write([]byte("{}"))
+ w.Write([]byte("{}")) //nolint:errcheck
return
} else if len(cves.Vulnerabilities) < 3 {
num = len(cves.Vulnerabilities)
@@ -150,7 +151,7 @@ func webJSON(w http.ResponseWriter, r *http.Request) {
config.Cfg.Log.Debug("unable to convert CVES to JSON", "error", err, "url", r.URL.Path)
}
- w.Write(output)
+ w.Write(output) //nolint:errcheck
}
func webTXT(w http.ResponseWriter, r *http.Request) {
@@ -159,4 +160,6 @@ func webTXT(w http.ResponseWriter, r *http.Request) {
tmpltError(w, http.StatusBadRequest, "Invalid http method.")
return
}
+
+ tmpltTXT(w)
}
diff --git a/internal/webserver/httpTemplate.go b/internal/webserver/httpTemplate.go
index f290175..4fa01b7 100644
--- a/internal/webserver/httpTemplate.go
+++ b/internal/webserver/httpTemplate.go
@@ -107,5 +107,45 @@ func tmpltStatusNotFound(w http.ResponseWriter, path string) {
}
func tmpltTXT(w http.ResponseWriter) {
+ tmplt, err := template.New("site.txt.tplt").Funcs(template.FuncMap{
+ "ToUpper": strings.ToUpper,
+ }).ParseFS(
+ assets.EmbedHTML,
+ "html/site.txt.tplt",
+ )
+ if err != nil {
+ config.Cfg.Log.Debug("unable to parse template", "error", err)
+ tmpltError(w, http.StatusInternalServerError, "Template Parse Error.")
+ return
+ }
+ var (
+ msgBuffer bytes.Buffer
+ cves []cisa.VulStruct
+ num int = 3
+ )
+
+ c := cisa.Read()
+ for _, i := range c.Vulnerabilities {
+ t, _ := time.Parse("2006-01-02", i.DateAdded)
+ if t.After(time.Now().Add(-time.Hour * 720)) {
+ cves = append(cves, i)
+ }
+ }
+
+ if len(cves) < 3 {
+ num = len(cves)
+ }
+
+ if err := tmplt.Execute(&msgBuffer, struct {
+ CVEs []cisa.VulStruct
+ }{
+ CVEs: cves[len(cves)-num:],
+ }); err != nil {
+ config.Cfg.Log.Debug("unable to execute html template", err)
+ tmpltError(w, http.StatusInternalServerError, "Template Parse Error.")
+ return
+ }
+
+ w.Write(msgBuffer.Bytes()) //nolint:errcheck
}
diff --git a/main.go b/main.go
index 602cd6d..374310f 100644
--- a/main.go
+++ b/main.go
@@ -58,7 +58,7 @@ func main() {
if len(cves) == 0 {
if err := dns.UpdateTXT("istheinternetonfire.app", "TXT", "Safe for now!"); err != nil {
config.Cfg.Log.Error("unable to update dns record", "error", err)
- time.Sleep(time.Second * time.Duration(config.Cfg.RefreshSeconds))
+ time.Sleep(time.Second * time.Duration(5*60))
continue
}
} else if len(cves) < 3 {
@@ -71,7 +71,7 @@ func main() {
}
if err := dns.UpdateTXT("istheinternetonfire.app", "TXT", txtData); err != nil {
config.Cfg.Log.Error("unable to update dns record", "error", err)
- time.Sleep(time.Second * time.Duration(config.Cfg.RefreshSeconds))
+ time.Sleep(time.Second * time.Duration(5*60))
continue
}