Compare commits

...
53 Commits
Author SHA1 Message Date
Joe 796a0dbde1 Merge pull request #1162 from jpts/fix-private-armory-github-auth
Add armory support for private Github APIs
2023-03-26 13:22:40 -07:00
Joe 6aeab60d62 Merge pull request #1166 from 4lxs/master
C2 http uri lowercased
2023-03-26 07:57:18 -07:00
svl 99c76c2da0 C2 http uri lowercased. Fixes #1126 2023-03-26 07:00:56 -04:00
Ronan Kervella 749f71d226 Merge pull request #1164 from DominicBreuker/synchronize-beacon-extension-tasks
Further stabilization of extensions in beacon mode
2023-03-23 14:42:56 -07:00
Dominic Breuker 3d7227ea2f execute regular tasks and extenions concurrently 2023-03-23 21:44:05 +01:00
Dominic Breuker 329730120d cleanup and variable rename 2023-03-23 21:32:29 +01:00
Dominic Breuker c6a29ea76a ensure waitgroup in beaconmain can never become negative 2023-03-23 21:26:25 +01:00
jpts c40f59bc39 feat: add armory support for private Github apis 2023-03-22 19:06:51 +00:00
Dominic Breuker b0e0df1cb5 ensure beacon registers extensions before it calls them 2023-03-21 23:18:21 +01:00
Joe 2ece520fdc Merge pull request #1159 from DominicBreuker/fix-extension-call-race-condition
avoid race condition in the extension callback on windows beacons
2023-03-20 17:23:37 -07:00
Joe 01017460e8 Merge pull request #1157 from BishopFox/10a8dependabot/go_modules/github.com/cheggaaa/pb/v3-3.1.2
Bump github.com/cheggaaa/pb/v3 from 3.1.0 to 3.1.2
2023-03-20 15:32:09 -07:00
Dominic Breuker f1613bbad9 avoid race condition in the extension callback on windows beacons 2023-03-20 21:36:16 +01:00
Joe 657d21e2ea Merge pull request #1152 from BishopFox/b4bddependabot/go_modules/google.golang.org/protobuf-1.30.0
Bump google.golang.org/protobuf from 1.28.1 to 1.30.0
2023-03-20 11:52:53 -07:00
Joe 9f64ef1486 Merge pull request #1158 from BishopFox/fix/chromdp-cookies
Update `DumpCookies` method
2023-03-20 11:52:19 -07:00
rkervella 918d729dc5 Update DumpCookies method 2023-03-20 10:09:15 -07:00
dependabot[bot] c506020570 Bump github.com/cheggaaa/pb/v3 from 3.1.0 to 3.1.2
Bumps [github.com/cheggaaa/pb/v3](https://github.com/cheggaaa/pb) from 3.1.0 to 3.1.2.
- [Release notes](https://github.com/cheggaaa/pb/releases)
- [Commits](https://github.com/cheggaaa/pb/compare/v3.1.0...v3.1.2)

---
updated-dependencies:
- dependency-name: github.com/cheggaaa/pb/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-20 16:49:37 +00:00
dependabot[bot] 9d7d1b76fc Bump google.golang.org/protobuf from 1.28.1 to 1.30.0
Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.28.1 to 1.30.0.
- [Release notes](https://github.com/protocolbuffers/protobuf-go/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash)
- [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.28.1...v1.30.0)

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-20 16:49:05 +00:00
Joe 3f5c434c26 Merge pull request #1153 from BishopFox/3d69dependabot/go_modules/github.com/chromedp/chromedp-0.9.1
Bump github.com/chromedp/chromedp from 0.8.8 to 0.9.1
2023-03-20 09:48:10 -07:00
Joe aa8e01e365 Merge pull request #1154 from BishopFox/9bd6dependabot/go_modules/gorm.io/driver/postgres-1.5.0
Bump gorm.io/driver/postgres from 1.4.8 to 1.5.0
2023-03-20 09:47:27 -07:00
Joe 8b84197d1a Merge pull request #1156 from BishopFox/07a1dependabot/github_actions/actions/setup-go-4
Bump actions/setup-go from 3 to 4
2023-03-20 09:46:33 -07:00
Joe cdd2a33aec Merge pull request #1155 from BishopFox/1374dependabot/go_modules/github.com/grpc-ecosystem/go-grpc-middleware-1.4.0
Bump github.com/grpc-ecosystem/go-grpc-middleware from 1.3.0 to 1.4.0
2023-03-20 09:46:15 -07:00
dependabot[bot] c6e65e6b69 Bump actions/setup-go from 3 to 4
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-20 04:02:39 +00:00
dependabot[bot] 8291364aad Bump github.com/grpc-ecosystem/go-grpc-middleware from 1.3.0 to 1.4.0
Bumps [github.com/grpc-ecosystem/go-grpc-middleware](https://github.com/grpc-ecosystem/go-grpc-middleware) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/grpc-ecosystem/go-grpc-middleware/releases)
- [Commits](https://github.com/grpc-ecosystem/go-grpc-middleware/compare/v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/grpc-ecosystem/go-grpc-middleware
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-20 04:02:34 +00:00
dependabot[bot] dff24ae31b Bump gorm.io/driver/postgres from 1.4.8 to 1.5.0
Bumps [gorm.io/driver/postgres](https://github.com/go-gorm/postgres) from 1.4.8 to 1.5.0.
- [Release notes](https://github.com/go-gorm/postgres/releases)
- [Commits](https://github.com/go-gorm/postgres/compare/v1.4.8...v1.5.0)

---
updated-dependencies:
- dependency-name: gorm.io/driver/postgres
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-20 04:02:30 +00:00
dependabot[bot] a3ea33bcdb Bump github.com/chromedp/chromedp from 0.8.8 to 0.9.1
Bumps [github.com/chromedp/chromedp](https://github.com/chromedp/chromedp) from 0.8.8 to 0.9.1.
- [Release notes](https://github.com/chromedp/chromedp/releases)
- [Commits](https://github.com/chromedp/chromedp/compare/v0.8.8...v0.9.1)

---
updated-dependencies:
- dependency-name: github.com/chromedp/chromedp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-20 04:01:46 +00:00
Joe dcb1fc3cf3 Merge pull request #1145 from BishopFox/a584dependabot/go_modules/github.com/fatih/color-1.15.0
Bump github.com/fatih/color from 1.14.1 to 1.15.0
2023-03-13 11:13:17 -07:00
Joe 3f721f2591 Merge pull request #1143 from BishopFox/a64fdependabot/go_modules/github.com/xlab/treeprint-1.2.0
Bump github.com/xlab/treeprint from 1.1.0 to 1.2.0
2023-03-13 07:15:23 -07:00
Joe 99914e4092 Merge pull request #1144 from BishopFox/fc29dependabot/go_modules/gorm.io/gorm-1.24.6
Bump gorm.io/gorm from 1.24.5 to 1.24.6
2023-03-13 06:41:53 -07:00
dependabot[bot] 4068fafdb9 Bump github.com/xlab/treeprint from 1.1.0 to 1.2.0
Bumps [github.com/xlab/treeprint](https://github.com/xlab/treeprint) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/xlab/treeprint/releases)
- [Commits](https://github.com/xlab/treeprint/compare/v1.1.0...v1.2.0)

---
updated-dependencies:
- dependency-name: github.com/xlab/treeprint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-13 13:24:08 +00:00
Joe ccc6066b79 Merge pull request #1142 from BishopFox/0a04dependabot/go_modules/github.com/miekg/dns-1.1.52
Bump github.com/miekg/dns from 1.1.51 to 1.1.52
2023-03-13 06:19:56 -07:00
Joe c53e617fec Merge pull request #1141 from BishopFox/d824dependabot/go_modules/golang.org/x/crypto-0.7.0
Bump golang.org/x/crypto from 0.6.0 to 0.7.0
2023-03-13 06:19:28 -07:00
dependabot[bot] 200a1a9942 Bump github.com/fatih/color from 1.14.1 to 1.15.0
Bumps [github.com/fatih/color](https://github.com/fatih/color) from 1.14.1 to 1.15.0.
- [Release notes](https://github.com/fatih/color/releases)
- [Commits](https://github.com/fatih/color/compare/v1.14.1...v1.15.0)

---
updated-dependencies:
- dependency-name: github.com/fatih/color
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-13 04:02:02 +00:00
dependabot[bot] 564aeec91f Bump gorm.io/gorm from 1.24.5 to 1.24.6
Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.24.5 to 1.24.6.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.24.5...v1.24.6)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-13 04:02:01 +00:00
dependabot[bot] 115f47a7b4 Bump github.com/miekg/dns from 1.1.51 to 1.1.52
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.51 to 1.1.52.
- [Release notes](https://github.com/miekg/dns/releases)
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](https://github.com/miekg/dns/compare/v1.1.51...v1.1.52)

---
updated-dependencies:
- dependency-name: github.com/miekg/dns
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-13 04:01:43 +00:00
dependabot[bot] bde3cd6e87 Bump golang.org/x/crypto from 0.6.0 to 0.7.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/crypto/releases)
- [Commits](https://github.com/golang/crypto/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-13 04:01:10 +00:00
moloch-- e6d9740410 Go v1.20.2 2023-03-09 18:12:57 -06:00
Joe 6240be3a4b Merge pull request #1137 from BishopFox/go/v1.20.2
Go v1.20.2
2023-03-09 11:30:09 -07:00
moloch-- 3a8017e7dd Go v1.20.2 2023-03-08 16:03:11 -07:00
Joe 1f76a3f4f3 Merge pull request #1136 from DominicBreuker/master
Unblock execute command if no output is requested
2023-03-07 22:09:13 -06:00
Dominic Breuker 5ab52bca05 unblock execute command if no output is requested 2023-03-07 22:09:24 +01:00
Joe dfcbdf7e07 Merge pull request #1132 from BishopFox/d866dependabot/go_modules/github.com/chromedp/chromedp-0.8.8
Bump github.com/chromedp/chromedp from 0.8.7 to 0.8.8
2023-03-06 12:07:04 -06:00
Joe 2dc1b69c92 Merge pull request #1134 from BishopFox/c58ddependabot/go_modules/github.com/jedib0t/go-pretty/v6-6.4.6
Bump github.com/jedib0t/go-pretty/v6 from 6.4.4 to 6.4.6
2023-03-06 12:06:37 -06:00
Joe 69058fe492 Merge pull request #1131 from BishopFox/1eaedependabot/go_modules/golang.org/x/net-0.8.0
Bump golang.org/x/net from 0.7.0 to 0.8.0
2023-03-06 10:58:37 -06:00
dependabot[bot] 9f811f8da0 Bump golang.org/x/net from 0.7.0 to 0.8.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.7.0 to 0.8.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-06 16:17:41 +00:00
dependabot[bot] 9585b430a5 Bump github.com/chromedp/chromedp from 0.8.7 to 0.8.8
Bumps [github.com/chromedp/chromedp](https://github.com/chromedp/chromedp) from 0.8.7 to 0.8.8.
- [Release notes](https://github.com/chromedp/chromedp/releases)
- [Commits](https://github.com/chromedp/chromedp/compare/v0.8.7...v0.8.8)

---
updated-dependencies:
- dependency-name: github.com/chromedp/chromedp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-06 16:17:35 +00:00
Joe efaffb1999 Merge pull request #1135 from BishopFox/37cddependabot/go_modules/golang.org/x/term-0.6.0
Bump golang.org/x/term from 0.5.0 to 0.6.0
2023-03-06 10:02:59 -06:00
dependabot[bot] 2f1f81cc0f Bump golang.org/x/term from 0.5.0 to 0.6.0
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/golang/term/releases)
- [Commits](https://github.com/golang/term/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-06 04:07:11 +00:00
dependabot[bot] 94d8b9fc8a Bump github.com/jedib0t/go-pretty/v6 from 6.4.4 to 6.4.6
Bumps [github.com/jedib0t/go-pretty/v6](https://github.com/jedib0t/go-pretty) from 6.4.4 to 6.4.6.
- [Release notes](https://github.com/jedib0t/go-pretty/releases)
- [Commits](https://github.com/jedib0t/go-pretty/compare/v6.4.4...v6.4.6)

---
updated-dependencies:
- dependency-name: github.com/jedib0t/go-pretty/v6
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2023-03-06 04:06:41 +00:00
Joe 1756fdfb62 Merge pull request #1130 from r00t0v3rr1d3/master
fix defunct processes on nix
2023-03-05 11:41:33 -06:00
Chris Shields 12e6f9a73d fix defunct processes on nix 2023-03-05 11:02:30 -05:00
Ronan Kervella b0a917ce41 Merge pull request #1128 from BishopFox/fix/ssh-kerberos
Fix `ssh` command
2023-03-03 13:10:24 -08:00
rkervella e3a2ff81ab Only try to read keytab if it was supplied as an argument 2023-03-03 11:53:56 -08:00
Ronan Kervella 71f94928bf Merge pull request #1122 from BishopFox/stage
Update go-clr, merge master
2023-02-28 20:10:02 -08:00
235 changed files with 6544 additions and 4249 deletions

No files matched your search

+4 -4
View File
@@ -13,9 +13,9 @@ jobs:
timeout-minutes: 45
steps:
- name: Go 1.20
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "1.20.1"
go-version: "1.20.2"
- name: OS Packages
run: |
@@ -63,9 +63,9 @@ jobs:
timeout-minutes: 45
steps:
- name: Go 1.20
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "^1.20"
go-version: "1.20.2"
- name: Mingw
run: brew install mingw-w64
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
steps:
# Setup go environment
- name: Go 1.20
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "^1.20"
+4 -4
View File
@@ -16,9 +16,9 @@ jobs:
timeout-minutes: 90
steps:
- name: Go 1.20
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "^1.20"
go-version: "1.20.2"
- name: OS Packages
run: |
@@ -50,9 +50,9 @@ jobs:
timeout-minutes: 90
steps:
- name: Go 1.20
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "^1.20"
go-version: "1.20.2"
- name: Mingw
run: brew install mingw-w64
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.20.1
FROM golang:1.20.2
#
# IMPORTANT: This Dockerfile is used for testing, I do not recommend deploying
+1 -1
View File
@@ -484,7 +484,7 @@ func fetchPackageSignature(wg *sync.WaitGroup, armoryConfig *assets.ArmoryConfig
var sig *minisign.Signature
if pkgParser, ok := pkgParsers[repoURL.Hostname()]; ok {
sig, _, err = pkgParser(armoryPkg, true, clientConfig)
sig, _, err = pkgParser(armoryConfig, armoryPkg, true, clientConfig)
} else {
sig, _, err = DefaultArmoryPkgParser(armoryConfig, armoryPkg, true, clientConfig)
}
+2 -2
View File
@@ -143,7 +143,7 @@ func installAliasPackageByName(name string, clientConfig ArmoryHTTPConfig, con *
var sig *minisign.Signature
var tarGz []byte
if pkgParser, ok := pkgParsers[repoURL.Hostname()]; ok {
sig, tarGz, err = pkgParser(&entry.Pkg, false, clientConfig)
sig, tarGz, err = pkgParser(entry.ArmoryConfig, &entry.Pkg, false, clientConfig)
} else {
sig, tarGz, err = DefaultArmoryPkgParser(entry.ArmoryConfig, &entry.Pkg, false, clientConfig)
}
@@ -261,7 +261,7 @@ func installExtensionPackageByName(name string, clientConfig ArmoryHTTPConfig, c
var sig *minisign.Signature
var tarGz []byte
if pkgParser, ok := pkgParsers[repoURL.Hostname()]; ok {
sig, tarGz, err = pkgParser(&entry.Pkg, false, clientConfig)
sig, tarGz, err = pkgParser(entry.ArmoryConfig, &entry.Pkg, false, clientConfig)
} else {
sig, tarGz, err = DefaultArmoryPkgParser(entry.ArmoryConfig, &entry.Pkg, false, clientConfig)
}
+64 -120
View File
@@ -40,7 +40,7 @@ import (
type ArmoryIndexParser func(*assets.ArmoryConfig, ArmoryHTTPConfig) (*ArmoryIndex, error)
// ArmoryPackageParser - Generic interface to fetch armory package manifests
type ArmoryPackageParser func(*ArmoryPackage, bool, ArmoryHTTPConfig) (*minisign.Signature, []byte, error)
type ArmoryPackageParser func(*assets.ArmoryConfig, *ArmoryPackage, bool, ArmoryHTTPConfig) (*minisign.Signature, []byte, error)
var (
indexParsers = map[string]ArmoryIndexParser{
@@ -79,28 +79,7 @@ func DefaultArmoryIndexParser(armoryConfig *assets.ArmoryConfig, clientConfig Ar
return nil, err
}
client := httpClient(clientConfig)
repoURL, err := url.Parse(armoryConfig.RepoURL)
if err != nil {
return nil, err
}
req := &http.Request{
Method: http.MethodGet,
URL: repoURL,
Header: map[string][]string{},
}
if armoryConfig.Authorization != "" {
req.Header.Set("Authorization", armoryConfig.Authorization)
}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
resp, body, err := httpRequest(clientConfig, armoryConfig.RepoURL, armoryConfig, http.Header{})
if resp.StatusCode != http.StatusOK {
return nil, errors.New("api returned non-200 status code")
}
@@ -125,9 +104,8 @@ func DefaultArmoryIndexParser(armoryConfig *assets.ArmoryConfig, clientConfig Ar
return nil, errors.New("index has invalid signature")
}
armoryIndex := &ArmoryIndex{ArmoryConfig: armoryConfig}
if err != nil {
return nil, err
armoryIndex := &ArmoryIndex{
ArmoryConfig: armoryConfig,
}
err = json.Unmarshal(armoryIndexData, armoryIndex)
if err != nil {
@@ -144,25 +122,7 @@ func DefaultArmoryPkgParser(armoryConfig *assets.ArmoryConfig, armoryPkg *Armory
return nil, nil, err
}
client := httpClient(clientConfig)
repoURL, err := url.Parse(armoryConfig.RepoURL)
if err != nil {
return nil, nil, err
}
req := &http.Request{
Method: http.MethodGet,
URL: repoURL,
Header: map[string][]string{},
}
if armoryConfig.Authorization != "" {
req.Header.Set("Authorization", armoryConfig.Authorization)
}
resp, err := client.Do(req)
if err != nil {
return nil, nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
resp, body, err := httpRequest(clientConfig, armoryConfig.RepoURL, armoryConfig, http.Header{})
if err != nil {
return nil, nil, err
}
@@ -187,18 +147,10 @@ func DefaultArmoryPkgParser(armoryConfig *assets.ArmoryConfig, armoryPkg *Armory
if tarGzURL.Scheme != "https" && tarGzURL.Scheme != "http" {
return nil, nil, errors.New("invalid url scheme")
}
resp, err := client.Get(tarGzURL.String())
tarGz, err = downloadRequest(clientConfig, tarGzURL.String(), armoryConfig)
if err != nil {
return nil, nil, err
}
defer resp.Body.Close()
tarGz, err = ioutil.ReadAll(resp.Body)
if err != nil {
return nil, nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, nil, errors.New("api returned non-200 status code")
}
}
return sig, tarGz, nil
}
@@ -239,13 +191,7 @@ func GithubAPIArmoryIndexParser(armoryConfig *assets.ArmoryConfig, clientConfig
return nil, err
}
client := httpClient(clientConfig)
resp, err := client.Get(armoryConfig.RepoURL)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
resp, body, err := httpRequest(clientConfig, armoryConfig.RepoURL, armoryConfig, http.Header{})
if err != nil {
return nil, err
}
@@ -253,7 +199,7 @@ func GithubAPIArmoryIndexParser(armoryConfig *assets.ArmoryConfig, clientConfig
if resp.StatusCode == http.StatusForbidden {
return nil, errors.New("you hit the github api rate limit (60 req/hr), try later")
}
return nil, errors.New("api returned non-200 status code")
return nil, fmt.Errorf("api returned non-200 status code: %d", resp.StatusCode)
}
releases := []GithubRelease{}
@@ -270,23 +216,13 @@ func GithubAPIArmoryIndexParser(armoryConfig *assets.ArmoryConfig, clientConfig
var sigData []byte
for _, asset := range release.Assets {
if asset.Name == armoryIndexFileName {
resp, err := client.Get(asset.BrowserDownloadURL)
if err != nil {
return nil, err
}
defer resp.Body.Close()
armoryIndexData, err = ioutil.ReadAll(resp.Body)
armoryIndexData, err = downloadRequest(clientConfig, asset.URL, armoryConfig)
if err != nil {
return nil, err
}
}
if asset.Name == armoryIndexSigFileName {
resp, err := client.Get(asset.BrowserDownloadURL)
if err != nil {
return nil, err
}
defer resp.Body.Close()
sigData, err = ioutil.ReadAll(resp.Body)
sigData, err = downloadRequest(clientConfig, asset.URL, armoryConfig)
if err != nil {
return nil, err
}
@@ -299,7 +235,9 @@ func GithubAPIArmoryIndexParser(armoryConfig *assets.ArmoryConfig, clientConfig
return nil, errors.New("invalid signature")
}
armoryIndex := &ArmoryIndex{}
armoryIndex := &ArmoryIndex{
ArmoryConfig: armoryConfig,
}
err = json.Unmarshal(armoryIndexData, armoryIndex)
if err != nil {
return nil, err
@@ -308,20 +246,14 @@ func GithubAPIArmoryIndexParser(armoryConfig *assets.ArmoryConfig, clientConfig
}
// GithubAPIArmoryPackageParser - Retrieve the minisig and tar.gz for an armory package from a GitHub release
func GithubAPIArmoryPackageParser(armoryPkg *ArmoryPackage, sigOnly bool, clientConfig ArmoryHTTPConfig) (*minisign.Signature, []byte, error) {
func GithubAPIArmoryPackageParser(armoryConfig *assets.ArmoryConfig, armoryPkg *ArmoryPackage, sigOnly bool, clientConfig ArmoryHTTPConfig) (*minisign.Signature, []byte, error) {
var publicKey minisign.PublicKey
err := publicKey.UnmarshalText([]byte(armoryPkg.PublicKey))
if err != nil {
return nil, nil, err
}
client := httpClient(clientConfig)
resp, err := client.Get(armoryPkg.RepoURL)
if err != nil {
return nil, nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
resp, body, err := httpRequest(clientConfig, armoryPkg.RepoURL, armoryConfig, http.Header{})
if err != nil {
return nil, nil, err
}
@@ -329,7 +261,7 @@ func GithubAPIArmoryPackageParser(armoryPkg *ArmoryPackage, sigOnly bool, client
if resp.StatusCode == http.StatusForbidden {
return nil, nil, errors.New("you hit the github api rate limit (60 req/hr), try later")
}
return nil, nil, errors.New("api returned non-200 status code")
return nil, nil, fmt.Errorf("api returned non-200 status code: %d", resp.StatusCode)
}
releases := []GithubRelease{}
@@ -343,14 +275,7 @@ func GithubAPIArmoryPackageParser(armoryPkg *ArmoryPackage, sigOnly bool, client
var tarGz []byte
for _, asset := range release.Assets {
if asset.Name == fmt.Sprintf("%s.minisig", armoryPkg.CommandName) {
var resp *http.Response
resp, err = client.Get(asset.BrowserDownloadURL)
if err != nil {
break
}
defer resp.Body.Close()
var body []byte
body, err = ioutil.ReadAll(resp.Body)
body, err := downloadRequest(clientConfig, asset.URL, armoryConfig)
if err != nil {
break
}
@@ -360,13 +285,7 @@ func GithubAPIArmoryPackageParser(armoryPkg *ArmoryPackage, sigOnly bool, client
}
}
if asset.Name == fmt.Sprintf("%s.tar.gz", armoryPkg.CommandName) && !sigOnly {
var resp *http.Response
resp, err = client.Get(asset.BrowserDownloadURL)
if err != nil {
break
}
defer resp.Body.Close()
tarGz, err = ioutil.ReadAll(resp.Body)
tarGz, err = downloadRequest(clientConfig, asset.URL, armoryConfig)
if err != nil {
break
}
@@ -380,31 +299,27 @@ func GithubAPIArmoryPackageParser(armoryPkg *ArmoryPackage, sigOnly bool, client
//
// GithubArmoryPackageParser - Uses github.com instead of api.github.com to download packages
func GithubArmoryPackageParser(armoryPkg *ArmoryPackage, sigOnly bool, clientConfig ArmoryHTTPConfig) (*minisign.Signature, []byte, error) {
func GithubArmoryPackageParser(_ *assets.ArmoryConfig, armoryPkg *ArmoryPackage, sigOnly bool, clientConfig ArmoryHTTPConfig) (*minisign.Signature, []byte, error) {
latestTag, err := githubLatestTagParser(armoryPkg, clientConfig)
if err != nil {
return nil, nil, err
}
client := httpClient(clientConfig)
sigURL, err := url.Parse(armoryPkg.RepoURL)
if err != nil {
return nil, nil, fmt.Errorf("failed to parse armory pkg url '%s': %s", armoryPkg.RepoURL, err)
}
sigURL.Path = path.Join(sigURL.Path, "releases", "download", latestTag, fmt.Sprintf("%s.minisig", armoryPkg.CommandName))
sigResp, err := client.Get(sigURL.String())
// Setup dummy auth here as the non-api endpoints don't support the Authorization header
noAuth := &assets.ArmoryConfig{
Authorization: "",
}
body, err := downloadRequest(clientConfig, sigURL.String(), noAuth)
if err != nil {
return nil, nil, err
}
defer sigResp.Body.Close()
if sigResp.StatusCode != http.StatusOK {
return nil, nil, fmt.Errorf("failed to get signature for armory pkg '%s': %s", armoryPkg.RepoURL, sigResp.Status)
}
var body []byte
body, err = ioutil.ReadAll(sigResp.Body)
if err != nil {
return nil, nil, fmt.Errorf("failed to read resp body '%s': %s", armoryPkg.RepoURL, err)
}
sig, err := parsePkgMinsig(body)
if err != nil {
return nil, nil, fmt.Errorf("failed to parse pkg sig '%s': %s", armoryPkg.RepoURL, err)
@@ -417,18 +332,10 @@ func GithubArmoryPackageParser(armoryPkg *ArmoryPackage, sigOnly bool, clientCon
return nil, nil, fmt.Errorf("failed to parse armory pkg url '%s': %s", armoryPkg.RepoURL, err)
}
tarGzURL.Path = path.Join(tarGzURL.Path, "releases", "download", latestTag, fmt.Sprintf("%s.tar.gz", armoryPkg.CommandName))
tarGzResp, err := client.Get(tarGzURL.String())
tarGz, err = downloadRequest(clientConfig, tarGzURL.String(), noAuth)
if err != nil {
return nil, nil, err
}
defer tarGzResp.Body.Close()
if tarGzResp.StatusCode != http.StatusOK {
return nil, nil, fmt.Errorf("failed to get tar.gz for armory pkg '%s': %s", armoryPkg.RepoURL, tarGzResp.Status)
}
tarGz, err = ioutil.ReadAll(tarGzResp.Body)
if err != nil {
return nil, nil, fmt.Errorf("failed to read tar.gz body '%s': %s", armoryPkg.RepoURL, err)
}
}
return sig, tarGz, nil
@@ -498,3 +405,40 @@ func httpClient(config ArmoryHTTPConfig) *http.Client {
},
}
}
func httpRequest(clientConfig ArmoryHTTPConfig, reqURL string, armoryConfig *assets.ArmoryConfig, extraHeaders http.Header) (*http.Response, []byte, error) {
client := httpClient(clientConfig)
req, err := http.NewRequest(http.MethodGet, reqURL, http.NoBody)
if err != nil {
return nil, nil, err
}
if len(extraHeaders) > 0 {
for key := range extraHeaders {
req.Header.Add(key, strings.Join(extraHeaders[key], ","))
}
}
if armoryConfig.Authorization != "" {
req.Header.Set("Authorization", armoryConfig.Authorization)
}
resp, err := client.Do(req)
if err != nil {
return nil, nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
return resp, body, err
}
func downloadRequest(clientConfig ArmoryHTTPConfig, reqURL string, armoryConfig *assets.ArmoryConfig) ([]byte, error) {
downloadHdr := http.Header{
"Accept": {"application/octet-stream"},
}
resp, body, err := httpRequest(clientConfig, reqURL, armoryConfig, downloadHdr)
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusFound {
return nil, fmt.Errorf("Error downloading asset: http %d", resp.StatusCode)
}
return body, err
}
+7 -4
View File
@@ -69,10 +69,13 @@ func SSHCmd(ctx *grumble.Context, con *console.SliverConsoleClient) {
con.PrintErrorf("You must specify a keytab file with the --kerberos-keytab flag\n")
return
}
kerberosKeytab, err := os.ReadFile(kerberosKeytabFile)
if err != nil {
con.PrintErrorf("%s\n", err)
return
kerberosKeytab := []byte{}
if kerberosKeytabFile != "" {
kerberosKeytab, err = os.ReadFile(kerberosKeytabFile)
if err != nil {
con.PrintErrorf("%s\n", err)
return
}
}
if password == "" && len(privKey) == 0 && !ctx.Flags.Bool("skip-loot") {
+1 -2
View File
@@ -488,10 +488,9 @@ func ParseHTTPc2(args string) ([]*clientpb.ImplantC2, error) {
return c2s, nil
}
for index, arg := range strings.Split(args, ",") {
arg = strings.ToLower(arg)
var uri *url.URL
var err error
if strings.HasPrefix(arg, "http://") || strings.HasPrefix(arg, "https://") {
if cmp := strings.ToLower(arg); strings.HasPrefix(cmp, "http://") || strings.HasPrefix(cmp, "https://") {
uri, err = url.Parse(arg)
if err != nil {
return nil, err
+2 -1
View File
@@ -32,6 +32,7 @@ import (
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/network"
"github.com/chromedp/cdproto/page"
"github.com/chromedp/cdproto/storage"
"github.com/chromedp/cdproto/target"
"github.com/chromedp/chromedp"
)
@@ -275,7 +276,7 @@ func DumpCookies(curse *core.CursedProcess, webSocketURL string) ([]*network.Coo
dumpCookieTasks := chromedp.Tasks{
// read network values
chromedp.ActionFunc(func(ctx context.Context) error {
cookies, err = network.GetCookies().Do(ctx)
cookies, err = storage.GetCookies().Do(ctx)
if err != nil {
return err
}
+2 -2
View File
@@ -20,8 +20,8 @@ set -e
# Creates the static go asset archives
GO_VER="1.20.1"
GARBLE_VER="1.20.2"
GO_VER="1.20.2"
GARBLE_VER="1.20.3"
SGN_VER="0.0.3"
GO_ARCH_1="amd64"
+19 -19
View File
@@ -12,46 +12,46 @@ require (
github.com/Binject/universal v0.0.0-20210304094126-daefaa886313
github.com/Ne0nd0g/go-clr v1.0.3
github.com/alecthomas/chroma v0.10.0
github.com/cheggaaa/pb/v3 v3.1.0
github.com/chromedp/cdproto v0.0.0-20230109101555-6b041c6303cc
github.com/chromedp/chromedp v0.8.7
github.com/cheggaaa/pb/v3 v3.1.2
github.com/chromedp/cdproto v0.0.0-20230220211738-2b1ec77315c9
github.com/chromedp/chromedp v0.9.1
github.com/desertbit/columnize v2.1.0+incompatible
github.com/desertbit/go-shlex v0.1.1
github.com/desertbit/grumble v1.1.1
github.com/desertbit/readline v1.5.1
github.com/fatih/color v1.14.1
github.com/fatih/color v1.15.0
github.com/gofrs/uuid v4.4.0+incompatible
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/jedib0t/go-pretty/v6 v6.4.4
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/jedib0t/go-pretty/v6 v6.4.6
github.com/kbinani/screenshot v0.0.0-20191211154542-3a185f1ce18f
github.com/lesnuages/go-winio v0.4.19
github.com/lesnuages/snitch v0.6.0
github.com/mattn/go-sqlite3 v1.14.16
github.com/miekg/dns v1.1.51
github.com/miekg/dns v1.1.52
github.com/moloch--/memmod v0.0.0-20211120144554-8b37cc654945
github.com/pquerna/otp v1.4.0
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
github.com/stretchr/testify v1.8.1
github.com/things-go/go-socks5 v0.0.3
github.com/xlab/treeprint v1.1.0
github.com/xlab/treeprint v1.2.0
github.com/yiya1989/sshkrb5 v0.0.0-20201110125252-a1455b75a35e
golang.org/x/crypto v0.6.0
golang.org/x/net v0.7.0
golang.org/x/sys v0.5.0
golang.org/x/term v0.5.0
golang.org/x/text v0.7.0
golang.org/x/crypto v0.7.0
golang.org/x/net v0.8.0
golang.org/x/sys v0.6.0
golang.org/x/term v0.6.0
golang.org/x/text v0.8.0
golang.zx2c4.com/wireguard v0.0.0-20220316235147-5aff28b14c24
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20220208144051-fde48d68ee68
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.28.1
google.golang.org/protobuf v1.30.0
gopkg.in/AlecAivazis/survey.v1 v1.8.8
gorm.io/driver/mysql v1.4.7
gorm.io/driver/postgres v1.4.8
gorm.io/driver/postgres v1.5.0
gorm.io/driver/sqlite v1.4.4
gorm.io/gorm v1.24.5
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11
gvisor.dev/gvisor v0.0.0-20220817001344-846276b3dbc5
modernc.org/sqlite v1.21.0
)
@@ -61,7 +61,7 @@ require (
github.com/BurntSushi/xgb v0.0.0-20201008132610-5f9e7b3c49cd // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/VirusTotal/vt-go v0.0.0-20210528074736-45bbe34cc8ab // indirect
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/awgh/cppgo v0.0.0-20210224085512-3d24bca8edc0 // indirect
github.com/awgh/rawreader v0.0.0-20200626064944-56820a9c6da4 // indirect
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
@@ -101,9 +101,9 @@ require (
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/thedevsaddam/gojsonq/v2 v2.5.2 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
golang.org/x/tools v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
gopkg.in/jcmturner/aescts.v1 v1.0.1 // indirect
+53 -48
View File
@@ -30,8 +30,8 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63n
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/VirusTotal/vt-go v0.0.0-20210528074736-45bbe34cc8ab h1:96tkQLYmgypA3W42fvC3UX3EoOP3hQZuT7d98lnnwyc=
github.com/VirusTotal/vt-go v0.0.0-20210528074736-45bbe34cc8ab/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
github.com/akamensky/argparse v1.2.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
github.com/akamensky/argparse v1.3.0/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
@@ -40,15 +40,16 @@ github.com/awgh/cppgo v0.0.0-20210224085512-3d24bca8edc0 h1:JjwxKkxzcBk4k8147g0e
github.com/awgh/cppgo v0.0.0-20210224085512-3d24bca8edc0/go.mod h1:IbERvuyb387Hppp8hX0SQTFt/mkej8+OhuS8L0nC2CI=
github.com/awgh/rawreader v0.0.0-20200626064944-56820a9c6da4 h1:cIAK2NNf2yafdgpFRNJrgZMwvy61BEVpGoHc2n4/yWs=
github.com/awgh/rawreader v0.0.0-20200626064944-56820a9c6da4/go.mod h1:SalMPBCab3yuID8nIhLfzwoBV+lBRyaC7NhuN8qL8xE=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cheggaaa/pb/v3 v3.1.0 h1:3uouEsl32RL7gTiQsuaXD4Bzbfl5tGztXGUvXbs4O04=
github.com/cheggaaa/pb/v3 v3.1.0/go.mod h1:YjrevcBqadFDaGQKRdmZxTY42pXEqda48Ea3lt0K/BE=
github.com/chromedp/cdproto v0.0.0-20230109101555-6b041c6303cc h1:pgBIUnhrsNh0Xi+8qUdHIP/nljIVz3laeRv23eqr45M=
github.com/chromedp/cdproto v0.0.0-20230109101555-6b041c6303cc/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
github.com/chromedp/chromedp v0.8.7 h1:dYOYc5ynTBzwSLOi+1IfgHwPr8r2BqV48l/RC+3OuJ0=
github.com/chromedp/chromedp v0.8.7/go.mod h1:iL+ywnwk3eG3EVXV1ackXBMNzdEh3Ye/KHvQkq1KRKU=
github.com/cheggaaa/pb/v3 v3.1.2 h1:FIxT3ZjOj9XJl0U4o2XbEhjFfZl7jCVCDOGq1ZAB7wQ=
github.com/cheggaaa/pb/v3 v3.1.2/go.mod h1:SNjnd0yKcW+kw0brSusraeDd5Bf1zBfxAzTL2ss3yQ4=
github.com/chromedp/cdproto v0.0.0-20230220211738-2b1ec77315c9 h1:wMSvdj3BswqfQOXp2R1bJOAE7xIQLt2dlMQDMf836VY=
github.com/chromedp/cdproto v0.0.0-20230220211738-2b1ec77315c9/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs=
github.com/chromedp/chromedp v0.9.1 h1:CC7cC5p1BeLiiS2gfNNPwp3OaUxtRMBjfiw3E3k6dFA=
github.com/chromedp/chromedp v0.9.1/go.mod h1:DUgZWRvYoEfgi66CgZ/9Yv+psgi+Sksy5DTScENWjaQ=
github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic=
github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
@@ -85,14 +86,14 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5 h1:Y5Q2mEwfzjMt5+3u70Gtw93ZOu2UuPeeeTBDntF7FoY=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5/go.mod h1:uF6rMu/1nvu+5DpiRLwusA6xB8zlkNoGzKn8lmYONUo=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
@@ -127,8 +128,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw=
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -153,8 +154,8 @@ github.com/jackc/pgx/v5 v5.3.0/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHo
github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8=
github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
github.com/jedib0t/go-pretty/v6 v6.4.4 h1:N+gz6UngBPF4M288kiMURPHELDMIhF/Em35aYuKrsSc=
github.com/jedib0t/go-pretty/v6 v6.4.4/go.mod h1:MgmISkTWDSFu0xOqiZ0mKNntMQ2mDgOcwOkwBEkMDJI=
github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1Rjl9Jw=
github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
@@ -170,7 +171,6 @@ github.com/kbinani/screenshot v0.0.0-20191211154542-3a185f1ce18f/go.mod h1:f8GY5
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
@@ -182,6 +182,7 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo=
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
github.com/lesnuages/go-winio v0.4.19 h1:lFDu1mnhg5em+8zTHO4ChSD11J56xkyE8m3N8IrVmbA=
github.com/lesnuages/go-winio v0.4.19/go.mod h1:rm7jf4kBcldxMeljR7c7XY1qVCBc+8z3PtSgkrT9Clk=
github.com/lesnuages/snitch v0.6.0 h1:vOao32MdYDHYDcTAq2CKszDh6Dn8Bv1Gmgc8uVh193U=
@@ -203,7 +204,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
@@ -214,8 +214,8 @@ github.com/mdlayher/netlink v1.6.0/go.mod h1:0o3PlBmGst1xve7wQ7j/hwpNaFaH4qCRyWC
github.com/mdlayher/socket v0.1.1/go.mod h1:mYV5YIZAfHh4dzDVzI8x8tWLWCliuX8Mon5Awbj+qDs=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/miekg/dns v1.1.51 h1:0+Xg7vObnhrz/4ZCZcZh7zPXlmU0aveS2HDBd0m0qSo=
github.com/miekg/dns v1.1.51/go.mod h1:2Z9d3CP1LQWihRZUf29mQ19yDThaI4DAYzte2CaQW5c=
github.com/miekg/dns v1.1.52 h1:Bmlc/qsNNULOe6bpXcUTsuOajd0DzRHwup6D9k1An0c=
github.com/miekg/dns v1.1.52/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY=
github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc=
github.com/moloch--/grumble v1.1.6 h1:FjPkuGOIwGL8nGkEH0EegnQgsl6Rn0R0fhBW/kcA0s8=
github.com/moloch--/grumble v1.1.6/go.mod h1:r7j3ShNy5EmOsegRD2DzTutIaGiLiA3M5yBTXXeLwcs=
@@ -224,6 +224,7 @@ github.com/moloch--/memmod v0.0.0-20211120144554-8b37cc654945/go.mod h1:1grVt4Ha
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw=
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
@@ -235,7 +236,6 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
@@ -268,16 +268,17 @@ github.com/thedevsaddam/gojsonq/v2 v2.5.2 h1:CoMVaYyKFsVj6TjU6APqAhAvC07hTI6IQen
github.com/thedevsaddam/gojsonq/v2 v2.5.2/go.mod h1:bv6Xa7kWy82uT0LnXPE2SzGqTj33TAEeR560MdJkiXs=
github.com/things-go/go-socks5 v0.0.3 h1:QtlIhkwDuLNCwW3wnt2uTjn1mQzpyjnwct2xdPuqroI=
github.com/things-go/go-socks5 v0.0.3/go.mod h1:f8Zx+n8kfzyT90hXM767cP6sysAud93+t9rV90IgMcg=
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
github.com/yiya1989/sshkrb5 v0.0.0-20201110125252-a1455b75a35e h1:6SWomM8ezwUwnN3lqKxE4r7bYVwpY9514DQkwBV9IPI=
github.com/yiya1989/sshkrb5 v0.0.0-20201110125252-a1455b75a35e/go.mod h1:r1bHcNa22x8rrg/Kj/cDF5bX6UtZrHiQgRFvj3Mnpl8=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -288,17 +289,19 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220208050332-20e1d8d225ab/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -313,10 +316,9 @@ golang.org/x/net v0.0.0-20211111083644-e5c967477495/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -349,6 +351,7 @@ golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -356,27 +359,27 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220207234003-57398862261d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -384,12 +387,13 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM=
golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -419,8 +423,8 @@ google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/AlecAivazis/survey.v1 v1.8.5/go.mod h1:iBNOmqKz/NUbZx3bA+4hAGLRC7fSK7tgtVDT4tB22XA=
gopkg.in/AlecAivazis/survey.v1 v1.8.8 h1:5UtTowJZTz1j7NxVzDGKTz6Lm9IWm8DDF6b7a2wq9VY=
gopkg.in/AlecAivazis/survey.v1 v1.8.8/go.mod h1:CaHjv79TCgAvXMSFJSVgonHXYWxnhzI3eoHtnX5UgUo=
@@ -440,20 +444,21 @@ gopkg.in/jcmturner/gokrb5.v7 v7.5.0/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuv
gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU=
gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.4.7 h1:rY46lkCspzGHn7+IYsNpSfEv9tA+SU4SkkB+GFX125Y=
gorm.io/driver/mysql v1.4.7/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc=
gorm.io/driver/postgres v1.4.8 h1:NDWizaclb7Q2aupT0jkwK8jx1HVCNzt+PQ8v/VnxviA=
gorm.io/driver/postgres v1.4.8/go.mod h1:O9MruWGNLUBUWVYfWuBClpf3HeGjOoybY0SNmCs3wsw=
gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U=
gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A=
gorm.io/driver/sqlite v1.4.4 h1:gIufGoR0dQzjkyqDyYSCvsYR6fba1Gw5YKDqKeChxFc=
gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.5 h1:g6OPREKqqlWq4kh/3MCQbZKImeB9e6Xgc4zD+JgNZGE=
gorm.io/gorm v1.24.5/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11 h1:9qNbmu21nNThCNnF5i2R3kw2aL27U8ZwbzccNjOmW0g=
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gvisor.dev/gvisor v0.0.0-20220817001344-846276b3dbc5 h1:cv/zaNV0nr1mJzaeo4S5mHIm5va1W0/9J3/5prlsuRM=
gvisor.dev/gvisor v0.0.0-20220817001344-846276b3dbc5/go.mod h1:TIvkJD0sxe8pIob3p6T8IzxXunlp6yfgktvTNp+DGNM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+16 -16
View File
@@ -37,12 +37,11 @@ const (
)
type WindowsExtension struct {
id string
data []byte
module *memmod.Module
arch string
init string
onFinish func([]byte)
id string
data []byte
module *memmod.Module
arch string
init string
sync.Mutex
}
@@ -101,8 +100,7 @@ func (w *WindowsExtension) Call(export string, arguments []byte, onFinish func([
if w.module == nil {
return errors.New("{{if .Config.Debug}} module not loaded {{end}}")
}
w.onFinish = onFinish
callback := syscall.NewCallback(w.extensionCallback)
callback := syscall.NewCallback(newWindowsExtensionCallback(onFinish))
exportPtr, err := w.module.ProcAddressByName(export)
if err != nil {
return err
@@ -127,13 +125,15 @@ func (w *WindowsExtension) Call(export string, arguments []byte, onFinish func([
return nil
}
// extensionCallback takes a buffer (char *) and its size (int) as parameters
// so we can pass data back to the Go process from the loaded DLL
func (w *WindowsExtension) extensionCallback(data uintptr, dataLen uintptr) uintptr {
outDataSize := int(dataLen)
outBytes := unsafe.Slice((*byte)(unsafe.Pointer(data)), outDataSize)
if dataLen > 0 {
w.onFinish(outBytes)
func newWindowsExtensionCallback(onFinish func([]byte)) func(data uintptr, dataLen uintptr) uintptr {
// extensionCallback takes a buffer (char *) and its size (int) as parameters
// so we can pass data back to the Go process from the loaded DLL
return func(data uintptr, dataLen uintptr) uintptr {
outDataSize := int(dataLen)
outBytes := unsafe.Slice((*byte)(unsafe.Pointer(data)), outDataSize)
if dataLen > 0 {
onFinish(outBytes)
}
return Success
}
return Success
}
+5
View File
@@ -612,6 +612,11 @@ func executeHandler(data []byte, resp RPCResponse) {
Err: fmt.Sprintf("%s", err),
}
}
go func() {
cmd.Wait()
}()
if cmd.Process != nil {
execResp.Pid = uint32(cmd.Process.Pid)
}
+70 -40
View File
@@ -394,13 +394,50 @@ func beaconMain(beacon *transports.Beacon, nextCheckin time.Time) error {
return nil
}
var tasksExtensionRegister []*sliverpb.Envelope
var tasksOther []*sliverpb.Envelope
for _, task := range tasks.Tasks {
switch task.Type {
case sliverpb.MsgRegisterExtensionReq:
tasksExtensionRegister = append(tasksExtensionRegister, task)
default:
tasksOther = append(tasksOther, task)
}
}
// ensure extensions are registered before they are called
var results []*sliverpb.Envelope
for _, r := range beaconHandleTasklist(tasksExtensionRegister) {
results = append(results, r)
}
for _, r := range beaconHandleTasklist(tasksOther) {
results = append(results, r)
}
err = beacon.Send(wrapEnvelope(sliverpb.MsgBeaconTasks, &sliverpb.BeaconTasks{
ID: InstanceID,
Tasks: results,
}))
if err != nil {
// {{if .Config.Debug}}
log.Printf("[beacon] error sending results %s", err)
// {{end}}
}
// {{if .Config.Debug}}
log.Printf("[beacon] all results sent to server, cleanup ...")
// {{end}}
return nil
}
func beaconHandleTasklist(tasks []*sliverpb.Envelope) []*sliverpb.Envelope {
results := []*sliverpb.Envelope{}
resultsMutex := &sync.Mutex{}
wg := &sync.WaitGroup{}
sysHandlers := handlers.GetSystemHandlers()
specHandlers := handlers.GetSpecialHandlers()
for _, task := range tasks.Tasks {
for _, task := range tasks {
// {{if .Config.Debug}}
log.Printf("[beacon] execute task %d", task.Type)
// {{end}}
@@ -409,37 +446,41 @@ func beaconMain(beacon *transports.Beacon, nextCheckin time.Time) error {
data := task.Data
taskID := task.ID
// {{if eq .Config.GOOS "windows" }}
go handlers.WrapperHandler(handler, data, func(data []byte, err error) {
resultsMutex.Lock()
defer resultsMutex.Unlock()
go func() {
defer wg.Done()
// {{if .Config.Debug}}
if err != nil {
log.Printf("[beacon] handler function returned an error: %s", err)
}
log.Printf("[beacon] task completed (id: %d)", taskID)
// {{end}}
results = append(results, &sliverpb.Envelope{
ID: taskID,
Data: data,
handlers.WrapperHandler(handler, data, func(data []byte, err error) {
resultsMutex.Lock()
defer resultsMutex.Unlock()
// {{if .Config.Debug}}
if err != nil {
log.Printf("[beacon] handler function returned an error: %s", err)
}
log.Printf("[beacon] task completed (id: %d)", taskID)
// {{end}}
results = append(results, &sliverpb.Envelope{
ID: taskID,
Data: data,
})
})
})
}()
// {{else}}
go handler(data, func(data []byte, err error) {
resultsMutex.Lock()
defer resultsMutex.Unlock()
go func() {
defer wg.Done()
// {{if .Config.Debug}}
if err != nil {
log.Printf("[beacon] handler function returned an error: %s", err)
}
log.Printf("[beacon] task completed (id: %d)", taskID)
// {{end}}
results = append(results, &sliverpb.Envelope{
ID: taskID,
Data: data,
handler(data, func(data []byte, err error) {
resultsMutex.Lock()
defer resultsMutex.Unlock()
// {{if .Config.Debug}}
if err != nil {
log.Printf("[beacon] handler function returned an error: %s", err)
}
log.Printf("[beacon] task completed (id: %d)", taskID)
// {{end}}
results = append(results, &sliverpb.Envelope{
ID: taskID,
Data: data,
})
})
})
}()
// {{end}}
} else if task.Type == sliverpb.MsgOpenSession {
go openSessionHandler(task.Data)
@@ -461,6 +502,7 @@ func beaconMain(beacon *transports.Beacon, nextCheckin time.Time) error {
resultsMutex.Unlock()
}
}
// {{if .Config.Debug}}
log.Printf("[beacon] waiting for task(s) to complete ...")
// {{end}}
@@ -469,19 +511,7 @@ func beaconMain(beacon *transports.Beacon, nextCheckin time.Time) error {
log.Printf("[beacon] all tasks completed, sending results to server")
// {{end}}
err = beacon.Send(wrapEnvelope(sliverpb.MsgBeaconTasks, &sliverpb.BeaconTasks{
ID: InstanceID,
Tasks: results,
}))
if err != nil {
// {{if .Config.Debug}}
log.Printf("[beacon] error sending results %s", err)
// {{end}}
}
// {{if .Config.Debug}}
log.Printf("[beacon] all results sent to server, cleanup ...")
// {{end}}
return nil
return results
}
func openSessionHandler(data []byte) {
+1
View File
@@ -1,2 +1,3 @@
.DS_Store
.*.sw?
/coverage.txt
+3
View File
@@ -0,0 +1,3 @@
{
"settingsInheritedFrom": "VividCortex/whitesource-config@master"
}
+17 -12
View File
@@ -1,4 +1,8 @@
# EWMA [![GoDoc](https://godoc.org/github.com/VividCortex/ewma?status.svg)](https://godoc.org/github.com/VividCortex/ewma) ![Build Status](https://circleci.com/gh/VividCortex/moving_average.png?circle-token=1459fa37f9ca0e50cef05d1963146d96d47ea523)
# EWMA
[![GoDoc](https://godoc.org/github.com/VividCortex/ewma?status.svg)](https://godoc.org/github.com/VividCortex/ewma)
![build](https://github.com/VividCortex/ewma/workflows/build/badge.svg)
[![codecov](https://codecov.io/gh/VividCortex/ewma/branch/master/graph/badge.svg)](https://codecov.io/gh/VividCortex/ewma)
This repo provides Exponentially Weighted Moving Average algorithms, or EWMAs for short, [based on our
Quantifying Abnormal Behavior talk](https://vividcortex.com/blog/2013/07/23/a-fast-go-library-for-exponential-moving-averages/).
@@ -103,23 +107,24 @@ View the GoDoc generated documentation [here](http://godoc.org/github.com/VividC
```go
package main
import "github.com/VividCortex/ewma"
func main() {
samples := [100]float64{
4599, 5711, 4746, 4621, 5037, 4218, 4925, 4281, 5207, 5203, 5594, 5149,
}
samples := [100]float64{
4599, 5711, 4746, 4621, 5037, 4218, 4925, 4281, 5207, 5203, 5594, 5149,
}
e := ewma.NewMovingAverage() //=> Returns a SimpleEWMA if called without params
a := ewma.NewMovingAverage(5) //=> returns a VariableEWMA with a decay of 2 / (5 + 1)
e := ewma.NewMovingAverage() //=> Returns a SimpleEWMA if called without params
a := ewma.NewMovingAverage(5) //=> returns a VariableEWMA with a decay of 2 / (5 + 1)
for _, f := range samples {
e.Add(f)
a.Add(f)
}
for _, f := range samples {
e.Add(f)
a.Add(f)
}
e.Value() //=> 13.577404704631077
a.Value() //=> 1.5806140565521463e-12
e.Value() //=> 13.577404704631077
a.Value() //=> 1.5806140565521463e-12
}
```
+6
View File
@@ -0,0 +1,6 @@
coverage:
status:
project:
default:
threshold: 15%
patch: off
+2 -2
View File
@@ -53,7 +53,7 @@ type GetPartialAXTreeParams struct {
NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node to get the partial accessibility tree for.
BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node to get the partial accessibility tree for.
ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node wrapper to get the partial accessibility tree for.
FetchRelatives bool `json:"fetchRelatives,omitempty"` // Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
FetchRelatives bool `json:"fetchRelatives,omitempty"` // Whether to fetch this node's ancestors, siblings and children. Defaults to true.
}
// GetPartialAXTree fetches the accessibility node and partial accessibility
@@ -87,7 +87,7 @@ func (p GetPartialAXTreeParams) WithObjectID(objectID runtime.RemoteObjectID) *G
return &p
}
// WithFetchRelatives whether to fetch this nodes ancestors, siblings and
// WithFetchRelatives whether to fetch this node's ancestors, siblings and
// children. Defaults to true.
func (p GetPartialAXTreeParams) WithFetchRelatives(fetchRelatives bool) *GetPartialAXTreeParams {
p.FetchRelatives = fetchRelatives
+2 -2
View File
@@ -1824,7 +1824,7 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoAudits17(in *jlexer.Lexer, ou
(*out.SourceCodeLocation).UnmarshalEasyJSON(in)
}
case "type":
(out.Type).UnmarshalEasyJSON(in)
out.Type = string(in.String())
default:
in.SkipRecursive()
}
@@ -1862,7 +1862,7 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoAudits17(out *jwriter.Writer,
{
const prefix string = ",\"type\":"
out.RawString(prefix)
(in.Type).MarshalEasyJSON(out)
out.String(string(in.Type))
}
out.RawByte('}')
}
+29 -209
View File
@@ -919,8 +919,16 @@ func (t GenericIssueErrorType) String() string {
// GenericIssueErrorType values.
const (
GenericIssueErrorTypeCrossOriginPortalPostMessageError GenericIssueErrorType = "CrossOriginPortalPostMessageError"
GenericIssueErrorTypeFormLabelForNameError GenericIssueErrorType = "FormLabelForNameError"
GenericIssueErrorTypeCrossOriginPortalPostMessageError GenericIssueErrorType = "CrossOriginPortalPostMessageError"
GenericIssueErrorTypeFormLabelForNameError GenericIssueErrorType = "FormLabelForNameError"
GenericIssueErrorTypeFormDuplicateIDForInputError GenericIssueErrorType = "FormDuplicateIdForInputError"
GenericIssueErrorTypeFormInputWithNoLabelError GenericIssueErrorType = "FormInputWithNoLabelError"
GenericIssueErrorTypeFormAutocompleteAttributeEmptyError GenericIssueErrorType = "FormAutocompleteAttributeEmptyError"
GenericIssueErrorTypeFormEmptyIDAndNameAttributesForInputError GenericIssueErrorType = "FormEmptyIdAndNameAttributesForInputError"
GenericIssueErrorTypeFormAriaLabelledByToNonExistingID GenericIssueErrorType = "FormAriaLabelledByToNonExistingId"
GenericIssueErrorTypeFormInputAssignedAutocompleteValueToIDOrNameAttributeError GenericIssueErrorType = "FormInputAssignedAutocompleteValueToIdOrNameAttributeError"
GenericIssueErrorTypeFormLabelHasNeitherForNorNestedInput GenericIssueErrorType = "FormLabelHasNeitherForNorNestedInput"
GenericIssueErrorTypeFormLabelForMatchesNonExistingIDError GenericIssueErrorType = "FormLabelForMatchesNonExistingIdError"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
@@ -941,6 +949,22 @@ func (t *GenericIssueErrorType) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = GenericIssueErrorTypeCrossOriginPortalPostMessageError
case GenericIssueErrorTypeFormLabelForNameError:
*t = GenericIssueErrorTypeFormLabelForNameError
case GenericIssueErrorTypeFormDuplicateIDForInputError:
*t = GenericIssueErrorTypeFormDuplicateIDForInputError
case GenericIssueErrorTypeFormInputWithNoLabelError:
*t = GenericIssueErrorTypeFormInputWithNoLabelError
case GenericIssueErrorTypeFormAutocompleteAttributeEmptyError:
*t = GenericIssueErrorTypeFormAutocompleteAttributeEmptyError
case GenericIssueErrorTypeFormEmptyIDAndNameAttributesForInputError:
*t = GenericIssueErrorTypeFormEmptyIDAndNameAttributesForInputError
case GenericIssueErrorTypeFormAriaLabelledByToNonExistingID:
*t = GenericIssueErrorTypeFormAriaLabelledByToNonExistingID
case GenericIssueErrorTypeFormInputAssignedAutocompleteValueToIDOrNameAttributeError:
*t = GenericIssueErrorTypeFormInputAssignedAutocompleteValueToIDOrNameAttributeError
case GenericIssueErrorTypeFormLabelHasNeitherForNorNestedInput:
*t = GenericIssueErrorTypeFormLabelHasNeitherForNorNestedInput
case GenericIssueErrorTypeFormLabelForMatchesNonExistingIDError:
*t = GenericIssueErrorTypeFormLabelForMatchesNonExistingIDError
default:
in.AddError(fmt.Errorf("unknown GenericIssueErrorType value: %v", v))
@@ -962,219 +986,15 @@ type GenericIssueDetails struct {
ViolatingNodeID cdp.BackendNodeID `json:"violatingNodeId,omitempty"`
}
// DeprecationIssueType [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Audits#type-DeprecationIssueType
type DeprecationIssueType string
// String returns the DeprecationIssueType as string value.
func (t DeprecationIssueType) String() string {
return string(t)
}
// DeprecationIssueType values.
const (
DeprecationIssueTypeAuthorizationCoveredByWildcard DeprecationIssueType = "AuthorizationCoveredByWildcard"
DeprecationIssueTypeCanRequestURLHTTPContainingNewline DeprecationIssueType = "CanRequestURLHTTPContainingNewline"
DeprecationIssueTypeChromeLoadTimesConnectionInfo DeprecationIssueType = "ChromeLoadTimesConnectionInfo"
DeprecationIssueTypeChromeLoadTimesFirstPaintAfterLoadTime DeprecationIssueType = "ChromeLoadTimesFirstPaintAfterLoadTime"
DeprecationIssueTypeChromeLoadTimesWasAlternateProtocolAvailable DeprecationIssueType = "ChromeLoadTimesWasAlternateProtocolAvailable"
DeprecationIssueTypeCookieWithTruncatingChar DeprecationIssueType = "CookieWithTruncatingChar"
DeprecationIssueTypeCrossOriginAccessBasedOnDocumentDomain DeprecationIssueType = "CrossOriginAccessBasedOnDocumentDomain"
DeprecationIssueTypeCrossOriginWindowAlert DeprecationIssueType = "CrossOriginWindowAlert"
DeprecationIssueTypeCrossOriginWindowConfirm DeprecationIssueType = "CrossOriginWindowConfirm"
DeprecationIssueTypeCSSSelectorInternalMediaControlsOverlayCastButton DeprecationIssueType = "CSSSelectorInternalMediaControlsOverlayCastButton"
DeprecationIssueTypeDeprecationExample DeprecationIssueType = "DeprecationExample"
DeprecationIssueTypeDocumentDomainSettingWithoutOriginAgentClusterHeader DeprecationIssueType = "DocumentDomainSettingWithoutOriginAgentClusterHeader"
DeprecationIssueTypeEventPath DeprecationIssueType = "EventPath"
DeprecationIssueTypeExpectCTHeader DeprecationIssueType = "ExpectCTHeader"
DeprecationIssueTypeGeolocationInsecureOrigin DeprecationIssueType = "GeolocationInsecureOrigin"
DeprecationIssueTypeGeolocationInsecureOriginDeprecatedNotRemoved DeprecationIssueType = "GeolocationInsecureOriginDeprecatedNotRemoved"
DeprecationIssueTypeGetUserMediaInsecureOrigin DeprecationIssueType = "GetUserMediaInsecureOrigin"
DeprecationIssueTypeHostCandidateAttributeGetter DeprecationIssueType = "HostCandidateAttributeGetter"
DeprecationIssueTypeIdentityInCanMakePaymentEvent DeprecationIssueType = "IdentityInCanMakePaymentEvent"
DeprecationIssueTypeInsecurePrivateNetworkSubresourceRequest DeprecationIssueType = "InsecurePrivateNetworkSubresourceRequest"
DeprecationIssueTypeLocalCSSFileExtensionRejected DeprecationIssueType = "LocalCSSFileExtensionRejected"
DeprecationIssueTypeMediaSourceAbortRemove DeprecationIssueType = "MediaSourceAbortRemove"
DeprecationIssueTypeMediaSourceDurationTruncatingBuffered DeprecationIssueType = "MediaSourceDurationTruncatingBuffered"
DeprecationIssueTypeNoSysexWebMIDIWithoutPermission DeprecationIssueType = "NoSysexWebMIDIWithoutPermission"
DeprecationIssueTypeNotificationInsecureOrigin DeprecationIssueType = "NotificationInsecureOrigin"
DeprecationIssueTypeNotificationPermissionRequestedIframe DeprecationIssueType = "NotificationPermissionRequestedIframe"
DeprecationIssueTypeObsoleteWebRtcCipherSuite DeprecationIssueType = "ObsoleteWebRtcCipherSuite"
DeprecationIssueTypeOpenWebDatabaseInsecureContext DeprecationIssueType = "OpenWebDatabaseInsecureContext"
DeprecationIssueTypeOverflowVisibleOnReplacedElement DeprecationIssueType = "OverflowVisibleOnReplacedElement"
DeprecationIssueTypePaymentInstruments DeprecationIssueType = "PaymentInstruments"
DeprecationIssueTypePaymentRequestCSPViolation DeprecationIssueType = "PaymentRequestCSPViolation"
DeprecationIssueTypePersistentQuotaType DeprecationIssueType = "PersistentQuotaType"
DeprecationIssueTypePictureSourceSrc DeprecationIssueType = "PictureSourceSrc"
DeprecationIssueTypePrefixedCancelAnimationFrame DeprecationIssueType = "PrefixedCancelAnimationFrame"
DeprecationIssueTypePrefixedRequestAnimationFrame DeprecationIssueType = "PrefixedRequestAnimationFrame"
DeprecationIssueTypePrefixedStorageInfo DeprecationIssueType = "PrefixedStorageInfo"
DeprecationIssueTypePrefixedVideoDisplayingFullscreen DeprecationIssueType = "PrefixedVideoDisplayingFullscreen"
DeprecationIssueTypePrefixedVideoEnterFullscreen DeprecationIssueType = "PrefixedVideoEnterFullscreen"
DeprecationIssueTypePrefixedVideoEnterFullScreen DeprecationIssueType = "PrefixedVideoEnterFullScreen"
DeprecationIssueTypePrefixedVideoExitFullscreen DeprecationIssueType = "PrefixedVideoExitFullscreen"
DeprecationIssueTypePrefixedVideoExitFullScreen DeprecationIssueType = "PrefixedVideoExitFullScreen"
DeprecationIssueTypePrefixedVideoSupportsFullscreen DeprecationIssueType = "PrefixedVideoSupportsFullscreen"
DeprecationIssueTypeRangeExpand DeprecationIssueType = "RangeExpand"
DeprecationIssueTypeRequestedSubresourceWithEmbeddedCredentials DeprecationIssueType = "RequestedSubresourceWithEmbeddedCredentials"
DeprecationIssueTypeRTCConstraintEnableDtlsSrtpFalse DeprecationIssueType = "RTCConstraintEnableDtlsSrtpFalse"
DeprecationIssueTypeRTCConstraintEnableDtlsSrtpTrue DeprecationIssueType = "RTCConstraintEnableDtlsSrtpTrue"
DeprecationIssueTypeRTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics DeprecationIssueType = "RTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics"
DeprecationIssueTypeRTCPeerConnectionSdpSemanticsPlanB DeprecationIssueType = "RTCPeerConnectionSdpSemanticsPlanB"
DeprecationIssueTypeRtcpMuxPolicyNegotiate DeprecationIssueType = "RtcpMuxPolicyNegotiate"
DeprecationIssueTypeSharedArrayBufferConstructedWithoutIsolation DeprecationIssueType = "SharedArrayBufferConstructedWithoutIsolation"
DeprecationIssueTypeTextToSpeechDisallowedByAutoplay DeprecationIssueType = "TextToSpeech_DisallowedByAutoplay"
DeprecationIssueTypeV8sharedArrayBufferConstructedInExtensionWithoutIsolation DeprecationIssueType = "V8SharedArrayBufferConstructedInExtensionWithoutIsolation"
DeprecationIssueTypeXHRJSONEncodingDetection DeprecationIssueType = "XHRJSONEncodingDetection"
DeprecationIssueTypeXMLHTTPRequestSynchronousInNonWorkerOutsideBeforeUnload DeprecationIssueType = "XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload"
DeprecationIssueTypeXRSupportsSession DeprecationIssueType = "XRSupportsSession"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t DeprecationIssueType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t DeprecationIssueType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *DeprecationIssueType) UnmarshalEasyJSON(in *jlexer.Lexer) {
v := in.String()
switch DeprecationIssueType(v) {
case DeprecationIssueTypeAuthorizationCoveredByWildcard:
*t = DeprecationIssueTypeAuthorizationCoveredByWildcard
case DeprecationIssueTypeCanRequestURLHTTPContainingNewline:
*t = DeprecationIssueTypeCanRequestURLHTTPContainingNewline
case DeprecationIssueTypeChromeLoadTimesConnectionInfo:
*t = DeprecationIssueTypeChromeLoadTimesConnectionInfo
case DeprecationIssueTypeChromeLoadTimesFirstPaintAfterLoadTime:
*t = DeprecationIssueTypeChromeLoadTimesFirstPaintAfterLoadTime
case DeprecationIssueTypeChromeLoadTimesWasAlternateProtocolAvailable:
*t = DeprecationIssueTypeChromeLoadTimesWasAlternateProtocolAvailable
case DeprecationIssueTypeCookieWithTruncatingChar:
*t = DeprecationIssueTypeCookieWithTruncatingChar
case DeprecationIssueTypeCrossOriginAccessBasedOnDocumentDomain:
*t = DeprecationIssueTypeCrossOriginAccessBasedOnDocumentDomain
case DeprecationIssueTypeCrossOriginWindowAlert:
*t = DeprecationIssueTypeCrossOriginWindowAlert
case DeprecationIssueTypeCrossOriginWindowConfirm:
*t = DeprecationIssueTypeCrossOriginWindowConfirm
case DeprecationIssueTypeCSSSelectorInternalMediaControlsOverlayCastButton:
*t = DeprecationIssueTypeCSSSelectorInternalMediaControlsOverlayCastButton
case DeprecationIssueTypeDeprecationExample:
*t = DeprecationIssueTypeDeprecationExample
case DeprecationIssueTypeDocumentDomainSettingWithoutOriginAgentClusterHeader:
*t = DeprecationIssueTypeDocumentDomainSettingWithoutOriginAgentClusterHeader
case DeprecationIssueTypeEventPath:
*t = DeprecationIssueTypeEventPath
case DeprecationIssueTypeExpectCTHeader:
*t = DeprecationIssueTypeExpectCTHeader
case DeprecationIssueTypeGeolocationInsecureOrigin:
*t = DeprecationIssueTypeGeolocationInsecureOrigin
case DeprecationIssueTypeGeolocationInsecureOriginDeprecatedNotRemoved:
*t = DeprecationIssueTypeGeolocationInsecureOriginDeprecatedNotRemoved
case DeprecationIssueTypeGetUserMediaInsecureOrigin:
*t = DeprecationIssueTypeGetUserMediaInsecureOrigin
case DeprecationIssueTypeHostCandidateAttributeGetter:
*t = DeprecationIssueTypeHostCandidateAttributeGetter
case DeprecationIssueTypeIdentityInCanMakePaymentEvent:
*t = DeprecationIssueTypeIdentityInCanMakePaymentEvent
case DeprecationIssueTypeInsecurePrivateNetworkSubresourceRequest:
*t = DeprecationIssueTypeInsecurePrivateNetworkSubresourceRequest
case DeprecationIssueTypeLocalCSSFileExtensionRejected:
*t = DeprecationIssueTypeLocalCSSFileExtensionRejected
case DeprecationIssueTypeMediaSourceAbortRemove:
*t = DeprecationIssueTypeMediaSourceAbortRemove
case DeprecationIssueTypeMediaSourceDurationTruncatingBuffered:
*t = DeprecationIssueTypeMediaSourceDurationTruncatingBuffered
case DeprecationIssueTypeNoSysexWebMIDIWithoutPermission:
*t = DeprecationIssueTypeNoSysexWebMIDIWithoutPermission
case DeprecationIssueTypeNotificationInsecureOrigin:
*t = DeprecationIssueTypeNotificationInsecureOrigin
case DeprecationIssueTypeNotificationPermissionRequestedIframe:
*t = DeprecationIssueTypeNotificationPermissionRequestedIframe
case DeprecationIssueTypeObsoleteWebRtcCipherSuite:
*t = DeprecationIssueTypeObsoleteWebRtcCipherSuite
case DeprecationIssueTypeOpenWebDatabaseInsecureContext:
*t = DeprecationIssueTypeOpenWebDatabaseInsecureContext
case DeprecationIssueTypeOverflowVisibleOnReplacedElement:
*t = DeprecationIssueTypeOverflowVisibleOnReplacedElement
case DeprecationIssueTypePaymentInstruments:
*t = DeprecationIssueTypePaymentInstruments
case DeprecationIssueTypePaymentRequestCSPViolation:
*t = DeprecationIssueTypePaymentRequestCSPViolation
case DeprecationIssueTypePersistentQuotaType:
*t = DeprecationIssueTypePersistentQuotaType
case DeprecationIssueTypePictureSourceSrc:
*t = DeprecationIssueTypePictureSourceSrc
case DeprecationIssueTypePrefixedCancelAnimationFrame:
*t = DeprecationIssueTypePrefixedCancelAnimationFrame
case DeprecationIssueTypePrefixedRequestAnimationFrame:
*t = DeprecationIssueTypePrefixedRequestAnimationFrame
case DeprecationIssueTypePrefixedStorageInfo:
*t = DeprecationIssueTypePrefixedStorageInfo
case DeprecationIssueTypePrefixedVideoDisplayingFullscreen:
*t = DeprecationIssueTypePrefixedVideoDisplayingFullscreen
case DeprecationIssueTypePrefixedVideoEnterFullscreen:
*t = DeprecationIssueTypePrefixedVideoEnterFullscreen
case DeprecationIssueTypePrefixedVideoEnterFullScreen:
*t = DeprecationIssueTypePrefixedVideoEnterFullScreen
case DeprecationIssueTypePrefixedVideoExitFullscreen:
*t = DeprecationIssueTypePrefixedVideoExitFullscreen
case DeprecationIssueTypePrefixedVideoExitFullScreen:
*t = DeprecationIssueTypePrefixedVideoExitFullScreen
case DeprecationIssueTypePrefixedVideoSupportsFullscreen:
*t = DeprecationIssueTypePrefixedVideoSupportsFullscreen
case DeprecationIssueTypeRangeExpand:
*t = DeprecationIssueTypeRangeExpand
case DeprecationIssueTypeRequestedSubresourceWithEmbeddedCredentials:
*t = DeprecationIssueTypeRequestedSubresourceWithEmbeddedCredentials
case DeprecationIssueTypeRTCConstraintEnableDtlsSrtpFalse:
*t = DeprecationIssueTypeRTCConstraintEnableDtlsSrtpFalse
case DeprecationIssueTypeRTCConstraintEnableDtlsSrtpTrue:
*t = DeprecationIssueTypeRTCConstraintEnableDtlsSrtpTrue
case DeprecationIssueTypeRTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics:
*t = DeprecationIssueTypeRTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics
case DeprecationIssueTypeRTCPeerConnectionSdpSemanticsPlanB:
*t = DeprecationIssueTypeRTCPeerConnectionSdpSemanticsPlanB
case DeprecationIssueTypeRtcpMuxPolicyNegotiate:
*t = DeprecationIssueTypeRtcpMuxPolicyNegotiate
case DeprecationIssueTypeSharedArrayBufferConstructedWithoutIsolation:
*t = DeprecationIssueTypeSharedArrayBufferConstructedWithoutIsolation
case DeprecationIssueTypeTextToSpeechDisallowedByAutoplay:
*t = DeprecationIssueTypeTextToSpeechDisallowedByAutoplay
case DeprecationIssueTypeV8sharedArrayBufferConstructedInExtensionWithoutIsolation:
*t = DeprecationIssueTypeV8sharedArrayBufferConstructedInExtensionWithoutIsolation
case DeprecationIssueTypeXHRJSONEncodingDetection:
*t = DeprecationIssueTypeXHRJSONEncodingDetection
case DeprecationIssueTypeXMLHTTPRequestSynchronousInNonWorkerOutsideBeforeUnload:
*t = DeprecationIssueTypeXMLHTTPRequestSynchronousInNonWorkerOutsideBeforeUnload
case DeprecationIssueTypeXRSupportsSession:
*t = DeprecationIssueTypeXRSupportsSession
default:
in.AddError(fmt.Errorf("unknown DeprecationIssueType value: %v", v))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *DeprecationIssueType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// DeprecationIssueDetails this issue tracks information needed to print a
// deprecation message.
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/third_party/blink/renderer/core/frame/deprecation/README.md.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Audits#type-DeprecationIssueDetails
type DeprecationIssueDetails struct {
AffectedFrame *AffectedFrame `json:"affectedFrame,omitempty"`
SourceCodeLocation *SourceCodeLocation `json:"sourceCodeLocation"`
Type DeprecationIssueType `json:"type"`
AffectedFrame *AffectedFrame `json:"affectedFrame,omitempty"`
SourceCodeLocation *SourceCodeLocation `json:"sourceCodeLocation"`
Type string `json:"type"` // One of the deprecation names from third_party/blink/renderer/core/frame/deprecation/deprecation.json5
}
// ClientHintIssueReason [no description].
+4 -4
View File
@@ -319,7 +319,7 @@ func (p *GetBrowserCommandLineParams) Do(ctx context.Context) (arguments []strin
// GetHistogramsParams get Chrome histograms.
type GetHistogramsParams struct {
Query string `json:"query,omitempty"` // Requested substring in name. Only histograms which have query as a substring in their name are extracted. An empty or absent query returns all histograms.
Delta bool `json:"delta,omitempty"` // If true, retrieve delta since last call.
Delta bool `json:"delta,omitempty"` // If true, retrieve delta since last delta call.
}
// GetHistograms get Chrome histograms.
@@ -339,7 +339,7 @@ func (p GetHistogramsParams) WithQuery(query string) *GetHistogramsParams {
return &p
}
// WithDelta if true, retrieve delta since last call.
// WithDelta if true, retrieve delta since last delta call.
func (p GetHistogramsParams) WithDelta(delta bool) *GetHistogramsParams {
p.Delta = delta
return &p
@@ -369,7 +369,7 @@ func (p *GetHistogramsParams) Do(ctx context.Context) (histograms []*Histogram,
// GetHistogramParams get a Chrome histogram by name.
type GetHistogramParams struct {
Name string `json:"name"` // Requested histogram name.
Delta bool `json:"delta,omitempty"` // If true, retrieve delta since last call.
Delta bool `json:"delta,omitempty"` // If true, retrieve delta since last delta call.
}
// GetHistogram get a Chrome histogram by name.
@@ -385,7 +385,7 @@ func GetHistogram(name string) *GetHistogramParams {
}
}
// WithDelta if true, retrieve delta since last call.
// WithDelta if true, retrieve delta since last delta call.
func (p GetHistogramParams) WithDelta(delta bool) *GetHistogramParams {
p.Delta = delta
return &p
+50 -4
View File
@@ -23,6 +23,7 @@ import (
"github.com/chromedp/cdproto/css"
"github.com/chromedp/cdproto/database"
"github.com/chromedp/cdproto/debugger"
"github.com/chromedp/cdproto/deviceaccess"
"github.com/chromedp/cdproto/deviceorientation"
"github.com/chromedp/cdproto/dom"
"github.com/chromedp/cdproto/domdebugger"
@@ -46,6 +47,7 @@ import (
"github.com/chromedp/cdproto/page"
"github.com/chromedp/cdproto/performance"
"github.com/chromedp/cdproto/performancetimeline"
"github.com/chromedp/cdproto/preload"
"github.com/chromedp/cdproto/profiler"
"github.com/chromedp/cdproto/runtime"
"github.com/chromedp/cdproto/security"
@@ -299,6 +301,11 @@ const (
EventDebuggerResumed = "Debugger.resumed"
EventDebuggerScriptFailedToParse = "Debugger.scriptFailedToParse"
EventDebuggerScriptParsed = "Debugger.scriptParsed"
CommandDeviceAccessEnable = deviceaccess.CommandEnable
CommandDeviceAccessDisable = deviceaccess.CommandDisable
CommandDeviceAccessSelectPrompt = deviceaccess.CommandSelectPrompt
CommandDeviceAccessCancelPrompt = deviceaccess.CommandCancelPrompt
EventDeviceAccessDeviceRequestPrompted = "DeviceAccess.deviceRequestPrompted"
CommandDeviceOrientationClearDeviceOrientationOverride = deviceorientation.CommandClearDeviceOrientationOverride
CommandDeviceOrientationSetDeviceOrientationOverride = deviceorientation.CommandSetDeviceOrientationOverride
CommandEmulationCanEmulate = emulation.CommandCanEmulate
@@ -518,7 +525,6 @@ const (
CommandPageEnable = page.CommandEnable
CommandPageGetAppManifest = page.CommandGetAppManifest
CommandPageGetInstallabilityErrors = page.CommandGetInstallabilityErrors
CommandPageGetManifestIcons = page.CommandGetManifestIcons
CommandPageGetAppID = page.CommandGetAppID
CommandPageGetAdScriptID = page.CommandGetAdScriptID
CommandPageGetFrameTree = page.CommandGetFrameTree
@@ -553,6 +559,7 @@ const (
CommandPageAddCompilationCache = page.CommandAddCompilationCache
CommandPageClearCompilationCache = page.CommandClearCompilationCache
CommandPageSetSPCTransactionMode = page.CommandSetSPCTransactionMode
CommandPageSetRPHRegistrationMode = page.CommandSetRPHRegistrationMode
CommandPageGenerateTestReport = page.CommandGenerateTestReport
CommandPageWaitForDebugger = page.CommandWaitForDebugger
CommandPageSetInterceptFileChooserDialog = page.CommandSetInterceptFileChooserDialog
@@ -573,6 +580,8 @@ const (
EventPageLifecycleEvent = "Page.lifecycleEvent"
EventPageBackForwardCacheNotUsed = "Page.backForwardCacheNotUsed"
EventPagePrerenderAttemptCompleted = "Page.prerenderAttemptCompleted"
EventPagePrefetchStatusUpdated = "Page.prefetchStatusUpdated"
EventPagePrerenderStatusUpdated = "Page.prerenderStatusUpdated"
EventPageLoadEventFired = "Page.loadEventFired"
EventPageNavigatedWithinDocument = "Page.navigatedWithinDocument"
EventPageScreencastFrame = "Page.screencastFrame"
@@ -585,6 +594,10 @@ const (
EventPerformanceMetrics = "Performance.metrics"
CommandPerformanceTimelineEnable = performancetimeline.CommandEnable
EventPerformanceTimelineTimelineEventAdded = "PerformanceTimeline.timelineEventAdded"
CommandPreloadEnable = preload.CommandEnable
CommandPreloadDisable = preload.CommandDisable
EventPreloadRuleSetUpdated = "Preload.ruleSetUpdated"
EventPreloadRuleSetRemoved = "Preload.ruleSetRemoved"
CommandProfilerDisable = profiler.CommandDisable
CommandProfilerEnable = profiler.CommandEnable
CommandProfilerGetBestEffortCoverage = profiler.CommandGetBestEffortCoverage
@@ -1448,6 +1461,21 @@ func UnmarshalMessage(msg *Message) (interface{}, error) {
case EventDebuggerScriptParsed:
v = new(debugger.EventScriptParsed)
case CommandDeviceAccessEnable:
return emptyVal, nil
case CommandDeviceAccessDisable:
return emptyVal, nil
case CommandDeviceAccessSelectPrompt:
return emptyVal, nil
case CommandDeviceAccessCancelPrompt:
return emptyVal, nil
case EventDeviceAccessDeviceRequestPrompted:
v = new(deviceaccess.EventDeviceRequestPrompted)
case CommandDeviceOrientationClearDeviceOrientationOverride:
return emptyVal, nil
@@ -2105,9 +2133,6 @@ func UnmarshalMessage(msg *Message) (interface{}, error) {
case CommandPageGetInstallabilityErrors:
v = new(page.GetInstallabilityErrorsReturns)
case CommandPageGetManifestIcons:
v = new(page.GetManifestIconsReturns)
case CommandPageGetAppID:
v = new(page.GetAppIDReturns)
@@ -2210,6 +2235,9 @@ func UnmarshalMessage(msg *Message) (interface{}, error) {
case CommandPageSetSPCTransactionMode:
return emptyVal, nil
case CommandPageSetRPHRegistrationMode:
return emptyVal, nil
case CommandPageGenerateTestReport:
return emptyVal, nil
@@ -2270,6 +2298,12 @@ func UnmarshalMessage(msg *Message) (interface{}, error) {
case EventPagePrerenderAttemptCompleted:
v = new(page.EventPrerenderAttemptCompleted)
case EventPagePrefetchStatusUpdated:
v = new(page.EventPrefetchStatusUpdated)
case EventPagePrerenderStatusUpdated:
v = new(page.EventPrerenderStatusUpdated)
case EventPageLoadEventFired:
v = new(page.EventLoadEventFired)
@@ -2306,6 +2340,18 @@ func UnmarshalMessage(msg *Message) (interface{}, error) {
case EventPerformanceTimelineTimelineEventAdded:
v = new(performancetimeline.EventTimelineEventAdded)
case CommandPreloadEnable:
return emptyVal, nil
case CommandPreloadDisable:
return emptyVal, nil
case EventPreloadRuleSetUpdated:
v = new(preload.EventRuleSetUpdated)
case EventPreloadRuleSetRemoved:
v = new(preload.EventRuleSetRemoved)
case CommandProfilerDisable:
return emptyVal, nil
+2 -2
View File
@@ -604,14 +604,14 @@ func TakeComputedStyleUpdates() *TakeComputedStyleUpdatesParams {
// TakeComputedStyleUpdatesReturns return values.
type TakeComputedStyleUpdatesReturns struct {
NodeIDs []cdp.NodeID `json:"nodeIds,omitempty"` // The list of node Ids that have their tracked computed styles updated
NodeIDs []cdp.NodeID `json:"nodeIds,omitempty"` // The list of node Ids that have their tracked computed styles updated.
}
// Do executes CSS.takeComputedStyleUpdates against the provided context.
//
// returns:
//
// nodeIDs - The list of node Ids that have their tracked computed styles updated
// nodeIDs - The list of node Ids that have their tracked computed styles updated.
func (p *TakeComputedStyleUpdatesParams) Do(ctx context.Context) (nodeIDs []cdp.NodeID, err error) {
// execute
var res TakeComputedStyleUpdatesReturns
+7 -4
View File
@@ -602,10 +602,11 @@ func (t SetScriptSourceStatus) String() string {
// SetScriptSourceStatus values.
const (
SetScriptSourceStatusOk SetScriptSourceStatus = "Ok"
SetScriptSourceStatusCompileError SetScriptSourceStatus = "CompileError"
SetScriptSourceStatusBlockedByActiveGenerator SetScriptSourceStatus = "BlockedByActiveGenerator"
SetScriptSourceStatusBlockedByActiveFunction SetScriptSourceStatus = "BlockedByActiveFunction"
SetScriptSourceStatusOk SetScriptSourceStatus = "Ok"
SetScriptSourceStatusCompileError SetScriptSourceStatus = "CompileError"
SetScriptSourceStatusBlockedByActiveGenerator SetScriptSourceStatus = "BlockedByActiveGenerator"
SetScriptSourceStatusBlockedByActiveFunction SetScriptSourceStatus = "BlockedByActiveFunction"
SetScriptSourceStatusBlockedByTopLevelEsModuleChange SetScriptSourceStatus = "BlockedByTopLevelEsModuleChange"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
@@ -630,6 +631,8 @@ func (t *SetScriptSourceStatus) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = SetScriptSourceStatusBlockedByActiveGenerator
case SetScriptSourceStatusBlockedByActiveFunction:
*t = SetScriptSourceStatusBlockedByActiveFunction
case SetScriptSourceStatusBlockedByTopLevelEsModuleChange:
*t = SetScriptSourceStatusBlockedByTopLevelEsModuleChange
default:
in.AddError(fmt.Errorf("unknown SetScriptSourceStatus value: %v", v))
+104
View File
@@ -0,0 +1,104 @@
// Package deviceaccess provides the Chrome DevTools Protocol
// commands, types, and events for the DeviceAccess domain.
//
// Generated by the cdproto-gen command.
package deviceaccess
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// EnableParams enable events in this domain.
type EnableParams struct{}
// Enable enable events in this domain.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes DeviceAccess.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// DisableParams disable events in this domain.
type DisableParams struct{}
// Disable disable events in this domain.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes DeviceAccess.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// SelectPromptParams select a device in response to a
// DeviceAccess.deviceRequestPrompted event.
type SelectPromptParams struct {
ID RequestID `json:"id"`
DeviceID DeviceID `json:"deviceId"`
}
// SelectPrompt select a device in response to a
// DeviceAccess.deviceRequestPrompted event.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#method-selectPrompt
//
// parameters:
//
// id
// deviceID
func SelectPrompt(id RequestID, deviceID DeviceID) *SelectPromptParams {
return &SelectPromptParams{
ID: id,
DeviceID: deviceID,
}
}
// Do executes DeviceAccess.selectPrompt against the provided context.
func (p *SelectPromptParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSelectPrompt, p, nil)
}
// CancelPromptParams cancel a prompt in response to a
// DeviceAccess.deviceRequestPrompted event.
type CancelPromptParams struct {
ID RequestID `json:"id"`
}
// CancelPrompt cancel a prompt in response to a
// DeviceAccess.deviceRequestPrompted event.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#method-cancelPrompt
//
// parameters:
//
// id
func CancelPrompt(id RequestID) *CancelPromptParams {
return &CancelPromptParams{
ID: id,
}
}
// Do executes DeviceAccess.cancelPrompt against the provided context.
func (p *CancelPromptParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandCancelPrompt, p, nil)
}
// Command names.
const (
CommandEnable = "DeviceAccess.enable"
CommandDisable = "DeviceAccess.disable"
CommandSelectPrompt = "DeviceAccess.selectPrompt"
CommandCancelPrompt = "DeviceAccess.cancelPrompt"
)
+466
View File
@@ -0,0 +1,466 @@
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
package deviceaccess
import (
json "encoding/json"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess(in *jlexer.Lexer, out *SelectPromptParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "id":
out.ID = RequestID(in.String())
case "deviceId":
out.DeviceID = DeviceID(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess(out *jwriter.Writer, in SelectPromptParams) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"id\":"
out.RawString(prefix[1:])
out.String(string(in.ID))
}
{
const prefix string = ",\"deviceId\":"
out.RawString(prefix)
out.String(string(in.DeviceID))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v SelectPromptParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SelectPromptParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *SelectPromptParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SelectPromptParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess1(in *jlexer.Lexer, out *PromptDevice) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "id":
out.ID = DeviceID(in.String())
case "name":
out.Name = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess1(out *jwriter.Writer, in PromptDevice) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"id\":"
out.RawString(prefix[1:])
out.String(string(in.ID))
}
{
const prefix string = ",\"name\":"
out.RawString(prefix)
out.String(string(in.Name))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v PromptDevice) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v PromptDevice) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *PromptDevice) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *PromptDevice) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess1(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess2(in *jlexer.Lexer, out *EventDeviceRequestPrompted) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "id":
out.ID = RequestID(in.String())
case "devices":
if in.IsNull() {
in.Skip()
out.Devices = nil
} else {
in.Delim('[')
if out.Devices == nil {
if !in.IsDelim(']') {
out.Devices = make([]*PromptDevice, 0, 8)
} else {
out.Devices = []*PromptDevice{}
}
} else {
out.Devices = (out.Devices)[:0]
}
for !in.IsDelim(']') {
var v1 *PromptDevice
if in.IsNull() {
in.Skip()
v1 = nil
} else {
if v1 == nil {
v1 = new(PromptDevice)
}
(*v1).UnmarshalEasyJSON(in)
}
out.Devices = append(out.Devices, v1)
in.WantComma()
}
in.Delim(']')
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess2(out *jwriter.Writer, in EventDeviceRequestPrompted) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"id\":"
out.RawString(prefix[1:])
out.String(string(in.ID))
}
{
const prefix string = ",\"devices\":"
out.RawString(prefix)
if in.Devices == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
out.RawString("null")
} else {
out.RawByte('[')
for v2, v3 := range in.Devices {
if v2 > 0 {
out.RawByte(',')
}
if v3 == nil {
out.RawString("null")
} else {
(*v3).MarshalEasyJSON(out)
}
}
out.RawByte(']')
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventDeviceRequestPrompted) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventDeviceRequestPrompted) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventDeviceRequestPrompted) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventDeviceRequestPrompted) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess2(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess3(in *jlexer.Lexer, out *EnableParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess3(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess3(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess4(in *jlexer.Lexer, out *DisableParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess4(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess4(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess5(in *jlexer.Lexer, out *CancelPromptParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "id":
out.ID = RequestID(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess5(out *jwriter.Writer, in CancelPromptParams) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"id\":"
out.RawString(prefix[1:])
out.String(string(in.ID))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v CancelPromptParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess5(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v CancelPromptParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoDeviceaccess5(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *CancelPromptParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess5(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *CancelPromptParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoDeviceaccess5(l, v)
}
+12
View File
@@ -0,0 +1,12 @@
package deviceaccess
// Code generated by cdproto-gen. DO NOT EDIT.
// EventDeviceRequestPrompted a device request opened a user prompt to select
// a device. Respond with the selectPrompt or cancelPrompt command.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#event-deviceRequestPrompted
type EventDeviceRequestPrompted struct {
ID RequestID `json:"id"`
Devices []*PromptDevice `json:"devices"`
}
+32
View File
@@ -0,0 +1,32 @@
package deviceaccess
// Code generated by cdproto-gen. DO NOT EDIT.
// RequestID device request id.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#type-RequestId
type RequestID string
// String returns the RequestID as string value.
func (t RequestID) String() string {
return string(t)
}
// DeviceID a device id.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#type-DeviceId
type DeviceID string
// String returns the DeviceID as string value.
func (t DeviceID) String() string {
return string(t)
}
// PromptDevice device information displayed in a user prompt to select a
// device.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DeviceAccess#type-PromptDevice
type PromptDevice struct {
ID DeviceID `json:"id"`
Name string `json:"name"` // Display name as it appears in a device request user prompt.
}
+3 -2
View File
@@ -501,14 +501,15 @@ func (p *GetContentQuadsParams) Do(ctx context.Context) (quads []Quad, err error
}
// GetDocumentParams returns the root DOM node (and optionally the subtree)
// to the caller.
// to the caller. Implicitly enables the DOM domain events for the current
// target.
type GetDocumentParams struct {
Depth int64 `json:"depth,omitempty"` // The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.
Pierce bool `json:"pierce,omitempty"` // Whether or not iframes and shadow roots should be traversed when returning the subtree (default is false).
}
// GetDocument returns the root DOM node (and optionally the subtree) to the
// caller.
// caller. Implicitly enables the DOM domain events for the current target.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/DOM#method-getDocument
//
+2 -2
View File
@@ -423,7 +423,7 @@ func (p *SetEmulatedMediaParams) Do(ctx context.Context) (err error) {
// SetEmulatedVisionDeficiencyParams emulates the given vision deficiency.
type SetEmulatedVisionDeficiencyParams struct {
Type SetEmulatedVisionDeficiencyType `json:"type"` // Vision deficiency to emulate.
Type SetEmulatedVisionDeficiencyType `json:"type"` // Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
}
// SetEmulatedVisionDeficiency emulates the given vision deficiency.
@@ -432,7 +432,7 @@ type SetEmulatedVisionDeficiencyParams struct {
//
// parameters:
//
// type - Vision deficiency to emulate.
// type - Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
func SetEmulatedVisionDeficiency(typeVal SetEmulatedVisionDeficiencyType) *SetEmulatedVisionDeficiencyParams {
return &SetEmulatedVisionDeficiencyParams{
Type: typeVal,
+16 -11
View File
@@ -102,8 +102,8 @@ type UserAgentBrandVersion struct {
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#type-UserAgentMetadata
type UserAgentMetadata struct {
Brands []*UserAgentBrandVersion `json:"brands,omitempty"`
FullVersionList []*UserAgentBrandVersion `json:"fullVersionList,omitempty"`
Brands []*UserAgentBrandVersion `json:"brands,omitempty"` // Brands appearing in Sec-CH-UA.
FullVersionList []*UserAgentBrandVersion `json:"fullVersionList,omitempty"` // Brands appearing in Sec-CH-UA-Full-Version-List.
Platform string `json:"platform"`
PlatformVersion string `json:"platformVersion"`
Architecture string `json:"architecture"`
@@ -301,7 +301,9 @@ func (t *SetEmitTouchEventsForMouseConfiguration) UnmarshalJSON(buf []byte) erro
return easyjson.Unmarshal(buf, t)
}
// SetEmulatedVisionDeficiencyType vision deficiency to emulate.
// SetEmulatedVisionDeficiencyType vision deficiency to emulate. Order:
// best-effort emulations come first, followed by any physiologically accurate
// emulations for medically recognized color vision deficiencies.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setEmulatedVisionDeficiency
type SetEmulatedVisionDeficiencyType string
@@ -313,12 +315,13 @@ func (t SetEmulatedVisionDeficiencyType) String() string {
// SetEmulatedVisionDeficiencyType values.
const (
SetEmulatedVisionDeficiencyTypeNone SetEmulatedVisionDeficiencyType = "none"
SetEmulatedVisionDeficiencyTypeAchromatopsia SetEmulatedVisionDeficiencyType = "achromatopsia"
SetEmulatedVisionDeficiencyTypeBlurredVision SetEmulatedVisionDeficiencyType = "blurredVision"
SetEmulatedVisionDeficiencyTypeDeuteranopia SetEmulatedVisionDeficiencyType = "deuteranopia"
SetEmulatedVisionDeficiencyTypeProtanopia SetEmulatedVisionDeficiencyType = "protanopia"
SetEmulatedVisionDeficiencyTypeTritanopia SetEmulatedVisionDeficiencyType = "tritanopia"
SetEmulatedVisionDeficiencyTypeNone SetEmulatedVisionDeficiencyType = "none"
SetEmulatedVisionDeficiencyTypeBlurredVision SetEmulatedVisionDeficiencyType = "blurredVision"
SetEmulatedVisionDeficiencyTypeReducedContrast SetEmulatedVisionDeficiencyType = "reducedContrast"
SetEmulatedVisionDeficiencyTypeAchromatopsia SetEmulatedVisionDeficiencyType = "achromatopsia"
SetEmulatedVisionDeficiencyTypeDeuteranopia SetEmulatedVisionDeficiencyType = "deuteranopia"
SetEmulatedVisionDeficiencyTypeProtanopia SetEmulatedVisionDeficiencyType = "protanopia"
SetEmulatedVisionDeficiencyTypeTritanopia SetEmulatedVisionDeficiencyType = "tritanopia"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
@@ -337,10 +340,12 @@ func (t *SetEmulatedVisionDeficiencyType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch SetEmulatedVisionDeficiencyType(v) {
case SetEmulatedVisionDeficiencyTypeNone:
*t = SetEmulatedVisionDeficiencyTypeNone
case SetEmulatedVisionDeficiencyTypeAchromatopsia:
*t = SetEmulatedVisionDeficiencyTypeAchromatopsia
case SetEmulatedVisionDeficiencyTypeBlurredVision:
*t = SetEmulatedVisionDeficiencyTypeBlurredVision
case SetEmulatedVisionDeficiencyTypeReducedContrast:
*t = SetEmulatedVisionDeficiencyTypeReducedContrast
case SetEmulatedVisionDeficiencyTypeAchromatopsia:
*t = SetEmulatedVisionDeficiencyTypeAchromatopsia
case SetEmulatedVisionDeficiencyTypeDeuteranopia:
*t = SetEmulatedVisionDeficiencyTypeDeuteranopia
case SetEmulatedVisionDeficiencyTypeProtanopia:
+18 -4
View File
@@ -416,8 +416,8 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork3(in *jlexer.Lexer, ou
continue
}
switch key {
case "type":
(out.Type).UnmarshalEasyJSON(in)
case "operation":
(out.Operation).UnmarshalEasyJSON(in)
case "refreshPolicy":
(out.RefreshPolicy).UnmarshalEasyJSON(in)
case "issuers":
@@ -458,9 +458,9 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork3(out *jwriter.Writer,
first := true
_ = first
{
const prefix string = ",\"type\":"
const prefix string = ",\"operation\":"
out.RawString(prefix[1:])
(in.Type).MarshalEasyJSON(out)
(in.Operation).MarshalEasyJSON(out)
}
{
const prefix string = ",\"refreshPolicy\":"
@@ -6859,6 +6859,10 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork64(in *jlexer.Lexer, o
out.StatusCode = int64(in.Int64())
case "headersText":
out.HeadersText = string(in.String())
case "cookiePartitionKey":
out.CookiePartitionKey = string(in.String())
case "cookiePartitionKeyOpaque":
out.CookiePartitionKeyOpaque = bool(in.Bool())
default:
in.SkipRecursive()
}
@@ -6940,6 +6944,16 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork64(out *jwriter.Writer
out.RawString(prefix)
out.String(string(in.HeadersText))
}
if in.CookiePartitionKey != "" {
const prefix string = ",\"cookiePartitionKey\":"
out.RawString(prefix)
out.String(string(in.CookiePartitionKey))
}
if in.CookiePartitionKeyOpaque {
const prefix string = ",\"cookiePartitionKeyOpaque\":"
out.RawString(prefix)
out.Bool(bool(in.CookiePartitionKeyOpaque))
}
out.RawByte('}')
}
+8 -6
View File
@@ -224,12 +224,14 @@ type EventRequestWillBeSentExtraInfo struct {
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Network#event-responseReceivedExtraInfo
type EventResponseReceivedExtraInfo struct {
RequestID RequestID `json:"requestId"` // Request identifier. Used to match this information to another responseReceived event.
BlockedCookies []*BlockedSetCookieWithReason `json:"blockedCookies"` // A list of cookies which were not stored from the response along with the corresponding reasons for blocking. The cookies here may not be valid due to syntax errors, which are represented by the invalid cookie line string instead of a proper cookie.
Headers Headers `json:"headers"` // Raw response headers as they were received over the wire.
ResourceIPAddressSpace IPAddressSpace `json:"resourceIPAddressSpace"` // The IP address space of the resource. The address space can only be determined once the transport established the connection, so we can't send it in requestWillBeSentExtraInfo.
StatusCode int64 `json:"statusCode"` // The status code of the response. This is useful in cases the request failed and no responseReceived event is triggered, which is the case for, e.g., CORS errors. This is also the correct status code for cached requests, where the status in responseReceived is a 200 and this will be 304.
HeadersText string `json:"headersText,omitempty"` // Raw response header text as it was received over the wire. The raw text may not always be available, such as in the case of HTTP/2 or QUIC.
RequestID RequestID `json:"requestId"` // Request identifier. Used to match this information to another responseReceived event.
BlockedCookies []*BlockedSetCookieWithReason `json:"blockedCookies"` // A list of cookies which were not stored from the response along with the corresponding reasons for blocking. The cookies here may not be valid due to syntax errors, which are represented by the invalid cookie line string instead of a proper cookie.
Headers Headers `json:"headers"` // Raw response headers as they were received over the wire.
ResourceIPAddressSpace IPAddressSpace `json:"resourceIPAddressSpace"` // The IP address space of the resource. The address space can only be determined once the transport established the connection, so we can't send it in requestWillBeSentExtraInfo.
StatusCode int64 `json:"statusCode"` // The status code of the response. This is useful in cases the request failed and no responseReceived event is triggered, which is the case for, e.g., CORS errors. This is also the correct status code for cached requests, where the status in responseReceived is a 200 and this will be 304.
HeadersText string `json:"headersText,omitempty"` // Raw response header text as it was received over the wire. The raw text may not always be available, such as in the case of HTTP/2 or QUIC.
CookiePartitionKey string `json:"cookiePartitionKey,omitempty"` // The cookie partition key that will be used to store partitioned cookies set in this response. Only sent when partitioned cookies are enabled.
CookiePartitionKeyOpaque bool `json:"cookiePartitionKeyOpaque,omitempty"` // True if partitioned cookies are enabled, but the partition key is not serializeable to string.
}
// EventTrustTokenOperationDone fired exactly once for each Trust Token
+4 -4
View File
@@ -887,8 +887,8 @@ func (t *ServiceWorkerResponseSource) UnmarshalJSON(buf []byte) error {
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Network#type-TrustTokenParams
type TrustTokenParams struct {
Type TrustTokenOperationType `json:"type"`
RefreshPolicy TrustTokenParamsRefreshPolicy `json:"refreshPolicy"` // Only set for "token-redemption" type and determine whether to request a fresh SRR or use a still valid cached SRR.
Operation TrustTokenOperationType `json:"operation"`
RefreshPolicy TrustTokenParamsRefreshPolicy `json:"refreshPolicy"` // Only set for "token-redemption" operation and determine whether to request a fresh SRR or use a still valid cached SRR.
Issuers []string `json:"issuers,omitempty"` // Origins of issuers from whom to request tokens or redemption records.
}
@@ -1978,8 +1978,8 @@ func (t *ReferrerPolicy) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// TrustTokenParamsRefreshPolicy only set for "token-redemption" type and
// determine whether to request a fresh SRR or use a still valid cached SRR.
// TrustTokenParamsRefreshPolicy only set for "token-redemption" operation
// and determine whether to request a fresh SRR or use a still valid cached SRR.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Network#type-TrustTokenParams
type TrustTokenParamsRefreshPolicy string
+818 -718
View File
File diff suppressed because it is too large. Load diff
+20
View File
@@ -154,6 +154,26 @@ type EventPrerenderAttemptCompleted struct {
DisallowedAPIMethod string `json:"disallowedApiMethod,omitempty"` // This is used to give users more information about the name of the API call that is incompatible with prerender and has caused the cancellation of the attempt
}
// EventPrefetchStatusUpdated tODO(crbug/1384419): Create a dedicated domain
// for preloading. Fired when a prefetch attempt is updated.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#event-prefetchStatusUpdated
type EventPrefetchStatusUpdated struct {
InitiatingFrameID cdp.FrameID `json:"initiatingFrameId"` // The frame id of the frame initiating prefetch.
PrefetchURL string `json:"prefetchUrl"`
Status PreloadingStatus `json:"status"`
}
// EventPrerenderStatusUpdated tODO(crbug/1384419): Create a dedicated domain
// for preloading. Fired when a prerender attempt is updated.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#event-prerenderStatusUpdated
type EventPrerenderStatusUpdated struct {
InitiatingFrameID cdp.FrameID `json:"initiatingFrameId"` // The frame id of the frame initiating prerender.
PrerenderingURL string `json:"prerenderingUrl"`
Status PreloadingStatus `json:"status"`
}
// EventLoadEventFired [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#event-loadEventFired
+28 -40
View File
@@ -375,43 +375,6 @@ func (p *GetInstallabilityErrorsParams) Do(ctx context.Context) (installabilityE
return res.InstallabilityErrors, nil
}
// GetManifestIconsParams [no description].
type GetManifestIconsParams struct{}
// GetManifestIcons [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-getManifestIcons
func GetManifestIcons() *GetManifestIconsParams {
return &GetManifestIconsParams{}
}
// GetManifestIconsReturns return values.
type GetManifestIconsReturns struct {
PrimaryIcon string `json:"primaryIcon,omitempty"`
}
// Do executes Page.getManifestIcons against the provided context.
//
// returns:
//
// primaryIcon
func (p *GetManifestIconsParams) Do(ctx context.Context) (primaryIcon []byte, err error) {
// execute
var res GetManifestIconsReturns
err = cdp.Execute(ctx, CommandGetManifestIcons, nil, &res)
if err != nil {
return nil, err
}
// decode
var dec []byte
dec, err = base64.StdEncoding.DecodeString(res.PrimaryIcon)
if err != nil {
return nil, err
}
return dec, nil
}
// GetAppIDParams returns the unique (PWA) app id. Only returns values if the
// feature flag 'WebAppEnableManifestId' is enabled.
type GetAppIDParams struct{}
@@ -1580,7 +1543,7 @@ func (p *ClearCompilationCacheParams) Do(ctx context.Context) (err error) {
// transaction mode.
// https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode.
type SetSPCTransactionModeParams struct {
Mode SetSPCTransactionModeMode `json:"mode"`
Mode AutoResponseMode `json:"mode"`
}
// SetSPCTransactionMode sets the Secure Payment Confirmation transaction
@@ -1592,7 +1555,7 @@ type SetSPCTransactionModeParams struct {
// parameters:
//
// mode
func SetSPCTransactionMode(mode SetSPCTransactionModeMode) *SetSPCTransactionModeParams {
func SetSPCTransactionMode(mode AutoResponseMode) *SetSPCTransactionModeParams {
return &SetSPCTransactionModeParams{
Mode: mode,
}
@@ -1603,6 +1566,31 @@ func (p *SetSPCTransactionModeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetSPCTransactionMode, p, nil)
}
// SetRPHRegistrationModeParams extensions for Custom Handlers API:
// https://html.spec.whatwg.org/multipage/system-state.html#rph-automation.
type SetRPHRegistrationModeParams struct {
Mode AutoResponseMode `json:"mode"`
}
// SetRPHRegistrationMode extensions for Custom Handlers API:
// https://html.spec.whatwg.org/multipage/system-state.html#rph-automation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setRPHRegistrationMode
//
// parameters:
//
// mode
func SetRPHRegistrationMode(mode AutoResponseMode) *SetRPHRegistrationModeParams {
return &SetRPHRegistrationModeParams{
Mode: mode,
}
}
// Do executes Page.setRPHRegistrationMode against the provided context.
func (p *SetRPHRegistrationModeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetRPHRegistrationMode, p, nil)
}
// GenerateTestReportParams generates a report for testing.
type GenerateTestReportParams struct {
Message string `json:"message"` // Message to be displayed in the report.
@@ -1690,7 +1678,6 @@ const (
CommandEnable = "Page.enable"
CommandGetAppManifest = "Page.getAppManifest"
CommandGetInstallabilityErrors = "Page.getInstallabilityErrors"
CommandGetManifestIcons = "Page.getManifestIcons"
CommandGetAppID = "Page.getAppId"
CommandGetAdScriptID = "Page.getAdScriptId"
CommandGetFrameTree = "Page.getFrameTree"
@@ -1725,6 +1712,7 @@ const (
CommandAddCompilationCache = "Page.addCompilationCache"
CommandClearCompilationCache = "Page.clearCompilationCache"
CommandSetSPCTransactionMode = "Page.setSPCTransactionMode"
CommandSetRPHRegistrationMode = "Page.setRPHRegistrationMode"
CommandGenerateTestReport = "Page.generateTestReport"
CommandWaitForDebugger = "Page.waitForDebugger"
CommandSetInterceptFileChooserDialog = "Page.setInterceptFileChooserDialog"
+135 -51
View File
@@ -111,6 +111,7 @@ const (
PermissionsPolicyFeatureUsb PermissionsPolicyFeature = "usb"
PermissionsPolicyFeatureVerticalScroll PermissionsPolicyFeature = "vertical-scroll"
PermissionsPolicyFeatureWebShare PermissionsPolicyFeature = "web-share"
PermissionsPolicyFeatureWindowManagement PermissionsPolicyFeature = "window-management"
PermissionsPolicyFeatureWindowPlacement PermissionsPolicyFeature = "window-placement"
PermissionsPolicyFeatureXrSpatialTracking PermissionsPolicyFeature = "xr-spatial-tracking"
)
@@ -279,6 +280,8 @@ func (t *PermissionsPolicyFeature) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = PermissionsPolicyFeatureVerticalScroll
case PermissionsPolicyFeatureWebShare:
*t = PermissionsPolicyFeatureWebShare
case PermissionsPolicyFeatureWindowManagement:
*t = PermissionsPolicyFeatureWindowManagement
case PermissionsPolicyFeatureWindowPlacement:
*t = PermissionsPolicyFeatureWindowPlacement
case PermissionsPolicyFeatureXrSpatialTracking:
@@ -840,6 +843,58 @@ type CompilationCacheParams struct {
Eager bool `json:"eager,omitempty"` // A hint to the backend whether eager compilation is recommended. (the actual compilation mode used is upon backend discretion).
}
// AutoResponseMode enum of possible auto-response for permissions / prompt
// dialogs.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#type-AutoResponseMode
type AutoResponseMode string
// String returns the AutoResponseMode as string value.
func (t AutoResponseMode) String() string {
return string(t)
}
// AutoResponseMode values.
const (
AutoResponseModeNone AutoResponseMode = "none"
AutoResponseModeAutoAccept AutoResponseMode = "autoAccept"
AutoResponseModeAutoReject AutoResponseMode = "autoReject"
AutoResponseModeAutoOptOut AutoResponseMode = "autoOptOut"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AutoResponseMode) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AutoResponseMode) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AutoResponseMode) UnmarshalEasyJSON(in *jlexer.Lexer) {
v := in.String()
switch AutoResponseMode(v) {
case AutoResponseModeNone:
*t = AutoResponseModeNone
case AutoResponseModeAutoAccept:
*t = AutoResponseModeAutoAccept
case AutoResponseModeAutoReject:
*t = AutoResponseModeAutoReject
case AutoResponseModeAutoOptOut:
*t = AutoResponseModeAutoOptOut
default:
in.AddError(fmt.Errorf("unknown AutoResponseMode value: %v", v))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AutoResponseMode) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// NavigationType the type of a frameNavigated event.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#type-NavigationType
@@ -1425,6 +1480,13 @@ const (
PrerenderFinalStatusActivationNavigationDestroyedBeforeSuccess PrerenderFinalStatus = "ActivationNavigationDestroyedBeforeSuccess"
PrerenderFinalStatusTabClosedByUserGesture PrerenderFinalStatus = "TabClosedByUserGesture"
PrerenderFinalStatusTabClosedWithoutUserGesture PrerenderFinalStatus = "TabClosedWithoutUserGesture"
PrerenderFinalStatusPrimaryMainFrameRendererProcessCrashed PrerenderFinalStatus = "PrimaryMainFrameRendererProcessCrashed"
PrerenderFinalStatusPrimaryMainFrameRendererProcessKilled PrerenderFinalStatus = "PrimaryMainFrameRendererProcessKilled"
PrerenderFinalStatusActivationFramePolicyNotCompatible PrerenderFinalStatus = "ActivationFramePolicyNotCompatible"
PrerenderFinalStatusPreloadingDisabled PrerenderFinalStatus = "PreloadingDisabled"
PrerenderFinalStatusBatterySaverEnabled PrerenderFinalStatus = "BatterySaverEnabled"
PrerenderFinalStatusActivatedDuringMainFrameNavigation PrerenderFinalStatus = "ActivatedDuringMainFrameNavigation"
PrerenderFinalStatusPreloadingUnsupportedByWebContents PrerenderFinalStatus = "PreloadingUnsupportedByWebContents"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
@@ -1539,6 +1601,20 @@ func (t *PrerenderFinalStatus) UnmarshalEasyJSON(in *jlexer.Lexer) {
*t = PrerenderFinalStatusTabClosedByUserGesture
case PrerenderFinalStatusTabClosedWithoutUserGesture:
*t = PrerenderFinalStatusTabClosedWithoutUserGesture
case PrerenderFinalStatusPrimaryMainFrameRendererProcessCrashed:
*t = PrerenderFinalStatusPrimaryMainFrameRendererProcessCrashed
case PrerenderFinalStatusPrimaryMainFrameRendererProcessKilled:
*t = PrerenderFinalStatusPrimaryMainFrameRendererProcessKilled
case PrerenderFinalStatusActivationFramePolicyNotCompatible:
*t = PrerenderFinalStatusActivationFramePolicyNotCompatible
case PrerenderFinalStatusPreloadingDisabled:
*t = PrerenderFinalStatusPreloadingDisabled
case PrerenderFinalStatusBatterySaverEnabled:
*t = PrerenderFinalStatusBatterySaverEnabled
case PrerenderFinalStatusActivatedDuringMainFrameNavigation:
*t = PrerenderFinalStatusActivatedDuringMainFrameNavigation
case PrerenderFinalStatusPreloadingUnsupportedByWebContents:
*t = PrerenderFinalStatusPreloadingUnsupportedByWebContents
default:
in.AddError(fmt.Errorf("unknown PrerenderFinalStatus value: %v", v))
@@ -1550,6 +1626,65 @@ func (t *PrerenderFinalStatus) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// PreloadingStatus preloading status values, see also
// PreloadingTriggeringOutcome. This status is shared by prefetchStatusUpdated
// and prerenderStatusUpdated.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#type-PreloadingStatus
type PreloadingStatus string
// String returns the PreloadingStatus as string value.
func (t PreloadingStatus) String() string {
return string(t)
}
// PreloadingStatus values.
const (
PreloadingStatusPending PreloadingStatus = "Pending"
PreloadingStatusRunning PreloadingStatus = "Running"
PreloadingStatusReady PreloadingStatus = "Ready"
PreloadingStatusSuccess PreloadingStatus = "Success"
PreloadingStatusFailure PreloadingStatus = "Failure"
PreloadingStatusNotSupported PreloadingStatus = "NotSupported"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t PreloadingStatus) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t PreloadingStatus) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *PreloadingStatus) UnmarshalEasyJSON(in *jlexer.Lexer) {
v := in.String()
switch PreloadingStatus(v) {
case PreloadingStatusPending:
*t = PreloadingStatusPending
case PreloadingStatusRunning:
*t = PreloadingStatusRunning
case PreloadingStatusReady:
*t = PreloadingStatusReady
case PreloadingStatusSuccess:
*t = PreloadingStatusSuccess
case PreloadingStatusFailure:
*t = PreloadingStatusFailure
case PreloadingStatusNotSupported:
*t = PreloadingStatusNotSupported
default:
in.AddError(fmt.Errorf("unknown PreloadingStatus value: %v", v))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *PreloadingStatus) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// FileChooserOpenedMode input mode.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#event-fileChooserOpened
@@ -1864,54 +1999,3 @@ func (t *SetWebLifecycleStateState) UnmarshalEasyJSON(in *jlexer.Lexer) {
func (t *SetWebLifecycleStateState) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// SetSPCTransactionModeMode [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Page#method-setSPCTransactionMode
type SetSPCTransactionModeMode string
// String returns the SetSPCTransactionModeMode as string value.
func (t SetSPCTransactionModeMode) String() string {
return string(t)
}
// SetSPCTransactionModeMode values.
const (
SetSPCTransactionModeModeNone SetSPCTransactionModeMode = "none"
SetSPCTransactionModeModeAutoAccept SetSPCTransactionModeMode = "autoAccept"
SetSPCTransactionModeModeAutoReject SetSPCTransactionModeMode = "autoReject"
SetSPCTransactionModeModeAutoOptOut SetSPCTransactionModeMode = "autoOptOut"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t SetSPCTransactionModeMode) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t SetSPCTransactionModeMode) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *SetSPCTransactionModeMode) UnmarshalEasyJSON(in *jlexer.Lexer) {
v := in.String()
switch SetSPCTransactionModeMode(v) {
case SetSPCTransactionModeModeNone:
*t = SetSPCTransactionModeModeNone
case SetSPCTransactionModeModeAutoAccept:
*t = SetSPCTransactionModeModeAutoAccept
case SetSPCTransactionModeModeAutoReject:
*t = SetSPCTransactionModeModeAutoReject
case SetSPCTransactionModeModeAutoOptOut:
*t = SetSPCTransactionModeModeAutoOptOut
default:
in.AddError(fmt.Errorf("unknown SetSPCTransactionModeMode value: %v", v))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *SetSPCTransactionModeMode) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
+362
View File
@@ -0,0 +1,362 @@
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
package preload
import (
json "encoding/json"
cdp "github.com/chromedp/cdproto/cdp"
easyjson "github.com/mailru/easyjson"
jlexer "github.com/mailru/easyjson/jlexer"
jwriter "github.com/mailru/easyjson/jwriter"
)
// suppress unused package warning
var (
_ *json.RawMessage
_ *jlexer.Lexer
_ *jwriter.Writer
_ easyjson.Marshaler
)
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload(in *jlexer.Lexer, out *RuleSet) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "id":
out.ID = RuleSetID(in.String())
case "loaderId":
out.LoaderID = cdp.LoaderID(in.String())
case "sourceText":
out.SourceText = string(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload(out *jwriter.Writer, in RuleSet) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"id\":"
out.RawString(prefix[1:])
out.String(string(in.ID))
}
{
const prefix string = ",\"loaderId\":"
out.RawString(prefix)
out.String(string(in.LoaderID))
}
{
const prefix string = ",\"sourceText\":"
out.RawString(prefix)
out.String(string(in.SourceText))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v RuleSet) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v RuleSet) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *RuleSet) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *RuleSet) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload1(in *jlexer.Lexer, out *EventRuleSetUpdated) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "ruleSet":
if in.IsNull() {
in.Skip()
out.RuleSet = nil
} else {
if out.RuleSet == nil {
out.RuleSet = new(RuleSet)
}
(*out.RuleSet).UnmarshalEasyJSON(in)
}
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload1(out *jwriter.Writer, in EventRuleSetUpdated) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"ruleSet\":"
out.RawString(prefix[1:])
if in.RuleSet == nil {
out.RawString("null")
} else {
(*in.RuleSet).MarshalEasyJSON(out)
}
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventRuleSetUpdated) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload1(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventRuleSetUpdated) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload1(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventRuleSetUpdated) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload1(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventRuleSetUpdated) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload1(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload2(in *jlexer.Lexer, out *EventRuleSetRemoved) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "id":
out.ID = RuleSetID(in.String())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload2(out *jwriter.Writer, in EventRuleSetRemoved) {
out.RawByte('{')
first := true
_ = first
{
const prefix string = ",\"id\":"
out.RawString(prefix[1:])
out.String(string(in.ID))
}
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EventRuleSetRemoved) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload2(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EventRuleSetRemoved) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload2(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EventRuleSetRemoved) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload2(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EventRuleSetRemoved) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload2(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload3(in *jlexer.Lexer, out *EnableParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload3(out *jwriter.Writer, in EnableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v EnableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload3(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v EnableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload3(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *EnableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload3(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *EnableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload3(l, v)
}
func easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload4(in *jlexer.Lexer, out *DisableParams) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeFieldName(false)
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload4(out *jwriter.Writer, in DisableParams) {
out.RawByte('{')
first := true
_ = first
out.RawByte('}')
}
// MarshalJSON supports json.Marshaler interface
func (v DisableParams) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload4(&w, v)
return w.Buffer.BuildBytes(), w.Error
}
// MarshalEasyJSON supports easyjson.Marshaler interface
func (v DisableParams) MarshalEasyJSON(w *jwriter.Writer) {
easyjsonC5a4559bEncodeGithubComChromedpCdprotoPreload4(w, v)
}
// UnmarshalJSON supports json.Unmarshaler interface
func (v *DisableParams) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload4(&r, v)
return r.Error()
}
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *DisableParams) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjsonC5a4559bDecodeGithubComChromedpCdprotoPreload4(l, v)
}
+18
View File
@@ -0,0 +1,18 @@
package preload
// Code generated by cdproto-gen. DO NOT EDIT.
// EventRuleSetUpdated upsert. Currently, it is only emitted when a rule set
// added.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Preload#event-ruleSetUpdated
type EventRuleSetUpdated struct {
RuleSet *RuleSet `json:"ruleSet"`
}
// EventRuleSetRemoved [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Preload#event-ruleSetRemoved
type EventRuleSetRemoved struct {
ID RuleSetID `json:"id"`
}
+49
View File
@@ -0,0 +1,49 @@
// Package preload provides the Chrome DevTools Protocol
// commands, types, and events for the Preload domain.
//
// Generated by the cdproto-gen command.
package preload
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// EnableParams [no description].
type EnableParams struct{}
// Enable [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Preload#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Preload.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// DisableParams [no description].
type DisableParams struct{}
// Disable [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Preload#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Preload.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// Command names.
const (
CommandEnable = "Preload.enable"
CommandDisable = "Preload.disable"
)
+26
View File
@@ -0,0 +1,26 @@
package preload
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"github.com/chromedp/cdproto/cdp"
)
// RuleSetID unique id.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Preload#type-RuleSetId
type RuleSetID string
// String returns the RuleSetID as string value.
func (t RuleSetID) String() string {
return string(t)
}
// RuleSet corresponds to SpeculationRuleSet.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Preload#type-RuleSet
type RuleSet struct {
ID RuleSetID `json:"id"`
LoaderID cdp.LoaderID `json:"loaderId"` // Identifies a document which the rule set is associated with.
SourceText string `json:"sourceText"` // Source text of JSON representing the rule set. If it comes from <script> tag, it is the textContent of the node. Note that it is a JSON for valid case. See also: - https://wicg.github.io/nav-speculation/speculation-rules.html - https://github.com/WICG/nav-speculation/blob/main/triggers.md
}
+7
View File
@@ -52,6 +52,8 @@ func easyjsonC5a4559bDecodeGithubComChromedpCdprotoWebauthn(in *jlexer.Lexer, ou
out.HasCredBlob = bool(in.Bool())
case "hasMinPinLength":
out.HasMinPinLength = bool(in.Bool())
case "hasPrf":
out.HasPrf = bool(in.Bool())
case "automaticPresenceSimulation":
out.AutomaticPresenceSimulation = bool(in.Bool())
case "isUserVerified":
@@ -110,6 +112,11 @@ func easyjsonC5a4559bEncodeGithubComChromedpCdprotoWebauthn(out *jwriter.Writer,
out.RawString(prefix)
out.Bool(bool(in.HasMinPinLength))
}
if in.HasPrf {
const prefix string = ",\"hasPrf\":"
out.RawString(prefix)
out.Bool(bool(in.HasPrf))
}
if in.AutomaticPresenceSimulation {
const prefix string = ",\"automaticPresenceSimulation\":"
out.RawString(prefix)
+1
View File
@@ -176,6 +176,7 @@ type VirtualAuthenticatorOptions struct {
HasLargeBlob bool `json:"hasLargeBlob,omitempty"` // If set to true, the authenticator will support the largeBlob extension. https://w3c.github.io/webauthn#largeBlob Defaults to false.
HasCredBlob bool `json:"hasCredBlob,omitempty"` // If set to true, the authenticator will support the credBlob extension. https://fidoalliance.org/specs/fido-v2.1-rd-20201208/fido-client-to-authenticator-protocol-v2.1-rd-20201208.html#sctn-credBlob-extension Defaults to false.
HasMinPinLength bool `json:"hasMinPinLength,omitempty"` // If set to true, the authenticator will support the minPinLength extension. https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#sctn-minpinlength-extension Defaults to false.
HasPrf bool `json:"hasPrf,omitempty"` // If set to true, the authenticator will support the prf extension. https://w3c.github.io/webauthn/#prf-extension Defaults to false.
AutomaticPresenceSimulation bool `json:"automaticPresenceSimulation,omitempty"` // If set to true, tests of user presence will succeed immediately. Otherwise, they will not be resolved. Defaults to true.
IsUserVerified bool `json:"isUserVerified,omitempty"` // Sets whether User Verification succeeds or fails for an authenticator. Defaults to false.
}
+12 -9
View File
@@ -50,7 +50,9 @@ func setupExecAllocator(opts ...ExecAllocatorOption) *ExecAllocator {
// DefaultExecAllocatorOptions are the ExecAllocator options used by NewContext
// if the given parent context doesn't have an allocator set up. Do not modify
// this global; instead, use NewExecAllocator. See ExampleExecAllocator.
// this global; instead, use NewExecAllocator. See [ExampleExecAllocator].
//
// [ExampleExecAllocator]: https://pkg.go.dev/github.com/chromedp/chromedp#example-ExecAllocator
var DefaultExecAllocatorOptions = [...]ExecAllocatorOption{
NoFirstRun,
NoDefaultBrowserCheck,
@@ -403,7 +405,7 @@ func Flag(name string, value interface{}) ExecAllocatorOption {
// Env is a list of generic environment variables in the form NAME=value
// to pass into the new Chrome process. These will be appended to the
// environment of the golang process as retrieved by os.Environ.
// environment of the Go process as retrieved by os.Environ.
func Env(vars ...string) ExecAllocatorOption {
return func(a *ExecAllocator) {
a.initEnv = append(a.initEnv, vars...)
@@ -435,7 +437,7 @@ func ProxyServer(proxy string) ExecAllocatorOption {
}
// IgnoreCertErrors is the command line option to ignore certificate-related
// errors. This options is useful when you need to access an HTTPS website
// errors. This option is useful when you need to access an HTTPS website
// through a proxy.
func IgnoreCertErrors(a *ExecAllocator) {
Flag("ignore-certificate-errors", true)(a)
@@ -482,11 +484,12 @@ func Headless(a *ExecAllocator) {
//
// The --disable-gpu option is a temporary workaround for a few bugs
// in headless mode. According to the references below, it's no longer required:
// - https://bugs.chromium.org/p/chromium/issues/detail?id=737678
// - https://github.com/puppeteer/puppeteer/pull/2908
// - https://github.com/puppeteer/puppeteer/pull/4523
// - https://bugs.chromium.org/p/chromium/issues/detail?id=737678
// - https://github.com/puppeteer/puppeteer/pull/2908
// - https://github.com/puppeteer/puppeteer/pull/4523
//
// But according to this reported issue, it's still required in some cases:
// - https://github.com/chromedp/chromedp/issues/904
// - https://github.com/chromedp/chromedp/issues/904
func DisableGPU(a *ExecAllocator) {
Flag("disable-gpu", true)(a)
}
@@ -515,8 +518,8 @@ func WSURLReadTimeout(t time.Duration) ExecAllocatorOption {
// the correct one by sending a request to "http://$HOST:$PORT/json/version".
//
// The url with the following formats are accepted:
// * ws://127.0.0.1:9222/
// * http://127.0.0.1:9222/
// - ws://127.0.0.1:9222/
// - http://127.0.0.1:9222/
//
// But "ws://127.0.0.1:9222/devtools/browser/" are not accepted.
// Because the allocator won't try to modify it and it's obviously invalid.
+7 -4
View File
@@ -122,12 +122,15 @@ func NewBrowser(ctx context.Context, urlstr string, opts ...BrowserOption) (*Bro
//
// It could be nil when the browser is allocated with RemoteAllocator.
// It could be useful for a monitoring system to collect process metrics of the browser process.
// (see https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#NewProcessCollector for an example)
// (See [prometheus.NewProcessCollector] for an example).
//
// Example:
// if process := chromedp.FromContext(ctx).Browser.Process(); process != nil {
// fmt.Printf("Browser PID: %v", process.Pid)
// }
//
// if process := chromedp.FromContext(ctx).Browser.Process(); process != nil {
// fmt.Printf("Browser PID: %v", process.Pid)
// }
//
// [prometheus.NewProcessCollector]: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#NewProcessCollector
func (b *Browser) Process() *os.Process {
return b.process
}
+7 -7
View File
@@ -7,11 +7,11 @@ import (
"github.com/chromedp/cdproto/runtime"
)
// CallAction are actions that calls a Javascript function using
// CallAction are actions that calls a JavaScript function using
// runtime.CallFunctionOn.
type CallAction Action
// CallFunctionOn is an action to call a Javascript function, unmarshaling
// CallFunctionOn is an action to call a JavaScript function, unmarshaling
// the result of the function to res.
//
// The handling of res is the same as that of Evaluate.
@@ -28,7 +28,7 @@ func CallFunctionOn(functionDeclaration string, res interface{}, opt CallOption,
})
}
func callFunctionOn(ctx context.Context, functionDeclaration string, res interface{}, opt CallOption, args ...interface{}) (bool, error) {
func callFunctionOn(ctx context.Context, functionDeclaration string, res interface{}, opt CallOption, args ...interface{}) (*runtime.RemoteObject, error) {
// set up parameters
p := runtime.CallFunctionOn(functionDeclaration).
WithSilent(true)
@@ -51,7 +51,7 @@ func callFunctionOn(ctx context.Context, functionDeclaration string, res interfa
ea.append(arg)
}
if ea.err != nil {
return false, ea.err
return nil, ea.err
}
p = p.WithArguments(ea.args)
}
@@ -59,13 +59,13 @@ func callFunctionOn(ctx context.Context, functionDeclaration string, res interfa
// call
v, exp, err := p.Do(ctx)
if err != nil {
return false, err
return nil, err
}
if exp != nil {
return false, exp
return nil, exp
}
return parseRemoteObject(v, res)
return v, parseRemoteObject(v, res)
}
// CallOption is a function to modify the runtime.CallFunctionOnParams
+111 -11
View File
@@ -6,7 +6,9 @@
// DevTools Protocol entirely in Go.
//
// This package includes a number of simple examples. Additionally,
// https://github.com/chromedp/examples contains more complex examples.
// [chromedp/examples] contains more complex examples.
//
// [chromedp/examples]: https://github.com/chromedp/examples
package chromedp
import (
@@ -47,6 +49,28 @@ type Context struct {
// unused page target, or create a new one.
targetID target.ID
// createBrowserContextParams is set up by WithNewBrowserContext. It is used
// to create a new BrowserContext.
createBrowserContextParams *target.CreateBrowserContextParams
// browserContextOwner indicates whether this context is a BrowserContext
// owner. The owner is responsible for disposing the BrowserContext once
// the context is done.
browserContextOwner bool
// BrowserContextID is set up by WithExistingBrowserContext.
//
// Otherwise, BrowserContextID holds a non-empty value in the following cases:
//
// 1. if the context is created with the WithNewBrowserContext option, a new
// BrowserContext is created on its first run, and BrowserContextID holds
// the id of that new BrowserContext;
//
// 2. if the context is not created with the WithTargetID option, and its
// parent context has a non-empty BrowserContextID, this context's
// BrowserContextID is copied from the parent context.
BrowserContextID cdp.BrowserContextID
browserListeners []cancelableListener
targetListeners []cancelableListener
@@ -71,7 +95,7 @@ type Context struct {
closedTarget sync.WaitGroup
// allocated is closed when an allocated browser completely stops. If no
// browser needs to be allocated, the channel is simply not initialised
// browser needs to be allocated, the channel is simply not initialized
// and remains nil.
allocated chan struct{}
@@ -91,7 +115,7 @@ type Context struct {
//
// Cancelling the returned context will close a tab or an entire browser,
// depending on the logic described above. To cancel a context while checking
// for errors, see Cancel.
// for errors, see [Cancel].
//
// Note that NewContext doesn't allocate nor start a browser; that happens the
// first time Run is used on the context.
@@ -99,9 +123,11 @@ func NewContext(parent context.Context, opts ...ContextOption) (context.Context,
ctx, cancel := context.WithCancel(parent)
c := &Context{cancel: cancel, first: true}
var parentBrowserContextID cdp.BrowserContextID
if pc := FromContext(parent); pc != nil {
c.Allocator = pc.Allocator
c.Browser = pc.Browser
parentBrowserContextID = pc.BrowserContextID
// don't inherit Target, so that NewContext can be used to
// create a new tab on the same browser.
@@ -121,6 +147,23 @@ func NewContext(parent context.Context, opts ...ContextOption) (context.Context,
for _, o := range opts {
o(c)
}
if c.createBrowserContextParams != nil && c.BrowserContextID != "" {
panic("WithExistingBrowserContext can not be used when WithNewBrowserContext is specified")
}
if c.targetID == "" {
if c.BrowserContextID == "" {
// Inherit BrowserContextID from its parent context.
c.BrowserContextID = parentBrowserContextID
}
} else {
if c.createBrowserContextParams != nil {
panic("WithNewBrowserContext can not be used when WithTargetID is specified")
}
if c.BrowserContextID != "" {
panic("WithExistingBrowserContext can not be used when WithTargetID is specified")
}
}
if c.Allocator == nil {
c.Allocator = setupExecAllocator(DefaultExecAllocatorOptions[:]...)
}
@@ -146,15 +189,22 @@ func NewContext(parent context.Context, opts ...ContextOption) (context.Context,
// We need a new context, as ctx is cancelled; use a 1s timeout.
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
browserExecutor := cdp.WithExecutor(ctx, c.Browser)
if id := c.Target.SessionID; id != "" {
action := target.DetachFromTarget().WithSessionID(id)
if err := action.Do(cdp.WithExecutor(ctx, c.Browser)); c.cancelErr == nil && err != nil {
if err := action.Do(browserExecutor); c.cancelErr == nil && err != nil {
c.cancelErr = err
}
}
if id := c.Target.TargetID; id != "" {
action := target.CloseTarget(id)
if err := action.Do(cdp.WithExecutor(ctx, c.Browser)); c.cancelErr == nil && err != nil {
if err := action.Do(browserExecutor); c.cancelErr == nil && err != nil {
c.cancelErr = err
}
}
if c.browserContextOwner {
action := target.DisposeBrowserContext(c.BrowserContextID)
if err := action.Do(browserExecutor); c.cancelErr == nil && err != nil {
c.cancelErr = err
}
}
@@ -185,9 +235,9 @@ func FromContext(ctx context.Context) *Context {
// Cancel. A timeout can be attached to this context to determine how long to
// wait for the browser to close itself:
//
// tctx, tcancel := context.WithTimeout(ctx, 10 * time.Second)
// defer tcancel()
// chromedp.Cancel(tctx)
// tctx, tcancel := context.WithTimeout(ctx, 10 * time.Second)
// defer tcancel()
// chromedp.Cancel(tctx)
//
// Usually a "defer cancel()" will be enough for most use cases. However, Cancel
// is the better option if one wants to gracefully close a browser, or catch
@@ -261,6 +311,15 @@ func initContextBrowser(ctx context.Context) (*Context, error) {
// Note that the first time Run is called on a context, a browser will be
// allocated via Allocator. Thus, it's generally a bad idea to use a context
// timeout on the first Run call, as it will stop the entire browser.
//
// Also note that the actions are run with the Target executor. In the case that
// a Browser executor is required, the action can be written like this:
//
// err := chromedp.Run(ctx, chromedp.ActionFunc(func(ctx context.Context) error {
// c := chromedp.FromContext(ctx)
// id, err := target.CreateBrowserContext().Do(cdp.WithExecutor(ctx, c.Browser))
// return err
// }))
func Run(ctx context.Context, actions ...Action) error {
c, err := initContextBrowser(ctx)
if err != nil {
@@ -298,7 +357,16 @@ func (c *Context) newTarget(ctx context.Context) error {
}
if !c.first {
var err error
c.targetID, err = target.CreateTarget("about:blank").Do(cdp.WithExecutor(ctx, c.Browser))
browserExecutor := cdp.WithExecutor(ctx, c.Browser)
if c.createBrowserContextParams != nil {
c.BrowserContextID, err = c.createBrowserContextParams.Do(browserExecutor)
if err != nil {
return err
}
c.browserContextOwner = true
c.createBrowserContextParams = nil
}
c.targetID, err = target.CreateTarget("about:blank").WithBrowserContextID(c.BrowserContextID).Do(browserExecutor)
if err != nil {
return err
}
@@ -409,6 +477,38 @@ func WithTargetID(id target.ID) ContextOption {
return func(c *Context) { c.targetID = id }
}
// CreateBrowserContextOption is a BrowserContext creation options.
type CreateBrowserContextOption = func(*target.CreateBrowserContextParams) *target.CreateBrowserContextParams
// WithNewBrowserContext sets up a context to create a new BrowserContext, and
// create a new target in this BrowserContext. A child context will create its
// target in this BrowserContext too, unless it's set up with other options.
// The new BrowserContext will be disposed when the context is done.
func WithNewBrowserContext(options ...CreateBrowserContextOption) ContextOption {
return func(c *Context) {
if c.first {
panic("WithNewBrowserContext can not be used before Browser is initialized")
}
params := target.CreateBrowserContext().WithDisposeOnDetach(true)
for _, o := range options {
params = o(params)
}
c.createBrowserContextParams = params
}
}
// WithExistingBrowserContext sets up a context to create a new target in the
// specified browser context.
func WithExistingBrowserContext(id cdp.BrowserContextID) ContextOption {
return func(c *Context) {
if c.first {
panic("WithExistingBrowserContext can not be used before Browser is initialized")
}
c.BrowserContextID = id
}
}
// WithLogf is a shortcut for WithBrowserOption(WithBrowserLogf(f)).
func WithLogf(f func(string, ...interface{})) ContextOption {
return WithBrowserOption(WithBrowserLogf(f))
@@ -572,7 +672,7 @@ func responseAction(resp **network.Response, actions ...Action) Action {
}
// If the ctx parameter was cancelled by the caller (or
// by a timeout etc) the select will race between
// by a timeout etc.) the select will race between
// lctx.Done and ctx.Done, since lctx is a sub-context
// of ctx. So we can't return nil here, as otherwise
// that race would mean that we would drop 50% of the
@@ -606,7 +706,7 @@ type Action interface {
Do(context.Context) error
}
// ActionFunc is a adapter to allow the use of ordinary func's as an Action.
// ActionFunc is an adapter to allow the use of ordinary func's as an Action.
type ActionFunc func(context.Context) error
// Do executes the func f using the provided context and frame handler.
+2 -2
View File
@@ -1,10 +1,10 @@
// Package device contains device emulation definitions for use with chromedp's
// Emulate action.
//
// See: https://raw.githubusercontent.com/puppeteer/puppeteer/main/src/common/DeviceDescriptors.ts
// See: https://raw.githubusercontent.com/puppeteer/puppeteer/main/packages/puppeteer-core/src/common/Device.ts
package device
// Generated by gen.go. DO NOT EDIT.
// Code generated by gen.go. DO NOT EDIT.
//go:generate go run gen.go
+2 -4
View File
@@ -82,8 +82,7 @@ func ResetViewport() EmulateAction {
// Device is the shared interface for known device types.
//
// See: github.com/chromedp/chromedp/device for a set of off-the-shelf devices
// and modes.
// See [device] for a set of off-the-shelf devices and modes.
type Device interface {
// Device returns the device info.
Device() device.Info
@@ -91,8 +90,7 @@ type Device interface {
// Emulate is an action to emulate a specific device.
//
// See: github.com/chromedp/chromedp/device for a set of off-the-shelf devices
// and modes.
// See [device] for a set of off-the-shelf devices and modes.
func Emulate(device Device) EmulateAction {
d := device.Device()
+6
View File
@@ -48,4 +48,10 @@ const (
// ErrPollingTimeout is the error that the timeout reached before the pageFunction returns a truthy value.
ErrPollingTimeout Error = "waiting for function failed: timeout"
// ErrJSUndefined is the error that the type of RemoteObject is "undefined".
ErrJSUndefined Error = "encountered an undefined value"
// ErrJSNull is the error that the value of RemoteObject is null.
ErrJSNull Error = "encountered a null value"
)
+44 -38
View File
@@ -3,16 +3,16 @@ package chromedp
import (
"context"
"encoding/json"
"fmt"
"reflect"
"github.com/chromedp/cdproto/runtime"
)
// EvaluateAction are actions that evaluate Javascript expressions using
// EvaluateAction are actions that evaluate JavaScript expressions using
// runtime.Evaluate.
type EvaluateAction Action
// Evaluate is an action to evaluate the Javascript expression, unmarshaling
// Evaluate is an action to evaluate the JavaScript expression, unmarshaling
// the result of the script evaluation to res.
//
// When res is nil, the script result will be ignored.
@@ -22,18 +22,16 @@ type EvaluateAction Action
//
// When res is a **runtime.RemoteObject, res will be set to the low-level
// protocol type, and no attempt will be made to convert the result.
// Original objects are maintained in memory until the page navigated or closed,
// unless they are either explicitly released or are released along with the
// other objects in their object group. runtime.ReleaseObject or
// runtime.ReleaseObjectGroup can be used to ask the browser to release
// original objects.
// The original objects could be maintained in memory until the page is
// navigated or closed. `runtime.ReleaseObject` or `runtime.ReleaseObjectGroup`
// can be used to ask the browser to release the original objects.
//
// For all other cases, the result of the script will be returned "by value" (ie,
// For all other cases, the result of the script will be returned "by value" (i.e.,
// JSON-encoded), and subsequently an attempt will be made to json.Unmarshal
// the script result to res. It returns an error if the script result is
// "undefined" in this case.
//
// Note: any exception encountered will be returned as an error.
// the script result to res. When the script result is "undefined" or "null",
// and the value that res points to can not be nil (only the value of a chan,
// func, interface, map, pointer, or slice can be nil), it returns [ErrJSUndefined]
// or [ErrJSNull] respectively.
func Evaluate(expression string, res interface{}, opts ...EvaluateOption) EvaluateAction {
return ActionFunc(func(ctx context.Context) error {
// set up parameters
@@ -58,16 +56,11 @@ func Evaluate(expression string, res interface{}, opts ...EvaluateOption) Evalua
return exp
}
_, err = parseRemoteObject(v, res)
return err
return parseRemoteObject(v, res)
})
}
func parseRemoteObject(v *runtime.RemoteObject, res interface{}) (undefined bool, err error) {
// undefined indicates that the result is a javascript "undefined" value.
// Poll needs this value to decide whether it's a timeout.
undefined = v.Type == "undefined"
func parseRemoteObject(v *runtime.RemoteObject, res interface{}) (err error) {
if res == nil {
return
}
@@ -82,34 +75,47 @@ func parseRemoteObject(v *runtime.RemoteObject, res interface{}) (undefined bool
return
}
if undefined {
// The unmarshal below would fail with the cryptic
// "unexpected end of JSON input" error, so try to give
// a better one here.
err = fmt.Errorf("encountered an undefined value")
return
value := v.Value
if value == nil {
rv := reflect.ValueOf(res)
if rv.Kind() == reflect.Ptr {
switch rv.Elem().Kind() {
// Common kinds that can be nil.
case reflect.Ptr, reflect.Map, reflect.Slice:
// It's weird that res is a pointer to the following kinds,
// but they can be nil too.
case reflect.Chan, reflect.Func, reflect.Interface:
default:
// When the value that `res` points to can not be set to nil,
// return [ErrJSUndefined] or [ErrJSNull] respectively.
if v.Type == "undefined" {
return ErrJSUndefined
}
return ErrJSNull
}
}
// Change the value to the json literal null to make json.Unmarshal happy.
value = []byte("null")
}
// unmarshal
err = json.Unmarshal(v.Value, res)
return
return json.Unmarshal(value, res)
}
// EvaluateAsDevTools is an action that evaluates a Javascript expression as
// EvaluateAsDevTools is an action that evaluates a JavaScript expression as
// Chrome DevTools would, evaluating the expression in the "console" context,
// and making the Command Line API available to the script.
//
// See Evaluate for more information on how script expressions are evaluated.
// See [Evaluate] for more information on how script expressions are evaluated.
//
// Note: this should not be used with untrusted Javascript.
// Note: this should not be used with untrusted JavaScript.
func EvaluateAsDevTools(expression string, res interface{}, opts ...EvaluateOption) EvaluateAction {
return Evaluate(expression, res, append(opts, EvalObjectGroup("console"), EvalWithCommandLineAPI)...)
}
// EvaluateOption is the type for Javascript evaluation options.
// EvaluateOption is the type for JavaScript evaluation options.
type EvaluateOption = func(*runtime.EvaluateParams) *runtime.EvaluateParams
// EvalObjectGroup is a evaluate option to set the object group.
// EvalObjectGroup is an evaluate option to set the object group.
func EvalObjectGroup(objectGroup string) EvaluateOption {
return func(p *runtime.EvaluateParams) *runtime.EvaluateParams {
return p.WithObjectGroup(objectGroup)
@@ -119,20 +125,20 @@ func EvalObjectGroup(objectGroup string) EvaluateOption {
// EvalWithCommandLineAPI is an evaluate option to make the DevTools Command
// Line API available to the evaluated script.
//
// See Evaluate for more information on how evaluate actions work.
// See [Evaluate] for more information on how evaluate actions work.
//
// Note: this should not be used with untrusted Javascript.
// Note: this should not be used with untrusted JavaScript.
func EvalWithCommandLineAPI(p *runtime.EvaluateParams) *runtime.EvaluateParams {
return p.WithIncludeCommandLineAPI(true)
}
// EvalIgnoreExceptions is a evaluate option that will cause Javascript
// EvalIgnoreExceptions is an evaluate option that will cause JavaScript
// evaluation to ignore exceptions.
func EvalIgnoreExceptions(p *runtime.EvaluateParams) *runtime.EvaluateParams {
return p.WithSilent(true)
}
// EvalAsValue is a evaluate option that will cause the evaluated Javascript
// EvalAsValue is an evaluate option that will cause the evaluated JavaScript
// expression to encode the result of the expression as a JSON-encoded value.
func EvalAsValue(p *runtime.EvaluateParams) *runtime.EvaluateParams {
return p.WithReturnByValue(true)
+4 -4
View File
@@ -23,7 +23,7 @@ func MouseEvent(typ input.MouseType, x, y float64, opts ...MouseOption) MouseAct
return p
}
// MouseClickXY is an action that sends a left mouse button click (ie,
// MouseClickXY is an action that sends a left mouse button click (i.e.,
// mousePressed and mouseReleased event) to the X, Y location.
func MouseClickXY(x, y float64, opts ...MouseOption) MouseAction {
return ActionFunc(func(ctx context.Context) error {
@@ -158,10 +158,10 @@ type KeyAction Action
//
// Only well-known, "printable" characters will have char events synthesized.
//
// See the SendKeys action to synthesize key events for a specific element
// See the [SendKeys] action to synthesize key events for a specific element
// node.
//
// See the chromedp/kb package for implementation details and list of
// See the [kb] package for implementation details and list of
// well-known keys.
func KeyEvent(keys string, opts ...KeyOption) KeyAction {
return ActionFunc(func(ctx context.Context) error {
@@ -180,7 +180,7 @@ func KeyEvent(keys string, opts ...KeyOption) KeyAction {
})
}
// KeyEventNode is a key action that dispatches a key event on a element node.
// KeyEventNode is a key action that dispatches a key event on an element node.
func KeyEventNode(n *cdp.Node, keys string, opts ...KeyOption) KeyAction {
return ActionFunc(func(ctx context.Context) error {
err := dom.Focus().WithNodeID(n.NodeID).Do(ctx)
+2 -2
View File
@@ -6,7 +6,7 @@ import (
var (
// textJS is a javascript snippet that returns the innerText of the specified
// visible (ie, offsetWidth || offsetHeight || getClientRects().length ) element.
// visible (i.e., offsetWidth || offsetHeight || getClientRects().length ) element.
//go:embed js/text.js
textJS string
@@ -53,7 +53,7 @@ var (
// waitForPredicatePageFunction is a javascript snippet that runs the polling in the
// browser. It's copied from puppeteer. See
// https://github.com/puppeteer/puppeteer/blob/669f04a7a6e96cc8353a8cb152898edbc25e7c15/src/common/DOMWorld.ts#L870-L944
// It's modified to make mutation polling respect timeout even when there is not DOM mutation.
// It's modified to make mutation polling respect timeout even when there is not a DOM mutation.
//go:embed js/waitForPredicatePageFunction.js
waitForPredicatePageFunction string
)
+14 -13
View File
@@ -2,7 +2,7 @@
// events.
package kb
// Generated by gen.go. DO NOT EDIT.
// Code generated by gen.go. DO NOT EDIT.
//go:generate go run gen.go
@@ -17,33 +17,34 @@ import (
// value.
//
// Example data for the following runes:
// '\r' '\n' | ',' '<' | 'a' 'A' | '\u0a07'
// _____________________________________________________
//
// Runes | '\r' '\n' | ',' '<' | 'a' 'A' | '\u0a07' |
// -----------|-------------|------------|------------|-------------|
// Code | "Enter" | "Comma" | "KeyA" | "MediaStop" |
// Key | "Enter" | "," "<" | "a" "A" | "MediaStop" |
// Text | "\r" "\r" | "," "<" | "a" "A" | "" |
// Unmodified | "\r" "\r" | "," "," | "a" "a" | "" |
// Native | 0x13 0x13 | 0xbc 0xbc | 0x61 0x41 | 0x00ae |
// Windows | 0x13 0x13 | 0xbc 0xbc | 0x61 0x41 | 0xe024 |
// Shift | false false | false true | false true | false |
// Print | true true | true true | true true | false |
type Key struct {
// Code is the key code:
// "Enter" | "Comma" | "KeyA" | "MediaStop"
Code string
// Key is the key value:
// "Enter" | "," "<" | "a" "A" | "MediaStop"
Key string
// Text is the text for printable keys:
// "\r" "\r" | "," "<" | "a" "A" | ""
Text string
// Unmodified is the unmodified text for printable keys:
// "\r" "\r" | "," "," | "a" "a" | ""
Unmodified string
// Native is the native scan code.
// 0x13 0x13 | 0xbc 0xbc | 0x61 0x41 | 0x00ae
Native int64
// Windows is the windows scan code.
// 0x13 0x13 | 0xbc 0xbc | 0x61 0x41 | 0xe024
// Windows is the Windows scan code.
Windows int64
// Shift indicates whether or not the Shift modifier should be sent.
// false false | false true | false true | false
Shift bool
// Print indicates whether or not the character is a printable character
// (ie, should a "char" event be generated).
// true true | true true | true true | false
// (i.e., should a "char" event be generated).
Print bool
}
+1 -1
View File
@@ -12,7 +12,7 @@ import (
// for the page to load.
//
// Note that these actions don't collect HTTP response information; for that,
// see RunResponse.
// see [RunResponse].
type NavigateAction Action
// Navigate is an action that navigates the current frame.
+16 -15
View File
@@ -9,12 +9,12 @@ import (
"github.com/chromedp/cdproto/runtime"
)
// PollAction are actions that will wait for a general Javascript predicate.
// PollAction are actions that will wait for a general JavaScript predicate.
//
// See Poll for details on building poll tasks.
// See [Poll] for details on building poll tasks.
type PollAction Action
// pollTask holds information pertaining to an poll task.
// pollTask holds information pertaining to a poll task.
//
// See Poll for details on building poll tasks.
type pollTask struct {
@@ -66,7 +66,7 @@ func (p *pollTask) Do(ctx context.Context) error {
args = append(args, p.timeout.Milliseconds())
args = append(args, p.args...)
undefined, err := callFunctionOn(ctx, waitForPredicatePageFunction, p.res,
r, err := callFunctionOn(ctx, waitForPredicatePageFunction, p.res,
func(p *runtime.CallFunctionOnParams) *runtime.CallFunctionOnParams {
return p.WithExecutionContextID(execCtx).
WithAwaitPromise(true).
@@ -75,24 +75,23 @@ func (p *pollTask) Do(ctx context.Context) error {
args...,
)
if undefined {
if r != nil && r.Type == "undefined" {
return ErrPollingTimeout
}
return err
}
// Poll is a poll action that will wait for a general Javascript predicate.
// It builds the predicate from a Javascript expression.
// Poll is a poll action that will wait for a general JavaScript predicate.
// It builds the predicate from a JavaScript expression.
//
// This is a copy of puppeteer's page.waitForFunction.
// see https://github.com/puppeteer/puppeteer/blob/v8.0.0/docs/api.md#pagewaitforfunctionpagefunction-options-args.
// This is a copy of puppeteer's [page.waitForFunction].
// It's named Poll intentionally to avoid messing up with the Wait* query actions.
// The behavior is not guaranteed to be compatible.
// For example, our implementation makes the poll task not survive from a navigation,
// and an error is raised in this case (see unit test TestPoll/NotSurviveNavigation).
//
// Polling Options
// # Polling Options
//
// The default polling mode is "raf", to constantly execute pageFunction in requestAnimationFrame callback.
// This is the tightest polling mode which is suitable to observe styling changes.
@@ -107,16 +106,18 @@ func (p *pollTask) Do(ctx context.Context) error {
//
// The WithPollingArgs option provides extra arguments to pass to the predicate.
// Only apply this option when the predicate is built from a function.
// See PollFunction.
// See [PollFunction].
//
// [page.waitForFunction]: https://github.com/puppeteer/puppeteer/blob/v8.0.0/docs/api.md#pagewaitforfunctionpagefunction-options-args
func Poll(expression string, res interface{}, opts ...PollOption) PollAction {
predicate := fmt.Sprintf(`return (%s);`, expression)
return poll(predicate, res, opts...)
}
// PollFunction is a poll action that will wait for a general Javascript predicate.
// It builds the predicate from a Javascript function.
// PollFunction is a poll action that will wait for a general JavaScript predicate.
// It builds the predicate from a JavaScript function.
//
// See Poll for details on building poll tasks.
// See [Poll] for details on building poll tasks.
func PollFunction(pageFunction string, res interface{}, opts ...PollOption) PollAction {
predicate := fmt.Sprintf(`return (%s)(...args);`, pageFunction)
@@ -138,7 +139,7 @@ func poll(predicate string, res interface{}, opts ...PollOption) PollAction {
return p
}
// PollOption is an poll task option.
// PollOption is a poll task option.
type PollOption = func(task *pollTask)
// WithPollingInterval makes it to poll the predicate with the specified interval.
+52 -51
View File
@@ -18,12 +18,12 @@ import (
// QueryAction are element query actions that select node elements from the
// browser's DOM for retrieval or manipulation.
//
// See Query for details on building element query selectors.
// See [Query] for details on building element query selectors.
type QueryAction Action
// Selector holds information pertaining to an element selection query.
//
// See Query for information on building an element selector and relevant
// See [Query] for information on building an element selector and relevant
// options.
type Selector struct {
sel interface{}
@@ -39,93 +39,93 @@ type Selector struct {
// node(s) matching the criteria.
//
// Query actions that target a browser DOM element node (or nodes) make use of
// Query, in conjunction with the After option (see below) to retrieve data or
// Query, in conjunction with the [After] option to retrieve data or
// to modify the element(s) selected by the query.
//
// For example:
//
// chromedp.Run(ctx, chromedp.SendKeys(`thing`, chromedp.ByID))
// chromedp.Run(ctx, chromedp.SendKeys(`thing`, chromedp.ByID))
//
// The above will perform a "SendKeys" action on the first element matching a
// The above will perform a [SendKeys] action on the first element matching a
// browser CSS query for "#thing".
//
// Element selection queries work in conjunction with specific actions and form
// the primary way of automating Tasks in the browser. They are typically
// [Element] selection queries work in conjunction with specific actions and form
// the primary way of automating [Tasks] in the browser. They are typically
// written in the following form:
//
// Action(selector[, parameter1, ...parameterN][,result][, queryOptions...])
// Action(selector[, parameter1, ...parameterN][,result][, queryOptions...])
//
// Where:
//
// Action - the action to perform
// selector - element query selection (typically a string), that any matching node(s) will have the action applied
// parameter[1-N] - parameter(s) needed for the individual action (if any)
// result - pointer to a result (if any)
// queryOptions - changes how queries are executed, or how nodes are waited for (see below)
// - Action - the action to perform
// - selector - element query selection (typically a string), that any matching node(s) will have the action applied
// - parameter[1-N] - parameter(s) needed for the individual action (if any)
// - result - pointer to a result (if any)
// - queryOptions - changes how queries are executed, or how nodes are waited for
//
// Query Options
// # Query Options
//
// By* options specify the type of element query used By the browser to perform
// the selection query. When not specified, element queries will use BySearch
// the selection query. When not specified, element queries will use [BySearch]
// (a wrapper for DOM.performSearch).
//
// Node* options specify node conditions that cause the query to wait until the
// specified condition is true. When not specified, queries will use the
// NodeReady wait condition.
// [NodeReady] wait condition.
//
// The AtLeast option alters the minimum number of nodes that must be returned
// The [AtLeast] option alters the minimum number of nodes that must be returned
// by the element query. If not specified, the default value is 1.
//
// The After option is used to specify a func that will be executed when
// The [After] option is used to specify a func that will be executed when
// element query has returned one or more elements, and after the node condition is
// true.
//
// By Options
// # By Options
//
// The BySearch (default) option enables querying for elements by plain text,
// The [BySearch] (default) option enables querying for elements by plain text,
// CSS selector or XPath query, wrapping DOM.performSearch.
//
// The ByID option enables querying for a single element with the matching CSS
// The [ByID] option enables querying for a single element with the matching CSS
// ID, wrapping DOM.querySelector. ByID is similar to calling
// document.querySelector('#' + ID) from within the browser.
//
// The ByQuery option enables querying for a single element using a CSS
// The [ByQuery] option enables querying for a single element using a CSS
// selector, wrapping DOM.querySelector. ByQuery is similar to calling
// document.querySelector() from within the browser.
//
// The ByQueryAll option enables querying for elements using a CSS selector,
// The [ByQueryAll] option enables querying for elements using a CSS selector,
// wrapping DOM.querySelectorAll. ByQueryAll is similar to calling
// document.querySelectorAll() from within the browser.
//
// The ByJSPath option enables querying for a single element using its "JS
// The [ByJSPath] option enables querying for a single element using its "JS
// Path" value, wrapping Runtime.evaluate. ByJSPath is similar to executing a
// Javascript snippet that returns a element from within the browser. ByJSPath
// JavaScript snippet that returns an element from within the browser. ByJSPath
// should be used only with trusted element queries, as it is passed directly
// to Runtime.evaluate, and no attempt is made to sanitize the query. Useful
// for querying DOM elements that cannot be retrieved using other By* funcs,
// such as ShadowDOM elements.
//
// Node Options
// # Node Options
//
// The NodeReady (default) option causes the query to wait until all element
// The [NodeReady] (default) option causes the query to wait until all element
// nodes matching the selector have been retrieved from the browser.
//
// The NodeVisible option causes the query to wait until all element nodes
// The [NodeVisible] option causes the query to wait until all element nodes
// matching the selector have been retrieved from the browser, and are visible.
//
// The NodeNotVisible option causes the query to wait until all element nodes
// The [NodeNotVisible] option causes the query to wait until all element nodes
// matching the selector have been retrieved from the browser, and are not
// visible.
//
// The NodeEnabled option causes the query to wait until all element nodes
// The [NodeEnabled] option causes the query to wait until all element nodes
// matching the selector have been retrieved from the browser, and are enabled
// (ie, do not have a 'disabled' attribute).
// (i.e., do not have a 'disabled' attribute).
//
// The NodeSelected option causes the query to wait until all element nodes
// matching the selector have been retrieved from the browser, and are are
// selected (ie, has a 'selected' attribute).
// The [NodeSelected] option causes the query to wait until all element nodes
// matching the selector have been retrieved from the browser, and are
// selected (i.e., has a 'selected' attribute).
//
// The NodeNotPresent option causes the query to wait until there are no
// The [NodeNotPresent] option causes the query to wait until there are no
// element nodes matching the selector.
func Query(sel interface{}, opts ...QueryOption) QueryAction {
s := &Selector{
@@ -422,7 +422,7 @@ func callFunctionOnNode(ctx context.Context, node *cdp.Node, function string, re
if err != nil {
return err
}
err = CallFunctionOn(function, &res,
err = CallFunctionOn(function, res,
func(p *runtime.CallFunctionOnParams) *runtime.CallFunctionOnParams {
return p.WithObjectID(r.ObjectID)
},
@@ -496,7 +496,7 @@ func NodeNotVisible(s *Selector) {
}
// NodeEnabled is an element query option to wait until all queried element
// nodes have been sent by the browser and are enabled (ie, do not have a
// nodes have been sent by the browser and are enabled (i.e., do not have a
// 'disabled' attribute).
func NodeEnabled(s *Selector) {
WaitFunc(s.waitReady(func(ctx context.Context, execCtx runtime.ExecutionContextID, n *cdp.Node) error {
@@ -514,7 +514,7 @@ func NodeEnabled(s *Selector) {
}
// NodeSelected is an element query option to wait until all queried element
// nodes have been sent by the browser and are selected (ie, has 'selected'
// nodes have been sent by the browser and are selected (i.e., has 'selected'
// attribute).
func NodeSelected(s *Selector) {
WaitFunc(s.waitReady(func(ctx context.Context, execCtx runtime.ExecutionContextID, n *cdp.Node) error {
@@ -575,7 +575,7 @@ func After(f func(context.Context, runtime.ExecutionContextID, ...*cdp.Node) err
}
// WaitReady is an element query action that waits until the element matching
// the selector is ready (ie, has been "loaded").
// the selector is ready (i.e., has been "loaded").
func WaitReady(sel interface{}, opts ...QueryOption) QueryAction {
return Query(sel, opts...)
}
@@ -593,13 +593,13 @@ func WaitNotVisible(sel interface{}, opts ...QueryOption) QueryAction {
}
// WaitEnabled is an element query action that waits until the element matching
// the selector is enabled (ie, does not have attribute 'disabled').
// the selector is enabled (i.e., does not have attribute 'disabled').
func WaitEnabled(sel interface{}, opts ...QueryOption) QueryAction {
return Query(sel, append(opts, NodeEnabled)...)
}
// WaitSelected is an element query action that waits until the element
// matching the selector is selected (ie, has attribute 'selected').
// matching the selector is selected (i.e., has attribute 'selected').
func WaitSelected(sel interface{}, opts ...QueryOption) QueryAction {
return Query(sel, append(opts, NodeSelected)...)
}
@@ -782,10 +782,10 @@ func Clear(sel interface{}, opts ...QueryOption) QueryAction {
}, opts...)
}
// Value is an element query action that retrieves the Javascript value field of the
// Value is an element query action that retrieves the JavaScript value field of the
// first element node matching the selector.
//
// Useful for retrieving an element's Javascript value, namely form, input,
// Useful for retrieving an element's JavaScript value, namely form, input,
// textarea, select, or any other element with a '.value' field.
func Value(sel interface{}, value *string, opts ...QueryOption) QueryAction {
if value == nil {
@@ -795,10 +795,10 @@ func Value(sel interface{}, value *string, opts ...QueryOption) QueryAction {
return JavascriptAttribute(sel, "value", value, opts...)
}
// SetValue is an element query action that sets the Javascript value of the first
// SetValue is an element query action that sets the JavaScript value of the first
// element node matching the selector.
//
// Useful for setting an element's Javascript value, namely form, input,
// Useful for setting an element's JavaScript value, namely form, input,
// textarea, select, or other element with a '.value' field.
func SetValue(sel interface{}, value string, opts ...QueryOption) QueryAction {
return SetJavascriptAttribute(sel, "value", value, opts...)
@@ -935,7 +935,7 @@ func RemoveAttribute(sel interface{}, name string, opts ...QueryOption) QueryAct
}, opts...)
}
// JavascriptAttribute is an element query action that retrieves the Javascript
// JavascriptAttribute is an element query action that retrieves the JavaScript
// attribute for the first element node matching the selector.
func JavascriptAttribute(sel interface{}, name string, res interface{}, opts ...QueryOption) QueryAction {
if res == nil {
@@ -954,7 +954,7 @@ func JavascriptAttribute(sel interface{}, name string, res interface{}, opts ...
}, opts...)
}
// SetJavascriptAttribute is an element query action that sets the Javascript attribute
// SetJavascriptAttribute is an element query action that sets the JavaScript attribute
// for the first element node matching the selector.
func SetJavascriptAttribute(sel interface{}, name, value string, opts ...QueryOption) QueryAction {
return QueryAfter(sel, func(ctx context.Context, execCtx runtime.ExecutionContextID, nodes ...*cdp.Node) error {
@@ -1021,11 +1021,12 @@ func DoubleClick(sel interface{}, opts ...QueryOption) QueryAction {
// events as needed for the runes in v, sending them to the first element node
// matching the selector.
//
// For a complete example on how to use SendKeys, see
// https://github.com/chromedp/examples/tree/master/keys.
// See the [keys] for a complete example on how to use SendKeys.
//
// Note: when the element query matches a input[type="file"] node, then
// Note: when the element query matches an input[type="file"] node, then
// dom.SetFileInputFiles is used to set the upload path of the input node to v.
//
// [keys]: https://github.com/chromedp/examples/tree/master/keys
func SendKeys(sel interface{}, v string, opts ...QueryOption) QueryAction {
return QueryAfter(sel, func(ctx context.Context, execCtx runtime.ExecutionContextID, nodes ...*cdp.Node) error {
if len(nodes) < 1 {
@@ -1053,7 +1054,7 @@ func SendKeys(sel interface{}, v string, opts ...QueryOption) QueryAction {
}, append(opts, NodeVisible)...)
}
// SetUploadFiles is an element query action that sets the files to upload (ie, for a
// SetUploadFiles is an element query action that sets the files to upload (i.e., for a
// input[type="file"] node) for the first element node matching the selector.
func SetUploadFiles(sel interface{}, files []string, opts ...QueryOption) QueryAction {
return QueryAfter(sel, func(ctx context.Context, execCtx runtime.ExecutionContextID, nodes ...*cdp.Node) error {
+8 -6
View File
@@ -24,10 +24,11 @@ import (
// These CDP commands are not sent by chromedp. If it does not work as expected,
// you can try to send those commands yourself.
//
// See CaptureScreenshot for capturing a screenshot of the browser viewport.
// See [CaptureScreenshot] for capturing a screenshot of the browser viewport.
//
// See the 'screenshot' example in the https://github.com/chromedp/examples
// project for an example of taking a screenshot of the entire page.
// See [screenshot] for an example of taking a screenshot of the entire page.
//
// [screenshot]: https://github.com/chromedp/examples/tree/master/screenshot
func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) QueryAction {
if picbuf == nil {
panic("picbuf cannot be nil")
@@ -77,10 +78,11 @@ func Screenshot(sel interface{}, picbuf *[]byte, opts ...QueryOption) QueryActio
// It's supposed to act the same as the command "Capture screenshot" in
// Chrome. See the behavior notes of Screenshot for more information.
//
// See the Screenshot action to take a screenshot of a specific element.
// See the [Screenshot] action to take a screenshot of a specific element.
//
// See the 'screenshot' example in the https://github.com/chromedp/examples
// project for an example of taking a screenshot of the entire page.
// See [screenshot] for an example of taking a screenshot of the entire page.
//
// [screenshot]: https://github.com/chromedp/examples/tree/master/screenshot
func CaptureScreenshot(res *[]byte) Action {
if res == nil {
panic("res cannot be nil")
+19
View File
@@ -0,0 +1,19 @@
package color
import (
"os"
"golang.org/x/sys/windows"
)
func init() {
// Opt-in for ansi color support for current process.
// https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#output-sequences
var outMode uint32
out := windows.Handle(os.Stdout.Fd())
if err := windows.GetConsoleMode(out, &outMode); err != nil {
return
}
outMode |= windows.ENABLE_PROCESSED_OUTPUT | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
_ = windows.SetConsoleMode(out, outMode)
}
-16
View File
@@ -1,16 +0,0 @@
sudo: false
language: go
go:
- 1.13.x
- 1.14.x
- 1.15.x
env:
global:
- GO111MODULE=on
script:
- make test
after_success:
- bash <(curl -s https://codecov.io/bash)
-51
View File
@@ -1,51 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
Types of changes:
- `Added` for new features.
- `Changed` for changes in existing functionality.
- `Deprecated` for soon-to-be removed features.
- `Removed` for now removed features.
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.
## [Unreleased]
### Added
- [#223](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/223) Add go-kit logging middleware - [adrien-f](https://github.com/adrien-f)
## [v1.1.0] - 2019-09-12
### Added
- [#226](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/226) Support for go modules.
- [#221](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/221) logging/zap add support for gRPC LoggerV2 - [kush-patel-hs](https://github.com/kush-patel-hs)
- [#181](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/181) Rate Limit support - [ceshihao](https://github.com/ceshihao)
- [#161](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/161) Retry on server stream call - [lonnblad](https://github.com/lonnblad)
- [#152](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/152) Exponential backoff functions - [polyfloyd](https://github.com/polyfloyd)
- [#147](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/147) Jaeger support for ctxtags extraction - [vporoshok](https://github.com/vporoshok)
- [#184](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/184) ctxTags identifies if the call was sampled
### Deprecated
- [#201](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/201) `golang.org/x/net/context` - [houz42](https://github.com/houz42)
- [#183](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/183) Documentation Generation in favour of <godoc.org>.
### Fixed
- [172](https://github.com/grpc-ecosystem/go-grpc-middleware/pull/172) Passing ctx into retry and recover - [johanbrandhorst](https://github.com/johanbrandhorst)
- Numerious documentation fixes.
## v1.0.0 - 2018-05-08
### Added
- grpc_auth
- grpc_ctxtags
- grpc_zap
- grpc_logrus
- grpc_opentracing
- grpc_retry
- grpc_validator
- grpc_recovery
[Unreleased]: https://github.com/grpc-ecosystem/go-grpc-middleware/compare/v1.1.0...HEAD
[v1.1.0]: https://github.com/grpc-ecosystem/go-grpc-middleware/compare/v1.0.0...v1.1.0
+31 -24
View File
@@ -7,16 +7,23 @@
[![codecov](https://codecov.io/gh/grpc-ecosystem/go-grpc-middleware/branch/master/graph/badge.svg)](https://codecov.io/gh/grpc-ecosystem/go-grpc-middleware)
[![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
[![quality: production](https://img.shields.io/badge/quality-production-orange.svg)](#status)
[![Slack](https://img.shields.io/badge/slack-%23grpc--middleware-brightgreen)](https://slack.com/share/IRUQCFC23/9Tm7hxRFVKKNoajQfMOcUiIk/enQtODc4ODI4NTIyMDcxLWM5NDA0ZTE4Njg5YjRjYWZkMTI5MzQwNDY3YzBjMzE1YzdjOGM5ZjI1NDNiM2JmNzI2YjM5ODE5OTRiNTEyOWE)
[![Slack](https://img.shields.io/badge/slack-%23grpc--middleware-brightgreen)](https://gophers.slack.com/archives/CNJL30P4P)
[gRPC Go](https://github.com/grpc/grpc-go) Middleware: interceptors, helpers, utilities.
## ⚠️ Status
Version [v2](https://github.com/grpc-ecosystem/go-grpc-middleware/tree/v2) is about to be released, with migration guide, which will replace v1. Try v2 and give us feedback!
Version v1 is currently in deprecation mode, which means only critical and safety bug fixes will be merged.
## Middleware
[gRPC Go](https://github.com/grpc/grpc-go) recently acquired support for
Interceptors, i.e. [middleware](https://medium.com/@matryer/writing-middleware-in-golang-and-how-go-makes-it-so-much-fun-4375c1246e81#.gv7tdlghs)
Interceptors, i.e. [middleware](https://medium.com/@matryer/writing-middleware-in-golang-and-how-go-makes-it-so-much-fun-4375c1246e81#.gv7tdlghs)
that is executed either on the gRPC Server before the request is passed onto the user's application logic, or on the gRPC client around the user call. It is a perfect way to implement
common patterns: auth, logging, message, validation, retries or monitoring.
common patterns: auth, logging, message, validation, retries, or monitoring.
These are generic building blocks that make it easy to build multiple microservices easily.
The purpose of this repository is to act as a go-to point for such reusable functionality. It contains
@@ -29,57 +36,57 @@ import "github.com/grpc-ecosystem/go-grpc-middleware"
myServer := grpc.NewServer(
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
grpc_recovery.StreamServerInterceptor(),
grpc_ctxtags.StreamServerInterceptor(),
grpc_opentracing.StreamServerInterceptor(),
grpc_prometheus.StreamServerInterceptor,
grpc_zap.StreamServerInterceptor(zapLogger),
grpc_auth.StreamServerInterceptor(myAuthFunction),
grpc_recovery.StreamServerInterceptor(),
)),
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
grpc_recovery.UnaryServerInterceptor(),
grpc_ctxtags.UnaryServerInterceptor(),
grpc_opentracing.UnaryServerInterceptor(),
grpc_prometheus.UnaryServerInterceptor,
grpc_zap.UnaryServerInterceptor(zapLogger),
grpc_auth.UnaryServerInterceptor(myAuthFunction),
grpc_recovery.UnaryServerInterceptor(),
)),
)
```
## Interceptors
*Please send a PR to add new interceptors or middleware to this list*
_Please send a PR to add new interceptors or middleware to this list_
#### Auth
* [`grpc_auth`](auth) - a customizable (via `AuthFunc`) piece of auth middleware
- [`grpc_auth`](auth) - a customizable (via `AuthFunc`) piece of auth middleware
#### Logging
* [`grpc_ctxtags`](tags/) - a library that adds a `Tag` map to context, with data populated from request body
* [`grpc_zap`](logging/zap/) - integration of [zap](https://github.com/uber-go/zap) logging library into gRPC handlers.
* [`grpc_logrus`](logging/logrus/) - integration of [logrus](https://github.com/sirupsen/logrus) logging library into gRPC handlers.
* [`grpc_kit`](logging/kit/) - integration of [go-kit](https://github.com/go-kit/kit/tree/master/log) logging library into gRPC handlers.
* [`grpc_grpc_logsettable`](logging/settable/) - a wrapper around `grpclog.LoggerV2` that allows to replace loggers in runtime (thread-safe).
- [`grpc_ctxtags`](tags/) - a library that adds a `Tag` map to context, with data populated from request body
- [`grpc_zap`](logging/zap/) - integration of [zap](https://github.com/uber-go/zap) logging library into gRPC handlers.
- [`grpc_logrus`](logging/logrus/) - integration of [logrus](https://github.com/sirupsen/logrus) logging library into gRPC handlers.
- [`grpc_kit`](logging/kit/) - integration of [go-kit/log](https://github.com/go-kit/log) logging library into gRPC handlers.
- [`grpc_grpc_logsettable`](logging/settable/) - a wrapper around `grpclog.LoggerV2` that allows to replace loggers in runtime (thread-safe).
#### Monitoring
* [`grpc_prometheus`⚡](https://github.com/grpc-ecosystem/go-grpc-prometheus) - Prometheus client-side and server-side monitoring middleware
* [`otgrpc`⚡](https://github.com/grpc-ecosystem/grpc-opentracing/tree/master/go/otgrpc) - [OpenTracing](http://opentracing.io/) client-side and server-side interceptors
* [`grpc_opentracing`](tracing/opentracing) - [OpenTracing](http://opentracing.io/) client-side and server-side interceptors with support for streaming and handler-returned tags
- [`grpc_prometheus`⚡](https://github.com/grpc-ecosystem/go-grpc-prometheus) - Prometheus client-side and server-side monitoring middleware
- [`otgrpc`⚡](https://github.com/grpc-ecosystem/grpc-opentracing/tree/master/go/otgrpc) - [OpenTracing](http://opentracing.io/) client-side and server-side interceptors
- [`grpc_opentracing`](tracing/opentracing) - [OpenTracing](http://opentracing.io/) client-side and server-side interceptors with support for streaming and handler-returned tags
- [`otelgrpc`](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/google.golang.org/grpc/otelgrpc) - [OpenTelemetry](https://opentelemetry.io/) client-side and server-side interceptors
#### Client
* [`grpc_retry`](retry/) - a generic gRPC response code retry mechanism, client-side middleware
- [`grpc_retry`](retry/) - a generic gRPC response code retry mechanism, client-side middleware
#### Server
* [`grpc_validator`](validator/) - codegen inbound message validation from `.proto` options
* [`grpc_recovery`](recovery/) - turn panics into gRPC errors
* [`ratelimit`](ratelimit/) - grpc rate limiting by your own limiter
- [`grpc_validator`](validator/) - codegen inbound message validation from `.proto` options
- [`grpc_recovery`](recovery/) - turn panics into gRPC errors
- [`ratelimit`](ratelimit/) - grpc rate limiting by your own limiter
## Status
This code has been running in *production* since May 2016 as the basis of the gRPC micro services stack at [Improbable](https://improbable.io).
Additional tooling will be added, and contributions are welcome.
## License
+89 -43
View File
@@ -16,22 +16,41 @@ import (
// Execution is done in left-to-right order, including passing of context.
// For example ChainUnaryServer(one, two, three) will execute one before two before three, and three
// will see context changes of one and two.
//
// While this can be useful in some scenarios, it is generally advisable to use google.golang.org/grpc.ChainUnaryInterceptor directly.
func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor {
n := len(interceptors)
// Dummy interceptor maintained for backward compatibility to avoid returning nil.
if n == 0 {
return func(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
return handler(ctx, req)
}
}
// The degenerate case, just return the single wrapped interceptor directly.
if n == 1 {
return interceptors[0]
}
// Return a function which satisfies the interceptor interface, and which is
// a closure over the given list of interceptors to be chained.
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
chainer := func(currentInter grpc.UnaryServerInterceptor, currentHandler grpc.UnaryHandler) grpc.UnaryHandler {
return func(currentCtx context.Context, currentReq interface{}) (interface{}, error) {
return currentInter(currentCtx, currentReq, info, currentHandler)
currHandler := handler
// Iterate backwards through all interceptors except the first (outermost).
// Wrap each one in a function which satisfies the handler interface, but
// is also a closure over the `info` and `handler` parameters. Then pass
// each pseudo-handler to the next outer interceptor as the handler to be called.
for i := n - 1; i > 0; i-- {
// Rebind to loop-local vars so they can be closed over.
innerHandler, i := currHandler, i
currHandler = func(currentCtx context.Context, currentReq interface{}) (interface{}, error) {
return interceptors[i](currentCtx, currentReq, info, innerHandler)
}
}
chainedHandler := handler
for i := n - 1; i >= 0; i-- {
chainedHandler = chainer(interceptors[i], chainedHandler)
}
return chainedHandler(ctx, req)
// Finally return the result of calling the outermost interceptor with the
// outermost pseudo-handler created above as its handler.
return interceptors[0](ctx, req, info, currHandler)
}
}
@@ -40,22 +59,31 @@ func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnarySer
// Execution is done in left-to-right order, including passing of context.
// For example ChainUnaryServer(one, two, three) will execute one before two before three.
// If you want to pass context between interceptors, use WrapServerStream.
//
// While this can be useful in some scenarios, it is generally advisable to use google.golang.org/grpc.ChainStreamInterceptor directly.
func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor {
n := len(interceptors)
return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
chainer := func(currentInter grpc.StreamServerInterceptor, currentHandler grpc.StreamHandler) grpc.StreamHandler {
return func(currentSrv interface{}, currentStream grpc.ServerStream) error {
return currentInter(currentSrv, currentStream, info, currentHandler)
// Dummy interceptor maintained for backward compatibility to avoid returning nil.
if n == 0 {
return func(srv interface{}, stream grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
return handler(srv, stream)
}
}
if n == 1 {
return interceptors[0]
}
return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
currHandler := handler
for i := n - 1; i > 0; i-- {
innerHandler, i := currHandler, i
currHandler = func(currentSrv interface{}, currentStream grpc.ServerStream) error {
return interceptors[i](currentSrv, currentStream, info, innerHandler)
}
}
chainedHandler := handler
for i := n - 1; i >= 0; i-- {
chainedHandler = chainer(interceptors[i], chainedHandler)
}
return chainedHandler(srv, ss)
return interceptors[0](srv, stream, info, currHandler)
}
}
@@ -66,19 +94,26 @@ func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.Stream
func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor {
n := len(interceptors)
// Dummy interceptor maintained for backward compatibility to avoid returning nil.
if n == 0 {
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
return invoker(ctx, method, req, reply, cc, opts...)
}
}
if n == 1 {
return interceptors[0]
}
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
chainer := func(currentInter grpc.UnaryClientInterceptor, currentInvoker grpc.UnaryInvoker) grpc.UnaryInvoker {
return func(currentCtx context.Context, currentMethod string, currentReq, currentRepl interface{}, currentConn *grpc.ClientConn, currentOpts ...grpc.CallOption) error {
return currentInter(currentCtx, currentMethod, currentReq, currentRepl, currentConn, currentInvoker, currentOpts...)
currInvoker := invoker
for i := n - 1; i > 0; i-- {
innerInvoker, i := currInvoker, i
currInvoker = func(currentCtx context.Context, currentMethod string, currentReq, currentRepl interface{}, currentConn *grpc.ClientConn, currentOpts ...grpc.CallOption) error {
return interceptors[i](currentCtx, currentMethod, currentReq, currentRepl, currentConn, innerInvoker, currentOpts...)
}
}
chainedInvoker := invoker
for i := n - 1; i >= 0; i-- {
chainedInvoker = chainer(interceptors[i], chainedInvoker)
}
return chainedInvoker(ctx, method, req, reply, cc, opts...)
return interceptors[0](ctx, method, req, reply, cc, currInvoker, opts...)
}
}
@@ -89,19 +124,26 @@ func ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryCli
func ChainStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.StreamClientInterceptor {
n := len(interceptors)
// Dummy interceptor maintained for backward compatibility to avoid returning nil.
if n == 0 {
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
return streamer(ctx, desc, cc, method, opts...)
}
}
if n == 1 {
return interceptors[0]
}
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
chainer := func(currentInter grpc.StreamClientInterceptor, currentStreamer grpc.Streamer) grpc.Streamer {
return func(currentCtx context.Context, currentDesc *grpc.StreamDesc, currentConn *grpc.ClientConn, currentMethod string, currentOpts ...grpc.CallOption) (grpc.ClientStream, error) {
return currentInter(currentCtx, currentDesc, currentConn, currentMethod, currentStreamer, currentOpts...)
currStreamer := streamer
for i := n - 1; i > 0; i-- {
innerStreamer, i := currStreamer, i
currStreamer = func(currentCtx context.Context, currentDesc *grpc.StreamDesc, currentConn *grpc.ClientConn, currentMethod string, currentOpts ...grpc.CallOption) (grpc.ClientStream, error) {
return interceptors[i](currentCtx, currentDesc, currentConn, currentMethod, innerStreamer, currentOpts...)
}
}
chainedStreamer := streamer
for i := n - 1; i >= 0; i-- {
chainedStreamer = chainer(interceptors[i], chainedStreamer)
}
return chainedStreamer(ctx, desc, cc, method, opts...)
return interceptors[0](ctx, desc, cc, method, currStreamer, opts...)
}
}
@@ -109,12 +151,16 @@ func ChainStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.Stream
//
// WithUnaryServerChain is a grpc.Server config option that accepts multiple unary interceptors.
// Basically syntactic sugar.
//
// Deprecated: use google.golang.org/grpc.ChainUnaryInterceptor instead.
func WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption {
return grpc.UnaryInterceptor(ChainUnaryServer(interceptors...))
return grpc.ChainUnaryInterceptor(interceptors...)
}
// WithStreamServerChain is a grpc.Server config option that accepts multiple stream interceptors.
// Basically syntactic sugar.
//
// Deprecated: use google.golang.org/grpc.ChainStreamInterceptor instead.
func WithStreamServerChain(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption {
return grpc.StreamInterceptor(ChainStreamServer(interceptors...))
return grpc.ChainStreamInterceptor(interceptors...)
}
@@ -10,7 +10,7 @@ import (
"google.golang.org/grpc/metadata"
)
// NiceMD is a convenience wrapper definiting extra functions on the metadata.
// NiceMD is a convenience wrapper defining extra functions on the metadata.
type NiceMD metadata.MD
// ExtractIncoming extracts an inbound metadata from the server-side context.
@@ -39,7 +39,7 @@ func ExtractOutgoing(ctx context.Context) NiceMD {
// Clone performs a *deep* copy of the metadata.MD.
//
// You can specify the lower-case copiedKeys to only copy certain whitelisted keys. If no keys are explicitly whitelisted
// You can specify the lower-case copiedKeys to only copy certain allow-listed keys. If no keys are explicitly allow-listed
// all keys get copied.
func (m NiceMD) Clone(copiedKeys ...string) NiceMD {
newMd := NiceMD(metadata.Pairs())
@@ -61,7 +61,7 @@ func (m NiceMD) Clone(copiedKeys ...string) NiceMD {
newMd[k] = make([]string, len(vv))
copy(newMd[k], vv)
}
return NiceMD(newMd)
return newMd
}
// ToOutgoing sets the given NiceMD as a client-side context for dispatching.
+1 -4
View File
@@ -365,10 +365,7 @@ func (t *Table) renderRowsHeader(out *strings.Builder) {
func (t *Table) renderTitle(out *strings.Builder) {
if t.title != "" {
colors := t.style.Title.Colors
colorsBorder := colors
if t.style.Options.DoNotColorBordersAndSeparators {
colorsBorder = nil
}
colorsBorder := t.getBorderColors(renderHint{isTitleRow: true})
rowLength := t.maxRowLength
if t.allowedRowLength != 0 && t.allowedRowLength < rowLength {
rowLength = t.allowedRowLength
+1
View File
@@ -12,6 +12,7 @@ type renderHint struct {
isLastLineOfRow bool // last-line of the current row?
isLastRow bool // last-row of header/footer/regular-rows?
isSeparatorRow bool // separator row?
isTitleRow bool // title row?
rowLineNumber int // the line number for a multi-line row
rowNumber int // the row number/index
}
+15 -13
View File
@@ -533,11 +533,13 @@ var (
// ColorOptions defines the ANSI colors to use for parts of the Table.
type ColorOptions struct {
IndexColumn text.Colors // index-column colors (row #, etc.)
Border text.Colors // borders (if nil, uses one of the below)
Footer text.Colors // footer row(s) colors
Header text.Colors // header row(s) colors
IndexColumn text.Colors // index-column colors (row #, etc.)
Row text.Colors // regular row(s) colors
RowAlternate text.Colors // regular row(s) colors for the even-numbered rows
Separator text.Colors // separators (if nil, uses one of the above)
}
var (
@@ -552,18 +554,18 @@ var (
// ColorOptionsBlackOnBlueWhite renders Black text on Blue/White background.
ColorOptionsBlackOnBlueWhite = ColorOptions{
IndexColumn: text.Colors{text.BgHiBlue, text.FgBlack},
Footer: text.Colors{text.BgBlue, text.FgBlack},
Header: text.Colors{text.BgHiBlue, text.FgBlack},
IndexColumn: text.Colors{text.BgHiBlue, text.FgBlack},
Row: text.Colors{text.BgHiWhite, text.FgBlack},
RowAlternate: text.Colors{text.BgWhite, text.FgBlack},
}
// ColorOptionsBlackOnCyanWhite renders Black text on Cyan/White background.
ColorOptionsBlackOnCyanWhite = ColorOptions{
IndexColumn: text.Colors{text.BgHiCyan, text.FgBlack},
Footer: text.Colors{text.BgCyan, text.FgBlack},
Header: text.Colors{text.BgHiCyan, text.FgBlack},
IndexColumn: text.Colors{text.BgHiCyan, text.FgBlack},
Row: text.Colors{text.BgHiWhite, text.FgBlack},
RowAlternate: text.Colors{text.BgWhite, text.FgBlack},
}
@@ -571,9 +573,9 @@ var (
// ColorOptionsBlackOnGreenWhite renders Black text on Green/White
// background.
ColorOptionsBlackOnGreenWhite = ColorOptions{
IndexColumn: text.Colors{text.BgHiGreen, text.FgBlack},
Footer: text.Colors{text.BgGreen, text.FgBlack},
Header: text.Colors{text.BgHiGreen, text.FgBlack},
IndexColumn: text.Colors{text.BgHiGreen, text.FgBlack},
Row: text.Colors{text.BgHiWhite, text.FgBlack},
RowAlternate: text.Colors{text.BgWhite, text.FgBlack},
}
@@ -581,18 +583,18 @@ var (
// ColorOptionsBlackOnMagentaWhite renders Black text on Magenta/White
// background.
ColorOptionsBlackOnMagentaWhite = ColorOptions{
IndexColumn: text.Colors{text.BgHiMagenta, text.FgBlack},
Footer: text.Colors{text.BgMagenta, text.FgBlack},
Header: text.Colors{text.BgHiMagenta, text.FgBlack},
IndexColumn: text.Colors{text.BgHiMagenta, text.FgBlack},
Row: text.Colors{text.BgHiWhite, text.FgBlack},
RowAlternate: text.Colors{text.BgWhite, text.FgBlack},
}
// ColorOptionsBlackOnRedWhite renders Black text on Red/White background.
ColorOptionsBlackOnRedWhite = ColorOptions{
IndexColumn: text.Colors{text.BgHiRed, text.FgBlack},
Footer: text.Colors{text.BgRed, text.FgBlack},
Header: text.Colors{text.BgHiRed, text.FgBlack},
IndexColumn: text.Colors{text.BgHiRed, text.FgBlack},
Row: text.Colors{text.BgHiWhite, text.FgBlack},
RowAlternate: text.Colors{text.BgWhite, text.FgBlack},
}
@@ -600,27 +602,27 @@ var (
// ColorOptionsBlackOnYellowWhite renders Black text on Yellow/White
// background.
ColorOptionsBlackOnYellowWhite = ColorOptions{
IndexColumn: text.Colors{text.BgHiYellow, text.FgBlack},
Footer: text.Colors{text.BgYellow, text.FgBlack},
Header: text.Colors{text.BgHiYellow, text.FgBlack},
IndexColumn: text.Colors{text.BgHiYellow, text.FgBlack},
Row: text.Colors{text.BgHiWhite, text.FgBlack},
RowAlternate: text.Colors{text.BgWhite, text.FgBlack},
}
// ColorOptionsBlueWhiteOnBlack renders Blue/White text on Black background.
ColorOptionsBlueWhiteOnBlack = ColorOptions{
IndexColumn: text.Colors{text.FgHiBlue, text.BgHiBlack},
Footer: text.Colors{text.FgBlue, text.BgHiBlack},
Header: text.Colors{text.FgHiBlue, text.BgHiBlack},
IndexColumn: text.Colors{text.FgHiBlue, text.BgHiBlack},
Row: text.Colors{text.FgHiWhite, text.BgBlack},
RowAlternate: text.Colors{text.FgWhite, text.BgBlack},
}
// ColorOptionsCyanWhiteOnBlack renders Cyan/White text on Black background.
ColorOptionsCyanWhiteOnBlack = ColorOptions{
IndexColumn: text.Colors{text.FgHiCyan, text.BgHiBlack},
Footer: text.Colors{text.FgCyan, text.BgHiBlack},
Header: text.Colors{text.FgHiCyan, text.BgHiBlack},
IndexColumn: text.Colors{text.FgHiCyan, text.BgHiBlack},
Row: text.Colors{text.FgHiWhite, text.BgBlack},
RowAlternate: text.Colors{text.FgWhite, text.BgBlack},
}
@@ -628,9 +630,9 @@ var (
// ColorOptionsGreenWhiteOnBlack renders Green/White text on Black
// background.
ColorOptionsGreenWhiteOnBlack = ColorOptions{
IndexColumn: text.Colors{text.FgHiGreen, text.BgHiBlack},
Footer: text.Colors{text.FgGreen, text.BgHiBlack},
Header: text.Colors{text.FgHiGreen, text.BgHiBlack},
IndexColumn: text.Colors{text.FgHiGreen, text.BgHiBlack},
Row: text.Colors{text.FgHiWhite, text.BgBlack},
RowAlternate: text.Colors{text.FgWhite, text.BgBlack},
}
@@ -638,18 +640,18 @@ var (
// ColorOptionsMagentaWhiteOnBlack renders Magenta/White text on Black
// background.
ColorOptionsMagentaWhiteOnBlack = ColorOptions{
IndexColumn: text.Colors{text.FgHiMagenta, text.BgHiBlack},
Footer: text.Colors{text.FgMagenta, text.BgHiBlack},
Header: text.Colors{text.FgHiMagenta, text.BgHiBlack},
IndexColumn: text.Colors{text.FgHiMagenta, text.BgHiBlack},
Row: text.Colors{text.FgHiWhite, text.BgBlack},
RowAlternate: text.Colors{text.FgWhite, text.BgBlack},
}
// ColorOptionsRedWhiteOnBlack renders Red/White text on Black background.
ColorOptionsRedWhiteOnBlack = ColorOptions{
IndexColumn: text.Colors{text.FgHiRed, text.BgHiBlack},
Footer: text.Colors{text.FgRed, text.BgHiBlack},
Header: text.Colors{text.FgHiRed, text.BgHiBlack},
IndexColumn: text.Colors{text.FgHiRed, text.BgHiBlack},
Row: text.Colors{text.FgHiWhite, text.BgBlack},
RowAlternate: text.Colors{text.FgWhite, text.BgBlack},
}
@@ -657,9 +659,9 @@ var (
// ColorOptionsYellowWhiteOnBlack renders Yellow/White text on Black
// background.
ColorOptionsYellowWhiteOnBlack = ColorOptions{
IndexColumn: text.Colors{text.FgHiYellow, text.BgHiBlack},
Footer: text.Colors{text.FgYellow, text.BgHiBlack},
Header: text.Colors{text.FgHiYellow, text.BgHiBlack},
IndexColumn: text.Colors{text.FgHiYellow, text.BgHiBlack},
Row: text.Colors{text.FgHiWhite, text.BgBlack},
RowAlternate: text.Colors{text.FgWhite, text.BgBlack},
}
+26 -4
View File
@@ -328,6 +328,10 @@ func (t *Table) getAutoIndexColumnIDs() rowStr {
func (t *Table) getBorderColors(hint renderHint) text.Colors {
if t.style.Options.DoNotColorBordersAndSeparators {
return nil
} else if t.style.Color.Border != nil {
return t.style.Color.Border
} else if hint.isTitleRow {
return t.style.Title.Colors
} else if hint.isHeaderRow {
return t.style.Color.Header
} else if hint.isFooterRow {
@@ -383,12 +387,13 @@ func (t *Table) getBorderRight(hint renderHint) string {
}
func (t *Table) getColumnColors(colIdx int, hint renderHint) text.Colors {
if hint.isBorderOrSeparator() && t.style.Options.DoNotColorBordersAndSeparators {
return text.Colors{} // not nil to force caller to paint with no colors
if hint.isBorderOrSeparator() {
if colors := t.getColumnColorsForBorderOrSeparator(colIdx, hint); colors != nil {
return colors
}
}
if t.rowPainter != nil && hint.isRegularNonSeparatorRow() && !t.isIndexColumn(colIdx, hint) {
colors := t.rowsColors[hint.rowNumber-1]
if colors != nil {
if colors := t.rowsColors[hint.rowNumber-1]; colors != nil {
return colors
}
}
@@ -405,6 +410,19 @@ func (t *Table) getColumnColors(colIdx int, hint renderHint) text.Colors {
return nil
}
func (t *Table) getColumnColorsForBorderOrSeparator(colIdx int, hint renderHint) text.Colors {
if t.style.Options.DoNotColorBordersAndSeparators {
return text.Colors{} // not nil to force caller to paint with no colors
}
if (hint.isBorderBottom || hint.isBorderTop) && t.style.Color.Border != nil {
return t.style.Color.Border
}
if hint.isSeparatorRow && t.style.Color.Separator != nil {
return t.style.Color.Separator
}
return nil
}
func (t *Table) getColumnSeparator(row rowStr, colIdx int, hint renderHint) string {
separator := t.style.Box.MiddleVertical
if hint.isSeparatorRow {
@@ -585,6 +603,10 @@ func (t *Table) getRowConfig(hint renderHint) RowConfig {
func (t *Table) getSeparatorColors(hint renderHint) text.Colors {
if t.style.Options.DoNotColorBordersAndSeparators {
return nil
} else if (hint.isBorderBottom || hint.isBorderTop) && t.style.Color.Border != nil {
return t.style.Color.Border
} else if t.style.Color.Separator != nil {
return t.style.Color.Separator
} else if hint.isHeaderRow {
return t.style.Color.Header
} else if hint.isFooterRow {
+51
View File
@@ -0,0 +1,51 @@
package text
import "strings"
// Constants
const (
CSIStartRune = rune(91) // [
CSIStopRune = 'm'
EscapeReset = EscapeStart + "0" + EscapeStop
EscapeStart = "\x1b["
EscapeStartRune = rune(27) // \x1b
EscapeStop = "m"
EscapeStopRune = 'm'
OSIStartRune = rune(93) // ]
OSIStopRune = '\\'
)
type escKind int
const (
escKindUnknown escKind = iota
escKindCSI
escKindOSI
)
type escSeq struct {
isIn bool
content strings.Builder
kind escKind
}
func (e *escSeq) InspectRune(r rune) {
if !e.isIn && r == EscapeStartRune {
e.isIn = true
e.kind = escKindUnknown
e.content.Reset()
e.content.WriteRune(r)
} else if e.isIn {
switch {
case e.kind == escKindUnknown && r == CSIStartRune:
e.kind = escKindCSI
case e.kind == escKindUnknown && r == OSIStartRune:
e.kind = escKindOSI
case e.kind == escKindCSI && r == CSIStopRune || e.kind == escKindOSI && r == OSIStopRune:
e.isIn = false
e.kind = escKindUnknown
}
e.content.WriteRune(r)
}
return
}
+34 -52
View File
@@ -7,15 +7,6 @@ import (
"github.com/mattn/go-runewidth"
)
// Constants
const (
EscapeReset = EscapeStart + "0" + EscapeStop
EscapeStart = "\x1b["
EscapeStartRune = rune(27) // \x1b
EscapeStop = "m"
EscapeStopRune = 'm'
)
// RuneWidth stuff
var (
rwCondition = runewidth.NewCondition()
@@ -35,23 +26,21 @@ func InsertEveryN(str string, runeToInsert rune, n int) string {
sLen := RuneWidthWithoutEscSequences(str)
var out strings.Builder
out.Grow(sLen + (sLen / n))
outLen, isEscSeq := 0, false
outLen, eSeq := 0, escSeq{}
for idx, c := range str {
if c == EscapeStartRune {
isEscSeq = true
if eSeq.isIn {
eSeq.InspectRune(c)
out.WriteRune(c)
continue
}
if !isEscSeq && outLen > 0 && (outLen%n) == 0 && idx != sLen {
eSeq.InspectRune(c)
if !eSeq.isIn && outLen > 0 && (outLen%n) == 0 && idx != sLen {
out.WriteRune(runeToInsert)
}
out.WriteRune(c)
if !isEscSeq {
if !eSeq.isIn {
outLen += RuneWidth(c)
}
if isEscSeq && c == EscapeStopRune {
isEscSeq = false
}
}
return out.String()
}
@@ -60,21 +49,19 @@ func InsertEveryN(str string, runeToInsert rune, n int) string {
// argument string. For ex.:
// LongestLineLen("Ghost!\nCome back here!\nRight now!") == 15
func LongestLineLen(str string) int {
maxLength, currLength, isEscSeq := 0, 0, false
maxLength, currLength, eSeq := 0, 0, escSeq{}
for _, c := range str {
if c == EscapeStartRune {
isEscSeq = true
} else if isEscSeq && c == EscapeStopRune {
isEscSeq = false
if eSeq.isIn {
eSeq.InspectRune(c)
continue
}
eSeq.InspectRune(c)
if c == '\n' {
if currLength > maxLength {
maxLength = currLength
}
currLength = 0
} else if !isEscSeq {
} else if !eSeq.isIn {
currLength += RuneWidth(c)
}
}
@@ -164,15 +151,14 @@ func RuneWidth(r rune) int {
// RuneWidthWithoutEscSequences("\x1b[33mGhost\x1b[0m") == 5
// RuneWidthWithoutEscSequences("\x1b[33mGhost\x1b[0") == 5
func RuneWidthWithoutEscSequences(str string) int {
count, isEscSeq := 0, false
count, eSeq := 0, escSeq{}
for _, c := range str {
if c == EscapeStartRune {
isEscSeq = true
} else if isEscSeq {
if c == EscapeStopRune {
isEscSeq = false
}
} else {
if eSeq.isIn {
eSeq.InspectRune(c)
continue
}
eSeq.InspectRune(c)
if !eSeq.isIn {
count += RuneWidth(c)
}
}
@@ -211,27 +197,23 @@ func Trim(str string, maxLen int) string {
var out strings.Builder
out.Grow(maxLen)
outLen, isEscSeq, lastEscSeq := 0, false, strings.Builder{}
outLen, eSeq := 0, escSeq{}
for _, sChr := range str {
out.WriteRune(sChr)
if sChr == EscapeStartRune {
isEscSeq = true
lastEscSeq.Reset()
lastEscSeq.WriteRune(sChr)
} else if isEscSeq {
lastEscSeq.WriteRune(sChr)
if sChr == EscapeStopRune {
isEscSeq = false
}
} else {
if eSeq.isIn {
eSeq.InspectRune(sChr)
out.WriteRune(sChr)
continue
}
eSeq.InspectRune(sChr)
if eSeq.isIn {
out.WriteRune(sChr)
continue
}
if outLen < maxLen {
outLen++
if outLen == maxLen {
break
}
out.WriteRune(sChr)
continue
}
}
if lastEscSeq.Len() > 0 && lastEscSeq.String() != EscapeReset {
out.WriteString(EscapeReset)
}
return out.String()
}
+5 -10
View File
@@ -106,7 +106,6 @@ func (c *Client) Dial(address string) (conn *Conn, err error) {
}
// DialContext connects to the address on the named network, with a context.Context.
// For TLS over TCP (DoT) the context isn't used yet. This will be enabled when Go 1.18 is released.
func (c *Client) DialContext(ctx context.Context, address string) (conn *Conn, err error) {
// create a new dialer with the appropriate timeout
var d net.Dialer
@@ -127,15 +126,11 @@ func (c *Client) DialContext(ctx context.Context, address string) (conn *Conn, e
if useTLS {
network = strings.TrimSuffix(network, "-tls")
// TODO(miekg): Enable after Go 1.18 is released, to be able to support two prev. releases.
/*
tlsDialer := tls.Dialer{
NetDialer: &d,
Config: c.TLSConfig,
}
conn.Conn, err = tlsDialer.DialContext(ctx, network, address)
*/
conn.Conn, err = tls.DialWithDialer(&d, network, address, c.TLSConfig)
tlsDialer := tls.Dialer{
NetDialer: &d,
Config: c.TLSConfig,
}
conn.Conn, err = tlsDialer.DialContext(ctx, network, address)
} else {
conn.Conn, err = d.DialContext(ctx, network, address)
}
+1 -1
View File
@@ -68,7 +68,7 @@ func ClientConfigFromReader(resolvconf io.Reader) (*ClientConfig, error) {
}
case "search": // set search path to given servers
c.Search = append([]string(nil), f[1:]...)
c.Search = cloneSlice(f[1:])
case "options": // magic options
for _, s := range f[1:] {
+16 -29
View File
@@ -263,7 +263,7 @@ func (e *EDNS0_NSID) copy() EDNS0 { return &EDNS0_NSID{e.Code, e.Nsid}
// o.Hdr.Name = "."
// o.Hdr.Rrtype = dns.TypeOPT
// e := new(dns.EDNS0_SUBNET)
// e.Code = dns.EDNS0SUBNET // by default this is filled in through unpacking OPT packets (unpackDataOpt)
// e.Code = dns.EDNS0SUBNET // by default this is filled in through unpacking OPT packets (unpackDataOpt)
// e.Family = 1 // 1 for IPv4 source address, 2 for IPv6
// e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6
// e.SourceScope = 0
@@ -520,8 +520,8 @@ type EDNS0_DAU struct {
// Option implements the EDNS0 interface.
func (e *EDNS0_DAU) Option() uint16 { return EDNS0DAU }
func (e *EDNS0_DAU) pack() ([]byte, error) { return e.AlgCode, nil }
func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = b; return nil }
func (e *EDNS0_DAU) pack() ([]byte, error) { return cloneSlice(e.AlgCode), nil }
func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = cloneSlice(b); return nil }
func (e *EDNS0_DAU) String() string {
s := ""
@@ -544,8 +544,8 @@ type EDNS0_DHU struct {
// Option implements the EDNS0 interface.
func (e *EDNS0_DHU) Option() uint16 { return EDNS0DHU }
func (e *EDNS0_DHU) pack() ([]byte, error) { return e.AlgCode, nil }
func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = b; return nil }
func (e *EDNS0_DHU) pack() ([]byte, error) { return cloneSlice(e.AlgCode), nil }
func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = cloneSlice(b); return nil }
func (e *EDNS0_DHU) String() string {
s := ""
@@ -568,8 +568,8 @@ type EDNS0_N3U struct {
// Option implements the EDNS0 interface.
func (e *EDNS0_N3U) Option() uint16 { return EDNS0N3U }
func (e *EDNS0_N3U) pack() ([]byte, error) { return e.AlgCode, nil }
func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = b; return nil }
func (e *EDNS0_N3U) pack() ([]byte, error) { return cloneSlice(e.AlgCode), nil }
func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = cloneSlice(b); return nil }
func (e *EDNS0_N3U) String() string {
// Re-use the hash map
@@ -646,30 +646,21 @@ type EDNS0_LOCAL struct {
// Option implements the EDNS0 interface.
func (e *EDNS0_LOCAL) Option() uint16 { return e.Code }
func (e *EDNS0_LOCAL) String() string {
return strconv.FormatInt(int64(e.Code), 10) + ":0x" + hex.EncodeToString(e.Data)
}
func (e *EDNS0_LOCAL) copy() EDNS0 {
b := make([]byte, len(e.Data))
copy(b, e.Data)
return &EDNS0_LOCAL{e.Code, b}
return &EDNS0_LOCAL{e.Code, cloneSlice(e.Data)}
}
func (e *EDNS0_LOCAL) pack() ([]byte, error) {
b := make([]byte, len(e.Data))
copied := copy(b, e.Data)
if copied != len(e.Data) {
return nil, ErrBuf
}
return b, nil
return cloneSlice(e.Data), nil
}
func (e *EDNS0_LOCAL) unpack(b []byte) error {
e.Data = make([]byte, len(b))
copied := copy(e.Data, b)
if copied != len(b) {
return ErrBuf
}
e.Data = cloneSlice(b)
return nil
}
@@ -732,14 +723,10 @@ type EDNS0_PADDING struct {
// Option implements the EDNS0 interface.
func (e *EDNS0_PADDING) Option() uint16 { return EDNS0PADDING }
func (e *EDNS0_PADDING) pack() ([]byte, error) { return e.Padding, nil }
func (e *EDNS0_PADDING) unpack(b []byte) error { e.Padding = b; return nil }
func (e *EDNS0_PADDING) pack() ([]byte, error) { return cloneSlice(e.Padding), nil }
func (e *EDNS0_PADDING) unpack(b []byte) error { e.Padding = cloneSlice(b); return nil }
func (e *EDNS0_PADDING) String() string { return fmt.Sprintf("%0X", e.Padding) }
func (e *EDNS0_PADDING) copy() EDNS0 {
b := make([]byte, len(e.Padding))
copy(b, e.Padding)
return &EDNS0_PADDING{b}
}
func (e *EDNS0_PADDING) copy() EDNS0 { return &EDNS0_PADDING{cloneSlice(e.Padding)} }
// Extended DNS Error Codes (RFC 8914).
const (
@@ -826,7 +813,7 @@ func (e *EDNS0_EDE) String() string {
func (e *EDNS0_EDE) pack() ([]byte, error) {
b := make([]byte, 2+len(e.ExtraText))
binary.BigEndian.PutUint16(b[0:], e.InfoCode)
copy(b[2:], []byte(e.ExtraText))
copy(b[2:], e.ExtraText)
return b, nil
}
+2 -2
View File
@@ -1,5 +1,5 @@
//go:build !go1.11 || (!aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd)
// +build !go1.11 !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd
// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
package dns
+1 -2
View File
@@ -1,5 +1,4 @@
//go:build go1.11 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd)
// +build go1.11
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build aix darwin dragonfly freebsd linux netbsd openbsd
package dns
+13 -18
View File
@@ -448,7 +448,7 @@ Loop:
return string(s), off1, nil
}
func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) {
func packTxt(txt []string, msg []byte, offset int) (int, error) {
if len(txt) == 0 {
if offset >= len(msg) {
return offset, ErrBuf
@@ -458,10 +458,7 @@ func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) {
}
var err error
for _, s := range txt {
if len(s) > len(tmp) {
return offset, ErrBuf
}
offset, err = packTxtString(s, msg, offset, tmp)
offset, err = packTxtString(s, msg, offset)
if err != nil {
return offset, err
}
@@ -469,32 +466,30 @@ func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) {
return offset, nil
}
func packTxtString(s string, msg []byte, offset int, tmp []byte) (int, error) {
func packTxtString(s string, msg []byte, offset int) (int, error) {
lenByteOffset := offset
if offset >= len(msg) || len(s) > len(tmp) {
if offset >= len(msg) || len(s) > 256*4+1 /* If all \DDD */ {
return offset, ErrBuf
}
offset++
bs := tmp[:len(s)]
copy(bs, s)
for i := 0; i < len(bs); i++ {
for i := 0; i < len(s); i++ {
if len(msg) <= offset {
return offset, ErrBuf
}
if bs[i] == '\\' {
if s[i] == '\\' {
i++
if i == len(bs) {
if i == len(s) {
break
}
// check for \DDD
if i+2 < len(bs) && isDigit(bs[i]) && isDigit(bs[i+1]) && isDigit(bs[i+2]) {
msg[offset] = dddToByte(bs[i:])
if i+2 < len(s) && isDigit(s[i]) && isDigit(s[i+1]) && isDigit(s[i+2]) {
msg[offset] = dddStringToByte(s[i:])
i += 2
} else {
msg[offset] = bs[i]
msg[offset] = s[i]
}
} else {
msg[offset] = bs[i]
msg[offset] = s[i]
}
offset++
}
@@ -1065,8 +1060,8 @@ func (dns *Msg) CopyTo(r1 *Msg) *Msg {
r1.Compress = dns.Compress
if len(dns.Question) > 0 {
r1.Question = make([]Question, len(dns.Question))
copy(r1.Question, dns.Question) // TODO(miek): Question is an immutable value, ok to do a shallow-copy
// TODO(miek): Question is an immutable value, ok to do a shallow-copy
r1.Question = cloneSlice(dns.Question)
}
rrArr := make([]RR, len(dns.Answer)+len(dns.Ns)+len(dns.Extra))
+3 -5
View File
@@ -299,8 +299,7 @@ func unpackString(msg []byte, off int) (string, int, error) {
}
func packString(s string, msg []byte, off int) (int, error) {
txtTmp := make([]byte, 256*4+1)
off, err := packTxtString(s, msg, off, txtTmp)
off, err := packTxtString(s, msg, off)
if err != nil {
return len(msg), err
}
@@ -402,8 +401,7 @@ func unpackStringTxt(msg []byte, off int) ([]string, int, error) {
}
func packStringTxt(s []string, msg []byte, off int) (int, error) {
txtTmp := make([]byte, 256*4+1) // If the whole string consists out of \DDD we need this many.
off, err := packTxt(s, msg, off, txtTmp)
off, err := packTxt(s, msg, off)
if err != nil {
return len(msg), err
}
@@ -625,7 +623,7 @@ func unpackDataSVCB(msg []byte, off int) ([]SVCBKeyValue, int, error) {
}
func packDataSVCB(pairs []SVCBKeyValue, msg []byte, off int) (int, error) {
pairs = append([]SVCBKeyValue(nil), pairs...)
pairs = cloneSlice(pairs)
sort.Slice(pairs, func(i, j int) bool {
return pairs[i].Key() < pairs[j].Key()
})
+1 -1
View File
@@ -1249,7 +1249,7 @@ func (rr *IPSECKEY) parse(c *zlexer, o string) *ParseError {
rr.GatewayAddr, rr.GatewayHost, err = parseAddrHostUnion(l.token, o, rr.GatewayType)
if err != nil {
return &ParseError{"", "AMTRELAY " + err.Error(), l}
return &ParseError{"", "IPSECKEY " + err.Error(), l}
}
c.Next() // zBlank
+1 -1
View File
@@ -224,7 +224,7 @@ type Server struct {
// Maximum number of TCP queries before we close the socket. Default is maxTCPQueries (unlimited if -1).
MaxTCPQueries int
// Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address.
// It is only supported on go1.11+ and when using ListenAndServe.
// It is only supported on certain GOOSes and when using ListenAndServe.
ReusePort bool
// AcceptMsgFunc will check the incoming message and will reject it early in the process.
// By default DefaultMsgAcceptFunc will be used.
+18 -29
View File
@@ -289,7 +289,7 @@ func (s *SVCBMandatory) String() string {
}
func (s *SVCBMandatory) pack() ([]byte, error) {
codes := append([]SVCBKey(nil), s.Code...)
codes := cloneSlice(s.Code)
sort.Slice(codes, func(i, j int) bool {
return codes[i] < codes[j]
})
@@ -328,9 +328,7 @@ func (s *SVCBMandatory) len() int {
}
func (s *SVCBMandatory) copy() SVCBKeyValue {
return &SVCBMandatory{
append([]SVCBKey(nil), s.Code...),
}
return &SVCBMandatory{cloneSlice(s.Code)}
}
// SVCBAlpn pair is used to list supported connection protocols.
@@ -481,9 +479,7 @@ func (s *SVCBAlpn) len() int {
}
func (s *SVCBAlpn) copy() SVCBKeyValue {
return &SVCBAlpn{
append([]string(nil), s.Alpn...),
}
return &SVCBAlpn{cloneSlice(s.Alpn)}
}
// SVCBNoDefaultAlpn pair signifies no support for default connection protocols.
@@ -595,6 +591,7 @@ func (s *SVCBIPv4Hint) unpack(b []byte) error {
if len(b) == 0 || len(b)%4 != 0 {
return errors.New("dns: svcbipv4hint: ipv4 address byte array length is not a multiple of 4")
}
b = cloneSlice(b)
x := make([]net.IP, 0, len(b)/4)
for i := 0; i < len(b); i += 4 {
x = append(x, net.IP(b[i:i+4]))
@@ -635,12 +632,9 @@ func (s *SVCBIPv4Hint) parse(b string) error {
func (s *SVCBIPv4Hint) copy() SVCBKeyValue {
hint := make([]net.IP, len(s.Hint))
for i, ip := range s.Hint {
hint[i] = copyIP(ip)
}
return &SVCBIPv4Hint{
Hint: hint,
hint[i] = cloneSlice(ip)
}
return &SVCBIPv4Hint{Hint: hint}
}
// SVCBECHConfig pair contains the ECHConfig structure defined in draft-ietf-tls-esni [RFC xxxx].
@@ -660,19 +654,18 @@ func (s *SVCBECHConfig) String() string { return toBase64(s.ECH) }
func (s *SVCBECHConfig) len() int { return len(s.ECH) }
func (s *SVCBECHConfig) pack() ([]byte, error) {
return append([]byte(nil), s.ECH...), nil
return cloneSlice(s.ECH), nil
}
func (s *SVCBECHConfig) copy() SVCBKeyValue {
return &SVCBECHConfig{
append([]byte(nil), s.ECH...),
}
return &SVCBECHConfig{cloneSlice(s.ECH)}
}
func (s *SVCBECHConfig) unpack(b []byte) error {
s.ECH = append([]byte(nil), b...)
s.ECH = cloneSlice(b)
return nil
}
func (s *SVCBECHConfig) parse(b string) error {
x, err := fromBase64([]byte(b))
if err != nil {
@@ -715,6 +708,7 @@ func (s *SVCBIPv6Hint) unpack(b []byte) error {
if len(b) == 0 || len(b)%16 != 0 {
return errors.New("dns: svcbipv6hint: ipv6 address byte array length not a multiple of 16")
}
b = cloneSlice(b)
x := make([]net.IP, 0, len(b)/16)
for i := 0; i < len(b); i += 16 {
ip := net.IP(b[i : i+16])
@@ -758,12 +752,9 @@ func (s *SVCBIPv6Hint) parse(b string) error {
func (s *SVCBIPv6Hint) copy() SVCBKeyValue {
hint := make([]net.IP, len(s.Hint))
for i, ip := range s.Hint {
hint[i] = copyIP(ip)
}
return &SVCBIPv6Hint{
Hint: hint,
hint[i] = cloneSlice(ip)
}
return &SVCBIPv6Hint{Hint: hint}
}
// SVCBDoHPath pair is used to indicate the URI template that the
@@ -831,11 +822,11 @@ type SVCBLocal struct {
func (s *SVCBLocal) Key() SVCBKey { return s.KeyCode }
func (s *SVCBLocal) String() string { return svcbParamToStr(s.Data) }
func (s *SVCBLocal) pack() ([]byte, error) { return append([]byte(nil), s.Data...), nil }
func (s *SVCBLocal) pack() ([]byte, error) { return cloneSlice(s.Data), nil }
func (s *SVCBLocal) len() int { return len(s.Data) }
func (s *SVCBLocal) unpack(b []byte) error {
s.Data = append([]byte(nil), b...)
s.Data = cloneSlice(b)
return nil
}
@@ -849,9 +840,7 @@ func (s *SVCBLocal) parse(b string) error {
}
func (s *SVCBLocal) copy() SVCBKeyValue {
return &SVCBLocal{s.KeyCode,
append([]byte(nil), s.Data...),
}
return &SVCBLocal{s.KeyCode, cloneSlice(s.Data)}
}
func (rr *SVCB) String() string {
@@ -867,8 +856,8 @@ func (rr *SVCB) String() string {
// areSVCBPairArraysEqual checks if SVCBKeyValue arrays are equal after sorting their
// copies. arrA and arrB have equal lengths, otherwise zduplicate.go wouldn't call this function.
func areSVCBPairArraysEqual(a []SVCBKeyValue, b []SVCBKeyValue) bool {
a = append([]SVCBKeyValue(nil), a...)
b = append([]SVCBKeyValue(nil), b...)
a = cloneSlice(a)
b = cloneSlice(b)
sort.Slice(a, func(i, j int) bool { return a[i].Key() < a[j].Key() })
sort.Slice(b, func(i, j int) bool { return b[i].Key() < b[j].Key() })
for i, e := range a {
+9 -11
View File
@@ -1531,7 +1531,7 @@ func (a *APLPrefix) str() string {
// equals reports whether two APL prefixes are identical.
func (a *APLPrefix) equals(b *APLPrefix) bool {
return a.Negation == b.Negation &&
bytes.Equal(a.Network.IP, b.Network.IP) &&
a.Network.IP.Equal(b.Network.IP) &&
bytes.Equal(a.Network.Mask, b.Network.Mask)
}
@@ -1599,21 +1599,19 @@ func euiToString(eui uint64, bits int) (hex string) {
return
}
// copyIP returns a copy of ip.
func copyIP(ip net.IP) net.IP {
p := make(net.IP, len(ip))
copy(p, ip)
return p
// cloneSlice returns a shallow copy of s.
func cloneSlice[E any, S ~[]E](s S) S {
if s == nil {
return nil
}
return append(S(nil), s...)
}
// copyNet returns a copy of a subnet.
func copyNet(n net.IPNet) net.IPNet {
m := make(net.IPMask, len(n.Mask))
copy(m, n.Mask)
return net.IPNet{
IP: copyIP(n.IP),
Mask: m,
IP: cloneSlice(n.IP),
Mask: cloneSlice(n.Mask),
}
}
+3 -4
View File
@@ -1,6 +1,9 @@
//go:build windows
// +build windows
// TODO(tmthrgd): Remove this Windows-specific code if go.dev/issue/7175 and
// go.dev/issue/7174 are ever fixed.
package dns
import "net"
@@ -15,7 +18,6 @@ func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr }
// ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a
// net.UDPAddr.
// TODO(fastest963): Once go1.10 is released, use ReadMsgUDP.
func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) {
n, raddr, err := conn.ReadFrom(b)
if err != nil {
@@ -25,12 +27,9 @@ func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) {
}
// WriteToSessionUDP acts just like net.UDPConn.WriteTo(), but uses a *SessionUDP instead of a net.Addr.
// TODO(fastest963): Once go1.10 is released, use WriteMsgUDP.
func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) {
return conn.WriteTo(b, session.raddr)
}
// TODO(fastest963): Once go1.10 is released and we can use *MsgUDP methods
// use the standard method in udp.go for these.
func setUDPSocketOptions(*net.UDPConn) error { return nil }
func parseDstFromOOB([]byte, net.IP) net.IP { return nil }
+1 -1
View File
@@ -3,7 +3,7 @@ package dns
import "fmt"
// Version is current version of this library.
var Version = v{1, 1, 51}
var Version = v{1, 1, 52}
// v holds the version of this library.
type v struct {
+364 -51
View File
@@ -263,6 +263,7 @@ func (rr *A) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *AAAA) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
if len(rr.AAAA) != 0 {
@@ -270,12 +271,14 @@ func (rr *AAAA) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *AFSDB) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Subtype
l += domainNameLen(rr.Hostname, off+l, compression, false)
return l
}
func (rr *AMTRELAY) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Precedence
@@ -290,10 +293,12 @@ func (rr *AMTRELAY) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *ANY) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
return l
}
func (rr *APL) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
for _, x := range rr.Prefixes {
@@ -301,6 +306,7 @@ func (rr *APL) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *AVC) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
for _, x := range rr.Txt {
@@ -308,6 +314,7 @@ func (rr *AVC) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *CAA) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Flag
@@ -315,6 +322,7 @@ func (rr *CAA) len(off int, compression map[string]struct{}) int {
l += len(rr.Value)
return l
}
func (rr *CERT) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Type
@@ -323,21 +331,25 @@ func (rr *CERT) len(off int, compression map[string]struct{}) int {
l += base64.StdEncoding.DecodedLen(len(rr.Certificate))
return l
}
func (rr *CNAME) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Target, off+l, compression, true)
return l
}
func (rr *DHCID) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += base64.StdEncoding.DecodedLen(len(rr.Digest))
return l
}
func (rr *DNAME) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Target, off+l, compression, false)
return l
}
func (rr *DNSKEY) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Flags
@@ -346,6 +358,7 @@ func (rr *DNSKEY) len(off int, compression map[string]struct{}) int {
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
return l
}
func (rr *DS) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // KeyTag
@@ -354,26 +367,31 @@ func (rr *DS) len(off int, compression map[string]struct{}) int {
l += len(rr.Digest) / 2
return l
}
func (rr *EID) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.Endpoint) / 2
return l
}
func (rr *EUI48) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 6 // Address
return l
}
func (rr *EUI64) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 8 // Address
return l
}
func (rr *GID) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 4 // Gid
return l
}
func (rr *GPOS) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.Longitude) + 1
@@ -381,12 +399,14 @@ func (rr *GPOS) len(off int, compression map[string]struct{}) int {
l += len(rr.Altitude) + 1
return l
}
func (rr *HINFO) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.Cpu) + 1
l += len(rr.Os) + 1
return l
}
func (rr *HIP) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // HitLength
@@ -399,6 +419,7 @@ func (rr *HIP) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *IPSECKEY) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Precedence
@@ -415,12 +436,14 @@ func (rr *IPSECKEY) len(off int, compression map[string]struct{}) int {
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
return l
}
func (rr *KX) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += domainNameLen(rr.Exchanger, off+l, compression, false)
return l
}
func (rr *L32) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
@@ -429,12 +452,14 @@ func (rr *L32) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *L64) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += 8 // Locator64
return l
}
func (rr *LOC) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Version
@@ -446,49 +471,58 @@ func (rr *LOC) len(off int, compression map[string]struct{}) int {
l += 4 // Altitude
return l
}
func (rr *LP) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += domainNameLen(rr.Fqdn, off+l, compression, false)
return l
}
func (rr *MB) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Mb, off+l, compression, true)
return l
}
func (rr *MD) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Md, off+l, compression, true)
return l
}
func (rr *MF) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Mf, off+l, compression, true)
return l
}
func (rr *MG) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Mg, off+l, compression, true)
return l
}
func (rr *MINFO) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Rmail, off+l, compression, true)
l += domainNameLen(rr.Email, off+l, compression, true)
return l
}
func (rr *MR) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Mr, off+l, compression, true)
return l
}
func (rr *MX) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += domainNameLen(rr.Mx, off+l, compression, true)
return l
}
func (rr *NAPTR) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Order
@@ -499,17 +533,20 @@ func (rr *NAPTR) len(off int, compression map[string]struct{}) int {
l += domainNameLen(rr.Replacement, off+l, compression, false)
return l
}
func (rr *NID) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += 8 // NodeID
return l
}
func (rr *NIMLOC) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.Locator) / 2
return l
}
func (rr *NINFO) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
for _, x := range rr.ZSData {
@@ -517,16 +554,19 @@ func (rr *NINFO) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *NS) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Ns, off+l, compression, true)
return l
}
func (rr *NSAPPTR) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Ptr, off+l, compression, false)
return l
}
func (rr *NSEC3PARAM) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Hash
@@ -536,21 +576,25 @@ func (rr *NSEC3PARAM) len(off int, compression map[string]struct{}) int {
l += len(rr.Salt) / 2
return l
}
func (rr *NULL) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.Data)
return l
}
func (rr *OPENPGPKEY) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
return l
}
func (rr *PTR) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Ptr, off+l, compression, true)
return l
}
func (rr *PX) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
@@ -558,11 +602,13 @@ func (rr *PX) len(off int, compression map[string]struct{}) int {
l += domainNameLen(rr.Mapx400, off+l, compression, false)
return l
}
func (rr *RFC3597) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.Rdata) / 2
return l
}
func (rr *RKEY) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Flags
@@ -571,12 +617,14 @@ func (rr *RKEY) len(off int, compression map[string]struct{}) int {
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
return l
}
func (rr *RP) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Mbox, off+l, compression, false)
l += domainNameLen(rr.Txt, off+l, compression, false)
return l
}
func (rr *RRSIG) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // TypeCovered
@@ -590,12 +638,14 @@ func (rr *RRSIG) len(off int, compression map[string]struct{}) int {
l += base64.StdEncoding.DecodedLen(len(rr.Signature))
return l
}
func (rr *RT) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += domainNameLen(rr.Host, off+l, compression, false)
return l
}
func (rr *SMIMEA) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Usage
@@ -604,6 +654,7 @@ func (rr *SMIMEA) len(off int, compression map[string]struct{}) int {
l += len(rr.Certificate) / 2
return l
}
func (rr *SOA) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Ns, off+l, compression, true)
@@ -615,6 +666,7 @@ func (rr *SOA) len(off int, compression map[string]struct{}) int {
l += 4 // Minttl
return l
}
func (rr *SPF) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
for _, x := range rr.Txt {
@@ -622,6 +674,7 @@ func (rr *SPF) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *SRV) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Priority
@@ -630,6 +683,7 @@ func (rr *SRV) len(off int, compression map[string]struct{}) int {
l += domainNameLen(rr.Target, off+l, compression, false)
return l
}
func (rr *SSHFP) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Algorithm
@@ -637,6 +691,7 @@ func (rr *SSHFP) len(off int, compression map[string]struct{}) int {
l += len(rr.FingerPrint) / 2
return l
}
func (rr *SVCB) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Priority
@@ -646,6 +701,7 @@ func (rr *SVCB) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *TA) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // KeyTag
@@ -654,12 +710,14 @@ func (rr *TA) len(off int, compression map[string]struct{}) int {
l += len(rr.Digest) / 2
return l
}
func (rr *TALINK) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.PreviousName, off+l, compression, false)
l += domainNameLen(rr.NextName, off+l, compression, false)
return l
}
func (rr *TKEY) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Algorithm, off+l, compression, false)
@@ -673,6 +731,7 @@ func (rr *TKEY) len(off int, compression map[string]struct{}) int {
l += len(rr.OtherData) / 2
return l
}
func (rr *TLSA) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l++ // Usage
@@ -681,6 +740,7 @@ func (rr *TLSA) len(off int, compression map[string]struct{}) int {
l += len(rr.Certificate) / 2
return l
}
func (rr *TSIG) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += domainNameLen(rr.Algorithm, off+l, compression, false)
@@ -694,6 +754,7 @@ func (rr *TSIG) len(off int, compression map[string]struct{}) int {
l += len(rr.OtherData) / 2
return l
}
func (rr *TXT) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
for _, x := range rr.Txt {
@@ -701,16 +762,19 @@ func (rr *TXT) len(off int, compression map[string]struct{}) int {
}
return l
}
func (rr *UID) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 4 // Uid
return l
}
func (rr *UINFO) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.Uinfo) + 1
return l
}
func (rr *URI) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 2 // Priority
@@ -718,11 +782,13 @@ func (rr *URI) len(off int, compression map[string]struct{}) int {
l += len(rr.Target)
return l
}
func (rr *X25) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += len(rr.PSDNAddress) + 1
return l
}
func (rr *ZONEMD) len(off int, compression map[string]struct{}) int {
l := rr.Hdr.len(off, compression)
l += 4 // Serial
@@ -734,20 +800,31 @@ func (rr *ZONEMD) len(off int, compression map[string]struct{}) int {
// copy() functions
func (rr *A) copy() RR {
return &A{rr.Hdr, copyIP(rr.A)}
return &A{rr.Hdr, cloneSlice(rr.A)}
}
func (rr *AAAA) copy() RR {
return &AAAA{rr.Hdr, copyIP(rr.AAAA)}
return &AAAA{rr.Hdr, cloneSlice(rr.AAAA)}
}
func (rr *AFSDB) copy() RR {
return &AFSDB{rr.Hdr, rr.Subtype, rr.Hostname}
}
func (rr *AMTRELAY) copy() RR {
return &AMTRELAY{rr.Hdr, rr.Precedence, rr.GatewayType, copyIP(rr.GatewayAddr), rr.GatewayHost}
return &AMTRELAY{
rr.Hdr,
rr.Precedence,
rr.GatewayType,
cloneSlice(rr.GatewayAddr),
rr.GatewayHost,
}
}
func (rr *ANY) copy() RR {
return &ANY{rr.Hdr}
}
func (rr *APL) copy() RR {
Prefixes := make([]APLPrefix, len(rr.Prefixes))
for i, e := range rr.Prefixes {
@@ -755,153 +832,270 @@ func (rr *APL) copy() RR {
}
return &APL{rr.Hdr, Prefixes}
}
func (rr *AVC) copy() RR {
Txt := make([]string, len(rr.Txt))
copy(Txt, rr.Txt)
return &AVC{rr.Hdr, Txt}
return &AVC{rr.Hdr, cloneSlice(rr.Txt)}
}
func (rr *CAA) copy() RR {
return &CAA{rr.Hdr, rr.Flag, rr.Tag, rr.Value}
return &CAA{
rr.Hdr,
rr.Flag,
rr.Tag,
rr.Value,
}
}
func (rr *CDNSKEY) copy() RR {
return &CDNSKEY{*rr.DNSKEY.copy().(*DNSKEY)}
}
func (rr *CDS) copy() RR {
return &CDS{*rr.DS.copy().(*DS)}
}
func (rr *CERT) copy() RR {
return &CERT{rr.Hdr, rr.Type, rr.KeyTag, rr.Algorithm, rr.Certificate}
return &CERT{
rr.Hdr,
rr.Type,
rr.KeyTag,
rr.Algorithm,
rr.Certificate,
}
}
func (rr *CNAME) copy() RR {
return &CNAME{rr.Hdr, rr.Target}
}
func (rr *CSYNC) copy() RR {
TypeBitMap := make([]uint16, len(rr.TypeBitMap))
copy(TypeBitMap, rr.TypeBitMap)
return &CSYNC{rr.Hdr, rr.Serial, rr.Flags, TypeBitMap}
return &CSYNC{
rr.Hdr,
rr.Serial,
rr.Flags,
cloneSlice(rr.TypeBitMap),
}
}
func (rr *DHCID) copy() RR {
return &DHCID{rr.Hdr, rr.Digest}
}
func (rr *DLV) copy() RR {
return &DLV{*rr.DS.copy().(*DS)}
}
func (rr *DNAME) copy() RR {
return &DNAME{rr.Hdr, rr.Target}
}
func (rr *DNSKEY) copy() RR {
return &DNSKEY{rr.Hdr, rr.Flags, rr.Protocol, rr.Algorithm, rr.PublicKey}
return &DNSKEY{
rr.Hdr,
rr.Flags,
rr.Protocol,
rr.Algorithm,
rr.PublicKey,
}
}
func (rr *DS) copy() RR {
return &DS{rr.Hdr, rr.KeyTag, rr.Algorithm, rr.DigestType, rr.Digest}
return &DS{
rr.Hdr,
rr.KeyTag,
rr.Algorithm,
rr.DigestType,
rr.Digest,
}
}
func (rr *EID) copy() RR {
return &EID{rr.Hdr, rr.Endpoint}
}
func (rr *EUI48) copy() RR {
return &EUI48{rr.Hdr, rr.Address}
}
func (rr *EUI64) copy() RR {
return &EUI64{rr.Hdr, rr.Address}
}
func (rr *GID) copy() RR {
return &GID{rr.Hdr, rr.Gid}
}
func (rr *GPOS) copy() RR {
return &GPOS{rr.Hdr, rr.Longitude, rr.Latitude, rr.Altitude}
return &GPOS{
rr.Hdr,
rr.Longitude,
rr.Latitude,
rr.Altitude,
}
}
func (rr *HINFO) copy() RR {
return &HINFO{rr.Hdr, rr.Cpu, rr.Os}
}
func (rr *HIP) copy() RR {
RendezvousServers := make([]string, len(rr.RendezvousServers))
copy(RendezvousServers, rr.RendezvousServers)
return &HIP{rr.Hdr, rr.HitLength, rr.PublicKeyAlgorithm, rr.PublicKeyLength, rr.Hit, rr.PublicKey, RendezvousServers}
return &HIP{
rr.Hdr,
rr.HitLength,
rr.PublicKeyAlgorithm,
rr.PublicKeyLength,
rr.Hit,
rr.PublicKey,
cloneSlice(rr.RendezvousServers),
}
}
func (rr *HTTPS) copy() RR {
return &HTTPS{*rr.SVCB.copy().(*SVCB)}
}
func (rr *IPSECKEY) copy() RR {
return &IPSECKEY{rr.Hdr, rr.Precedence, rr.GatewayType, rr.Algorithm, copyIP(rr.GatewayAddr), rr.GatewayHost, rr.PublicKey}
return &IPSECKEY{
rr.Hdr,
rr.Precedence,
rr.GatewayType,
rr.Algorithm,
cloneSlice(rr.GatewayAddr),
rr.GatewayHost,
rr.PublicKey,
}
}
func (rr *KEY) copy() RR {
return &KEY{*rr.DNSKEY.copy().(*DNSKEY)}
}
func (rr *KX) copy() RR {
return &KX{rr.Hdr, rr.Preference, rr.Exchanger}
}
func (rr *L32) copy() RR {
return &L32{rr.Hdr, rr.Preference, copyIP(rr.Locator32)}
return &L32{rr.Hdr, rr.Preference, cloneSlice(rr.Locator32)}
}
func (rr *L64) copy() RR {
return &L64{rr.Hdr, rr.Preference, rr.Locator64}
}
func (rr *LOC) copy() RR {
return &LOC{rr.Hdr, rr.Version, rr.Size, rr.HorizPre, rr.VertPre, rr.Latitude, rr.Longitude, rr.Altitude}
return &LOC{
rr.Hdr,
rr.Version,
rr.Size,
rr.HorizPre,
rr.VertPre,
rr.Latitude,
rr.Longitude,
rr.Altitude,
}
}
func (rr *LP) copy() RR {
return &LP{rr.Hdr, rr.Preference, rr.Fqdn}
}
func (rr *MB) copy() RR {
return &MB{rr.Hdr, rr.Mb}
}
func (rr *MD) copy() RR {
return &MD{rr.Hdr, rr.Md}
}
func (rr *MF) copy() RR {
return &MF{rr.Hdr, rr.Mf}
}
func (rr *MG) copy() RR {
return &MG{rr.Hdr, rr.Mg}
}
func (rr *MINFO) copy() RR {
return &MINFO{rr.Hdr, rr.Rmail, rr.Email}
}
func (rr *MR) copy() RR {
return &MR{rr.Hdr, rr.Mr}
}
func (rr *MX) copy() RR {
return &MX{rr.Hdr, rr.Preference, rr.Mx}
}
func (rr *NAPTR) copy() RR {
return &NAPTR{rr.Hdr, rr.Order, rr.Preference, rr.Flags, rr.Service, rr.Regexp, rr.Replacement}
return &NAPTR{
rr.Hdr,
rr.Order,
rr.Preference,
rr.Flags,
rr.Service,
rr.Regexp,
rr.Replacement,
}
}
func (rr *NID) copy() RR {
return &NID{rr.Hdr, rr.Preference, rr.NodeID}
}
func (rr *NIMLOC) copy() RR {
return &NIMLOC{rr.Hdr, rr.Locator}
}
func (rr *NINFO) copy() RR {
ZSData := make([]string, len(rr.ZSData))
copy(ZSData, rr.ZSData)
return &NINFO{rr.Hdr, ZSData}
return &NINFO{rr.Hdr, cloneSlice(rr.ZSData)}
}
func (rr *NS) copy() RR {
return &NS{rr.Hdr, rr.Ns}
}
func (rr *NSAPPTR) copy() RR {
return &NSAPPTR{rr.Hdr, rr.Ptr}
}
func (rr *NSEC) copy() RR {
TypeBitMap := make([]uint16, len(rr.TypeBitMap))
copy(TypeBitMap, rr.TypeBitMap)
return &NSEC{rr.Hdr, rr.NextDomain, TypeBitMap}
return &NSEC{rr.Hdr, rr.NextDomain, cloneSlice(rr.TypeBitMap)}
}
func (rr *NSEC3) copy() RR {
TypeBitMap := make([]uint16, len(rr.TypeBitMap))
copy(TypeBitMap, rr.TypeBitMap)
return &NSEC3{rr.Hdr, rr.Hash, rr.Flags, rr.Iterations, rr.SaltLength, rr.Salt, rr.HashLength, rr.NextDomain, TypeBitMap}
return &NSEC3{
rr.Hdr,
rr.Hash,
rr.Flags,
rr.Iterations,
rr.SaltLength,
rr.Salt,
rr.HashLength,
rr.NextDomain,
cloneSlice(rr.TypeBitMap),
}
}
func (rr *NSEC3PARAM) copy() RR {
return &NSEC3PARAM{rr.Hdr, rr.Hash, rr.Flags, rr.Iterations, rr.SaltLength, rr.Salt}
return &NSEC3PARAM{
rr.Hdr,
rr.Hash,
rr.Flags,
rr.Iterations,
rr.SaltLength,
rr.Salt,
}
}
func (rr *NULL) copy() RR {
return &NULL{rr.Hdr, rr.Data}
}
func (rr *OPENPGPKEY) copy() RR {
return &OPENPGPKEY{rr.Hdr, rr.PublicKey}
}
func (rr *OPT) copy() RR {
Option := make([]EDNS0, len(rr.Option))
for i, e := range rr.Option {
@@ -909,86 +1103,205 @@ func (rr *OPT) copy() RR {
}
return &OPT{rr.Hdr, Option}
}
func (rr *PTR) copy() RR {
return &PTR{rr.Hdr, rr.Ptr}
}
func (rr *PX) copy() RR {
return &PX{rr.Hdr, rr.Preference, rr.Map822, rr.Mapx400}
return &PX{
rr.Hdr,
rr.Preference,
rr.Map822,
rr.Mapx400,
}
}
func (rr *RFC3597) copy() RR {
return &RFC3597{rr.Hdr, rr.Rdata}
}
func (rr *RKEY) copy() RR {
return &RKEY{rr.Hdr, rr.Flags, rr.Protocol, rr.Algorithm, rr.PublicKey}
return &RKEY{
rr.Hdr,
rr.Flags,
rr.Protocol,
rr.Algorithm,
rr.PublicKey,
}
}
func (rr *RP) copy() RR {
return &RP{rr.Hdr, rr.Mbox, rr.Txt}
}
func (rr *RRSIG) copy() RR {
return &RRSIG{rr.Hdr, rr.TypeCovered, rr.Algorithm, rr.Labels, rr.OrigTtl, rr.Expiration, rr.Inception, rr.KeyTag, rr.SignerName, rr.Signature}
return &RRSIG{
rr.Hdr,
rr.TypeCovered,
rr.Algorithm,
rr.Labels,
rr.OrigTtl,
rr.Expiration,
rr.Inception,
rr.KeyTag,
rr.SignerName,
rr.Signature,
}
}
func (rr *RT) copy() RR {
return &RT{rr.Hdr, rr.Preference, rr.Host}
}
func (rr *SIG) copy() RR {
return &SIG{*rr.RRSIG.copy().(*RRSIG)}
}
func (rr *SMIMEA) copy() RR {
return &SMIMEA{rr.Hdr, rr.Usage, rr.Selector, rr.MatchingType, rr.Certificate}
return &SMIMEA{
rr.Hdr,
rr.Usage,
rr.Selector,
rr.MatchingType,
rr.Certificate,
}
}
func (rr *SOA) copy() RR {
return &SOA{rr.Hdr, rr.Ns, rr.Mbox, rr.Serial, rr.Refresh, rr.Retry, rr.Expire, rr.Minttl}
return &SOA{
rr.Hdr,
rr.Ns,
rr.Mbox,
rr.Serial,
rr.Refresh,
rr.Retry,
rr.Expire,
rr.Minttl,
}
}
func (rr *SPF) copy() RR {
Txt := make([]string, len(rr.Txt))
copy(Txt, rr.Txt)
return &SPF{rr.Hdr, Txt}
return &SPF{rr.Hdr, cloneSlice(rr.Txt)}
}
func (rr *SRV) copy() RR {
return &SRV{rr.Hdr, rr.Priority, rr.Weight, rr.Port, rr.Target}
return &SRV{
rr.Hdr,
rr.Priority,
rr.Weight,
rr.Port,
rr.Target,
}
}
func (rr *SSHFP) copy() RR {
return &SSHFP{rr.Hdr, rr.Algorithm, rr.Type, rr.FingerPrint}
return &SSHFP{
rr.Hdr,
rr.Algorithm,
rr.Type,
rr.FingerPrint,
}
}
func (rr *SVCB) copy() RR {
Value := make([]SVCBKeyValue, len(rr.Value))
for i, e := range rr.Value {
Value[i] = e.copy()
}
return &SVCB{rr.Hdr, rr.Priority, rr.Target, Value}
return &SVCB{
rr.Hdr,
rr.Priority,
rr.Target,
Value,
}
}
func (rr *TA) copy() RR {
return &TA{rr.Hdr, rr.KeyTag, rr.Algorithm, rr.DigestType, rr.Digest}
return &TA{
rr.Hdr,
rr.KeyTag,
rr.Algorithm,
rr.DigestType,
rr.Digest,
}
}
func (rr *TALINK) copy() RR {
return &TALINK{rr.Hdr, rr.PreviousName, rr.NextName}
}
func (rr *TKEY) copy() RR {
return &TKEY{rr.Hdr, rr.Algorithm, rr.Inception, rr.Expiration, rr.Mode, rr.Error, rr.KeySize, rr.Key, rr.OtherLen, rr.OtherData}
return &TKEY{
rr.Hdr,
rr.Algorithm,
rr.Inception,
rr.Expiration,
rr.Mode,
rr.Error,
rr.KeySize,
rr.Key,
rr.OtherLen,
rr.OtherData,
}
}
func (rr *TLSA) copy() RR {
return &TLSA{rr.Hdr, rr.Usage, rr.Selector, rr.MatchingType, rr.Certificate}
return &TLSA{
rr.Hdr,
rr.Usage,
rr.Selector,
rr.MatchingType,
rr.Certificate,
}
}
func (rr *TSIG) copy() RR {
return &TSIG{rr.Hdr, rr.Algorithm, rr.TimeSigned, rr.Fudge, rr.MACSize, rr.MAC, rr.OrigId, rr.Error, rr.OtherLen, rr.OtherData}
return &TSIG{
rr.Hdr,
rr.Algorithm,
rr.TimeSigned,
rr.Fudge,
rr.MACSize,
rr.MAC,
rr.OrigId,
rr.Error,
rr.OtherLen,
rr.OtherData,
}
}
func (rr *TXT) copy() RR {
Txt := make([]string, len(rr.Txt))
copy(Txt, rr.Txt)
return &TXT{rr.Hdr, Txt}
return &TXT{rr.Hdr, cloneSlice(rr.Txt)}
}
func (rr *UID) copy() RR {
return &UID{rr.Hdr, rr.Uid}
}
func (rr *UINFO) copy() RR {
return &UINFO{rr.Hdr, rr.Uinfo}
}
func (rr *URI) copy() RR {
return &URI{rr.Hdr, rr.Priority, rr.Weight, rr.Target}
return &URI{
rr.Hdr,
rr.Priority,
rr.Weight,
rr.Target,
}
}
func (rr *X25) copy() RR {
return &X25{rr.Hdr, rr.PSDNAddress}
}
func (rr *ZONEMD) copy() RR {
return &ZONEMD{rr.Hdr, rr.Serial, rr.Scheme, rr.Hash, rr.Digest}
return &ZONEMD{
rr.Hdr,
rr.Serial,
rr.Scheme,
rr.Hash,
rr.Digest,
}
}
+3
View File
@@ -0,0 +1,3 @@
vendor/**
.idea
**/**.iml
+42 -42
View File
@@ -16,28 +16,28 @@ type Value interface{}
type MetaValue interface{}
// NodeVisitor function type for iterating over nodes
type NodeVisitor func(item *node)
type NodeVisitor func(item *Node)
// Tree represents a tree structure with leaf-nodes and branch-nodes.
type Tree interface {
// AddNode adds a new node to a branch.
// AddNode adds a new Node to a branch.
AddNode(v Value) Tree
// AddMetaNode adds a new node with meta value provided to a branch.
// AddMetaNode adds a new Node with meta value provided to a branch.
AddMetaNode(meta MetaValue, v Value) Tree
// AddBranch adds a new branch node (a level deeper).
// AddBranch adds a new branch Node (a level deeper).
AddBranch(v Value) Tree
// AddMetaBranch adds a new branch node (a level deeper) with meta value provided.
// AddMetaBranch adds a new branch Node (a level deeper) with meta value provided.
AddMetaBranch(meta MetaValue, v Value) Tree
// Branch converts a leaf-node to a branch-node,
// applying this on a branch-node does no effect.
// Branch converts a leaf-Node to a branch-Node,
// applying this on a branch-Node does no effect.
Branch() Tree
// FindByMeta finds a node whose meta value matches the provided one by reflect.DeepEqual,
// FindByMeta finds a Node whose meta value matches the provided one by reflect.DeepEqual,
// returns nil if not found.
FindByMeta(meta MetaValue) Tree
// FindByValue finds a node whose value matches the provided one by reflect.DeepEqual,
// FindByValue finds a Node whose value matches the provided one by reflect.DeepEqual,
// returns nil if not found.
FindByValue(value Value) Tree
// returns the last node of a tree
// returns the last Node of a tree
FindLastNode() Tree
// String renders the tree or subtree as a string.
String() string
@@ -48,19 +48,19 @@ type Tree interface {
SetMetaValue(meta MetaValue)
// VisitAll iterates over the tree, branches and nodes.
// If need to iterate over the whole tree, use the root node.
// If need to iterate over the whole tree, use the root Node.
// Note this method uses a breadth-first approach.
VisitAll(fn NodeVisitor)
}
type node struct {
Root *node
type Node struct {
Root *Node
Meta MetaValue
Value Value
Nodes []*node
Nodes []*Node
}
func (n *node) FindLastNode() Tree {
func (n *Node) FindLastNode() Tree {
ns := n.Nodes
if len(ns) == 0 {
return nil
@@ -68,16 +68,16 @@ func (n *node) FindLastNode() Tree {
return ns[len(ns)-1]
}
func (n *node) AddNode(v Value) Tree {
n.Nodes = append(n.Nodes, &node{
func (n *Node) AddNode(v Value) Tree {
n.Nodes = append(n.Nodes, &Node{
Root: n,
Value: v,
})
return n
}
func (n *node) AddMetaNode(meta MetaValue, v Value) Tree {
n.Nodes = append(n.Nodes, &node{
func (n *Node) AddMetaNode(meta MetaValue, v Value) Tree {
n.Nodes = append(n.Nodes, &Node{
Root: n,
Meta: meta,
Value: v,
@@ -85,8 +85,8 @@ func (n *node) AddMetaNode(meta MetaValue, v Value) Tree {
return n
}
func (n *node) AddBranch(v Value) Tree {
branch := &node{
func (n *Node) AddBranch(v Value) Tree {
branch := &Node{
Root: n,
Value: v,
}
@@ -94,8 +94,8 @@ func (n *node) AddBranch(v Value) Tree {
return branch
}
func (n *node) AddMetaBranch(meta MetaValue, v Value) Tree {
branch := &node{
func (n *Node) AddMetaBranch(meta MetaValue, v Value) Tree {
branch := &Node{
Root: n,
Meta: meta,
Value: v,
@@ -104,12 +104,12 @@ func (n *node) AddMetaBranch(meta MetaValue, v Value) Tree {
return branch
}
func (n *node) Branch() Tree {
func (n *Node) Branch() Tree {
n.Root = nil
return n
}
func (n *node) FindByMeta(meta MetaValue) Tree {
func (n *Node) FindByMeta(meta MetaValue) Tree {
for _, node := range n.Nodes {
if reflect.DeepEqual(node.Meta, meta) {
return node
@@ -121,7 +121,7 @@ func (n *node) FindByMeta(meta MetaValue) Tree {
return nil
}
func (n *node) FindByValue(value Value) Tree {
func (n *Node) FindByValue(value Value) Tree {
for _, node := range n.Nodes {
if reflect.DeepEqual(node.Value, value) {
return node
@@ -133,7 +133,7 @@ func (n *node) FindByValue(value Value) Tree {
return nil
}
func (n *node) Bytes() []byte {
func (n *Node) Bytes() []byte {
buf := new(bytes.Buffer)
level := 0
var levelsEnded []int
@@ -158,19 +158,19 @@ func (n *node) Bytes() []byte {
return buf.Bytes()
}
func (n *node) String() string {
func (n *Node) String() string {
return string(n.Bytes())
}
func (n *node) SetValue(value Value) {
func (n *Node) SetValue(value Value) {
n.Value = value
}
func (n *node) SetMetaValue(meta MetaValue) {
func (n *Node) SetMetaValue(meta MetaValue) {
n.Meta = meta
}
func (n *node) VisitAll(fn NodeVisitor) {
func (n *Node) VisitAll(fn NodeVisitor) {
for _, node := range n.Nodes {
fn(node)
@@ -182,7 +182,7 @@ func (n *node) VisitAll(fn NodeVisitor) {
}
func printNodes(wr io.Writer,
level int, levelsEnded []int, nodes []*node) {
level int, levelsEnded []int, nodes []*Node) {
for i, node := range nodes {
edge := EdgeTypeMid
@@ -198,7 +198,7 @@ func printNodes(wr io.Writer,
}
func printValues(wr io.Writer,
level int, levelsEnded []int, edge EdgeType, node *node) {
level int, levelsEnded []int, edge EdgeType, node *Node) {
for i := 0; i < level; i++ {
if isEnded(levelsEnded, i) {
@@ -227,7 +227,7 @@ func isEnded(levelsEnded []int, level int) bool {
return false
}
func renderValue(level int, node *node) Value {
func renderValue(level int, node *Node) Value {
lines := strings.Split(fmt.Sprintf("%v", node.Value), "\n")
// If value does not contain multiple lines, return itself.
@@ -248,10 +248,10 @@ func renderValue(level int, node *node) Value {
// padding returns a padding for the multiline values with correctly placed link edges.
// It is generated by traversing the tree upwards (from leaf to the root of the tree)
// and, on each level, checking if the node the last one of its siblings.
// If a node is the last one, the padding on that level should be empty (there's nothing to link to below it).
// If a node is not the last one, the padding on that level should be the link edge so the sibling below is correctly connected.
func padding(level int, node *node) string {
// and, on each level, checking if the Node the last one of its siblings.
// If a Node is the last one, the padding on that level should be empty (there's nothing to link to below it).
// If a Node is not the last one, the padding on that level should be the link edge so the sibling below is correctly connected.
func padding(level int, node *Node) string {
links := make([]string, level+1)
for node.Root != nil {
@@ -267,8 +267,8 @@ func padding(level int, node *node) string {
return strings.Join(links, "")
}
// isLast checks if the node is the last one in the slice of its parent children
func isLast(n *node) bool {
// isLast checks if the Node is the last one in the slice of its parent children
func isLast(n *Node) bool {
return n == n.Root.FindLastNode()
}
@@ -285,10 +285,10 @@ var IndentSize = 3
// New Generates new tree
func New() Tree {
return &node{Value: "."}
return &Node{Value: "."}
}
// NewWithRoot Generates new tree with the given root value
func NewWithRoot(root Value) Tree {
return &node{Value: root}
return &Node{Value: root}
}
+2 -1
View File
@@ -114,7 +114,8 @@ var cipherModes = map[string]*cipherMode{
"arcfour": {16, 0, streamCipherMode(0, newRC4)},
// AEAD ciphers
gcmCipherID: {16, 12, newGCMCipher},
gcm128CipherID: {16, 12, newGCMCipher},
gcm256CipherID: {32, 12, newGCMCipher},
chacha20Poly1305ID: {64, 0, newChaCha20Cipher},
// CBC mode is insecure and so is not included in the default config.
+5 -4
View File
@@ -28,7 +28,7 @@ const (
// supportedCiphers lists ciphers we support but might not recommend.
var supportedCiphers = []string{
"aes128-ctr", "aes192-ctr", "aes256-ctr",
"[email protected]",
"[email protected]", gcm256CipherID,
chacha20Poly1305ID,
"arcfour256", "arcfour128", "arcfour",
aes128cbcID,
@@ -37,7 +37,7 @@ var supportedCiphers = []string{
// preferredCiphers specifies the default preference for ciphers.
var preferredCiphers = []string{
"[email protected]",
"[email protected]", gcm256CipherID,
chacha20Poly1305ID,
"aes128-ctr", "aes192-ctr", "aes256-ctr",
}
@@ -168,7 +168,7 @@ func (a *directionAlgorithms) rekeyBytes() int64 {
// 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is
// 128.
switch a.Cipher {
case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcmCipherID, aes128cbcID:
case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcm128CipherID, gcm256CipherID, aes128cbcID:
return 16 * (1 << 32)
}
@@ -178,7 +178,8 @@ func (a *directionAlgorithms) rekeyBytes() int64 {
}
var aeadCiphers = map[string]bool{
gcmCipherID: true,
gcm128CipherID: true,
gcm256CipherID: true,
chacha20Poly1305ID: true,
}
+2 -1
View File
@@ -17,7 +17,8 @@ import (
const debugTransport = false
const (
gcmCipherID = "[email protected]"
gcm128CipherID = "[email protected]"
gcm256CipherID = "[email protected]"
aes128cbcID = "aes128-cbc"
tripledescbcID = "3des-cbc"
)
+15
View File
@@ -24,6 +24,21 @@ var hwCap uint
var hwCap2 uint
func readHWCAP() error {
// For Go 1.21+, get auxv from the Go runtime.
if a := getAuxv(); len(a) > 0 {
for len(a) >= 2 {
tag, val := a[0], uint(a[1])
a = a[2:]
switch tag {
case _AT_HWCAP:
hwCap = val
case _AT_HWCAP2:
hwCap2 = val
}
}
return nil
}
buf, err := ioutil.ReadFile(procAuxv)
if err != nil {
// e.g. on android /proc/self/auxv is not accessible, so silently
+16
View File
@@ -0,0 +1,16 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cpu
// getAuxvFn is non-nil on Go 1.21+ (via runtime_auxv_go121.go init)
// on platforms that use auxv.
var getAuxvFn func() []uintptr
func getAuxv() []uintptr {
if getAuxvFn == nil {
return nil
}
return getAuxvFn()
}
+19
View File
@@ -0,0 +1,19 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.21
// +build go1.21
package cpu
import (
_ "unsafe" // for linkname
)
//go:linkname runtime_getAuxv runtime.getAuxv
func runtime_getAuxv() []uintptr
func init() {
getAuxvFn = runtime_getAuxv
}
+1 -1
View File
@@ -63,7 +63,7 @@ func LookPath(file string) (string, error) {
}
func fixCmd(name string, cmd *exec.Cmd) {
if filepath.Base(name) == name && !filepath.IsAbs(cmd.Path) {
if filepath.Base(name) == name && !filepath.IsAbs(cmd.Path) && !isGo119ErrFieldSet(cmd) {
// exec.Command was called with a bare binary name and
// exec.LookPath returned a path which is not absolute.
// Set cmd.lookPathErr and clear cmd.Path so that it
+6
View File
@@ -7,6 +7,12 @@
package execabs
import "os/exec"
func isGo119ErrDot(err error) bool {
return false
}
func isGo119ErrFieldSet(cmd *exec.Cmd) bool {
return false
}
+4
View File
@@ -15,3 +15,7 @@ import (
func isGo119ErrDot(err error) bool {
return errors.Is(err, exec.ErrDot)
}
func isGo119ErrFieldSet(cmd *exec.Cmd) bool {
return cmd.Err != nil
}
+6 -11
View File
@@ -8,7 +8,6 @@
package unix
import (
"runtime"
"unsafe"
)
@@ -27,7 +26,7 @@ func IoctlSetInt(fd int, req uint, value int) error {
// passing the integer value directly.
func IoctlSetPointerInt(fd int, req uint, value int) error {
v := int32(value)
return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
return ioctlPtr(fd, req, unsafe.Pointer(&v))
}
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
@@ -36,9 +35,7 @@ func IoctlSetPointerInt(fd int, req uint, value int) error {
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
// TODO: if we get the chance, remove the req parameter and
// hardcode TIOCSWINSZ.
err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value)
return err
return ioctlPtr(fd, req, unsafe.Pointer(value))
}
// IoctlSetTermios performs an ioctl on fd with a *Termios.
@@ -46,9 +43,7 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
// The req value will usually be TCSETA or TIOCSETA.
func IoctlSetTermios(fd int, req uint, value *Termios) error {
// TODO: if we get the chance, remove the req parameter.
err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value)
return err
return ioctlPtr(fd, req, unsafe.Pointer(value))
}
// IoctlGetInt performs an ioctl operation which gets an integer value
@@ -58,18 +53,18 @@ func IoctlSetTermios(fd int, req uint, value *Termios) error {
// for those, IoctlRetInt should be used instead of this function.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
err := ioctlPtr(fd, req, unsafe.Pointer(&value))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
err := ioctlPtr(fd, req, unsafe.Pointer(&value))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
err := ioctlPtr(fd, req, unsafe.Pointer(&value))
return &value, err
}
Loaded 100 of 235 files, more files were not shown because too many files have changed in this diff. Show more