feat: add UserAgent

This commit is contained in:
Medzik 2021-10-15 19:15:29 +00:00
parent d906c0d3b4
commit f9a954fbd3
3 changed files with 11 additions and 1 deletions

View File

@ -1,6 +1,11 @@
package config
import "time"
import (
"fmt"
"runtime"
"strings"
"time"
)
const GH_Repo = "MedzikUser/go-pingbot"
@ -8,4 +13,5 @@ var (
Version = "dev"
Build = ""
StartTime time.Time
UserAgent = fmt.Sprintf("PingBot/%s go/%s", Version, strings.Replace(runtime.Version(), "go", "", 1))
)

View File

@ -24,6 +24,7 @@ type cmdOpts struct {
func main() {
log.Info("You're using verion: ", config.Version)
log.Info(config.UserAgent)
var wg sync.WaitGroup

View File

@ -6,6 +6,7 @@ import (
"time"
"github.com/MedzikUser/go-utils/common"
"gitlab.com/gaming0skar123/go/pingbot/config"
)
func ping() int {
@ -30,6 +31,8 @@ func loop(url string) {
return
}
req.Header.Set("User-Agent", config.UserAgent)
client := http.DefaultClient
r, err := client.Do(req)
if err != nil {