-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (47 loc) · 1.17 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
57
58
package main
import (
"fmt"
"net/http"
"time"
)
var (
configFileName string = `wstail.ini`
configFileFinal string
whitelistFileName string = `whitelist.txt`
whitelistFileFinal string
version = `1.0.1`
timeStart = time.Now().Round(time.Second)
sessionMap = make(map[uint64]*map[uint64]bool)
sessionChan = make(map[uint64]*chan uint64)
tailBind = make(chan sessionInfo, 1000)
filePool = make(map[uint64]*fileContent)
fileMap = make(map[string]uint64)
httpListen = `:58888`
buffLen = 4096
writeWait time.Duration
fileAllow map[string]bool
dirAllow map[string]bool
sessionSerial uint64
fileSerial uint64
transOut uint64 = 0
noopInterval int64 = 25
iWriteWait int64 = 10
)
func main() {
arg := arg()
loadConfig()
return
go refreshWhiteList()
go manager()
http.HandleFunc(`/ws/status`, statusPage)
http.HandleFunc(`/ws/tail`, serveWs)
http.HandleFunc(`/ws/config`, configPage)
fmt.Println(`WsTail started`)
err := http.ListenAndServe(httpListen, nil)
if err != nil {
panic("ListenAndServe fail: " + err.Error())
}
}
func writeHttp(w http.ResponseWriter, s string) {
w.Write([]byte(s))
}