update
This commit is contained in:
parent
414e370ce5
commit
7eab9d9ed0
5
.github/workflows/agent.yml
vendored
5
.github/workflows/agent.yml
vendored
@ -8,11 +8,16 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
# https://github.com/goreleaser/goreleaser-cross/issues/29
|
||||||
|
image: goreleaser/goreleaser-cross:v1.19.2
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: "^1.20.0"
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v2
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/test-on-pr.yml
vendored
2
.github/workflows/test-on-pr.yml
vendored
@ -12,6 +12,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: "^1.20.0"
|
||||||
- name: Unit test
|
- name: Unit test
|
||||||
run: |
|
run: |
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -18,6 +18,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: "^1.20.0"
|
||||||
- name: Unit test
|
- name: Unit test
|
||||||
run: |
|
run: |
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
10
main.go
10
main.go
@ -71,13 +71,21 @@ var (
|
|||||||
const (
|
const (
|
||||||
delayWhenError = time.Second * 10 // Agent 重连间隔
|
delayWhenError = time.Second * 10 // Agent 重连间隔
|
||||||
networkTimeOut = time.Second * 5 // 普通网络超时
|
networkTimeOut = time.Second * 5 // 普通网络超时
|
||||||
|
macOSChromeUA = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
|
flag.CommandLine.ParseErrorsWhitelist.UnknownFlags = true
|
||||||
|
|
||||||
http.DefaultClient.Timeout = time.Second * 5
|
http.DefaultClient.Timeout = time.Second * 5
|
||||||
httpClient.Transport = bpc.AddCloudFlareByPass(httpClient.Transport)
|
httpClient.Transport = bpc.AddCloudFlareByPass(httpClient.Transport, bpc.Options{
|
||||||
|
AddMissingHeaders: true,
|
||||||
|
Headers: map[string]string{
|
||||||
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
|
||||||
|
"Accept-Language": "en-US,en;q=0.5",
|
||||||
|
"User-Agent": monitor.MacOSChromeUA,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
ex, err := os.Executable()
|
ex, err := os.Executable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,11 +7,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
fakeUa "github.com/EDDYCJY/fake-useragent"
|
|
||||||
|
|
||||||
"github.com/nezhahq/agent/pkg/util"
|
"github.com/nezhahq/agent/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const MacOSChromeUA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
|
||||||
|
|
||||||
type geoIP struct {
|
type geoIP struct {
|
||||||
CountryCode string `json:"country_code,omitempty"`
|
CountryCode string `json:"country_code,omitempty"`
|
||||||
CountryCode2 string `json:"countryCode,omitempty"`
|
CountryCode2 string `json:"countryCode,omitempty"`
|
||||||
@ -120,6 +120,6 @@ func httpGetWithUA(client *http.Client, url string) (*http.Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req.Header.Add("User-Agent", fakeUa.Random())
|
req.Header.Add("User-Agent", MacOSChromeUA)
|
||||||
return client.Do(req)
|
return client.Do(req)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user