docker alpine
This commit is contained in:
parent
21fafce4a8
commit
48d385e230
7 changed files with 50 additions and 16 deletions
13
Dockerfile
13
Dockerfile
|
|
@ -1,10 +1,17 @@
|
|||
FROM ubuntu:20.04
|
||||
FROM golang:alpine AS builder
|
||||
|
||||
RUN apt update && apt install -y arp-scan && apt clean \
|
||||
RUN apk add build-base
|
||||
COPY src /src
|
||||
RUN cd /src && go build .
|
||||
|
||||
|
||||
FROM alpine
|
||||
|
||||
RUN apk add arp-scan \
|
||||
&& mkdir /data
|
||||
|
||||
COPY src/templates /app/templates
|
||||
COPY src/watchyourlan /app/
|
||||
COPY --from=builder /src/watchyourlan /app/
|
||||
|
||||
EXPOSE 8840
|
||||
|
||||
|
|
|
|||
13
Dockerfile.ubuntu
Normal file
13
Dockerfile.ubuntu
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
FROM ubuntu:20.04
|
||||
|
||||
RUN apt update && apt install -y arp-scan && apt clean \
|
||||
&& mkdir /data
|
||||
|
||||
COPY src/templates /app/templates
|
||||
COPY src/watchyourlan /app/
|
||||
|
||||
EXPOSE 8840
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT ["./watchyourlan"]
|
||||
2
Makefile
2
Makefile
|
|
@ -1,7 +1,7 @@
|
|||
DUSER=aceberg
|
||||
DNAME=watchyourlan
|
||||
|
||||
VERSION=0.4
|
||||
VERSION=0.5
|
||||
|
||||
mod:
|
||||
cd src && \
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ func host_in_db(host Host, dbHosts []Host) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func db_compare(foundHosts []Host, dbHosts []Host) {
|
||||
func hosts_compare(foundHosts []Host, dbHosts []Host) {
|
||||
// fmt.Println("Found hosts:", foundHosts)
|
||||
// fmt.Println("DB hosts:", dbHosts)
|
||||
|
||||
|
|
@ -10,6 +10,7 @@ func get_config(path string) (config Conf) {
|
|||
viper.SetDefault("DBPATH", "/data/db.sqlite")
|
||||
viper.SetDefault("GUIIP", "localhost")
|
||||
viper.SetDefault("GUIPORT", "8840")
|
||||
viper.SetDefault("TIMEOUT", "60")
|
||||
|
||||
viper.SetConfigFile(path)
|
||||
viper.SetConfigType("env")
|
||||
|
|
@ -21,6 +22,7 @@ func get_config(path string) (config Conf) {
|
|||
config.DbPath = viper.Get("DBPATH").(string)
|
||||
config.GuiIP = viper.Get("GUIIP").(string)
|
||||
config.GuiPort = viper.Get("GUIPORT").(string)
|
||||
config.Timeout = viper.GetInt("TIMEOUT")
|
||||
|
||||
// fmt.Println(viper.Get("DBPATH"))
|
||||
|
||||
|
|
|
|||
32
src/main.go
32
src/main.go
|
|
@ -1,8 +1,9 @@
|
|||
package main
|
||||
|
||||
// import (
|
||||
// "fmt"
|
||||
// )
|
||||
import (
|
||||
// "fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Host struct {
|
||||
Id uint16
|
||||
|
|
@ -20,21 +21,32 @@ type Conf struct {
|
|||
DbPath string
|
||||
GuiIP string
|
||||
GuiPort string
|
||||
Timeout int
|
||||
}
|
||||
|
||||
var AppConfig Conf
|
||||
var AllHosts []Host
|
||||
|
||||
func scan() {
|
||||
for {
|
||||
foundHosts := parse_output(scan_iface(AppConfig.Iface))
|
||||
dbHosts := db_select()
|
||||
db_setnow()
|
||||
hosts_compare(foundHosts, dbHosts)
|
||||
|
||||
AllHosts = db_select()
|
||||
// fmt.Println("Refresh")
|
||||
time.Sleep(time.Duration(AppConfig.Timeout) * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
AllHosts = []Host{}
|
||||
AppConfig = get_config("./data/config")
|
||||
db_create()
|
||||
|
||||
foundHosts := parse_output(scan_iface(AppConfig.Iface))
|
||||
dbHosts := db_select()
|
||||
db_setnow()
|
||||
db_compare(foundHosts, dbHosts)
|
||||
|
||||
AllHosts = db_select()
|
||||
|
||||
// fmt.Println("Timeout: ", AppConfig.Timeout)
|
||||
go scan()
|
||||
|
||||
webgui()
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
<title>Watch Your LAN</title>
|
||||
<meta charset="utf-8">
|
||||
<!--Auto refresh (seconds)-->
|
||||
<!-- <meta http-equiv="refresh" content="10"> -->
|
||||
<!-- <meta http-equiv="refresh" content="60"> -->
|
||||
<!--Favicon-->
|
||||
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/6k7AP+uSQD/z50A7urjAD85MgAAOO8AWlpaAADIawAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADEREQAAAAAzEREREQAAAzEREREREAAzFxEREVERADN3d3VVVREDM3d3dYVlERMzd3d1VVUREzM3ERESERETMzcRESERERMzNxESMREREzM3ESNEQREwMzcSMxEREwAzNyM0REQzAAMzMzMzMzAAADMzMzMzAAAAADMzMwAAD4HwAA4AcAAMADAACAAQAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIABAACAAQAAwAMAAOAHAAD4HwAA" rel="icon" type="image/x-icon" />
|
||||
<!--Bootstrap theme-->
|
||||
|
|
|
|||
Loading…
Reference in a new issue