2024-05-17 20:24:06 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2024-05-27 09:42:27 +02:00
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
2024-05-23 13:24:02 +02:00
|
|
|
|
2024-05-17 20:24:06 +02:00
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
|
|
|
"github.com/netbirdio/netbird/relay/server"
|
2024-05-27 09:42:27 +02:00
|
|
|
"github.com/netbirdio/netbird/util"
|
2024-05-17 20:24:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
util.InitLog("trace", "console")
|
|
|
|
}
|
|
|
|
|
2024-05-27 09:42:27 +02:00
|
|
|
func waitForExitSignal() {
|
|
|
|
osSigs := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(osSigs, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
_ = <-osSigs
|
|
|
|
}
|
2024-05-17 20:24:06 +02:00
|
|
|
|
2024-05-27 09:42:27 +02:00
|
|
|
func main() {
|
2024-05-23 13:24:02 +02:00
|
|
|
address := "10.145.236.1:1235"
|
2024-05-17 20:24:06 +02:00
|
|
|
srv := server.NewServer()
|
|
|
|
err := srv.Listen(address)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("failed to bind server: %s", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2024-05-26 22:14:33 +02:00
|
|
|
|
2024-05-27 09:42:27 +02:00
|
|
|
waitForExitSignal()
|
|
|
|
|
|
|
|
err = srv.Close()
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("failed to close server: %s", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2024-05-17 20:24:06 +02:00
|
|
|
}
|