-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (33 loc) · 764 Bytes
/
Copy pathmain.go
File metadata and controls
41 lines (33 loc) · 764 Bytes
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
package main
import (
"flag"
"fmt"
"github.com/meixinyun/masscan-httpservice/core"
"github.com/meixinyun/masscan-httpservice/g"
myhttp "github.com/meixinyun/masscan-httpservice/http"
"net/http"
"os"
)
func configMasscanRoutes() {
http.HandleFunc("/masscan", func(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
cmd := r.Form.Get("cmd")
core.ExecutionCmd(cmd)
result := core.GetResult()
response := fmt.Sprintf("%s\r\n",result)
w.Write([]byte(response))
})
}
func main() {
cfg := flag.String("c", "cfg.json", "configuration file")
version := flag.Bool("v", false, "show version")
flag.Parse()
if *version {
fmt.Println(g.VERSION)
os.Exit(0)
}
g.ParseConfig(*cfg)
configMasscanRoutes()
go myhttp.Start()
select {}
}