diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 9926bc7..9ec6629 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -3,14 +3,14 @@ name: Docker on: push: branches: [ "main" ] - paths-ignore: - - '**.md' - - 'Makefile' + paths: + - 'Dockerfile' + - 'scr/**' pull_request: branches: [ "main" ] - paths-ignore: - - '**.md' - - 'Makefile' + paths: + - 'Dockerfile' + - 'scr/**' env: IMAGE_NAME: watchyourlan diff --git a/Dockerfile b/Dockerfile index 83521bd..be29126 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,12 @@ RUN cd /src && go build . FROM alpine +WORKDIR /app + RUN apk add --no-cache tzdata arp-scan \ && mkdir /data COPY src/templates /app/templates COPY --from=builder /src/watchyourlan /app/ -WORKDIR /app - ENTRYPOINT ["./watchyourlan"] \ No newline at end of file diff --git a/src/db-connect.go b/src/db-connect.go index 86ae5b3..5734a13 100644 --- a/src/db-connect.go +++ b/src/db-connect.go @@ -21,7 +21,7 @@ func db_select() (dbHosts []Host) { db, _ := sql.Open("sqlite3", AppConfig.DbPath) defer db.Close() - sqlStatement := `SELECT * FROM "now"` + sqlStatement := `SELECT * FROM "now" ORDER BY DATE DESC` res, err := db.Query(sqlStatement) if err != nil { diff --git a/src/index.go b/src/index.go index fe7c71d..7935bd8 100644 --- a/src/index.go +++ b/src/index.go @@ -8,9 +8,16 @@ import ( ) func index(w http.ResponseWriter, r *http.Request) { - //fmt.Println(AllHosts) + type allData struct { + Config Conf + Hosts []Host + } + var guiData allData + guiData.Config = AppConfig + guiData.Hosts = AllHosts + tmpl, _ := template.ParseFiles("templates/index.html", "templates/header.html") - tmpl.ExecuteTemplate(w, "index", AllHosts) + tmpl.ExecuteTemplate(w, "index", guiData) } func update_host(w http.ResponseWriter, r *http.Request) { diff --git a/src/templates/header.html b/src/templates/header.html index c5ee0c3..b064b45 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -4,7 +4,7 @@ Watch Your LAN - + diff --git a/src/templates/index.html b/src/templates/index.html index 38b4dbd..ce0b442 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -5,6 +5,7 @@

Online

+

Scanning interface: {{ .Config.Iface }}

@@ -13,7 +14,7 @@ - {{ range . }} + {{ range .Hosts }} {{ if eq .Now 1 }} @@ -41,7 +42,7 @@ - {{ range . }} + {{ range .Hosts }}
NameHardware Known
{{ .Name }}Last seen Known