|
@@ -4,12 +4,12 @@ import (
|
|
|
"be-vpn/internal/dto"
|
|
|
"bytes"
|
|
|
"encoding/json"
|
|
|
- "github.com/robfig/cron/v3"
|
|
|
"github.com/tidwall/gjson"
|
|
|
"io"
|
|
|
"log"
|
|
|
"net/http"
|
|
|
"os"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
func main() {
|
|
@@ -35,9 +35,11 @@ func main() {
|
|
|
|
|
|
request := dto.RegisterRequest{CountryCode: countryCode, Secret: buf.String()}
|
|
|
body, err := json.Marshal(request)
|
|
|
+ if err != nil {
|
|
|
+ log.Printf("err: %+v", err)
|
|
|
+ }
|
|
|
|
|
|
- c := cron.New(cron.WithChain(cron.SkipIfStillRunning(cron.DefaultLogger)))
|
|
|
- if _, err := c.AddFunc("* * * * *", func() {
|
|
|
+ for true {
|
|
|
// send request
|
|
|
reader := bytes.NewBuffer(body)
|
|
|
resp, err := http.Post("https://localhost:8080/register", "application/json", reader)
|
|
@@ -49,7 +51,6 @@ func main() {
|
|
|
log.Printf("err: %+v", err)
|
|
|
}
|
|
|
log.Printf("resp: %s", string(respBody))
|
|
|
- }); err != nil {
|
|
|
- log.Fatalf("err: %+v", err)
|
|
|
+ time.Sleep(1 * time.Second)
|
|
|
}
|
|
|
}
|