-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (34 loc) · 888 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 (
"net/http"
"github.com/gorilla/websocket"
"github.com/Team-Alua/nevi-proxy/clients"
"github.com/Team-Alua/nevi-proxy/protocol"
)
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {
return true
},
}
var clientList *clients.List
func NeviProxy(w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
panic(err)
}
c := clients.NewClient(conn)
clientList.AddClient(c)
go c.Listen()
go c.Repeat()
}
func main() {
clientList = clients.NewList()
go clientList.PingClients()
proto := protocol.NewProtocol(clientList.Mailer, clientList)
go proto.HandleMail()
http.HandleFunc("/nevi-proxy", NeviProxy)
http.ListenAndServe(":8080", nil)
return
}