-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
42 lines (32 loc) · 777 Bytes
/
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
package main
import (
"flag"
"net/http"
)
var pastebin *handler
var conf config
var confpath string
func init() {
flag.StringVar(&confpath, "c", "./config.json", "Set the config path")
flag.Parse()
err := readConf(confpath, &conf)
if err != nil {
panic("Open Config Error")
}
pastebin = NewHandler(conf.BuffSize)
for i := 0; i < len(conf.WhiteList); i++ {
pastebin.whitelist[conf.WhiteList[i]] = struct{}{}
}
go pastebin.timeToCleanUp(conf.CleanDur)
}
func main() {
http.HandleFunc("/add", pastebin.add)
http.HandleFunc("/get", pastebin.get)
http.HandleFunc("/del", pastebin.del)
if conf.EnableTLS {
http.ListenAndServeTLS("0.0.0.0:"+conf.Port,
conf.CertPath, conf.KeyPath, nil)
} else {
http.ListenAndServe("0.0.0.0:"+conf.Port, nil)
}
}