-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (45 loc) · 1.43 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"embed"
"flag"
"log"
"os"
"path/filepath"
"github.com/17xande/keylogger"
piplayer "github.com/17xande/pi-player/pkg/piplayer"
)
//go:embed pkg/piplayer/assets
var statAssets embed.FS
//go:embed pkg/piplayer/templates
var statTemplates embed.FS
func main() {
addr := flag.String("addr", ":8080", "The addr of the application.")
test := flag.String("test", "", "send \"mac\", \"linux\", or \"web\" to test the code on mac or linux or to test only the web interface.")
debug := flag.Bool("debug", false, "print extra information for debugging.")
// dlv := flag.Bool("dlv", false, "Let the program know if delve is being used to debug so the application directory can be changed.")
flag.Parse()
ex, err := os.Executable()
if err != nil {
panic(err)
}
exPath := filepath.Dir(ex)
conf, err := piplayer.ConfigLoad("")
if err != nil {
log.Printf("Current directory: %s\n", exPath)
log.Fatalf("Error loading config.\n%v", err)
}
if *debug || conf.Debug {
conf.Debug = true
log.Println("Debug mode enabled")
log.Printf("Config file: %v", conf)
}
a := piplayer.NewAPIHandler(conf.Debug, test, statAssets, statTemplates)
kl := keylogger.NewKeyLogger(conf.Remote.Names)
p := piplayer.NewPlayer(&a, conf, kl)
p.Server = piplayer.NewServer(p, *addr)
// Start the browser
// We have to start it async because the code has
// to carry on, so that the server comes online.
go p.FirstRun()
piplayer.Start(p)
}