-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (27 loc) · 788 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
package main
import (
"net"
"strconv"
"github.com/lanestolen/grpc-router/config"
"github.com/lanestolen/grpc-router/dhcp"
"github.com/lanestolen/grpc-router/netcontroller"
"github.com/lanestolen/grpc-router/wireguard"
"github.com/rs/zerolog/log"
"google.golang.org/grpc"
)
func main() {
conf, err := config.ParseConfig()
if err != nil {
log.Fatal().Err(err).Msg("couldn't parse config")
}
port := strconv.FormatUint(uint64(conf.ServiceConfig.Domain.Port), 10)
grpcServer := grpc.NewServer()
netcontroller.OpenNetController()
lis, err := net.Listen("tcp", ":"+port)
if err != nil {
log.Fatal().Err(err).Str("port", port).Msg("failed to listen on port")
}
dhcp.NewDHCPServer(grpcServer)
wireguard.NewWireguardServer(grpcServer, conf)
grpcServer.Serve(lis)
}