forked from aceberg/WatchYourLAN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/25 :: Added basic auth to webUI
- Loading branch information
1 parent
0c49949
commit 5f99309
Showing
4 changed files
with
77 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
"time" | ||
) | ||
|
||
type Host struct { | ||
Id uint16 | ||
Name string | ||
Ip string | ||
Mac string | ||
Hw string | ||
Date string | ||
Known uint16 | ||
Now uint16 | ||
Id uint16 | ||
Name string | ||
Ip string | ||
Mac string | ||
Hw string | ||
Date string | ||
Known uint16 | ||
Now uint16 | ||
} | ||
|
||
type Conf struct { | ||
Iface string | ||
DbPath string | ||
GuiIP string | ||
GuiPort string | ||
Timeout int | ||
ShoutUrl string | ||
Theme string | ||
Iface string | ||
DbPath string | ||
GuiIP string | ||
GuiPort string | ||
GuiAuth string | ||
ShoutUrl string | ||
Theme string | ||
Timeout int | ||
} | ||
|
||
var AppConfig Conf | ||
var AllHosts []Host | ||
|
||
func scan_and_compare() { | ||
var foundHosts []Host | ||
var dbHosts []Host | ||
for { // Endless | ||
foundHosts = arp_scan() // Scan interfaces | ||
dbHosts = db_select() // Select everything from DB | ||
db_setnow() // Mark hosts in DB as offline | ||
hosts_compare(foundHosts, dbHosts) // Compare hosts online and in DB | ||
// and add them to DB | ||
AllHosts = db_select() | ||
time.Sleep(time.Duration(AppConfig.Timeout) * time.Second) // Timeout | ||
} | ||
var foundHosts []Host | ||
var dbHosts []Host | ||
for { // Endless | ||
foundHosts = arp_scan() // Scan interfaces | ||
dbHosts = db_select() // Select everything from DB | ||
db_setnow() // Mark hosts in DB as offline | ||
hosts_compare(foundHosts, dbHosts) // Compare hosts online and in DB | ||
// and add them to DB | ||
AllHosts = db_select() | ||
time.Sleep(time.Duration(AppConfig.Timeout) * time.Second) // Timeout | ||
} | ||
} | ||
|
||
func main() { | ||
AllHosts = []Host{} | ||
AppConfig = get_config() // Get config from Defaults, Config file, Env | ||
AllHosts = []Host{} | ||
AppConfig = get_config() // Get config from Defaults, Config file, Env | ||
|
||
db_create() // Check if DB exists. Create if not | ||
|
||
go scan_and_compare() | ||
db_create() // Check if DB exists. Create if not | ||
|
||
webgui() // Start web GUI | ||
} | ||
go scan_and_compare() | ||
|
||
webgui() // Start web GUI | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters