From 13f408284964de4b9fc783b4f5683b9b0ccc000f Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Wed, 17 Aug 2022 11:40:31 +0700 Subject: [PATCH] Dockerfile --- Dockerfile | 13 +++++++++++++ Makefile | 32 ++++++++++++++++++++++++++++---- arpscan.go | 2 +- getconfig.go | 2 +- templates/index.html | 2 +- watchyourlan | Bin 0 -> 14399184 bytes 6 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 Dockerfile create mode 100755 watchyourlan 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 @@
57^Q1}QY1kzB`7* 6Nm@DQYJ0!ubo^6XgNPw<{RWm8@6R
z$0`Nn1%|&5LqvFt?C0Og@LZ;+iT6jE{)Dlf#9b=+T#5NWS9k8$%Im(yha_Gv;sX4@
zolJjIz`Xt#4T+xgo8-8hp%VYAY&WVW%6{*aV5N!aQ3B!#d0ix)243IkI|I62>dWv0
z5|3sNr!$>vd46en^*ZCpd`0q8o2SRQzN1dcw?SZ6l!MGqGw%yD`6g?8W`9QG=b#u#
zPyG{8?w>K9Mw5h_ZkC!npW)~6{7wH-!WS_-jQQpmCdUPLLR=p*{U+Y8Ss7l)e5ih1
z(*GF4H}kx(2H5S;{*s0b~~po#=@ylzfsffGDn|FEp$RC%tEw|H
|Bi+l}U-dZmr0RZs+2`vkL!3
zoa#KRI=5h&s{*&P`*cED_ico_J!N<#4Rl+|@M!wE5WSBYuDZJ+O*LBF;ltD1W|PGo
zg?nn81@JWYRI|n18}}R1E$$fHb7C?r?!kB{vRcqM&HbJO7%k3|oFiscCOsTUY`IW%
zcmF(+I7&Tq|MEN%=Ct9)#!G4O0m9C2qZI4+ZQz#bJb*fzP{;EFMnQ8GqDvVbOOge#
z3G|Z)+(`m=PgH(V2z%Oa6P~LWd0b;3i*q{wOHt@~nlL$cBb!5r?<4jAr%G}Jx|#Gd
z3pl;)iC)4v^b{%3wBcqv4`ZC^jr}cxx-Ka6Tq|&XiSqMNPWH=lHRBaqe4wl#ybFQ%
zUcy@~5PyDBBF;p^&pS&_Sc%y00C)$5o