package main

import (
	"fmt"
	"keksvpn/pkg/wgfunc"
	"time"
)

func main()  {
	serverConfig := wgfunc.WireGuardConfig{
		Name:       "sample-server",
		IPRanges:   []string{"10.0.1.0/24"},
		Port:       0,
		PrivateKey: "kDUIomFdDOW0VaOMS6Vu8+1rw/8SemeobSa7ZN66J38=",
	}
	server, err := wgfunc.NewWireGuard(serverConfig)
	if err != nil {
		panic(err)
	}

	fmt.Println("Start WireGuard")
	err = server.Up()
	if err != nil {
		server.Down()
		panic(err)
	}
	defer server.Down()

	fmt.Println("WireGuard online")
	time.Sleep(5 * time.Second)
	fmt.Println("Shoutdown server")
	err = server.Down()
	if err != nil {
		panic(err)
	}
	fmt.Println("bye")
}