diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e04a76e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM ubuntu:20.04 + +RUN apt update && apt install -y arp-scan && apt clean \ + && mkdir /data + +COPY templates /app/templates +COPY watchyourlan /app/ + +EXPOSE 8840 + +WORKDIR /app + +ENTRYPOINT ["./watchyourlan"] \ No newline at end of file diff --git a/Makefile b/Makefile index 84ca203..8f4bfea 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,32 @@ +DUSER=aceberg +DNAME=watchyourlan +DPORT=8840 +VERSION=0.4 + mod: rm go.mod - go mod init watchyourlan + go mod init $(DNAME) go mod tidy + run: - go run . -build: - go build . \ No newline at end of file + sudo go run . + +go-build: + go build . + +docker-build: + docker build -t $(DUSER)/$(DNAME):latest -t $(DUSER)/$(DNAME):$(VERSION) . + +docker-run: + docker rm wyl || true + docker run --name wyl \ + -e "IFACE=virbr-bw" \ + --network="host" \ + -v ~/.dockerdata/wyl:/data \ + $(DUSER)/$(DNAME):$(VERSION) + +clean: + rm $(DNAME) || true + docker rmi -f $(DUSER)/$(DNAME):latest $(DUSER)/$(DNAME):$(VERSION) + +dev: go-build docker-build docker-run \ No newline at end of file diff --git a/arpscan.go b/arpscan.go index b0fbeea..0e07311 100644 --- a/arpscan.go +++ b/arpscan.go @@ -9,7 +9,7 @@ import ( ) func scan_iface(iface string) (string) { - cmd, err := exec.Command("sudo", "arp-scan", "-l", "-N", "-x", "-I", iface).Output() + cmd, err := exec.Command("arp-scan", "-glNx", "-I", iface).Output() if err != nil { log.Fatal(err) } diff --git a/getconfig.go b/getconfig.go index d705aee..bf1a392 100644 --- a/getconfig.go +++ b/getconfig.go @@ -7,7 +7,7 @@ import ( func get_config(path string) (config Conf) { viper.SetDefault("IFACE", "eth0") - viper.SetDefault("DBPATH", "data/db.sqlite") + viper.SetDefault("DBPATH", "/data/db.sqlite") viper.SetDefault("GUIIP", "localhost") viper.SetDefault("GUIPORT", "8840") diff --git a/templates/index.html b/templates/index.html index d7d5038..de52e2d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -30,7 +30,7 @@ Ip Mac Hardware - Date + Last seen Known {{ range . }} diff --git a/watchyourlan b/watchyourlan new file mode 100755 index 0000000..eccfc7f Binary files /dev/null and b/watchyourlan differ