mirror of https://github.com/MedzikUser/go-pingbot
feat: add UserAgent
This commit is contained in:
parent
d906c0d3b4
commit
f9a954fbd3
|
@ -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))
|
||||
)
|
||||
|
|
1
main.go
1
main.go
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue