-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (40 loc) · 1008 Bytes
/
Copy pathmain.go
File metadata and controls
46 lines (40 loc) · 1008 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
42
43
44
45
46
package main
import (
"Rshell/pkg/database"
"Rshell/pkg/encrypt"
"Rshell/pkg/logger"
"Rshell/pkg/routers"
"Rshell/pkg/utils"
"embed"
"flag"
"io/fs"
"os"
"strconv"
)
//go:embed dist
var embedFS embed.FS
func main() {
utils.InitFunction()
var bindPort = flag.Int("p", 8089, "Specify alternate port")
flag.Parse()
if *bindPort > 65535 || *bindPort < 0 {
flag.Usage()
os.Exit(0)
}
database.ConnectDateBase()
defer database.Engine.Close()
encrypt.GenerateKeyPair()
database.Engine.Update(&database.Clients{Online: "2"})
database.Engine.Update(&database.Listener{Status: 2})
database.Engine.Update(&database.Socks5{Status: 2})
database.Engine.Update(&database.WebDelivery{Status: 2})
distFS, _ := fs.Sub(embedFS, "dist")
staticFs, _ := fs.Sub(distFS, "static")
r := routers.NewRouter(embedFS, staticFs)
logger.Info("Listening on port " + strconv.Itoa(*bindPort))
err := r.Run("0.0.0.0:" + strconv.Itoa(*bindPort))
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}
}