mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
feat: add UserAgent
This commit is contained in:
parent
d906c0d3b4
commit
f9a954fbd3
3 changed files with 11 additions and 1 deletions
|
@ -1,6 +1,11 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
const GH_Repo = "MedzikUser/go-pingbot"
|
const GH_Repo = "MedzikUser/go-pingbot"
|
||||||
|
|
||||||
|
@ -8,4 +13,5 @@ var (
|
||||||
Version = "dev"
|
Version = "dev"
|
||||||
Build = ""
|
Build = ""
|
||||||
StartTime time.Time
|
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() {
|
func main() {
|
||||||
log.Info("You're using verion: ", config.Version)
|
log.Info("You're using verion: ", config.Version)
|
||||||
|
log.Info(config.UserAgent)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/MedzikUser/go-utils/common"
|
"github.com/MedzikUser/go-utils/common"
|
||||||
|
"gitlab.com/gaming0skar123/go/pingbot/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ping() int {
|
func ping() int {
|
||||||
|
@ -30,6 +31,8 @@ func loop(url string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.Header.Set("User-Agent", config.UserAgent)
|
||||||
|
|
||||||
client := http.DefaultClient
|
client := http.DefaultClient
|
||||||
r, err := client.Do(req)
|
r, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue