diff --git a/internal/web/public/box.svg b/internal/web/public/box.svg deleted file mode 100644 index a9d9224..0000000 --- a/internal/web/public/box.svg +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/internal/web/public/css/index.css b/internal/web/public/css/index.css deleted file mode 100644 index 0660a2d..0000000 --- a/internal/web/public/css/index.css +++ /dev/null @@ -1,30 +0,0 @@ -/* Sort button */ -.my-btn { - height: 100%; - background-color: #00000000; - color: var(--bs-primary); - text-align: center; -} -.my-btn:hover { - background-color: #0000001a; -} - -/* History box */ -.my-box-on::before, .my-box-off::before { - content: url(/fs/public/box.svg); - border-left: thin solid black; -} -.my-box-on { - background-color: var(--bs-success); -} -.my-box-off { - background-color: var(--bs-gray-500); -} -.my-box-on:hover, .my-box-off:hover { - background-color: #0000001a; -} - - -.hidden { - display: none; -} \ No newline at end of file diff --git a/internal/web/public/js/filter-search.js b/internal/web/public/js/filter-search.js deleted file mode 100644 index 7287df7..0000000 --- a/internal/web/public/js/filter-search.js +++ /dev/null @@ -1,68 +0,0 @@ -let oldFilter = ''; -let bkpArray; - -function filterFunc(field, value) { - - if (oldFilter == field) { - addrsArray = bkpArray; - } - - switch (field) { - case 'iface': - addrsArray = addrsArray.filter((item) => item.Iface == value); - break; - case 'known': - addrsArray = addrsArray.filter((item) => item.Known == value); - break; - case 'line': - addrsArray = addrsArray.filter((item) => item.Now == value); - break; - default: - console.log("Filter error"); - } - - oldFilter = field; - - displayArrayData(addrsArray); -} - -function resetFilter() { - addrsArray = bkpArray; - displayArrayData(addrsArray); -} - -function searchFunc() { - const s = document.getElementById('search').value; - - if (s != "") { - - const sl = s.toLowerCase(); - - let newArray = []; - - for (let item of addrsArray) { - - if (searchItem(item, sl)) { - newArray.push(item); - } - } - addrsArray = newArray; - } else { - addrsArray = bkpArray; - } - - displayArrayData(addrsArray); -} - -function searchItem(item, sl) { - - const name = item.Name.toLowerCase(); - const hw = item.Hw.toLowerCase(); - const mac = item.Mac.toLowerCase(); - - if ((name.includes(sl)) || (item.Iface.includes(sl)) || (item.IP.includes(sl)) || (mac.includes(sl)) || (hw.includes(sl)) || (item.Date.includes(sl))) { - return true; - } else { - return false; - } -} \ No newline at end of file diff --git a/internal/web/public/js/hist-html.js b/internal/web/public/js/hist-html.js deleted file mode 100644 index c0d7313..0000000 --- a/internal/web/public/js/hist-html.js +++ /dev/null @@ -1,24 +0,0 @@ - -function getHistHTML(hist) { - - let html = '', col, title; - - for (let h of hist) { - if (h.Now != 0) { - col = `my-box-on`; - } else { - col = `my-box-off`; - } - title = `title="Date: ${h.Date}\nIface: ${h.Iface}\nIP: ${h.IP}\nKnown: ${h.Known}"`; - - html = html + ``; - } - return html; -} - -function sortHistByDate(hist) { - - hist.sort((a, b) => (a.Date < b.Date ? 1 : -1)); - - return hist; -} \ No newline at end of file diff --git a/internal/web/public/js/history.js b/internal/web/public/js/history.js deleted file mode 100644 index 8599705..0000000 --- a/internal/web/public/js/history.js +++ /dev/null @@ -1,66 +0,0 @@ -let show = 500; -let addrsArray; - -loadAddrs(); - -async function loadAddrs() { - - const n = localStorage.getItem("histShow"); - if (n != null) { - show = n; - } - - const url = '/api/all'; - addrsArray = await (await fetch(url)).json(); - - loadHistory(); -} - -async function loadHistory() { - - let tr, td, url, hist; - let i = 0; - - document.getElementById('showHist').innerHTML = ''; - - for (let a of addrsArray) { - url = '/api/history/'+a.Mac; - hist = await (await fetch(url)).json(); - - if (hist != null) { - hist = sortHistByDate(hist); - - if (show > 0) { - hist = hist.slice(0, show); - } - - td = getHistHTML(hist); // hist-html.js - } - - i = i + 1; - - tr = ` - - ${i}. - -

${a.Name}

-

${a.IP}

-

${a.Mac}

- - ${td} - `; - - document.getElementById('showHist').insertAdjacentHTML('beforeend', tr); - } -} - -function showHist(n) { - show = n; - localStorage.setItem("histShow", show); - loadHistory(); -} - -function manualShow() { - const n = document.getElementById('man-show').value; - showHist(n); -} diff --git a/internal/web/public/js/host-scan.js b/internal/web/public/js/host-scan.js deleted file mode 100644 index 0b39027..0000000 --- a/internal/web/public/js/host-scan.js +++ /dev/null @@ -1,54 +0,0 @@ -let stop = false; - -function stopScan() { - stop = true; -} - -async function scanAddr() { - const addr = document.getElementById("hostIP").value; - let begin = document.getElementById("begin").value; - let end = document.getElementById("end").value; - - document.getElementById('foundPorts').innerHTML = ""; - - if (begin == "") { - begin = 1 - } - if (end == "") { - end = 65535 - } - let portOpen = false; - stop = false; - found = 0; - - document.getElementById('stopBtn').style.visibility = "visible"; - - for (let i = begin ; i <= end; i++) { - - if (stop) { - break; - } - if (found > 9) { - found = 0; - document.getElementById('foundPorts').insertAdjacentHTML('beforeend', '
'); - } - - let url = '/api/port/'+addr+'/'+i; - portOpen = await (await fetch(url)).json(); - - document.getElementById("curPort").innerHTML = "Scanning port "+i; - - if (portOpen) { - found = found + 1; - let html = genHTML(addr, i); - document.getElementById('foundPorts').insertAdjacentHTML('beforeend', html); - } - } - - document.getElementById('stopBtn').style.visibility = "hidden"; -} - -function genHTML(addr, port) { - html = `${port}   `; - return html; -} diff --git a/internal/web/public/js/host.js b/internal/web/public/js/host.js deleted file mode 100644 index 560ac71..0000000 --- a/internal/web/public/js/host.js +++ /dev/null @@ -1,47 +0,0 @@ -let show = 500; -let mac; - -async function delHost(id) { - - const url = '/api/host/del/'+id; - - await fetch(url); - - window.location.href = '/'; -} - -async function loadHistory(m) { - - const n = localStorage.getItem("hostShow"); - if (n != null) { - show = n; - } - - mac = m; - const url = '/api/history/'+mac; - - let hist = await (await fetch(url)).json(); - hist = sortHistByDate(hist); - if (show > 0) { - hist = hist.slice(0, show); - } - - // console.log("HIST", hist); - displayHistory(hist); -} - -function displayHistory(hist) { - - document.getElementById('showHist').innerHTML = getHistHTML(hist); // hist-html.js -} - -function showHist(n) { - show = n; - localStorage.setItem("hostShow", show); - loadHistory(mac); -} - -function manualShow() { - const n = document.getElementById('man-show').value; - showHist(n); -} \ No newline at end of file diff --git a/internal/web/public/js/index.js b/internal/web/public/js/index.js deleted file mode 100644 index 09f3fed..0000000 --- a/internal/web/public/js/index.js +++ /dev/null @@ -1,98 +0,0 @@ -let addrsArray = {}; -let edit = "0"; - -loadAddrs(); - -function createHTML(addr, i) { - let now = ``; - if (addr.Now == 1) { - now = ``; - } - - let known = ''; - if (addr.Known == 1) { - known = `checked`; - } - - // Needs option to use value in js - let name = `${addr.Name}`; - if (edit == 1) { - name = ``; - } - - let html = ` - - ${i}. - ${name} - ${addr.Iface} - - ${addr.IP} - - ${addr.Mac} - ${addr.Hw} - ${addr.Date} - -
- -
- - ${now} - - `; - - return html; -} - -async function loadAddrs() { - - const url = '/api/all'; - addrsArray = await (await fetch(url)).json(); - bkpArray = addrsArray; - - field = localStorage.getItem("sortField"); - down = JSON.parse(localStorage.getItem("sortDown")); - - checkNotEmpty(addrsArray); -} - -function sortBy(f) { - field = f; - if (field != oldField) { - oldField = field; - down = !down; - } else { - oldField = ''; - down = !down; - } - - localStorage.setItem("sortDown", down); - localStorage.setItem("sortField", field); - checkNotEmpty(addrsArray); -} - -function editClick() { - - edit = 1 - edit; - loadAddrs(); -} - -function checkNotEmpty(someArray) { - - if (someArray.length > 0) { - if ((field != null) && (down != null)) { - sortByAny(someArray); - } else { - displayArrayData(someArray); - } - } -} - -async function editForm(id, known) { - - const name = document.getElementById("name"+id).value; - const url = '/api/edit/'+id+'/'+name+'/'+known; - - // console.log(url); - - await fetch(url); -} diff --git a/internal/web/public/js/notify.js b/internal/web/public/js/notify.js deleted file mode 100644 index b3c7291..0000000 --- a/internal/web/public/js/notify.js +++ /dev/null @@ -1,5 +0,0 @@ -async function testNotifications() { - - const url = '/api/notify_test'; - await fetch(url); -} diff --git a/internal/web/public/js/refresh.js b/internal/web/public/js/refresh.js deleted file mode 100644 index ca55455..0000000 --- a/internal/web/public/js/refresh.js +++ /dev/null @@ -1,26 +0,0 @@ -let ref = false; -let refInterval; - -autoRefresh(); - -function toggleRefresh() { - ref = !ref; - - localStorage.setItem("refAuto", ref); - - autoRefresh(); -} - -function autoRefresh() { - - ref = JSON.parse(localStorage.getItem("refAuto")); - document.getElementById("ref").checked = ref; - - if (ref) { - const timeout = document.getElementById("ref-timeout").value; - console.log("Refresh timeout", timeout); - refInterval = setInterval(loadAddrs, timeout * 1000); - } else { - clearInterval(refInterval); - } -} \ No newline at end of file diff --git a/internal/web/public/js/sort.js b/internal/web/public/js/sort.js deleted file mode 100644 index 9354569..0000000 --- a/internal/web/public/js/sort.js +++ /dev/null @@ -1,47 +0,0 @@ -let oldField = ''; -let field = ''; -let down = false; - -function displayArrayData(someArray) { - document.getElementById('tBody').innerHTML = ""; - - let i = 0; - for (let item of someArray){ - i = i + 1; - html = createHTML(item, i); - document.getElementById('tBody').insertAdjacentHTML('beforeend', html); - } -} - -function sortByAny(someArray) { - - if (field == 'IP') { - someArray.sort((a, b) => sortIP(a, b, down)); - } else { - someArray.sort((a, b) => byField(a, b, field, down)); - } - - displayArrayData(someArray); -} - -function byField(a, b, fieldName, down){ - if (a[fieldName] > b[fieldName]) { - return down ? 1 : -1; - } else { - return !down ? 1 : -1; - } -} - -function sortIP(a, b, down) { - const num1 = numIP(a); - const num2 = numIP(b); - if (down) { - return num1-num2; - } else { - return num2-num1; - } -} - -function numIP(a) { - return Number(a.IP.split(".").map((num) => (`000${num}`).slice(-3) ).join("")); -} \ No newline at end of file diff --git a/internal/web/templates/config.html b/internal/web/templates/config.html deleted file mode 100644 index b32631e..0000000 --- a/internal/web/templates/config.html +++ /dev/null @@ -1,233 +0,0 @@ -{{ define "config.html" }} - - -
-
-
-
-
Basic config
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Host
Port
Theme
Color mode
Local node-bootstrap URL
Shoutrrr URL - -
-
-
- -
-
Scan settings
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Interfaces
Timeout (seconds)
Args for arp-scan
Arp Strings{{ range .Config.ArpStrs }} - {{ end }} - -
Log level
Trim History (hours)
Store History in DB -
- {{ if .Config.HistInDB }} - - {{ else }} - - {{ end }} -
-
Use DB
PG Connect URL - -
-
-
-
- -
-
-
InfluxDB2 config
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Enable -
- {{ if .Config.InfluxEnable }} - - {{ else }} - - {{ end }} -
-
Address
Token
Org
Bucket
Skip TLS verify -
- {{ if .Config.InfluxSkipTLS }} - - {{ else }} - - {{ end }} -
-
-
-
- -
-
-
Prometheus config
-
- - - - - - - - - - - -
Enable -
- {{ if .Config.PrometheusEnable }} - - {{ else }} - - {{ end }} -
-
-
-
- -
-
- About (v{{ .Version }}) -
-
-

● After changing Host or Port the app must be restarted

-

Shoutrrr URL provides notifications to Discord, Email, Gotify, Telegram and other services. Link to documentation

-

Interfaces - one or more, space separated

-

Timeout (seconds) - time between scans

-

Args for arp-scan - pass your own arguments to arp-scan. Enable debug log level to see resulting command. (Example: -r 1). See docs for more.

-

Arp Strings - can setup scans for vlans, docker0 and etcetera. See docs for more.

-

Trim History - remove history after (hours)

-

Store History in DB - if off, the History will be stored only in memory and will be lost on app restart. Though, it will keep the app DB smaller and InfluxDB is recommended for long term History storage

-

PG Connect URL - address to connect to PostgreSQL DB. (Example: postgres://username:password@192.168.0.1:5432/dbname?sslmode=disable). Full list of URL parameters here

-

● If you find this app useful, please, donate

-

● Commission you own app (Golang, HTML/JS, Flutter). Contact here

-
-
-
-
-
- - -{{ template "footer.html" }} -{{ end }} diff --git a/internal/web/templates/footer.html b/internal/web/templates/footer.html deleted file mode 100644 index ff9a2d2..0000000 --- a/internal/web/templates/footer.html +++ /dev/null @@ -1,4 +0,0 @@ -{{ define "footer.html"}} - - -{{ end }} \ No newline at end of file diff --git a/internal/web/templates/header.html b/internal/web/templates/header.html deleted file mode 100644 index ae1ee75..0000000 --- a/internal/web/templates/header.html +++ /dev/null @@ -1,57 +0,0 @@ -{{ define "header.html"}} - - - - - WatchYourLAN - - - - - {{ if eq .Config.NodePath "" }} - - - - - - - {{ else }} - - - - {{ end }} - - - -{{ end }} \ No newline at end of file diff --git a/internal/web/templates/history.html b/internal/web/templates/history.html deleted file mode 100644 index cb9ec09..0000000 --- a/internal/web/templates/history.html +++ /dev/null @@ -1,40 +0,0 @@ -{{ define "history.html" }} - - -
-
-
-
-
-
- - - -
-
-
- - - - - - - - -
HostHistory
-
-
-
-
-
- - - -{{ template "footer.html" }} -{{ end }} \ No newline at end of file diff --git a/internal/web/templates/host.html b/internal/web/templates/host.html deleted file mode 100644 index 6b7b291..0000000 --- a/internal/web/templates/host.html +++ /dev/null @@ -1,120 +0,0 @@ -{{ define "host.html" }} - - -
-
-
-
-
Host
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ID{{ .Host.ID }}
Name{{ .Host.Name }}
DNS name{{ .Host.DNS }}
Iface{{ .Host.Iface }}
IP{{ .Host.IP }}
MAC{{ .Host.Mac }}
Hardware{{ .Host.Hw }}
Date{{ .Host.Date }}
Known{{ if eq .Host.Known 1 }}Yes{{ else }}No{{ end }}
Online{{ if eq .Host.Now 0 }} - - {{ else }} - - {{ end }} -
- -
-
-
-
- -
-
-
Port scan
-
-
- - - - - -
- -
- -
-
-
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
-
-
-
- - - - - -{{ template "footer.html" }} -{{ end }} diff --git a/internal/web/templates/old_index.html b/internal/web/templates/old_index.html deleted file mode 100644 index 440c56f..0000000 --- a/internal/web/templates/old_index.html +++ /dev/null @@ -1,73 +0,0 @@ -{{ define "oldindex.html" }} - - -
-
-
-
- - -
-
-
-
-
-
-
-
-
- - - - - - - - -
-
-
- - -
-
-
-
-
- - - - - - - - - - - - - - -
Name Iface IP MAC Hardware Date Known Online
-
-
-
-
-
- - - - - -{{ template "footer.html" }} -{{ end }} \ No newline at end of file