-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (39 loc) · 836 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
43
44
45
46
47
48
49
50
51
package main
import (
"log"
"main/authserver"
"os"
"github.com/joho/godotenv"
)
func init() {
err := godotenv.Load()
if err != nil {
log.Print("No .env file found")
}
// check if rsa.private file exists, if it doesn't, log fatal
_, err = os.Stat("./rsa.private")
if os.IsNotExist(err) {
log.Fatal("Error: rsa.private file not found")
}
}
func main() {
// initialize our server struct
as, err := authserver.Start(os.Getenv("IP"), os.Getenv("PORT"))
if err != nil {
log.Fatal(err)
}
receive, _ := as.InitializeChannels()
defer func() {
if err := as.AuthService.Client.Prisma.Disconnect(); err != nil {
panic(err)
}
}()
for {
conn, err := as.TCPListen.Accept()
if err != nil {
log.Printf("Error accepting connection: %v", err)
continue
}
go as.ListenForPackets(conn, receive)
}
}