updated dependencies
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Paul 2024-12-08 11:14:11 +01:00
parent d01239e2ed
commit f0bd6b8168
49 changed files with 1444 additions and 261 deletions

10
go.mod
View File

@ -3,9 +3,9 @@ module git.paulbsd.com/paulbsd/ipbl
go 1.23 go 1.23
require ( require (
github.com/labstack/echo/v4 v4.12.0 github.com/labstack/echo/v4 v4.13.0
github.com/lib/pq v1.10.9 github.com/lib/pq v1.10.9
golang.org/x/net v0.30.0 golang.org/x/net v0.32.0
gopkg.in/ini.v1 v1.67.0 gopkg.in/ini.v1 v1.67.0
xorm.io/xorm v1.3.9 xorm.io/xorm v1.3.9
) )
@ -25,8 +25,8 @@ require (
github.com/syndtr/goleveldb v1.0.0 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.28.0 // indirect golang.org/x/crypto v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.19.0 // indirect golang.org/x/text v0.21.0 // indirect
xorm.io/builder v0.3.13 // indirect xorm.io/builder v0.3.13 // indirect
) )

10
go.sum
View File

@ -38,6 +38,8 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
github.com/labstack/echo/v4 v4.13.0 h1:8DjSi4H/k+RqoOmwXkxW14A2H1pdPdS95+qmdJ4q1Tg=
github.com/labstack/echo/v4 v4.13.0/go.mod h1:61j7WN2+bp8V21qerqRs4yVlVTGyOagMBpF0vE7VcmM=
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
@ -92,6 +94,8 @@ golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY=
golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= 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/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
@ -106,6 +110,8 @@ golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -126,6 +132,8 @@ golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
@ -134,6 +142,8 @@ golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/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-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=

View File

@ -1,5 +1,37 @@
# Changelog # Changelog
## v4.13.0 - 2024-12-04
**BREAKING CHANGE** JWT Middleware Removed from Core use [labstack/echo-jwt](https://github.com/labstack/echo-jwt) instead
The JWT middleware has been **removed from Echo core** due to another security vulnerability, [CVE-2024-51744](https://nvd.nist.gov/vuln/detail/CVE-2024-51744). For more details, refer to issue [#2699](https://github.com/labstack/echo/issues/2699). A drop-in replacement is available in the [labstack/echo-jwt](https://github.com/labstack/echo-jwt) repository.
**Important**: Direct assignments like `token := c.Get("user").(*jwt.Token)` will now cause a panic due to an invalid cast. Update your code accordingly. Replace the current imports from `"github.com/golang-jwt/jwt"` in your handlers to the new middleware version using `"github.com/golang-jwt/jwt/v5"`.
Background:
The version of `golang-jwt/jwt` (v3.2.2) previously used in Echo core has been in an unmaintained state for some time. This is not the first vulnerability affecting this library; earlier issues were addressed in [PR #1946](https://github.com/labstack/echo/pull/1946).
JWT middleware was marked as deprecated in Echo core as of [v4.10.0](https://github.com/labstack/echo/releases/tag/v4.10.0) on 2022-12-27. If you did not notice that, consider leveraging tools like [Staticcheck](https://staticcheck.dev/) to catch such deprecations earlier in you dev/CI flow. For bonus points - check out [gosec](https://github.com/securego/gosec).
We sincerely apologize for any inconvenience caused by this change. While we strive to maintain backward compatibility within Echo core, recurring security issues with third-party dependencies have forced this decision.
**Enhancements**
* remove jwt middleware by @stevenwhitehead in https://github.com/labstack/echo/pull/2701
* optimization: struct alignment by @behnambm in https://github.com/labstack/echo/pull/2636
* bind: Maintain backwards compatibility for map[string]interface{} binding by @thesaltree in https://github.com/labstack/echo/pull/2656
* Add Go 1.23 to CI by @aldas in https://github.com/labstack/echo/pull/2675
* improve `MultipartForm` test by @martinyonatann in https://github.com/labstack/echo/pull/2682
* `bind` : add support of multipart multi files by @martinyonatann in https://github.com/labstack/echo/pull/2684
* Add TemplateRenderer struct to ease creating renderers for `html/template` and `text/template` packages. by @aldas in https://github.com/labstack/echo/pull/2690
* Refactor TestBasicAuth to utilize table-driven test format by @ErikOlson in https://github.com/labstack/echo/pull/2688
* Remove broken header by @aldas in https://github.com/labstack/echo/pull/2705
* fix(bind body): content-length can be -1 by @phamvinhdat in https://github.com/labstack/echo/pull/2710
* CORS middleware should compile allowOrigin regexp at creation by @aldas in https://github.com/labstack/echo/pull/2709
* Shorten Github issue template and add test example by @aldas in https://github.com/labstack/echo/pull/2711
## v4.12.0 - 2024-04-15 ## v4.12.0 - 2024-04-15
**Security** **Security**

View File

@ -31,6 +31,6 @@ benchmark: ## Run benchmarks
help: ## Display this help screen help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
goversion ?= "1.19" goversion ?= "1.20"
test_version: ## Run tests inside Docker with given version (defaults to 1.19 oldest supported). Example: make test_version goversion=1.19 test_version: ## Run tests inside Docker with given version (defaults to 1.20 oldest supported). Example: make test_version goversion=1.20
@docker run --rm -it -v $(shell pwd):/project golang:$(goversion) /bin/sh -c "cd /project && make init check" @docker run --rm -it -v $(shell pwd):/project golang:$(goversion) /bin/sh -c "cd /project && make init check"

View File

@ -1,5 +1,3 @@
<a href="https://echo.labstack.com"><img height="80" src="https://cdn.labstack.com/images/echo-logo.svg"></a>
[![Sourcegraph](https://sourcegraph.com/github.com/labstack/echo/-/badge.svg?style=flat-square)](https://sourcegraph.com/github.com/labstack/echo?badge) [![Sourcegraph](https://sourcegraph.com/github.com/labstack/echo/-/badge.svg?style=flat-square)](https://sourcegraph.com/github.com/labstack/echo?badge)
[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/labstack/echo/v4) [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/github.com/labstack/echo/v4)
[![Go Report Card](https://goreportcard.com/badge/github.com/labstack/echo?style=flat-square)](https://goreportcard.com/report/github.com/labstack/echo) [![Go Report Card](https://goreportcard.com/badge/github.com/labstack/echo?style=flat-square)](https://goreportcard.com/report/github.com/labstack/echo)
@ -77,6 +75,7 @@ package main
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware" "github.com/labstack/echo/v4/middleware"
"log/slog"
"net/http" "net/http"
) )
@ -92,7 +91,9 @@ func main() {
e.GET("/", hello) e.GET("/", hello)
// Start server // Start server
e.Logger.Fatal(e.Start(":1323")) if err := e.Start(":8080"); err != nil && !errors.Is(err, http.ErrServerClosed) {
slog.Error("failed to start server", "error", err)
}
} }
// Handler // Handler

View File

@ -8,6 +8,7 @@ import (
"encoding/xml" "encoding/xml"
"errors" "errors"
"fmt" "fmt"
"mime/multipart"
"net/http" "net/http"
"reflect" "reflect"
"strconv" "strconv"
@ -45,7 +46,7 @@ func (b *DefaultBinder) BindPathParams(c Context, i interface{}) error {
for i, name := range names { for i, name := range names {
params[name] = []string{values[i]} params[name] = []string{values[i]}
} }
if err := b.bindData(i, params, "param"); err != nil { if err := b.bindData(i, params, "param", nil); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
} }
return nil return nil
@ -53,7 +54,7 @@ func (b *DefaultBinder) BindPathParams(c Context, i interface{}) error {
// BindQueryParams binds query params to bindable object // BindQueryParams binds query params to bindable object
func (b *DefaultBinder) BindQueryParams(c Context, i interface{}) error { func (b *DefaultBinder) BindQueryParams(c Context, i interface{}) error {
if err := b.bindData(i, c.QueryParams(), "query"); err != nil { if err := b.bindData(i, c.QueryParams(), "query", nil); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
} }
return nil return nil
@ -66,13 +67,16 @@ func (b *DefaultBinder) BindQueryParams(c Context, i interface{}) error {
// See MIMEMultipartForm: https://golang.org/pkg/net/http/#Request.ParseMultipartForm // See MIMEMultipartForm: https://golang.org/pkg/net/http/#Request.ParseMultipartForm
func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) { func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
req := c.Request() req := c.Request()
if req.ContentLength == 0 { if req.ContentLength <= 0 {
return return
} }
ctype := req.Header.Get(HeaderContentType) // mediatype is found like `mime.ParseMediaType()` does it
switch { base, _, _ := strings.Cut(req.Header.Get(HeaderContentType), ";")
case strings.HasPrefix(ctype, MIMEApplicationJSON): mediatype := strings.TrimSpace(base)
switch mediatype {
case MIMEApplicationJSON:
if err = c.Echo().JSONSerializer.Deserialize(c, i); err != nil { if err = c.Echo().JSONSerializer.Deserialize(c, i); err != nil {
switch err.(type) { switch err.(type) {
case *HTTPError: case *HTTPError:
@ -81,7 +85,7 @@ func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
} }
} }
case strings.HasPrefix(ctype, MIMEApplicationXML), strings.HasPrefix(ctype, MIMETextXML): case MIMEApplicationXML, MIMETextXML:
if err = xml.NewDecoder(req.Body).Decode(i); err != nil { if err = xml.NewDecoder(req.Body).Decode(i); err != nil {
if ute, ok := err.(*xml.UnsupportedTypeError); ok { if ute, ok := err.(*xml.UnsupportedTypeError); ok {
return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ute.Type, ute.Error())).SetInternal(err) return NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unsupported type error: type=%v, error=%v", ute.Type, ute.Error())).SetInternal(err)
@ -90,12 +94,20 @@ func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
} }
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
} }
case strings.HasPrefix(ctype, MIMEApplicationForm), strings.HasPrefix(ctype, MIMEMultipartForm): case MIMEApplicationForm:
params, err := c.FormParams() params, err := c.FormParams()
if err != nil { if err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
} }
if err = b.bindData(i, params, "form"); err != nil { if err = b.bindData(i, params, "form", nil); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
case MIMEMultipartForm:
params, err := c.MultipartForm()
if err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
}
if err = b.bindData(i, params.Value, "form", params.File); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
} }
default: default:
@ -106,7 +118,7 @@ func (b *DefaultBinder) BindBody(c Context, i interface{}) (err error) {
// BindHeaders binds HTTP headers to a bindable object // BindHeaders binds HTTP headers to a bindable object
func (b *DefaultBinder) BindHeaders(c Context, i interface{}) error { func (b *DefaultBinder) BindHeaders(c Context, i interface{}) error {
if err := b.bindData(i, c.Request().Header, "header"); err != nil { if err := b.bindData(i, c.Request().Header, "header", nil); err != nil {
return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err) return NewHTTPError(http.StatusBadRequest, err.Error()).SetInternal(err)
} }
return nil return nil
@ -132,10 +144,11 @@ func (b *DefaultBinder) Bind(i interface{}, c Context) (err error) {
} }
// bindData will bind data ONLY fields in destination struct that have EXPLICIT tag // bindData will bind data ONLY fields in destination struct that have EXPLICIT tag
func (b *DefaultBinder) bindData(destination interface{}, data map[string][]string, tag string) error { func (b *DefaultBinder) bindData(destination interface{}, data map[string][]string, tag string, dataFiles map[string][]*multipart.FileHeader) error {
if destination == nil || len(data) == 0 { if destination == nil || (len(data) == 0 && len(dataFiles) == 0) {
return nil return nil
} }
hasFiles := len(dataFiles) > 0
typ := reflect.TypeOf(destination).Elem() typ := reflect.TypeOf(destination).Elem()
val := reflect.ValueOf(destination).Elem() val := reflect.ValueOf(destination).Elem()
@ -159,6 +172,10 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
for k, v := range data { for k, v := range data {
if isElemString { if isElemString {
val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v[0])) val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v[0]))
} else if isElemInterface {
// To maintain backward compatibility, we always bind to the first string value
// and not the slice of strings when dealing with map[string]interface{}{}
val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v[0]))
} else { } else {
val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v)) val.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(v))
} }
@ -175,7 +192,7 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
return errors.New("binding element must be a struct") return errors.New("binding element must be a struct")
} }
for i := 0; i < typ.NumField(); i++ { for i := 0; i < typ.NumField(); i++ { // iterate over all destination fields
typeField := typ.Field(i) typeField := typ.Field(i)
structField := val.Field(i) structField := val.Field(i)
if typeField.Anonymous { if typeField.Anonymous {
@ -194,10 +211,10 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
} }
if inputFieldName == "" { if inputFieldName == "" {
// If tag is nil, we inspect if the field is a not BindUnmarshaler struct and try to bind data into it (might contains fields with tags). // If tag is nil, we inspect if the field is a not BindUnmarshaler struct and try to bind data into it (might contain fields with tags).
// structs that implement BindUnmarshaler are bound only when they have explicit tag // structs that implement BindUnmarshaler are bound only when they have explicit tag
if _, ok := structField.Addr().Interface().(BindUnmarshaler); !ok && structFieldKind == reflect.Struct { if _, ok := structField.Addr().Interface().(BindUnmarshaler); !ok && structFieldKind == reflect.Struct {
if err := b.bindData(structField.Addr().Interface(), data, tag); err != nil { if err := b.bindData(structField.Addr().Interface(), data, tag, dataFiles); err != nil {
return err return err
} }
} }
@ -205,10 +222,20 @@ func (b *DefaultBinder) bindData(destination interface{}, data map[string][]stri
continue continue
} }
if hasFiles {
if ok, err := isFieldMultipartFile(structField.Type()); err != nil {
return err
} else if ok {
if ok := setMultipartFileHeaderTypes(structField, inputFieldName, dataFiles); ok {
continue
}
}
}
inputValue, exists := data[inputFieldName] inputValue, exists := data[inputFieldName]
if !exists { if !exists {
// Go json.Unmarshal supports case insensitive binding. However the // Go json.Unmarshal supports case-insensitive binding. However the
// url params are bound case sensitive which is inconsistent. To // url params are bound case-sensitive which is inconsistent. To
// fix this we must check all of the map values in a // fix this we must check all of the map values in a
// case-insensitive search. // case-insensitive search.
for k, v := range data { for k, v := range data {
@ -390,3 +417,50 @@ func setFloatField(value string, bitSize int, field reflect.Value) error {
} }
return err return err
} }
var (
// NOT supported by bind as you can NOT check easily empty struct being actual file or not
multipartFileHeaderType = reflect.TypeOf(multipart.FileHeader{})
// supported by bind as you can check by nil value if file existed or not
multipartFileHeaderPointerType = reflect.TypeOf(&multipart.FileHeader{})
multipartFileHeaderSliceType = reflect.TypeOf([]multipart.FileHeader(nil))
multipartFileHeaderPointerSliceType = reflect.TypeOf([]*multipart.FileHeader(nil))
)
func isFieldMultipartFile(field reflect.Type) (bool, error) {
switch field {
case multipartFileHeaderPointerType,
multipartFileHeaderSliceType,
multipartFileHeaderPointerSliceType:
return true, nil
case multipartFileHeaderType:
return true, errors.New("binding to multipart.FileHeader struct is not supported, use pointer to struct")
default:
return false, nil
}
}
func setMultipartFileHeaderTypes(structField reflect.Value, inputFieldName string, files map[string][]*multipart.FileHeader) bool {
fileHeaders := files[inputFieldName]
if len(fileHeaders) == 0 {
return false
}
result := true
switch structField.Type() {
case multipartFileHeaderPointerSliceType:
structField.Set(reflect.ValueOf(fileHeaders))
case multipartFileHeaderSliceType:
headers := make([]multipart.FileHeader, len(fileHeaders))
for i, fileHeader := range fileHeaders {
headers[i] = *fileHeader
}
structField.Set(reflect.ValueOf(headers))
case multipartFileHeaderPointerType:
structField.Set(reflect.ValueOf(fileHeaders[0]))
default:
result = false
}
return result
}

View File

@ -69,9 +69,9 @@ import (
type BindingError struct { type BindingError struct {
// Field is the field name where value binding failed // Field is the field name where value binding failed
Field string `json:"field"` Field string `json:"field"`
*HTTPError
// Values of parameter that failed to bind. // Values of parameter that failed to bind.
Values []string `json:"-"` Values []string `json:"-"`
*HTTPError
} }
// NewBindingError creates new instance of binding error // NewBindingError creates new instance of binding error
@ -94,16 +94,15 @@ func (be *BindingError) Error() string {
// ValueBinder provides utility methods for binding query or path parameter to various Go built-in types // ValueBinder provides utility methods for binding query or path parameter to various Go built-in types
type ValueBinder struct { type ValueBinder struct {
// failFast is flag for binding methods to return without attempting to bind when previous binding already failed
failFast bool
errors []error
// ValueFunc is used to get single parameter (first) value from request // ValueFunc is used to get single parameter (first) value from request
ValueFunc func(sourceParam string) string ValueFunc func(sourceParam string) string
// ValuesFunc is used to get all values for parameter from request. i.e. `/api/search?ids=1&ids=2` // ValuesFunc is used to get all values for parameter from request. i.e. `/api/search?ids=1&ids=2`
ValuesFunc func(sourceParam string) []string ValuesFunc func(sourceParam string) []string
// ErrorFunc is used to create errors. Allows you to use your own error type, that for example marshals to your specific json response // ErrorFunc is used to create errors. Allows you to use your own error type, that for example marshals to your specific json response
ErrorFunc func(sourceParam string, values []string, message interface{}, internalError error) error ErrorFunc func(sourceParam string, values []string, message interface{}, internalError error) error
errors []error
// failFast is flag for binding methods to return without attempting to bind when previous binding already failed
failFast bool
} }
// QueryParamsBinder creates query parameter value binder // QueryParamsBinder creates query parameter value binder

View File

@ -200,31 +200,31 @@ type Context interface {
} }
type context struct { type context struct {
logger Logger
request *http.Request request *http.Request
response *Response response *Response
query url.Values query url.Values
echo *Echo echo *Echo
logger Logger
store Map store Map
lock sync.RWMutex lock sync.RWMutex
// following fields are set by Router // following fields are set by Router
handler HandlerFunc
// path is route path that Router matched. It is empty string where there is no route match. // path is route path that Router matched. It is empty string where there is no route match.
// Route registered with RouteNotFound is considered as a match and path therefore is not empty. // Route registered with RouteNotFound is considered as a match and path therefore is not empty.
path string path string
// pnames length is tied to param count for the matched route
pnames []string
// Usually echo.Echo is sizing pvalues but there could be user created middlewares that decide to // Usually echo.Echo is sizing pvalues but there could be user created middlewares that decide to
// overwrite parameter by calling SetParamNames + SetParamValues. // overwrite parameter by calling SetParamNames + SetParamValues.
// When echo.Echo allocated that slice it length/capacity is tied to echo.Echo.maxParam value. // When echo.Echo allocated that slice it length/capacity is tied to echo.Echo.maxParam value.
// //
// It is important that pvalues size is always equal or bigger to pnames length. // It is important that pvalues size is always equal or bigger to pnames length.
pvalues []string pvalues []string
handler HandlerFunc
// pnames length is tied to param count for the matched route
pnames []string
} }
const ( const (

View File

@ -45,7 +45,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
stdLog "log" stdLog "log"
"net" "net"
"net/http" "net/http"
@ -91,10 +90,6 @@ type Echo struct {
Listener net.Listener Listener net.Listener
TLSListener net.Listener TLSListener net.Listener
AutoTLSManager autocert.Manager AutoTLSManager autocert.Manager
DisableHTTP2 bool
Debug bool
HideBanner bool
HidePort bool
HTTPErrorHandler HTTPErrorHandler HTTPErrorHandler HTTPErrorHandler
Binder Binder Binder Binder
JSONSerializer JSONSerializer JSONSerializer JSONSerializer
@ -106,6 +101,10 @@ type Echo struct {
// OnAddRouteHandler is called when Echo adds new route to specific host router. // OnAddRouteHandler is called when Echo adds new route to specific host router.
OnAddRouteHandler func(host string, route Route, handler HandlerFunc, middleware []MiddlewareFunc) OnAddRouteHandler func(host string, route Route, handler HandlerFunc, middleware []MiddlewareFunc)
DisableHTTP2 bool
Debug bool
HideBanner bool
HidePort bool
} }
// Route contains a handler and information for matching against requests. // Route contains a handler and information for matching against requests.
@ -117,9 +116,9 @@ type Route struct {
// HTTPError represents an error that occurred while handling a request. // HTTPError represents an error that occurred while handling a request.
type HTTPError struct { type HTTPError struct {
Code int `json:"-"`
Message interface{} `json:"message"`
Internal error `json:"-"` // Stores the error returned by an external dependency Internal error `json:"-"` // Stores the error returned by an external dependency
Message interface{} `json:"message"`
Code int `json:"-"`
} }
// MiddlewareFunc defines a function to process middleware. // MiddlewareFunc defines a function to process middleware.
@ -142,11 +141,6 @@ type JSONSerializer interface {
Deserialize(c Context, i interface{}) error Deserialize(c Context, i interface{}) error
} }
// Renderer is the interface that wraps the Render function.
type Renderer interface {
Render(io.Writer, string, interface{}, Context) error
}
// Map defines a generic map of type `map[string]interface{}`. // Map defines a generic map of type `map[string]interface{}`.
type Map map[string]interface{} type Map map[string]interface{}
@ -265,7 +259,7 @@ const (
const ( const (
// Version of Echo // Version of Echo
Version = "4.12.0" Version = "4.13.0"
website = "https://echo.labstack.com" website = "https://echo.labstack.com"
// http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo // http://patorjk.com/software/taag/#p=display&f=Small%20Slant&t=Echo
banner = ` banner = `

View File

@ -102,8 +102,8 @@ func StaticFileHandler(file string, filesystem fs.FS) HandlerFunc {
// traverse up from current executable run path. // traverse up from current executable run path.
// NB: private because you really should use fs.FS implementation instances // NB: private because you really should use fs.FS implementation instances
type defaultFS struct { type defaultFS struct {
prefix string
fs fs.FS fs fs.FS
prefix string
} }
func newDefaultFS() *defaultFS { func newDefaultFS() *defaultFS {

View File

@ -14,8 +14,8 @@ type Group struct {
common common
host string host string
prefix string prefix string
middleware []MiddlewareFunc
echo *Echo echo *Echo
middleware []MiddlewareFunc
} }
// Use implements `Echo#Use()` for sub-routes within the Group. // Use implements `Echo#Use()` for sub-routes within the Group.

View File

@ -134,10 +134,10 @@ Private IPv6 address ranges:
*/ */
type ipChecker struct { type ipChecker struct {
trustExtraRanges []*net.IPNet
trustLoopback bool trustLoopback bool
trustLinkLocal bool trustLinkLocal bool
trustPrivateNet bool trustPrivateNet bool
trustExtraRanges []*net.IPNet
} }
// TrustOption is config for which IP address to trust // TrustOption is config for which IP address to trust

29
vendor/github.com/labstack/echo/v4/renderer.go generated vendored Normal file
View File

@ -0,0 +1,29 @@
package echo
import "io"
// Renderer is the interface that wraps the Render function.
type Renderer interface {
Render(io.Writer, string, interface{}, Context) error
}
// TemplateRenderer is helper to ease creating renderers for `html/template` and `text/template` packages.
// Example usage:
//
// e.Renderer = &echo.TemplateRenderer{
// Template: template.Must(template.ParseGlob("templates/*.html")),
// }
//
// e.Renderer = &echo.TemplateRenderer{
// Template: template.Must(template.New("hello").Parse("Hello, {{.}}!")),
// }
type TemplateRenderer struct {
Template interface {
ExecuteTemplate(wr io.Writer, name string, data any) error
}
}
// Render renders the template with given data.
func (t *TemplateRenderer) Render(w io.Writer, name string, data interface{}, c Context) error {
return t.Template.ExecuteTemplate(w, name, data)
}

View File

@ -14,10 +14,10 @@ import (
// by an HTTP handler to construct an HTTP response. // by an HTTP handler to construct an HTTP response.
// See: https://golang.org/pkg/net/http/#ResponseWriter // See: https://golang.org/pkg/net/http/#ResponseWriter
type Response struct { type Response struct {
Writer http.ResponseWriter
echo *Echo echo *Echo
beforeFuncs []func() beforeFuncs []func()
afterFuncs []func() afterFuncs []func()
Writer http.ResponseWriter
Status int Status int
Size int64 Size int64
Committed bool Committed bool
@ -86,7 +86,7 @@ func (r *Response) Write(b []byte) (n int, err error) {
// buffered data to the client. // buffered data to the client.
// See [http.Flusher](https://golang.org/pkg/net/http/#Flusher) // See [http.Flusher](https://golang.org/pkg/net/http/#Flusher)
func (r *Response) Flush() { func (r *Response) Flush() {
err := responseControllerFlush(r.Writer) err := http.NewResponseController(r.Writer).Flush()
if err != nil && errors.Is(err, http.ErrNotSupported) { if err != nil && errors.Is(err, http.ErrNotSupported) {
panic(errors.New("response writer flushing is not supported")) panic(errors.New("response writer flushing is not supported"))
} }
@ -96,7 +96,7 @@ func (r *Response) Flush() {
// take over the connection. // take over the connection.
// See [http.Hijacker](https://golang.org/pkg/net/http/#Hijacker) // See [http.Hijacker](https://golang.org/pkg/net/http/#Hijacker)
func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) { func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) {
return responseControllerHijack(r.Writer) return http.NewResponseController(r.Writer).Hijack()
} }
// Unwrap returns the original http.ResponseWriter. // Unwrap returns the original http.ResponseWriter.

View File

@ -1,44 +0,0 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
//go:build !go1.20
package echo
import (
"bufio"
"fmt"
"net"
"net/http"
)
// TODO: remove when Go 1.23 is released and we do not support 1.19 anymore
func responseControllerFlush(rw http.ResponseWriter) error {
for {
switch t := rw.(type) {
case interface{ FlushError() error }:
return t.FlushError()
case http.Flusher:
t.Flush()
return nil
case interface{ Unwrap() http.ResponseWriter }:
rw = t.Unwrap()
default:
return fmt.Errorf("%w", http.ErrNotSupported)
}
}
}
// TODO: remove when Go 1.23 is released and we do not support 1.19 anymore
func responseControllerHijack(rw http.ResponseWriter) (net.Conn, *bufio.ReadWriter, error) {
for {
switch t := rw.(type) {
case http.Hijacker:
return t.Hijack()
case interface{ Unwrap() http.ResponseWriter }:
rw = t.Unwrap()
default:
return nil, nil, fmt.Errorf("%w", http.ErrNotSupported)
}
}
}

View File

@ -1,20 +0,0 @@
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
//go:build go1.20
package echo
import (
"bufio"
"net"
"net/http"
)
func responseControllerFlush(rw http.ResponseWriter) error {
return http.NewResponseController(rw).Flush()
}
func responseControllerHijack(rw http.ResponseWriter) (net.Conn, *bufio.ReadWriter, error) {
return http.NewResponseController(rw).Hijack()
}

View File

@ -18,32 +18,31 @@ type Router struct {
} }
type node struct { type node struct {
kind kind
label byte
prefix string
parent *node
staticChildren children
originalPath string
methods *routeMethods methods *routeMethods
parent *node
paramChild *node paramChild *node
anyChild *node anyChild *node
// notFoundHandler is handler registered with RouteNotFound method and is executed for 404 cases
notFoundHandler *routeMethod
prefix string
originalPath string
staticChildren children
paramsCount int paramsCount int
label byte
kind kind
// isLeaf indicates that node does not have child routes // isLeaf indicates that node does not have child routes
isLeaf bool isLeaf bool
// isHandler indicates that node has at least one handler registered to it // isHandler indicates that node has at least one handler registered to it
isHandler bool isHandler bool
// notFoundHandler is handler registered with RouteNotFound method and is executed for 404 cases
notFoundHandler *routeMethod
} }
type kind uint8 type kind uint8
type children []*node type children []*node
type routeMethod struct { type routeMethod struct {
handler HandlerFunc
ppath string ppath string
pnames []string pnames []string
handler HandlerFunc
} }
type routeMethods struct { type routeMethods struct {
@ -242,18 +241,18 @@ func (r *Router) insert(method, path string, h HandlerFunc) {
if i == lcpIndex { if i == lcpIndex {
// path node is last fragment of route path. ie. `/users/:id` // path node is last fragment of route path. ie. `/users/:id`
r.insertNode(method, path[:i], paramKind, routeMethod{ppath, pnames, h}) r.insertNode(method, path[:i], paramKind, routeMethod{ppath: ppath, pnames: pnames, handler: h})
} else { } else {
r.insertNode(method, path[:i], paramKind, routeMethod{}) r.insertNode(method, path[:i], paramKind, routeMethod{})
} }
} else if path[i] == '*' { } else if path[i] == '*' {
r.insertNode(method, path[:i], staticKind, routeMethod{}) r.insertNode(method, path[:i], staticKind, routeMethod{})
pnames = append(pnames, "*") pnames = append(pnames, "*")
r.insertNode(method, path[:i+1], anyKind, routeMethod{ppath, pnames, h}) r.insertNode(method, path[:i+1], anyKind, routeMethod{ppath: ppath, pnames: pnames, handler: h})
} }
} }
r.insertNode(method, path, staticKind, routeMethod{ppath, pnames, h}) r.insertNode(method, path, staticKind, routeMethod{ppath: ppath, pnames: pnames, handler: h})
} }
func (r *Router) insertNode(method, path string, t kind, rm routeMethod) { func (r *Router) insertNode(method, path string, t kind, rm routeMethod) {

View File

@ -8,8 +8,8 @@ package http2
import ( import (
"context" "context"
"crypto/tls"
"errors" "errors"
"net"
"net/http" "net/http"
"sync" "sync"
) )
@ -158,7 +158,7 @@ func (c *dialCall) dial(ctx context.Context, addr string) {
// This code decides which ones live or die. // This code decides which ones live or die.
// The return value used is whether c was used. // The return value used is whether c was used.
// c is never closed. // c is never closed.
func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c *tls.Conn) (used bool, err error) { func (p *clientConnPool) addConnIfNeeded(key string, t *Transport, c net.Conn) (used bool, err error) {
p.mu.Lock() p.mu.Lock()
for _, cc := range p.conns[key] { for _, cc := range p.conns[key] {
if cc.CanTakeNewRequest() { if cc.CanTakeNewRequest() {
@ -194,8 +194,8 @@ type addConnCall struct {
err error err error
} }
func (c *addConnCall) run(t *Transport, key string, tc *tls.Conn) { func (c *addConnCall) run(t *Transport, key string, nc net.Conn) {
cc, err := t.NewClientConn(tc) cc, err := t.NewClientConn(nc)
p := c.p p := c.p
p.mu.Lock() p.mu.Lock()

View File

@ -1490,7 +1490,7 @@ func (mh *MetaHeadersFrame) checkPseudos() error {
pf := mh.PseudoFields() pf := mh.PseudoFields()
for i, hf := range pf { for i, hf := range pf {
switch hf.Name { switch hf.Name {
case ":method", ":path", ":scheme", ":authority": case ":method", ":path", ":scheme", ":authority", ":protocol":
isRequest = true isRequest = true
case ":status": case ":status":
isResponse = true isResponse = true
@ -1498,7 +1498,7 @@ func (mh *MetaHeadersFrame) checkPseudos() error {
return pseudoHeaderError(hf.Name) return pseudoHeaderError(hf.Name)
} }
// Check for duplicates. // Check for duplicates.
// This would be a bad algorithm, but N is 4. // This would be a bad algorithm, but N is 5.
// And this doesn't allocate. // And this doesn't allocate.
for _, hf2 := range pf[:i] { for _, hf2 := range pf[:i] {
if hf.Name == hf2.Name { if hf.Name == hf2.Name {

View File

@ -38,6 +38,7 @@ var (
logFrameWrites bool logFrameWrites bool
logFrameReads bool logFrameReads bool
inTests bool inTests bool
disableExtendedConnectProtocol bool
) )
func init() { func init() {
@ -50,6 +51,9 @@ func init() {
logFrameWrites = true logFrameWrites = true
logFrameReads = true logFrameReads = true
} }
if strings.Contains(e, "http2xconnect=0") {
disableExtendedConnectProtocol = true
}
} }
const ( const (
@ -141,6 +145,10 @@ func (s Setting) Valid() error {
if s.Val < 16384 || s.Val > 1<<24-1 { if s.Val < 16384 || s.Val > 1<<24-1 {
return ConnectionError(ErrCodeProtocol) return ConnectionError(ErrCodeProtocol)
} }
case SettingEnableConnectProtocol:
if s.Val != 1 && s.Val != 0 {
return ConnectionError(ErrCodeProtocol)
}
} }
return nil return nil
} }
@ -156,6 +164,7 @@ const (
SettingInitialWindowSize SettingID = 0x4 SettingInitialWindowSize SettingID = 0x4
SettingMaxFrameSize SettingID = 0x5 SettingMaxFrameSize SettingID = 0x5
SettingMaxHeaderListSize SettingID = 0x6 SettingMaxHeaderListSize SettingID = 0x6
SettingEnableConnectProtocol SettingID = 0x8
) )
var settingName = map[SettingID]string{ var settingName = map[SettingID]string{
@ -165,6 +174,7 @@ var settingName = map[SettingID]string{
SettingInitialWindowSize: "INITIAL_WINDOW_SIZE", SettingInitialWindowSize: "INITIAL_WINDOW_SIZE",
SettingMaxFrameSize: "MAX_FRAME_SIZE", SettingMaxFrameSize: "MAX_FRAME_SIZE",
SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE", SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE",
SettingEnableConnectProtocol: "ENABLE_CONNECT_PROTOCOL",
} }
func (s SettingID) String() string { func (s SettingID) String() string {

View File

@ -306,7 +306,7 @@ func ConfigureServer(s *http.Server, conf *Server) error {
if s.TLSNextProto == nil { if s.TLSNextProto == nil {
s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){} s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){}
} }
protoHandler := func(hs *http.Server, c *tls.Conn, h http.Handler) { protoHandler := func(hs *http.Server, c net.Conn, h http.Handler, sawClientPreface bool) {
if testHookOnConn != nil { if testHookOnConn != nil {
testHookOnConn() testHookOnConn()
} }
@ -326,9 +326,28 @@ func ConfigureServer(s *http.Server, conf *Server) error {
Context: ctx, Context: ctx,
Handler: h, Handler: h,
BaseConfig: hs, BaseConfig: hs,
SawClientPreface: sawClientPreface,
}) })
} }
s.TLSNextProto[NextProtoTLS] = protoHandler s.TLSNextProto[NextProtoTLS] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
protoHandler(hs, c, h, false)
}
// The "unencrypted_http2" TLSNextProto key is used to pass off non-TLS HTTP/2 conns.
//
// A connection passed in this method has already had the HTTP/2 preface read from it.
s.TLSNextProto[nextProtoUnencryptedHTTP2] = func(hs *http.Server, c *tls.Conn, h http.Handler) {
nc, err := unencryptedNetConnFromTLSConn(c)
if err != nil {
if lg := hs.ErrorLog; lg != nil {
lg.Print(err)
} else {
log.Print(err)
}
go c.Close()
return
}
protoHandler(hs, nc, h, true)
}
return nil return nil
} }
@ -913,14 +932,18 @@ func (sc *serverConn) serve(conf http2Config) {
sc.vlogf("http2: server connection from %v on %p", sc.conn.RemoteAddr(), sc.hs) sc.vlogf("http2: server connection from %v on %p", sc.conn.RemoteAddr(), sc.hs)
} }
sc.writeFrame(FrameWriteRequest{ settings := writeSettings{
write: writeSettings{
{SettingMaxFrameSize, conf.MaxReadFrameSize}, {SettingMaxFrameSize, conf.MaxReadFrameSize},
{SettingMaxConcurrentStreams, sc.advMaxStreams}, {SettingMaxConcurrentStreams, sc.advMaxStreams},
{SettingMaxHeaderListSize, sc.maxHeaderListSize()}, {SettingMaxHeaderListSize, sc.maxHeaderListSize()},
{SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize}, {SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize},
{SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)}, {SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)},
}, }
if !disableExtendedConnectProtocol {
settings = append(settings, Setting{SettingEnableConnectProtocol, 1})
}
sc.writeFrame(FrameWriteRequest{
write: settings,
}) })
sc.unackedSettings++ sc.unackedSettings++
@ -1782,6 +1805,9 @@ func (sc *serverConn) processSetting(s Setting) error {
sc.maxFrameSize = int32(s.Val) // the maximum valid s.Val is < 2^31 sc.maxFrameSize = int32(s.Val) // the maximum valid s.Val is < 2^31
case SettingMaxHeaderListSize: case SettingMaxHeaderListSize:
sc.peerMaxHeaderListSize = s.Val sc.peerMaxHeaderListSize = s.Val
case SettingEnableConnectProtocol:
// Receipt of this parameter by a server does not
// have any impact
default: default:
// Unknown setting: "An endpoint that receives a SETTINGS // Unknown setting: "An endpoint that receives a SETTINGS
// frame with any unknown or unsupported identifier MUST // frame with any unknown or unsupported identifier MUST
@ -2212,11 +2238,17 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
scheme: f.PseudoValue("scheme"), scheme: f.PseudoValue("scheme"),
authority: f.PseudoValue("authority"), authority: f.PseudoValue("authority"),
path: f.PseudoValue("path"), path: f.PseudoValue("path"),
protocol: f.PseudoValue("protocol"),
}
// extended connect is disabled, so we should not see :protocol
if disableExtendedConnectProtocol && rp.protocol != "" {
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
} }
isConnect := rp.method == "CONNECT" isConnect := rp.method == "CONNECT"
if isConnect { if isConnect {
if rp.path != "" || rp.scheme != "" || rp.authority == "" { if rp.protocol == "" && (rp.path != "" || rp.scheme != "" || rp.authority == "") {
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol)) return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
} }
} else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") { } else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") {
@ -2240,6 +2272,9 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
if rp.authority == "" { if rp.authority == "" {
rp.authority = rp.header.Get("Host") rp.authority = rp.header.Get("Host")
} }
if rp.protocol != "" {
rp.header.Set(":protocol", rp.protocol)
}
rw, req, err := sc.newWriterAndRequestNoBody(st, rp) rw, req, err := sc.newWriterAndRequestNoBody(st, rp)
if err != nil { if err != nil {
@ -2266,6 +2301,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
type requestParam struct { type requestParam struct {
method string method string
scheme, authority, path string scheme, authority, path string
protocol string
header http.Header header http.Header
} }
@ -2307,7 +2343,7 @@ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*r
var url_ *url.URL var url_ *url.URL
var requestURI string var requestURI string
if rp.method == "CONNECT" { if rp.method == "CONNECT" && rp.protocol == "" {
url_ = &url.URL{Host: rp.authority} url_ = &url.URL{Host: rp.authority}
requestURI = rp.authority // mimic HTTP/1 server behavior requestURI = rp.authority // mimic HTTP/1 server behavior
} else { } else {
@ -2880,6 +2916,11 @@ func (w *responseWriter) SetWriteDeadline(deadline time.Time) error {
return nil return nil
} }
func (w *responseWriter) EnableFullDuplex() error {
// We always support full duplex responses, so this is a no-op.
return nil
}
func (w *responseWriter) Flush() { func (w *responseWriter) Flush() {
w.FlushError() w.FlushError()
} }

View File

@ -202,6 +202,20 @@ func (t *Transport) markNewGoroutine() {
} }
} }
func (t *Transport) now() time.Time {
if t != nil && t.transportTestHooks != nil {
return t.transportTestHooks.group.Now()
}
return time.Now()
}
func (t *Transport) timeSince(when time.Time) time.Duration {
if t != nil && t.transportTestHooks != nil {
return t.now().Sub(when)
}
return time.Since(when)
}
// newTimer creates a new time.Timer, or a synthetic timer in tests. // newTimer creates a new time.Timer, or a synthetic timer in tests.
func (t *Transport) newTimer(d time.Duration) timer { func (t *Transport) newTimer(d time.Duration) timer {
if t.transportTestHooks != nil { if t.transportTestHooks != nil {
@ -281,8 +295,8 @@ func configureTransports(t1 *http.Transport) (*Transport, error) {
if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") { if !strSliceContains(t1.TLSClientConfig.NextProtos, "http/1.1") {
t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1") t1.TLSClientConfig.NextProtos = append(t1.TLSClientConfig.NextProtos, "http/1.1")
} }
upgradeFn := func(authority string, c *tls.Conn) http.RoundTripper { upgradeFn := func(scheme, authority string, c net.Conn) http.RoundTripper {
addr := authorityAddr("https", authority) addr := authorityAddr(scheme, authority)
if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil { if used, err := connPool.addConnIfNeeded(addr, t2, c); err != nil {
go c.Close() go c.Close()
return erringRoundTripper{err} return erringRoundTripper{err}
@ -293,18 +307,37 @@ func configureTransports(t1 *http.Transport) (*Transport, error) {
// was unknown) // was unknown)
go c.Close() go c.Close()
} }
if scheme == "http" {
return (*unencryptedTransport)(t2)
}
return t2 return t2
} }
if m := t1.TLSNextProto; len(m) == 0 { if t1.TLSNextProto == nil {
t1.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{ t1.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)
"h2": upgradeFn,
} }
} else { t1.TLSNextProto[NextProtoTLS] = func(authority string, c *tls.Conn) http.RoundTripper {
m["h2"] = upgradeFn return upgradeFn("https", authority, c)
}
// The "unencrypted_http2" TLSNextProto key is used to pass off non-TLS HTTP/2 conns.
t1.TLSNextProto[nextProtoUnencryptedHTTP2] = func(authority string, c *tls.Conn) http.RoundTripper {
nc, err := unencryptedNetConnFromTLSConn(c)
if err != nil {
go c.Close()
return erringRoundTripper{err}
}
return upgradeFn("http", authority, nc)
} }
return t2, nil return t2, nil
} }
// unencryptedTransport is a Transport with a RoundTrip method that
// always permits http:// URLs.
type unencryptedTransport Transport
func (t *unencryptedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
return (*Transport)(t).RoundTripOpt(req, RoundTripOpt{allowHTTP: true})
}
func (t *Transport) connPool() ClientConnPool { func (t *Transport) connPool() ClientConnPool {
t.connPoolOnce.Do(t.initConnPool) t.connPoolOnce.Do(t.initConnPool)
return t.connPoolOrDef return t.connPoolOrDef
@ -324,7 +357,7 @@ type ClientConn struct {
t *Transport t *Transport
tconn net.Conn // usually *tls.Conn, except specialized impls tconn net.Conn // usually *tls.Conn, except specialized impls
tlsState *tls.ConnectionState // nil only for specialized impls tlsState *tls.ConnectionState // nil only for specialized impls
reused uint32 // whether conn is being reused; atomic atomicReused uint32 // whether conn is being reused; atomic
singleUse bool // whether being used for a single http.Request singleUse bool // whether being used for a single http.Request
getConnCalled bool // used by clientConnPool getConnCalled bool // used by clientConnPool
@ -343,6 +376,7 @@ type ClientConn struct {
closing bool closing bool
closed bool closed bool
seenSettings bool // true if we've seen a settings frame, false otherwise seenSettings bool // true if we've seen a settings frame, false otherwise
seenSettingsChan chan struct{} // closed when seenSettings is true or frame reading fails
wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back
goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received
goAwayDebug string // goAway frame's debug data, retained as a string goAwayDebug string // goAway frame's debug data, retained as a string
@ -363,6 +397,25 @@ type ClientConn struct {
initialStreamRecvWindowSize int32 initialStreamRecvWindowSize int32
readIdleTimeout time.Duration readIdleTimeout time.Duration
pingTimeout time.Duration pingTimeout time.Duration
extendedConnectAllowed bool
// rstStreamPingsBlocked works around an unfortunate gRPC behavior.
// gRPC strictly limits the number of PING frames that it will receive.
// The default is two pings per two hours, but the limit resets every time
// the gRPC endpoint sends a HEADERS or DATA frame. See golang/go#70575.
//
// rstStreamPingsBlocked is set after receiving a response to a PING frame
// bundled with an RST_STREAM (see pendingResets below), and cleared after
// receiving a HEADERS or DATA frame.
rstStreamPingsBlocked bool
// pendingResets is the number of RST_STREAM frames we have sent to the peer,
// without confirming that the peer has received them. When we send a RST_STREAM,
// we bundle it with a PING frame, unless a PING is already in flight. We count
// the reset stream against the connection's concurrency limit until we get
// a PING response. This limits the number of requests we'll try to send to a
// completely unresponsive connection.
pendingResets int
// reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests. // reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests.
// Write to reqHeaderMu to lock it, read from it to unlock. // Write to reqHeaderMu to lock it, read from it to unlock.
@ -423,9 +476,9 @@ type clientStream struct {
firstByte bool // got the first response byte firstByte bool // got the first response byte
pastHeaders bool // got first MetaHeadersFrame (actual headers) pastHeaders bool // got first MetaHeadersFrame (actual headers)
pastTrailers bool // got optional second MetaHeadersFrame (trailers) pastTrailers bool // got optional second MetaHeadersFrame (trailers)
num1xx uint8 // number of 1xx responses seen
readClosed bool // peer sent an END_STREAM flag readClosed bool // peer sent an END_STREAM flag
readAborted bool // read loop reset the stream readAborted bool // read loop reset the stream
totalHeaderSize int64 // total size of 1xx headers seen
trailer http.Header // accumulated trailers trailer http.Header // accumulated trailers
resTrailer *http.Header // client's Response.Trailer resTrailer *http.Header // client's Response.Trailer
@ -530,6 +583,8 @@ type RoundTripOpt struct {
// no cached connection is available, RoundTripOpt // no cached connection is available, RoundTripOpt
// will return ErrNoCachedConn. // will return ErrNoCachedConn.
OnlyCachedConn bool OnlyCachedConn bool
allowHTTP bool // allow http:// URLs
} }
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
@ -562,7 +617,14 @@ func authorityAddr(scheme string, authority string) (addr string) {
// RoundTripOpt is like RoundTrip, but takes options. // RoundTripOpt is like RoundTrip, but takes options.
func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) { func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) {
if !(req.URL.Scheme == "https" || (req.URL.Scheme == "http" && t.AllowHTTP)) { switch req.URL.Scheme {
case "https":
// Always okay.
case "http":
if !t.AllowHTTP && !opt.allowHTTP {
return nil, errors.New("http2: unencrypted HTTP/2 not enabled")
}
default:
return nil, errors.New("http2: unsupported scheme") return nil, errors.New("http2: unsupported scheme")
} }
@ -573,7 +635,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err) t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err)
return nil, err return nil, err
} }
reused := !atomic.CompareAndSwapUint32(&cc.reused, 0, 1) reused := !atomic.CompareAndSwapUint32(&cc.atomicReused, 0, 1)
traceGotConn(req, cc, reused) traceGotConn(req, cc, reused)
res, err := cc.RoundTrip(req) res, err := cc.RoundTrip(req)
if err != nil && retry <= 6 { if err != nil && retry <= 6 {
@ -598,6 +660,22 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
} }
} }
} }
if err == errClientConnNotEstablished {
// This ClientConn was created recently,
// this is the first request to use it,
// and the connection is closed and not usable.
//
// In this state, cc.idleTimer will remove the conn from the pool
// when it fires. Stop the timer and remove it here so future requests
// won't try to use this connection.
//
// If the timer has already fired and we're racing it, the redundant
// call to MarkDead is harmless.
if cc.idleTimer != nil {
cc.idleTimer.Stop()
}
t.connPool().MarkDead(cc)
}
if err != nil { if err != nil {
t.vlogf("RoundTrip failure: %v", err) t.vlogf("RoundTrip failure: %v", err)
return nil, err return nil, err
@ -618,6 +696,7 @@ func (t *Transport) CloseIdleConnections() {
var ( var (
errClientConnClosed = errors.New("http2: client conn is closed") errClientConnClosed = errors.New("http2: client conn is closed")
errClientConnUnusable = errors.New("http2: client conn not usable") errClientConnUnusable = errors.New("http2: client conn not usable")
errClientConnNotEstablished = errors.New("http2: client conn could not be established")
errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY") errClientConnGotGoAway = errors.New("http2: Transport received Server's graceful shutdown GOAWAY")
) )
@ -752,11 +831,13 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead. peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
streams: make(map[uint32]*clientStream), streams: make(map[uint32]*clientStream),
singleUse: singleUse, singleUse: singleUse,
seenSettingsChan: make(chan struct{}),
wantSettingsAck: true, wantSettingsAck: true,
readIdleTimeout: conf.SendPingTimeout, readIdleTimeout: conf.SendPingTimeout,
pingTimeout: conf.PingTimeout, pingTimeout: conf.PingTimeout,
pings: make(map[[8]byte]chan struct{}), pings: make(map[[8]byte]chan struct{}),
reqHeaderMu: make(chan struct{}, 1), reqHeaderMu: make(chan struct{}, 1),
lastActive: t.now(),
} }
var group synctestGroupInterface var group synctestGroupInterface
if t.transportTestHooks != nil { if t.transportTestHooks != nil {
@ -960,7 +1041,7 @@ func (cc *ClientConn) State() ClientConnState {
return ClientConnState{ return ClientConnState{
Closed: cc.closed, Closed: cc.closed,
Closing: cc.closing || cc.singleUse || cc.doNotReuse || cc.goAway != nil, Closing: cc.closing || cc.singleUse || cc.doNotReuse || cc.goAway != nil,
StreamsActive: len(cc.streams), StreamsActive: len(cc.streams) + cc.pendingResets,
StreamsReserved: cc.streamsReserved, StreamsReserved: cc.streamsReserved,
StreamsPending: cc.pendingRequests, StreamsPending: cc.pendingRequests,
LastIdle: cc.lastIdle, LastIdle: cc.lastIdle,
@ -992,16 +1073,38 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
// writing it. // writing it.
maxConcurrentOkay = true maxConcurrentOkay = true
} else { } else {
maxConcurrentOkay = int64(len(cc.streams)+cc.streamsReserved+1) <= int64(cc.maxConcurrentStreams) // We can take a new request if the total of
// - active streams;
// - reservation slots for new streams; and
// - streams for which we have sent a RST_STREAM and a PING,
// but received no subsequent frame
// is less than the concurrency limit.
maxConcurrentOkay = cc.currentRequestCountLocked() < int(cc.maxConcurrentStreams)
} }
st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay && st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay &&
!cc.doNotReuse && !cc.doNotReuse &&
int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 && int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 &&
!cc.tooIdleLocked() !cc.tooIdleLocked()
// If this connection has never been used for a request and is closed,
// then let it take a request (which will fail).
//
// This avoids a situation where an error early in a connection's lifetime
// goes unreported.
if cc.nextStreamID == 1 && cc.streamsReserved == 0 && cc.closed {
st.canTakeNewRequest = true
}
return return
} }
// currentRequestCountLocked reports the number of concurrency slots currently in use,
// including active streams, reserved slots, and reset streams waiting for acknowledgement.
func (cc *ClientConn) currentRequestCountLocked() int {
return len(cc.streams) + cc.streamsReserved + cc.pendingResets
}
func (cc *ClientConn) canTakeNewRequestLocked() bool { func (cc *ClientConn) canTakeNewRequestLocked() bool {
st := cc.idleStateLocked() st := cc.idleStateLocked()
return st.canTakeNewRequest return st.canTakeNewRequest
@ -1014,7 +1117,7 @@ func (cc *ClientConn) tooIdleLocked() bool {
// times are compared based on their wall time. We don't want // times are compared based on their wall time. We don't want
// to reuse a connection that's been sitting idle during // to reuse a connection that's been sitting idle during
// VM/laptop suspend if monotonic time was also frozen. // VM/laptop suspend if monotonic time was also frozen.
return cc.idleTimeout != 0 && !cc.lastIdle.IsZero() && time.Since(cc.lastIdle.Round(0)) > cc.idleTimeout return cc.idleTimeout != 0 && !cc.lastIdle.IsZero() && cc.t.timeSince(cc.lastIdle.Round(0)) > cc.idleTimeout
} }
// onIdleTimeout is called from a time.AfterFunc goroutine. It will // onIdleTimeout is called from a time.AfterFunc goroutine. It will
@ -1376,6 +1479,8 @@ func (cs *clientStream) doRequest(req *http.Request, streamf func(*clientStream)
cs.cleanupWriteRequest(err) cs.cleanupWriteRequest(err)
} }
var errExtendedConnectNotSupported = errors.New("net/http: extended connect not supported by peer")
// writeRequest sends a request. // writeRequest sends a request.
// //
// It returns nil after the request is written, the response read, // It returns nil after the request is written, the response read,
@ -1391,12 +1496,31 @@ func (cs *clientStream) writeRequest(req *http.Request, streamf func(*clientStre
return err return err
} }
// wait for setting frames to be received, a server can change this value later,
// but we just wait for the first settings frame
var isExtendedConnect bool
if req.Method == "CONNECT" && req.Header.Get(":protocol") != "" {
isExtendedConnect = true
}
// Acquire the new-request lock by writing to reqHeaderMu. // Acquire the new-request lock by writing to reqHeaderMu.
// This lock guards the critical section covering allocating a new stream ID // This lock guards the critical section covering allocating a new stream ID
// (requires mu) and creating the stream (requires wmu). // (requires mu) and creating the stream (requires wmu).
if cc.reqHeaderMu == nil { if cc.reqHeaderMu == nil {
panic("RoundTrip on uninitialized ClientConn") // for tests panic("RoundTrip on uninitialized ClientConn") // for tests
} }
if isExtendedConnect {
select {
case <-cs.reqCancel:
return errRequestCanceled
case <-ctx.Done():
return ctx.Err()
case <-cc.seenSettingsChan:
if !cc.extendedConnectAllowed {
return errExtendedConnectNotSupported
}
}
}
select { select {
case cc.reqHeaderMu <- struct{}{}: case cc.reqHeaderMu <- struct{}{}:
case <-cs.reqCancel: case <-cs.reqCancel:
@ -1578,6 +1702,7 @@ func (cs *clientStream) cleanupWriteRequest(err error) {
cs.reqBodyClosed = make(chan struct{}) cs.reqBodyClosed = make(chan struct{})
} }
bodyClosed := cs.reqBodyClosed bodyClosed := cs.reqBodyClosed
closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil
cc.mu.Unlock() cc.mu.Unlock()
if mustCloseBody { if mustCloseBody {
cs.reqBody.Close() cs.reqBody.Close()
@ -1602,16 +1727,44 @@ func (cs *clientStream) cleanupWriteRequest(err error) {
if cs.sentHeaders { if cs.sentHeaders {
if se, ok := err.(StreamError); ok { if se, ok := err.(StreamError); ok {
if se.Cause != errFromPeer { if se.Cause != errFromPeer {
cc.writeStreamReset(cs.ID, se.Code, err) cc.writeStreamReset(cs.ID, se.Code, false, err)
} }
} else { } else {
cc.writeStreamReset(cs.ID, ErrCodeCancel, err) // We're cancelling an in-flight request.
//
// This could be due to the server becoming unresponsive.
// To avoid sending too many requests on a dead connection,
// we let the request continue to consume a concurrency slot
// until we can confirm the server is still responding.
// We do this by sending a PING frame along with the RST_STREAM
// (unless a ping is already in flight).
//
// For simplicity, we don't bother tracking the PING payload:
// We reset cc.pendingResets any time we receive a PING ACK.
//
// We skip this if the conn is going to be closed on idle,
// because it's short lived and will probably be closed before
// we get the ping response.
ping := false
if !closeOnIdle {
cc.mu.Lock()
// rstStreamPingsBlocked works around a gRPC behavior:
// see comment on the field for details.
if !cc.rstStreamPingsBlocked {
if cc.pendingResets == 0 {
ping = true
}
cc.pendingResets++
}
cc.mu.Unlock()
}
cc.writeStreamReset(cs.ID, ErrCodeCancel, ping, err)
} }
} }
cs.bufPipe.CloseWithError(err) // no-op if already closed cs.bufPipe.CloseWithError(err) // no-op if already closed
} else { } else {
if cs.sentHeaders && !cs.sentEndStream { if cs.sentHeaders && !cs.sentEndStream {
cc.writeStreamReset(cs.ID, ErrCodeNo, nil) cc.writeStreamReset(cs.ID, ErrCodeNo, false, nil)
} }
cs.bufPipe.CloseWithError(errRequestCanceled) cs.bufPipe.CloseWithError(errRequestCanceled)
} }
@ -1633,12 +1786,17 @@ func (cs *clientStream) cleanupWriteRequest(err error) {
// Must hold cc.mu. // Must hold cc.mu.
func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error { func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error {
for { for {
cc.lastActive = time.Now() if cc.closed && cc.nextStreamID == 1 && cc.streamsReserved == 0 {
// This is the very first request sent to this connection.
// Return a fatal error which aborts the retry loop.
return errClientConnNotEstablished
}
cc.lastActive = cc.t.now()
if cc.closed || !cc.canTakeNewRequestLocked() { if cc.closed || !cc.canTakeNewRequestLocked() {
return errClientConnUnusable return errClientConnUnusable
} }
cc.lastIdle = time.Time{} cc.lastIdle = time.Time{}
if int64(len(cc.streams)) < int64(cc.maxConcurrentStreams) { if cc.currentRequestCountLocked() < int(cc.maxConcurrentStreams) {
return nil return nil
} }
cc.pendingRequests++ cc.pendingRequests++
@ -1910,7 +2068,7 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error)
func validateHeaders(hdrs http.Header) string { func validateHeaders(hdrs http.Header) string {
for k, vv := range hdrs { for k, vv := range hdrs {
if !httpguts.ValidHeaderFieldName(k) { if !httpguts.ValidHeaderFieldName(k) && k != ":protocol" {
return fmt.Sprintf("name %q", k) return fmt.Sprintf("name %q", k)
} }
for _, v := range vv { for _, v := range vv {
@ -1926,6 +2084,10 @@ func validateHeaders(hdrs http.Header) string {
var errNilRequestURL = errors.New("http2: Request.URI is nil") var errNilRequestURL = errors.New("http2: Request.URI is nil")
func isNormalConnect(req *http.Request) bool {
return req.Method == "CONNECT" && req.Header.Get(":protocol") == ""
}
// requires cc.wmu be held. // requires cc.wmu be held.
func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) { func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
cc.hbuf.Reset() cc.hbuf.Reset()
@ -1946,7 +2108,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
} }
var path string var path string
if req.Method != "CONNECT" { if !isNormalConnect(req) {
path = req.URL.RequestURI() path = req.URL.RequestURI()
if !validPseudoPath(path) { if !validPseudoPath(path) {
orig := path orig := path
@ -1983,7 +2145,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
m = http.MethodGet m = http.MethodGet
} }
f(":method", m) f(":method", m)
if req.Method != "CONNECT" { if !isNormalConnect(req) {
f(":path", path) f(":path", path)
f(":scheme", req.URL.Scheme) f(":scheme", req.URL.Scheme)
} }
@ -2180,10 +2342,10 @@ func (cc *ClientConn) forgetStreamID(id uint32) {
if len(cc.streams) != slen-1 { if len(cc.streams) != slen-1 {
panic("forgetting unknown stream id") panic("forgetting unknown stream id")
} }
cc.lastActive = time.Now() cc.lastActive = cc.t.now()
if len(cc.streams) == 0 && cc.idleTimer != nil { if len(cc.streams) == 0 && cc.idleTimer != nil {
cc.idleTimer.Reset(cc.idleTimeout) cc.idleTimer.Reset(cc.idleTimeout)
cc.lastIdle = time.Now() cc.lastIdle = cc.t.now()
} }
// Wake up writeRequestBody via clientStream.awaitFlowControl and // Wake up writeRequestBody via clientStream.awaitFlowControl and
// wake up RoundTrip if there is a pending request. // wake up RoundTrip if there is a pending request.
@ -2243,7 +2405,6 @@ func isEOFOrNetReadError(err error) bool {
func (rl *clientConnReadLoop) cleanup() { func (rl *clientConnReadLoop) cleanup() {
cc := rl.cc cc := rl.cc
cc.t.connPool().MarkDead(cc)
defer cc.closeConn() defer cc.closeConn()
defer close(cc.readerDone) defer close(cc.readerDone)
@ -2267,6 +2428,24 @@ func (rl *clientConnReadLoop) cleanup() {
} }
cc.closed = true cc.closed = true
// If the connection has never been used, and has been open for only a short time,
// leave it in the connection pool for a little while.
//
// This avoids a situation where new connections are constantly created,
// added to the pool, fail, and are removed from the pool, without any error
// being surfaced to the user.
const unusedWaitTime = 5 * time.Second
idleTime := cc.t.now().Sub(cc.lastActive)
if atomic.LoadUint32(&cc.atomicReused) == 0 && idleTime < unusedWaitTime {
cc.idleTimer = cc.t.afterFunc(unusedWaitTime-idleTime, func() {
cc.t.connPool().MarkDead(cc)
})
} else {
cc.mu.Unlock() // avoid any deadlocks in MarkDead
cc.t.connPool().MarkDead(cc)
cc.mu.Lock()
}
for _, cs := range cc.streams { for _, cs := range cc.streams {
select { select {
case <-cs.peerClosed: case <-cs.peerClosed:
@ -2324,7 +2503,7 @@ func (rl *clientConnReadLoop) run() error {
cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err) cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
} }
if se, ok := err.(StreamError); ok { if se, ok := err.(StreamError); ok {
if cs := rl.streamByID(se.StreamID); cs != nil { if cs := rl.streamByID(se.StreamID, notHeaderOrDataFrame); cs != nil {
if se.Cause == nil { if se.Cause == nil {
se.Cause = cc.fr.errDetail se.Cause = cc.fr.errDetail
} }
@ -2370,13 +2549,16 @@ func (rl *clientConnReadLoop) run() error {
if VerboseLogs { if VerboseLogs {
cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err) cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err)
} }
if !cc.seenSettings {
close(cc.seenSettingsChan)
}
return err return err
} }
} }
} }
func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error { func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error {
cs := rl.streamByID(f.StreamID) cs := rl.streamByID(f.StreamID, headerOrDataFrame)
if cs == nil { if cs == nil {
// We'd get here if we canceled a request while the // We'd get here if we canceled a request while the
// server had its response still in flight. So if this // server had its response still in flight. So if this
@ -2494,15 +2676,34 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
if f.StreamEnded() { if f.StreamEnded() {
return nil, errors.New("1xx informational response with END_STREAM flag") return nil, errors.New("1xx informational response with END_STREAM flag")
} }
cs.num1xx++
const max1xxResponses = 5 // arbitrary bound on number of informational responses, same as net/http
if cs.num1xx > max1xxResponses {
return nil, errors.New("http2: too many 1xx informational responses")
}
if fn := cs.get1xxTraceFunc(); fn != nil { if fn := cs.get1xxTraceFunc(); fn != nil {
// If the 1xx response is being delivered to the user,
// then they're responsible for limiting the number
// of responses.
if err := fn(statusCode, textproto.MIMEHeader(header)); err != nil { if err := fn(statusCode, textproto.MIMEHeader(header)); err != nil {
return nil, err return nil, err
} }
} else {
// If the user didn't examine the 1xx response, then we
// limit the size of all 1xx headers.
//
// This differs a bit from the HTTP/1 implementation, which
// limits the size of all 1xx headers plus the final response.
// Use the larger limit of MaxHeaderListSize and
// net/http.Transport.MaxResponseHeaderBytes.
limit := int64(cs.cc.t.maxHeaderListSize())
if t1 := cs.cc.t.t1; t1 != nil && t1.MaxResponseHeaderBytes > limit {
limit = t1.MaxResponseHeaderBytes
}
for _, h := range f.Fields {
cs.totalHeaderSize += int64(h.Size())
}
if cs.totalHeaderSize > limit {
if VerboseLogs {
log.Printf("http2: 1xx informational responses too large")
}
return nil, errors.New("header list too large")
}
} }
if statusCode == 100 { if statusCode == 100 {
traceGot100Continue(cs.trace) traceGot100Continue(cs.trace)
@ -2686,7 +2887,7 @@ func (b transportResponseBody) Close() error {
func (rl *clientConnReadLoop) processData(f *DataFrame) error { func (rl *clientConnReadLoop) processData(f *DataFrame) error {
cc := rl.cc cc := rl.cc
cs := rl.streamByID(f.StreamID) cs := rl.streamByID(f.StreamID, headerOrDataFrame)
data := f.Data() data := f.Data()
if cs == nil { if cs == nil {
cc.mu.Lock() cc.mu.Lock()
@ -2821,9 +3022,22 @@ func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) {
cs.abortStream(err) cs.abortStream(err)
} }
func (rl *clientConnReadLoop) streamByID(id uint32) *clientStream { // Constants passed to streamByID for documentation purposes.
const (
headerOrDataFrame = true
notHeaderOrDataFrame = false
)
// streamByID returns the stream with the given id, or nil if no stream has that id.
// If headerOrData is true, it clears rst.StreamPingsBlocked.
func (rl *clientConnReadLoop) streamByID(id uint32, headerOrData bool) *clientStream {
rl.cc.mu.Lock() rl.cc.mu.Lock()
defer rl.cc.mu.Unlock() defer rl.cc.mu.Unlock()
if headerOrData {
// Work around an unfortunate gRPC behavior.
// See comment on ClientConn.rstStreamPingsBlocked for details.
rl.cc.rstStreamPingsBlocked = false
}
cs := rl.cc.streams[id] cs := rl.cc.streams[id]
if cs != nil && !cs.readAborted { if cs != nil && !cs.readAborted {
return cs return cs
@ -2917,6 +3131,21 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
case SettingHeaderTableSize: case SettingHeaderTableSize:
cc.henc.SetMaxDynamicTableSize(s.Val) cc.henc.SetMaxDynamicTableSize(s.Val)
cc.peerMaxHeaderTableSize = s.Val cc.peerMaxHeaderTableSize = s.Val
case SettingEnableConnectProtocol:
if err := s.Valid(); err != nil {
return err
}
// If the peer wants to send us SETTINGS_ENABLE_CONNECT_PROTOCOL,
// we require that it do so in the first SETTINGS frame.
//
// When we attempt to use extended CONNECT, we wait for the first
// SETTINGS frame to see if the server supports it. If we let the
// server enable the feature with a later SETTINGS frame, then
// users will see inconsistent results depending on whether we've
// seen that frame or not.
if !cc.seenSettings {
cc.extendedConnectAllowed = s.Val == 1
}
default: default:
cc.vlogf("Unhandled Setting: %v", s) cc.vlogf("Unhandled Setting: %v", s)
} }
@ -2934,6 +3163,7 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
// connection can establish to our default. // connection can establish to our default.
cc.maxConcurrentStreams = defaultMaxConcurrentStreams cc.maxConcurrentStreams = defaultMaxConcurrentStreams
} }
close(cc.seenSettingsChan)
cc.seenSettings = true cc.seenSettings = true
} }
@ -2942,7 +3172,7 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error { func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
cc := rl.cc cc := rl.cc
cs := rl.streamByID(f.StreamID) cs := rl.streamByID(f.StreamID, notHeaderOrDataFrame)
if f.StreamID != 0 && cs == nil { if f.StreamID != 0 && cs == nil {
return nil return nil
} }
@ -2971,7 +3201,7 @@ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
} }
func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error { func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error {
cs := rl.streamByID(f.StreamID) cs := rl.streamByID(f.StreamID, notHeaderOrDataFrame)
if cs == nil { if cs == nil {
// TODO: return error if server tries to RST_STREAM an idle stream // TODO: return error if server tries to RST_STREAM an idle stream
return nil return nil
@ -3046,6 +3276,12 @@ func (rl *clientConnReadLoop) processPing(f *PingFrame) error {
close(c) close(c)
delete(cc.pings, f.Data) delete(cc.pings, f.Data)
} }
if cc.pendingResets > 0 {
// See clientStream.cleanupWriteRequest.
cc.pendingResets = 0
cc.rstStreamPingsBlocked = true
cc.cond.Broadcast()
}
return nil return nil
} }
cc := rl.cc cc := rl.cc
@ -3068,13 +3304,20 @@ func (rl *clientConnReadLoop) processPushPromise(f *PushPromiseFrame) error {
return ConnectionError(ErrCodeProtocol) return ConnectionError(ErrCodeProtocol)
} }
func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error) { // writeStreamReset sends a RST_STREAM frame.
// When ping is true, it also sends a PING frame with a random payload.
func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, ping bool, err error) {
// TODO: map err to more interesting error codes, once the // TODO: map err to more interesting error codes, once the
// HTTP community comes up with some. But currently for // HTTP community comes up with some. But currently for
// RST_STREAM there's no equivalent to GOAWAY frame's debug // RST_STREAM there's no equivalent to GOAWAY frame's debug
// data, and the error codes are all pretty vague ("cancel"). // data, and the error codes are all pretty vague ("cancel").
cc.wmu.Lock() cc.wmu.Lock()
cc.fr.WriteRSTStream(streamID, code) cc.fr.WriteRSTStream(streamID, code)
if ping {
var payload [8]byte
rand.Read(payload[:])
cc.fr.WritePing(false, payload)
}
cc.bw.Flush() cc.bw.Flush()
cc.wmu.Unlock() cc.wmu.Unlock()
} }
@ -3228,7 +3471,7 @@ func traceGotConn(req *http.Request, cc *ClientConn, reused bool) {
cc.mu.Lock() cc.mu.Lock()
ci.WasIdle = len(cc.streams) == 0 && reused ci.WasIdle = len(cc.streams) == 0 && reused
if ci.WasIdle && !cc.lastActive.IsZero() { if ci.WasIdle && !cc.lastActive.IsZero() {
ci.IdleTime = time.Since(cc.lastActive) ci.IdleTime = cc.t.timeSince(cc.lastActive)
} }
cc.mu.Unlock() cc.mu.Unlock()

32
vendor/golang.org/x/net/http2/unencrypted.go generated vendored Normal file
View File

@ -0,0 +1,32 @@
// Copyright 2024 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 http2
import (
"crypto/tls"
"errors"
"net"
)
const nextProtoUnencryptedHTTP2 = "unencrypted_http2"
// unencryptedNetConnFromTLSConn retrieves a net.Conn wrapped in a *tls.Conn.
//
// TLSNextProto functions accept a *tls.Conn.
//
// When passing an unencrypted HTTP/2 connection to a TLSNextProto function,
// we pass a *tls.Conn with an underlying net.Conn containing the unencrypted connection.
// To be extra careful about mistakes (accidentally dropping TLS encryption in a place
// where we want it), the tls.Conn contains a net.Conn with an UnencryptedNetConn method
// that returns the actual connection we want to use.
func unencryptedNetConnFromTLSConn(tc *tls.Conn) (net.Conn, error) {
conner, ok := tc.NetConn().(interface {
UnencryptedNetConn() net.Conn
})
if !ok {
return nil, errors.New("http2: TLS conn unexpectedly found in unencrypted handoff")
}
return conner.UnencryptedNetConn(), nil
}

View File

@ -58,6 +58,102 @@ func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
return &value, err return &value, err
} }
// IoctlGetEthtoolTsInfo fetches ethtool timestamping and PHC
// association for the network device specified by ifname.
func IoctlGetEthtoolTsInfo(fd int, ifname string) (*EthtoolTsInfo, error) {
ifr, err := NewIfreq(ifname)
if err != nil {
return nil, err
}
value := EthtoolTsInfo{Cmd: ETHTOOL_GET_TS_INFO}
ifrd := ifr.withData(unsafe.Pointer(&value))
err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
return &value, err
}
// IoctlGetHwTstamp retrieves the hardware timestamping configuration
// for the network device specified by ifname.
func IoctlGetHwTstamp(fd int, ifname string) (*HwTstampConfig, error) {
ifr, err := NewIfreq(ifname)
if err != nil {
return nil, err
}
value := HwTstampConfig{}
ifrd := ifr.withData(unsafe.Pointer(&value))
err = ioctlIfreqData(fd, SIOCGHWTSTAMP, &ifrd)
return &value, err
}
// IoctlSetHwTstamp updates the hardware timestamping configuration for
// the network device specified by ifname.
func IoctlSetHwTstamp(fd int, ifname string, cfg *HwTstampConfig) error {
ifr, err := NewIfreq(ifname)
if err != nil {
return err
}
ifrd := ifr.withData(unsafe.Pointer(cfg))
return ioctlIfreqData(fd, SIOCSHWTSTAMP, &ifrd)
}
// FdToClockID derives the clock ID from the file descriptor number
// - see clock_gettime(3), FD_TO_CLOCKID macros. The resulting ID is
// suitable for system calls like ClockGettime.
func FdToClockID(fd int) int32 { return int32((int(^fd) << 3) | 3) }
// IoctlPtpClockGetcaps returns the description of a given PTP device.
func IoctlPtpClockGetcaps(fd int) (*PtpClockCaps, error) {
var value PtpClockCaps
err := ioctlPtr(fd, PTP_CLOCK_GETCAPS2, unsafe.Pointer(&value))
return &value, err
}
// IoctlPtpSysOffsetPrecise returns a description of the clock
// offset compared to the system clock.
func IoctlPtpSysOffsetPrecise(fd int) (*PtpSysOffsetPrecise, error) {
var value PtpSysOffsetPrecise
err := ioctlPtr(fd, PTP_SYS_OFFSET_PRECISE2, unsafe.Pointer(&value))
return &value, err
}
// IoctlPtpSysOffsetExtended returns an extended description of the
// clock offset compared to the system clock. The samples parameter
// specifies the desired number of measurements.
func IoctlPtpSysOffsetExtended(fd int, samples uint) (*PtpSysOffsetExtended, error) {
value := PtpSysOffsetExtended{Samples: uint32(samples)}
err := ioctlPtr(fd, PTP_SYS_OFFSET_EXTENDED2, unsafe.Pointer(&value))
return &value, err
}
// IoctlPtpPinGetfunc returns the configuration of the specified
// I/O pin on given PTP device.
func IoctlPtpPinGetfunc(fd int, index uint) (*PtpPinDesc, error) {
value := PtpPinDesc{Index: uint32(index)}
err := ioctlPtr(fd, PTP_PIN_GETFUNC2, unsafe.Pointer(&value))
return &value, err
}
// IoctlPtpPinSetfunc updates configuration of the specified PTP
// I/O pin.
func IoctlPtpPinSetfunc(fd int, pd *PtpPinDesc) error {
return ioctlPtr(fd, PTP_PIN_SETFUNC2, unsafe.Pointer(pd))
}
// IoctlPtpPeroutRequest configures the periodic output mode of the
// PTP I/O pins.
func IoctlPtpPeroutRequest(fd int, r *PtpPeroutRequest) error {
return ioctlPtr(fd, PTP_PEROUT_REQUEST2, unsafe.Pointer(r))
}
// IoctlPtpExttsRequest configures the external timestamping mode
// of the PTP I/O pins.
func IoctlPtpExttsRequest(fd int, r *PtpExttsRequest) error {
return ioctlPtr(fd, PTP_EXTTS_REQUEST2, unsafe.Pointer(r))
}
// IoctlGetWatchdogInfo fetches information about a watchdog device from the // IoctlGetWatchdogInfo fetches information about a watchdog device from the
// Linux watchdog API. For more information, see: // Linux watchdog API. For more information, see:
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html. // https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.

View File

@ -158,6 +158,16 @@ includes_Linux='
#endif #endif
#define _GNU_SOURCE #define _GNU_SOURCE
// See the description in unix/linux/types.go
#if defined(__ARM_EABI__) || \
(defined(__mips__) && (_MIPS_SIM == _ABIO32)) || \
(defined(__powerpc__) && (!defined(__powerpc64__)))
# ifdef _TIME_BITS
# undef _TIME_BITS
# endif
# define _TIME_BITS 32
#endif
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of // <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
// these structures. We just include them copied from <bits/termios.h>. // these structures. We just include them copied from <bits/termios.h>.
#if defined(__powerpc__) #if defined(__powerpc__)
@ -256,6 +266,7 @@ struct ltchars {
#include <linux/nsfs.h> #include <linux/nsfs.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/pps.h> #include <linux/pps.h>
#include <linux/ptp_clock.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/reboot.h> #include <linux/reboot.h>
@ -527,6 +538,7 @@ ccflags="$@"
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ || $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
$2 ~ /^NFC_.*_(MAX)?SIZE$/ || $2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
$2 ~ /^PTP_/ ||
$2 ~ /^RAW_PAYLOAD_/ || $2 ~ /^RAW_PAYLOAD_/ ||
$2 ~ /^[US]F_/ || $2 ~ /^[US]F_/ ||
$2 ~ /^TP_STATUS_/ || $2 ~ /^TP_STATUS_/ ||

View File

@ -1860,6 +1860,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error) //sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
//sys ClockGetres(clockid int32, res *Timespec) (err error) //sys ClockGetres(clockid int32, res *Timespec) (err error)
//sys ClockGettime(clockid int32, time *Timespec) (err error) //sys ClockGettime(clockid int32, time *Timespec) (err error)
//sys ClockSettime(clockid int32, time *Timespec) (err error)
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) //sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
//sys Close(fd int) (err error) //sys Close(fd int) (err error)
//sys CloseRange(first uint, last uint, flags uint) (err error) //sys CloseRange(first uint, last uint, flags uint) (err error)

View File

@ -768,6 +768,15 @@ func Munmap(b []byte) (err error) {
return mapper.Munmap(b) return mapper.Munmap(b)
} }
func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) {
xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset)
return unsafe.Pointer(xaddr), err
}
func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) {
return mapper.munmap(uintptr(addr), length)
}
//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A //sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
//sysnb Getgid() (gid int) //sysnb Getgid() (gid int)
//sysnb Getpid() (pid int) //sysnb Getpid() (pid int)
@ -816,10 +825,10 @@ func Lstat(path string, stat *Stat_t) (err error) {
// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/ // for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
func isSpecialPath(path []byte) (v bool) { func isSpecialPath(path []byte) (v bool) {
var special = [4][8]byte{ var special = [4][8]byte{
[8]byte{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'}, {'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
[8]byte{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'}, {'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'}, {'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}} {'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
var i, j int var i, j int
for i = 0; i < len(special); i++ { for i = 0; i < len(special); i++ {
@ -3115,3 +3124,90 @@ func legacy_Mkfifoat(dirfd int, path string, mode uint32) (err error) {
//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT //sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT //sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT //sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT
func fcntlAsIs(fd uintptr, cmd int, arg uintptr) (val int, err error) {
runtime.EnterSyscall()
r0, e2, e1 := CallLeFuncWithErr(GetZosLibVec()+SYS_FCNTL<<4, uintptr(fd), uintptr(cmd), arg)
runtime.ExitSyscall()
val = int(r0)
if int64(r0) == -1 {
err = errnoErr2(e1, e2)
}
return
}
func Fcntl(fd uintptr, cmd int, op interface{}) (ret int, err error) {
switch op.(type) {
case *Flock_t:
err = FcntlFlock(fd, cmd, op.(*Flock_t))
if err != nil {
ret = -1
}
return
case int:
return FcntlInt(fd, cmd, op.(int))
case *F_cnvrt:
return fcntlAsIs(fd, cmd, uintptr(unsafe.Pointer(op.(*F_cnvrt))))
case unsafe.Pointer:
return fcntlAsIs(fd, cmd, uintptr(op.(unsafe.Pointer)))
default:
return -1, EINVAL
}
return
}
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
}
return sendfile(outfd, infd, offset, count)
}
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
// TODO: use LE call instead if the call is implemented
originalOffset, err := Seek(infd, 0, SEEK_CUR)
if err != nil {
return -1, err
}
//start reading data from in_fd
if offset != nil {
_, err := Seek(infd, *offset, SEEK_SET)
if err != nil {
return -1, err
}
}
buf := make([]byte, count)
readBuf := make([]byte, 0)
var n int = 0
for i := 0; i < count; i += n {
n, err := Read(infd, buf)
if n == 0 {
if err != nil {
return -1, err
} else { // EOF
break
}
}
readBuf = append(readBuf, buf...)
buf = buf[0:0]
}
n2, err := Write(outfd, readBuf)
if err != nil {
return -1, err
}
//When sendfile() returns, this variable will be set to the
// offset of the byte following the last byte that was read.
if offset != nil {
*offset = *offset + int64(n)
// If offset is not NULL, then sendfile() does not modify the file
// offset of in_fd
_, err := Seek(infd, originalOffset, SEEK_SET)
if err != nil {
return -1, err
}
}
return n2, nil
}

View File

@ -321,6 +321,9 @@ const (
AUDIT_INTEGRITY_STATUS = 0x70a AUDIT_INTEGRITY_STATUS = 0x70a
AUDIT_IPC = 0x517 AUDIT_IPC = 0x517
AUDIT_IPC_SET_PERM = 0x51f AUDIT_IPC_SET_PERM = 0x51f
AUDIT_IPE_ACCESS = 0x58c
AUDIT_IPE_CONFIG_CHANGE = 0x58d
AUDIT_IPE_POLICY_LOAD = 0x58e
AUDIT_KERNEL = 0x7d0 AUDIT_KERNEL = 0x7d0
AUDIT_KERNEL_OTHER = 0x524 AUDIT_KERNEL_OTHER = 0x524
AUDIT_KERN_MODULE = 0x532 AUDIT_KERN_MODULE = 0x532
@ -489,6 +492,7 @@ const (
BPF_F_ID = 0x20 BPF_F_ID = 0x20
BPF_F_NETFILTER_IP_DEFRAG = 0x1 BPF_F_NETFILTER_IP_DEFRAG = 0x1
BPF_F_QUERY_EFFECTIVE = 0x1 BPF_F_QUERY_EFFECTIVE = 0x1
BPF_F_REDIRECT_FLAGS = 0x19
BPF_F_REPLACE = 0x4 BPF_F_REPLACE = 0x4
BPF_F_SLEEPABLE = 0x10 BPF_F_SLEEPABLE = 0x10
BPF_F_STRICT_ALIGNMENT = 0x1 BPF_F_STRICT_ALIGNMENT = 0x1
@ -1166,6 +1170,7 @@ const (
EXTA = 0xe EXTA = 0xe
EXTB = 0xf EXTB = 0xf
F2FS_SUPER_MAGIC = 0xf2f52010 F2FS_SUPER_MAGIC = 0xf2f52010
FALLOC_FL_ALLOCATE_RANGE = 0x0
FALLOC_FL_COLLAPSE_RANGE = 0x8 FALLOC_FL_COLLAPSE_RANGE = 0x8
FALLOC_FL_INSERT_RANGE = 0x20 FALLOC_FL_INSERT_RANGE = 0x20
FALLOC_FL_KEEP_SIZE = 0x1 FALLOC_FL_KEEP_SIZE = 0x1
@ -1799,6 +1804,8 @@ const (
LANDLOCK_ACCESS_NET_BIND_TCP = 0x1 LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2 LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
LANDLOCK_CREATE_RULESET_VERSION = 0x1 LANDLOCK_CREATE_RULESET_VERSION = 0x1
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
LANDLOCK_SCOPE_SIGNAL = 0x2
LINUX_REBOOT_CMD_CAD_OFF = 0x0 LINUX_REBOOT_CMD_CAD_OFF = 0x0
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
LINUX_REBOOT_CMD_HALT = 0xcdef0123 LINUX_REBOOT_CMD_HALT = 0xcdef0123
@ -1924,6 +1931,7 @@ const (
MNT_FORCE = 0x1 MNT_FORCE = 0x1
MNT_ID_REQ_SIZE_VER0 = 0x18 MNT_ID_REQ_SIZE_VER0 = 0x18
MNT_ID_REQ_SIZE_VER1 = 0x20 MNT_ID_REQ_SIZE_VER1 = 0x20
MNT_NS_INFO_SIZE_VER0 = 0x10
MODULE_INIT_COMPRESSED_FILE = 0x4 MODULE_INIT_COMPRESSED_FILE = 0x4
MODULE_INIT_IGNORE_MODVERSIONS = 0x1 MODULE_INIT_IGNORE_MODVERSIONS = 0x1
MODULE_INIT_IGNORE_VERMAGIC = 0x2 MODULE_INIT_IGNORE_VERMAGIC = 0x2
@ -2625,6 +2633,28 @@ const (
PR_UNALIGN_NOPRINT = 0x1 PR_UNALIGN_NOPRINT = 0x1
PR_UNALIGN_SIGBUS = 0x2 PR_UNALIGN_SIGBUS = 0x2
PSTOREFS_MAGIC = 0x6165676c PSTOREFS_MAGIC = 0x6165676c
PTP_CLK_MAGIC = '='
PTP_ENABLE_FEATURE = 0x1
PTP_EXTTS_EDGES = 0x6
PTP_EXTTS_EVENT_VALID = 0x1
PTP_EXTTS_V1_VALID_FLAGS = 0x7
PTP_EXTTS_VALID_FLAGS = 0x1f
PTP_EXT_OFFSET = 0x10
PTP_FALLING_EDGE = 0x4
PTP_MAX_SAMPLES = 0x19
PTP_PEROUT_DUTY_CYCLE = 0x2
PTP_PEROUT_ONE_SHOT = 0x1
PTP_PEROUT_PHASE = 0x4
PTP_PEROUT_V1_VALID_FLAGS = 0x0
PTP_PEROUT_VALID_FLAGS = 0x7
PTP_PIN_GETFUNC = 0xc0603d06
PTP_PIN_GETFUNC2 = 0xc0603d0f
PTP_RISING_EDGE = 0x2
PTP_STRICT_FLAGS = 0x8
PTP_SYS_OFFSET_EXTENDED = 0xc4c03d09
PTP_SYS_OFFSET_EXTENDED2 = 0xc4c03d12
PTP_SYS_OFFSET_PRECISE = 0xc0403d08
PTP_SYS_OFFSET_PRECISE2 = 0xc0403d11
PTRACE_ATTACH = 0x10 PTRACE_ATTACH = 0x10
PTRACE_CONT = 0x7 PTRACE_CONT = 0x7
PTRACE_DETACH = 0x11 PTRACE_DETACH = 0x11
@ -2948,6 +2978,7 @@ const (
RWF_WRITE_LIFE_NOT_SET = 0x0 RWF_WRITE_LIFE_NOT_SET = 0x0
SCHED_BATCH = 0x3 SCHED_BATCH = 0x3
SCHED_DEADLINE = 0x6 SCHED_DEADLINE = 0x6
SCHED_EXT = 0x7
SCHED_FIFO = 0x1 SCHED_FIFO = 0x1
SCHED_FLAG_ALL = 0x7f SCHED_FLAG_ALL = 0x7f
SCHED_FLAG_DL_OVERRUN = 0x4 SCHED_FLAG_DL_OVERRUN = 0x4

View File

@ -109,6 +109,7 @@ const (
HIDIOCGRAWINFO = 0x80084803 HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802 HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801 HIDIOCGRDESCSIZE = 0x80044801
HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -237,6 +238,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCUNBRIDGECHAN = 0x7434
PPPIOCXFERUNIT = 0x744e PPPIOCXFERUNIT = 0x744e
PR_SET_PTRACER_ANY = 0xffffffff PR_SET_PTRACER_ANY = 0xffffffff
PTP_CLOCK_GETCAPS = 0x80503d01
PTP_CLOCK_GETCAPS2 = 0x80503d0a
PTP_ENABLE_PPS = 0x40043d04
PTP_ENABLE_PPS2 = 0x40043d0d
PTP_EXTTS_REQUEST = 0x40103d02
PTP_EXTTS_REQUEST2 = 0x40103d0b
PTP_MASK_CLEAR_ALL = 0x3d13
PTP_MASK_EN_SINGLE = 0x40043d14
PTP_PEROUT_REQUEST = 0x40383d03
PTP_PEROUT_REQUEST2 = 0x40383d0c
PTP_PIN_SETFUNC = 0x40603d07
PTP_PIN_SETFUNC2 = 0x40603d10
PTP_SYS_OFFSET = 0x43403d05
PTP_SYS_OFFSET2 = 0x43403d0e
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GETFPXREGS = 0x12 PTRACE_GETFPXREGS = 0x12
PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA = 0x19
@ -283,6 +298,8 @@ const (
RTC_WIE_ON = 0x700f RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010 RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -321,6 +338,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -109,6 +109,7 @@ const (
HIDIOCGRAWINFO = 0x80084803 HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802 HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801 HIDIOCGRDESCSIZE = 0x80044801
HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -237,6 +238,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCUNBRIDGECHAN = 0x7434
PPPIOCXFERUNIT = 0x744e PPPIOCXFERUNIT = 0x744e
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x80503d01
PTP_CLOCK_GETCAPS2 = 0x80503d0a
PTP_ENABLE_PPS = 0x40043d04
PTP_ENABLE_PPS2 = 0x40043d0d
PTP_EXTTS_REQUEST = 0x40103d02
PTP_EXTTS_REQUEST2 = 0x40103d0b
PTP_MASK_CLEAR_ALL = 0x3d13
PTP_MASK_EN_SINGLE = 0x40043d14
PTP_PEROUT_REQUEST = 0x40383d03
PTP_PEROUT_REQUEST2 = 0x40383d0c
PTP_PIN_SETFUNC = 0x40603d07
PTP_PIN_SETFUNC2 = 0x40603d10
PTP_SYS_OFFSET = 0x43403d05
PTP_SYS_OFFSET2 = 0x43403d0e
PTRACE_ARCH_PRCTL = 0x1e PTRACE_ARCH_PRCTL = 0x1e
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GETFPXREGS = 0x12 PTRACE_GETFPXREGS = 0x12
@ -284,6 +299,8 @@ const (
RTC_WIE_ON = 0x700f RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010 RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -322,6 +339,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x80084803 HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802 HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801 HIDIOCGRDESCSIZE = 0x80044801
HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -234,6 +235,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCUNBRIDGECHAN = 0x7434
PPPIOCXFERUNIT = 0x744e PPPIOCXFERUNIT = 0x744e
PR_SET_PTRACER_ANY = 0xffffffff PR_SET_PTRACER_ANY = 0xffffffff
PTP_CLOCK_GETCAPS = 0x80503d01
PTP_CLOCK_GETCAPS2 = 0x80503d0a
PTP_ENABLE_PPS = 0x40043d04
PTP_ENABLE_PPS2 = 0x40043d0d
PTP_EXTTS_REQUEST = 0x40103d02
PTP_EXTTS_REQUEST2 = 0x40103d0b
PTP_MASK_CLEAR_ALL = 0x3d13
PTP_MASK_EN_SINGLE = 0x40043d14
PTP_PEROUT_REQUEST = 0x40383d03
PTP_PEROUT_REQUEST2 = 0x40383d0c
PTP_PIN_SETFUNC = 0x40603d07
PTP_PIN_SETFUNC2 = 0x40603d10
PTP_SYS_OFFSET = 0x43403d05
PTP_SYS_OFFSET2 = 0x43403d0e
PTRACE_GETCRUNCHREGS = 0x19 PTRACE_GETCRUNCHREGS = 0x19
PTRACE_GETFDPIC = 0x1f PTRACE_GETFDPIC = 0x1f
PTRACE_GETFDPIC_EXEC = 0x0 PTRACE_GETFDPIC_EXEC = 0x0
@ -289,6 +304,8 @@ const (
RTC_WIE_ON = 0x700f RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010 RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -327,6 +344,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -112,6 +112,7 @@ const (
HIDIOCGRAWINFO = 0x80084803 HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802 HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801 HIDIOCGRDESCSIZE = 0x80044801
HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -205,6 +206,7 @@ const (
PERF_EVENT_IOC_SET_BPF = 0x40042408 PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40082406 PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405 PERF_EVENT_IOC_SET_OUTPUT = 0x2405
POE_MAGIC = 0x504f4530
PPPIOCATTACH = 0x4004743d PPPIOCATTACH = 0x4004743d
PPPIOCATTCHAN = 0x40047438 PPPIOCATTCHAN = 0x40047438
PPPIOCBRIDGECHAN = 0x40047435 PPPIOCBRIDGECHAN = 0x40047435
@ -240,6 +242,20 @@ const (
PROT_BTI = 0x10 PROT_BTI = 0x10
PROT_MTE = 0x20 PROT_MTE = 0x20
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x80503d01
PTP_CLOCK_GETCAPS2 = 0x80503d0a
PTP_ENABLE_PPS = 0x40043d04
PTP_ENABLE_PPS2 = 0x40043d0d
PTP_EXTTS_REQUEST = 0x40103d02
PTP_EXTTS_REQUEST2 = 0x40103d0b
PTP_MASK_CLEAR_ALL = 0x3d13
PTP_MASK_EN_SINGLE = 0x40043d14
PTP_PEROUT_REQUEST = 0x40383d03
PTP_PEROUT_REQUEST2 = 0x40383d0c
PTP_PIN_SETFUNC = 0x40603d07
PTP_PIN_SETFUNC2 = 0x40603d10
PTP_SYS_OFFSET = 0x43403d05
PTP_SYS_OFFSET2 = 0x43403d0e
PTRACE_PEEKMTETAGS = 0x21 PTRACE_PEEKMTETAGS = 0x21
PTRACE_POKEMTETAGS = 0x22 PTRACE_POKEMTETAGS = 0x22
PTRACE_SYSEMU = 0x1f PTRACE_SYSEMU = 0x1f
@ -280,6 +296,8 @@ const (
RTC_WIE_ON = 0x700f RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010 RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -318,6 +336,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -109,6 +109,7 @@ const (
HIDIOCGRAWINFO = 0x80084803 HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802 HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801 HIDIOCGRDESCSIZE = 0x80044801
HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -238,6 +239,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCUNBRIDGECHAN = 0x7434
PPPIOCXFERUNIT = 0x744e PPPIOCXFERUNIT = 0x744e
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x80503d01
PTP_CLOCK_GETCAPS2 = 0x80503d0a
PTP_ENABLE_PPS = 0x40043d04
PTP_ENABLE_PPS2 = 0x40043d0d
PTP_EXTTS_REQUEST = 0x40103d02
PTP_EXTTS_REQUEST2 = 0x40103d0b
PTP_MASK_CLEAR_ALL = 0x3d13
PTP_MASK_EN_SINGLE = 0x40043d14
PTP_PEROUT_REQUEST = 0x40383d03
PTP_PEROUT_REQUEST2 = 0x40383d0c
PTP_PIN_SETFUNC = 0x40603d07
PTP_PIN_SETFUNC2 = 0x40603d10
PTP_SYS_OFFSET = 0x43403d05
PTP_SYS_OFFSET2 = 0x43403d0e
PTRACE_SYSEMU = 0x1f PTRACE_SYSEMU = 0x1f
PTRACE_SYSEMU_SINGLESTEP = 0x20 PTRACE_SYSEMU_SINGLESTEP = 0x20
RLIMIT_AS = 0x9 RLIMIT_AS = 0x9
@ -276,6 +291,8 @@ const (
RTC_WIE_ON = 0x700f RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010 RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -314,6 +331,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x100 IEXTEN = 0x100
@ -234,6 +235,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCUNBRIDGECHAN = 0x20007434
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PR_SET_PTRACER_ANY = 0xffffffff PR_SET_PTRACER_ANY = 0xffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA = 0x19
PTRACE_GET_THREAD_AREA_3264 = 0xc4 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@ -282,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -320,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029 SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10 SO_DONTROUTE = 0x10
SO_ERROR = 0x1007 SO_ERROR = 0x1007

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x100 IEXTEN = 0x100
@ -234,6 +235,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCUNBRIDGECHAN = 0x20007434
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA = 0x19
PTRACE_GET_THREAD_AREA_3264 = 0xc4 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@ -282,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -320,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029 SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10 SO_DONTROUTE = 0x10
SO_ERROR = 0x1007 SO_ERROR = 0x1007

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x100 IEXTEN = 0x100
@ -234,6 +235,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCUNBRIDGECHAN = 0x20007434
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA = 0x19
PTRACE_GET_THREAD_AREA_3264 = 0xc4 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@ -282,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -320,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029 SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10 SO_DONTROUTE = 0x10
SO_ERROR = 0x1007 SO_ERROR = 0x1007

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x100 IEXTEN = 0x100
@ -234,6 +235,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCUNBRIDGECHAN = 0x20007434
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PR_SET_PTRACER_ANY = 0xffffffff PR_SET_PTRACER_ANY = 0xffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GET_THREAD_AREA = 0x19 PTRACE_GET_THREAD_AREA = 0x19
PTRACE_GET_THREAD_AREA_3264 = 0xc4 PTRACE_GET_THREAD_AREA_3264 = 0xc4
@ -282,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -320,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029 SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10 SO_DONTROUTE = 0x10
SO_ERROR = 0x1007 SO_ERROR = 0x1007

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x4000 HUPCL = 0x4000
ICANON = 0x100 ICANON = 0x100
IEXTEN = 0x400 IEXTEN = 0x400
@ -237,6 +238,20 @@ const (
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PROT_SAO = 0x10 PROT_SAO = 0x10
PR_SET_PTRACER_ANY = 0xffffffff PR_SET_PTRACER_ANY = 0xffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETEVRREGS = 0x14 PTRACE_GETEVRREGS = 0x14
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GETREGS64 = 0x16 PTRACE_GETREGS64 = 0x16
@ -337,6 +352,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -375,6 +392,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x4000 HUPCL = 0x4000
ICANON = 0x100 ICANON = 0x100
IEXTEN = 0x400 IEXTEN = 0x400
@ -237,6 +238,20 @@ const (
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PROT_SAO = 0x10 PROT_SAO = 0x10
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETEVRREGS = 0x14 PTRACE_GETEVRREGS = 0x14
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GETREGS64 = 0x16 PTRACE_GETREGS64 = 0x16
@ -341,6 +356,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -379,6 +396,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x4000 HUPCL = 0x4000
ICANON = 0x100 ICANON = 0x100
IEXTEN = 0x400 IEXTEN = 0x400
@ -237,6 +238,20 @@ const (
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PROT_SAO = 0x10 PROT_SAO = 0x10
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETEVRREGS = 0x14 PTRACE_GETEVRREGS = 0x14
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GETREGS64 = 0x16 PTRACE_GETREGS64 = 0x16
@ -341,6 +356,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -379,6 +396,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x80084803 HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802 HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801 HIDIOCGRDESCSIZE = 0x80044801
HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -234,6 +235,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCUNBRIDGECHAN = 0x7434
PPPIOCXFERUNIT = 0x744e PPPIOCXFERUNIT = 0x744e
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x80503d01
PTP_CLOCK_GETCAPS2 = 0x80503d0a
PTP_ENABLE_PPS = 0x40043d04
PTP_ENABLE_PPS2 = 0x40043d0d
PTP_EXTTS_REQUEST = 0x40103d02
PTP_EXTTS_REQUEST2 = 0x40103d0b
PTP_MASK_CLEAR_ALL = 0x3d13
PTP_MASK_EN_SINGLE = 0x40043d14
PTP_PEROUT_REQUEST = 0x40383d03
PTP_PEROUT_REQUEST2 = 0x40383d0c
PTP_PIN_SETFUNC = 0x40603d07
PTP_PIN_SETFUNC2 = 0x40603d10
PTP_SYS_OFFSET = 0x43403d05
PTP_SYS_OFFSET2 = 0x43403d0e
PTRACE_GETFDPIC = 0x21 PTRACE_GETFDPIC = 0x21
PTRACE_GETFDPIC_EXEC = 0x0 PTRACE_GETFDPIC_EXEC = 0x0
PTRACE_GETFDPIC_INTERP = 0x1 PTRACE_GETFDPIC_INTERP = 0x1
@ -273,6 +288,8 @@ const (
RTC_WIE_ON = 0x700f RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010 RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -311,6 +328,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x80084803 HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802 HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801 HIDIOCGRDESCSIZE = 0x80044801
HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -234,6 +235,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x7434 PPPIOCUNBRIDGECHAN = 0x7434
PPPIOCXFERUNIT = 0x744e PPPIOCXFERUNIT = 0x744e
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x80503d01
PTP_CLOCK_GETCAPS2 = 0x80503d0a
PTP_ENABLE_PPS = 0x40043d04
PTP_ENABLE_PPS2 = 0x40043d0d
PTP_EXTTS_REQUEST = 0x40103d02
PTP_EXTTS_REQUEST2 = 0x40103d0b
PTP_MASK_CLEAR_ALL = 0x3d13
PTP_MASK_EN_SINGLE = 0x40043d14
PTP_PEROUT_REQUEST = 0x40383d03
PTP_PEROUT_REQUEST2 = 0x40383d0c
PTP_PIN_SETFUNC = 0x40603d07
PTP_PIN_SETFUNC2 = 0x40603d10
PTP_SYS_OFFSET = 0x43403d05
PTP_SYS_OFFSET2 = 0x43403d0e
PTRACE_DISABLE_TE = 0x5010 PTRACE_DISABLE_TE = 0x5010
PTRACE_ENABLE_TE = 0x5009 PTRACE_ENABLE_TE = 0x5009
PTRACE_GET_LAST_BREAK = 0x5006 PTRACE_GET_LAST_BREAK = 0x5006
@ -345,6 +360,8 @@ const (
RTC_WIE_ON = 0x700f RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010 RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f RTC_WKALM_SET = 0x4028700f
SCM_DEVMEM_DMABUF = 0x4f
SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25 SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36 SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a SCM_TIMESTAMPING_PKTINFO = 0x3a
@ -383,6 +400,9 @@ const (
SO_CNX_ADVICE = 0x35 SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39 SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44 SO_DETACH_REUSEPORT_BPF = 0x44
SO_DEVMEM_DMABUF = 0x4f
SO_DEVMEM_DONTNEED = 0x50
SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27 SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5 SO_DONTROUTE = 0x5
SO_ERROR = 0x4 SO_ERROR = 0x4

View File

@ -112,6 +112,7 @@ const (
HIDIOCGRAWINFO = 0x40084803 HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802 HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801 HIDIOCGRDESCSIZE = 0x40044801
HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400 HUPCL = 0x400
ICANON = 0x2 ICANON = 0x2
IEXTEN = 0x8000 IEXTEN = 0x8000
@ -239,6 +240,20 @@ const (
PPPIOCUNBRIDGECHAN = 0x20007434 PPPIOCUNBRIDGECHAN = 0x20007434
PPPIOCXFERUNIT = 0x2000744e PPPIOCXFERUNIT = 0x2000744e
PR_SET_PTRACER_ANY = 0xffffffffffffffff PR_SET_PTRACER_ANY = 0xffffffffffffffff
PTP_CLOCK_GETCAPS = 0x40503d01
PTP_CLOCK_GETCAPS2 = 0x40503d0a
PTP_ENABLE_PPS = 0x80043d04
PTP_ENABLE_PPS2 = 0x80043d0d
PTP_EXTTS_REQUEST = 0x80103d02
PTP_EXTTS_REQUEST2 = 0x80103d0b
PTP_MASK_CLEAR_ALL = 0x20003d13
PTP_MASK_EN_SINGLE = 0x80043d14
PTP_PEROUT_REQUEST = 0x80383d03
PTP_PEROUT_REQUEST2 = 0x80383d0c
PTP_PIN_SETFUNC = 0x80603d07
PTP_PIN_SETFUNC2 = 0x80603d10
PTP_SYS_OFFSET = 0x83403d05
PTP_SYS_OFFSET2 = 0x83403d0e
PTRACE_GETFPAREGS = 0x14 PTRACE_GETFPAREGS = 0x14
PTRACE_GETFPREGS = 0xe PTRACE_GETFPREGS = 0xe
PTRACE_GETFPREGS64 = 0x19 PTRACE_GETFPREGS64 = 0x19
@ -336,6 +351,8 @@ const (
RTC_WIE_ON = 0x2000700f RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010 RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f RTC_WKALM_SET = 0x8028700f
SCM_DEVMEM_DMABUF = 0x58
SCM_DEVMEM_LINEAR = 0x57
SCM_TIMESTAMPING = 0x23 SCM_TIMESTAMPING = 0x23
SCM_TIMESTAMPING_OPT_STATS = 0x38 SCM_TIMESTAMPING_OPT_STATS = 0x38
SCM_TIMESTAMPING_PKTINFO = 0x3c SCM_TIMESTAMPING_PKTINFO = 0x3c
@ -422,6 +439,9 @@ const (
SO_CNX_ADVICE = 0x37 SO_CNX_ADVICE = 0x37
SO_COOKIE = 0x3b SO_COOKIE = 0x3b
SO_DETACH_REUSEPORT_BPF = 0x47 SO_DETACH_REUSEPORT_BPF = 0x47
SO_DEVMEM_DMABUF = 0x58
SO_DEVMEM_DONTNEED = 0x59
SO_DEVMEM_LINEAR = 0x57
SO_DOMAIN = 0x1029 SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10 SO_DONTROUTE = 0x10
SO_ERROR = 0x1007 SO_ERROR = 0x1007

View File

@ -592,6 +592,16 @@ func ClockGettime(clockid int32, time *Timespec) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockSettime(clockid int32, time *Timespec) (err error) {
_, _, e1 := Syscall(SYS_CLOCK_SETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) { func ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error) {
_, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0) _, _, e1 := Syscall6(SYS_CLOCK_NANOSLEEP, uintptr(clockid), uintptr(flags), uintptr(unsafe.Pointer(request)), uintptr(unsafe.Pointer(remain)), 0, 0)
if e1 != 0 { if e1 != 0 {

View File

@ -462,11 +462,14 @@ type FdSet struct {
const ( const (
SizeofIfMsghdr = 0x70 SizeofIfMsghdr = 0x70
SizeofIfMsghdr2 = 0xa0
SizeofIfData = 0x60 SizeofIfData = 0x60
SizeofIfData64 = 0x80
SizeofIfaMsghdr = 0x14 SizeofIfaMsghdr = 0x14
SizeofIfmaMsghdr = 0x10 SizeofIfmaMsghdr = 0x10
SizeofIfmaMsghdr2 = 0x14 SizeofIfmaMsghdr2 = 0x14
SizeofRtMsghdr = 0x5c SizeofRtMsghdr = 0x5c
SizeofRtMsghdr2 = 0x5c
SizeofRtMetrics = 0x38 SizeofRtMetrics = 0x38
) )
@ -480,6 +483,20 @@ type IfMsghdr struct {
Data IfData Data IfData
} }
type IfMsghdr2 struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Snd_len int32
Snd_maxlen int32
Snd_drops int32
Timer int32
Data IfData64
}
type IfData struct { type IfData struct {
Type uint8 Type uint8
Typelen uint8 Typelen uint8
@ -512,6 +529,34 @@ type IfData struct {
Reserved2 uint32 Reserved2 uint32
} }
type IfData64 struct {
Type uint8
Typelen uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Recvquota uint8
Xmitquota uint8
Unused1 uint8
Mtu uint32
Metric uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
Opackets uint64
Oerrors uint64
Collisions uint64
Ibytes uint64
Obytes uint64
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Noproto uint64
Recvtiming uint32
Xmittiming uint32
Lastchange Timeval32
}
type IfaMsghdr struct { type IfaMsghdr struct {
Msglen uint16 Msglen uint16
Version uint8 Version uint8
@ -557,6 +602,21 @@ type RtMsghdr struct {
Rmx RtMetrics Rmx RtMetrics
} }
type RtMsghdr2 struct {
Msglen uint16
Version uint8
Type uint8
Index uint16
Flags int32
Addrs int32
Refcnt int32
Parentflags int32
Reserved int32
Use int32
Inits uint32
Rmx RtMetrics
}
type RtMetrics struct { type RtMetrics struct {
Locks uint32 Locks uint32
Mtu uint32 Mtu uint32

View File

@ -462,11 +462,14 @@ type FdSet struct {
const ( const (
SizeofIfMsghdr = 0x70 SizeofIfMsghdr = 0x70
SizeofIfMsghdr2 = 0xa0
SizeofIfData = 0x60 SizeofIfData = 0x60
SizeofIfData64 = 0x80
SizeofIfaMsghdr = 0x14 SizeofIfaMsghdr = 0x14
SizeofIfmaMsghdr = 0x10 SizeofIfmaMsghdr = 0x10
SizeofIfmaMsghdr2 = 0x14 SizeofIfmaMsghdr2 = 0x14
SizeofRtMsghdr = 0x5c SizeofRtMsghdr = 0x5c
SizeofRtMsghdr2 = 0x5c
SizeofRtMetrics = 0x38 SizeofRtMetrics = 0x38
) )
@ -480,6 +483,20 @@ type IfMsghdr struct {
Data IfData Data IfData
} }
type IfMsghdr2 struct {
Msglen uint16
Version uint8
Type uint8
Addrs int32
Flags int32
Index uint16
Snd_len int32
Snd_maxlen int32
Snd_drops int32
Timer int32
Data IfData64
}
type IfData struct { type IfData struct {
Type uint8 Type uint8
Typelen uint8 Typelen uint8
@ -512,6 +529,34 @@ type IfData struct {
Reserved2 uint32 Reserved2 uint32
} }
type IfData64 struct {
Type uint8
Typelen uint8
Physical uint8
Addrlen uint8
Hdrlen uint8
Recvquota uint8
Xmitquota uint8
Unused1 uint8
Mtu uint32
Metric uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
Opackets uint64
Oerrors uint64
Collisions uint64
Ibytes uint64
Obytes uint64
Imcasts uint64
Omcasts uint64
Iqdrops uint64
Noproto uint64
Recvtiming uint32
Xmittiming uint32
Lastchange Timeval32
}
type IfaMsghdr struct { type IfaMsghdr struct {
Msglen uint16 Msglen uint16
Version uint8 Version uint8
@ -557,6 +602,21 @@ type RtMsghdr struct {
Rmx RtMetrics Rmx RtMetrics
} }
type RtMsghdr2 struct {
Msglen uint16
Version uint8
Type uint8
Index uint16
Flags int32
Addrs int32
Refcnt int32
Parentflags int32
Reserved int32
Use int32
Inits uint32
Rmx RtMetrics
}
type RtMetrics struct { type RtMetrics struct {
Locks uint32 Locks uint32
Mtu uint32 Mtu uint32

View File

@ -1752,12 +1752,6 @@ const (
IFLA_IPVLAN_UNSPEC = 0x0 IFLA_IPVLAN_UNSPEC = 0x0
IFLA_IPVLAN_MODE = 0x1 IFLA_IPVLAN_MODE = 0x1
IFLA_IPVLAN_FLAGS = 0x2 IFLA_IPVLAN_FLAGS = 0x2
NETKIT_NEXT = -0x1
NETKIT_PASS = 0x0
NETKIT_DROP = 0x2
NETKIT_REDIRECT = 0x7
NETKIT_L2 = 0x0
NETKIT_L3 = 0x1
IFLA_NETKIT_UNSPEC = 0x0 IFLA_NETKIT_UNSPEC = 0x0
IFLA_NETKIT_PEER_INFO = 0x1 IFLA_NETKIT_PEER_INFO = 0x1
IFLA_NETKIT_PRIMARY = 0x2 IFLA_NETKIT_PRIMARY = 0x2
@ -1796,6 +1790,7 @@ const (
IFLA_VXLAN_DF = 0x1d IFLA_VXLAN_DF = 0x1d
IFLA_VXLAN_VNIFILTER = 0x1e IFLA_VXLAN_VNIFILTER = 0x1e
IFLA_VXLAN_LOCALBYPASS = 0x1f IFLA_VXLAN_LOCALBYPASS = 0x1f
IFLA_VXLAN_LABEL_POLICY = 0x20
IFLA_GENEVE_UNSPEC = 0x0 IFLA_GENEVE_UNSPEC = 0x0
IFLA_GENEVE_ID = 0x1 IFLA_GENEVE_ID = 0x1
IFLA_GENEVE_REMOTE = 0x2 IFLA_GENEVE_REMOTE = 0x2
@ -1825,6 +1820,8 @@ const (
IFLA_GTP_ROLE = 0x4 IFLA_GTP_ROLE = 0x4
IFLA_GTP_CREATE_SOCKETS = 0x5 IFLA_GTP_CREATE_SOCKETS = 0x5
IFLA_GTP_RESTART_COUNT = 0x6 IFLA_GTP_RESTART_COUNT = 0x6
IFLA_GTP_LOCAL = 0x7
IFLA_GTP_LOCAL6 = 0x8
IFLA_BOND_UNSPEC = 0x0 IFLA_BOND_UNSPEC = 0x0
IFLA_BOND_MODE = 0x1 IFLA_BOND_MODE = 0x1
IFLA_BOND_ACTIVE_SLAVE = 0x2 IFLA_BOND_ACTIVE_SLAVE = 0x2
@ -1857,6 +1854,7 @@ const (
IFLA_BOND_AD_LACP_ACTIVE = 0x1d IFLA_BOND_AD_LACP_ACTIVE = 0x1d
IFLA_BOND_MISSED_MAX = 0x1e IFLA_BOND_MISSED_MAX = 0x1e
IFLA_BOND_NS_IP6_TARGET = 0x1f IFLA_BOND_NS_IP6_TARGET = 0x1f
IFLA_BOND_COUPLED_CONTROL = 0x20
IFLA_BOND_AD_INFO_UNSPEC = 0x0 IFLA_BOND_AD_INFO_UNSPEC = 0x0
IFLA_BOND_AD_INFO_AGGREGATOR = 0x1 IFLA_BOND_AD_INFO_AGGREGATOR = 0x1
IFLA_BOND_AD_INFO_NUM_PORTS = 0x2 IFLA_BOND_AD_INFO_NUM_PORTS = 0x2
@ -1925,6 +1923,7 @@ const (
IFLA_HSR_SEQ_NR = 0x5 IFLA_HSR_SEQ_NR = 0x5
IFLA_HSR_VERSION = 0x6 IFLA_HSR_VERSION = 0x6
IFLA_HSR_PROTOCOL = 0x7 IFLA_HSR_PROTOCOL = 0x7
IFLA_HSR_INTERLINK = 0x8
IFLA_STATS_UNSPEC = 0x0 IFLA_STATS_UNSPEC = 0x0
IFLA_STATS_LINK_64 = 0x1 IFLA_STATS_LINK_64 = 0x1
IFLA_STATS_LINK_XSTATS = 0x2 IFLA_STATS_LINK_XSTATS = 0x2
@ -1977,6 +1976,15 @@ const (
IFLA_DSA_MASTER = 0x1 IFLA_DSA_MASTER = 0x1
) )
const (
NETKIT_NEXT = -0x1
NETKIT_PASS = 0x0
NETKIT_DROP = 0x2
NETKIT_REDIRECT = 0x7
NETKIT_L2 = 0x0
NETKIT_L3 = 0x1
)
const ( const (
NF_INET_PRE_ROUTING = 0x0 NF_INET_PRE_ROUTING = 0x0
NF_INET_LOCAL_IN = 0x1 NF_INET_LOCAL_IN = 0x1
@ -2586,8 +2594,8 @@ const (
SOF_TIMESTAMPING_BIND_PHC = 0x8000 SOF_TIMESTAMPING_BIND_PHC = 0x8000
SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000 SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000
SOF_TIMESTAMPING_LAST = 0x10000 SOF_TIMESTAMPING_LAST = 0x20000
SOF_TIMESTAMPING_MASK = 0x1ffff SOF_TIMESTAMPING_MASK = 0x3ffff
SCM_TSTAMP_SND = 0x0 SCM_TSTAMP_SND = 0x0
SCM_TSTAMP_SCHED = 0x1 SCM_TSTAMP_SCHED = 0x1
@ -3533,7 +3541,7 @@ type Nhmsg struct {
type NexthopGrp struct { type NexthopGrp struct {
Id uint32 Id uint32
Weight uint8 Weight uint8
Resvd1 uint8 High uint8
Resvd2 uint16 Resvd2 uint16
} }
@ -3794,7 +3802,7 @@ const (
ETHTOOL_MSG_PSE_GET = 0x24 ETHTOOL_MSG_PSE_GET = 0x24
ETHTOOL_MSG_PSE_SET = 0x25 ETHTOOL_MSG_PSE_SET = 0x25
ETHTOOL_MSG_RSS_GET = 0x26 ETHTOOL_MSG_RSS_GET = 0x26
ETHTOOL_MSG_USER_MAX = 0x2c ETHTOOL_MSG_USER_MAX = 0x2d
ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@ -3834,7 +3842,7 @@ const (
ETHTOOL_MSG_MODULE_NTF = 0x24 ETHTOOL_MSG_MODULE_NTF = 0x24
ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_PSE_GET_REPLY = 0x25
ETHTOOL_MSG_RSS_GET_REPLY = 0x26 ETHTOOL_MSG_RSS_GET_REPLY = 0x26
ETHTOOL_MSG_KERNEL_MAX = 0x2c ETHTOOL_MSG_KERNEL_MAX = 0x2e
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
ETHTOOL_FLAG_OMIT_REPLY = 0x2 ETHTOOL_FLAG_OMIT_REPLY = 0x2
ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLAG_STATS = 0x4
@ -3842,7 +3850,7 @@ const (
ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_INDEX = 0x1
ETHTOOL_A_HEADER_DEV_NAME = 0x2 ETHTOOL_A_HEADER_DEV_NAME = 0x2
ETHTOOL_A_HEADER_FLAGS = 0x3 ETHTOOL_A_HEADER_FLAGS = 0x3
ETHTOOL_A_HEADER_MAX = 0x3 ETHTOOL_A_HEADER_MAX = 0x4
ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0 ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0
ETHTOOL_A_BITSET_BIT_INDEX = 0x1 ETHTOOL_A_BITSET_BIT_INDEX = 0x1
ETHTOOL_A_BITSET_BIT_NAME = 0x2 ETHTOOL_A_BITSET_BIT_NAME = 0x2
@ -4023,11 +4031,11 @@ const (
ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0 ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0
ETHTOOL_A_CABLE_RESULT_PAIR = 0x1 ETHTOOL_A_CABLE_RESULT_PAIR = 0x1
ETHTOOL_A_CABLE_RESULT_CODE = 0x2 ETHTOOL_A_CABLE_RESULT_CODE = 0x2
ETHTOOL_A_CABLE_RESULT_MAX = 0x2 ETHTOOL_A_CABLE_RESULT_MAX = 0x3
ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0 ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0
ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1 ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1
ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2 ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2
ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x2 ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x3
ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1 ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1
ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2 ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2
@ -4110,6 +4118,107 @@ type EthtoolDrvinfo struct {
Regdump_len uint32 Regdump_len uint32
} }
type EthtoolTsInfo struct {
Cmd uint32
So_timestamping uint32
Phc_index int32
Tx_types uint32
Tx_reserved [3]uint32
Rx_filters uint32
Rx_reserved [3]uint32
}
type HwTstampConfig struct {
Flags int32
Tx_type int32
Rx_filter int32
}
const (
HWTSTAMP_FILTER_NONE = 0x0
HWTSTAMP_FILTER_ALL = 0x1
HWTSTAMP_FILTER_SOME = 0x2
HWTSTAMP_FILTER_PTP_V1_L4_EVENT = 0x3
HWTSTAMP_FILTER_PTP_V2_L4_EVENT = 0x6
HWTSTAMP_FILTER_PTP_V2_L2_EVENT = 0x9
HWTSTAMP_FILTER_PTP_V2_EVENT = 0xc
)
const (
HWTSTAMP_TX_OFF = 0x0
HWTSTAMP_TX_ON = 0x1
HWTSTAMP_TX_ONESTEP_SYNC = 0x2
)
type (
PtpClockCaps struct {
Max_adj int32
N_alarm int32
N_ext_ts int32
N_per_out int32
Pps int32
N_pins int32
Cross_timestamping int32
Adjust_phase int32
Max_phase_adj int32
Rsv [11]int32
}
PtpClockTime struct {
Sec int64
Nsec uint32
Reserved uint32
}
PtpExttsEvent struct {
T PtpClockTime
Index uint32
Flags uint32
Rsv [2]uint32
}
PtpExttsRequest struct {
Index uint32
Flags uint32
Rsv [2]uint32
}
PtpPeroutRequest struct {
StartOrPhase PtpClockTime
Period PtpClockTime
Index uint32
Flags uint32
On PtpClockTime
}
PtpPinDesc struct {
Name [64]byte
Index uint32
Func uint32
Chan uint32
Rsv [5]uint32
}
PtpSysOffset struct {
Samples uint32
Rsv [3]uint32
Ts [51]PtpClockTime
}
PtpSysOffsetExtended struct {
Samples uint32
Clockid int32
Rsv [2]uint32
Ts [25][3]PtpClockTime
}
PtpSysOffsetPrecise struct {
Device PtpClockTime
Realtime PtpClockTime
Monoraw PtpClockTime
Rsv [4]uint32
}
)
const (
PTP_PF_NONE = 0x0
PTP_PF_EXTTS = 0x1
PTP_PF_PEROUT = 0x2
PTP_PF_PHYSYNC = 0x3
)
type ( type (
HIDRawReportDescriptor struct { HIDRawReportDescriptor struct {
Size uint32 Size uint32
@ -4291,6 +4400,7 @@ const (
type LandlockRulesetAttr struct { type LandlockRulesetAttr struct {
Access_fs uint64 Access_fs uint64
Access_net uint64 Access_net uint64
Scoped uint64
} }
type LandlockPathBeneathAttr struct { type LandlockPathBeneathAttr struct {

View File

@ -377,6 +377,12 @@ type Flock_t struct {
Pid int32 Pid int32
} }
type F_cnvrt struct {
Cvtcmd int32
Pccsid int16
Fccsid int16
}
type Termios struct { type Termios struct {
Cflag uint32 Cflag uint32
Iflag uint32 Iflag uint32

10
vendor/modules.txt vendored
View File

@ -17,7 +17,7 @@ github.com/golang/snappy
# github.com/json-iterator/go v1.1.12 # github.com/json-iterator/go v1.1.12
## explicit; go 1.12 ## explicit; go 1.12
github.com/json-iterator/go github.com/json-iterator/go
# github.com/labstack/echo/v4 v4.12.0 # github.com/labstack/echo/v4 v4.13.0
## explicit; go 1.18 ## explicit; go 1.18
github.com/labstack/echo/v4 github.com/labstack/echo/v4
# github.com/labstack/gommon v0.4.2 # github.com/labstack/gommon v0.4.2
@ -65,11 +65,11 @@ github.com/valyala/bytebufferpool
# github.com/valyala/fasttemplate v1.2.2 # github.com/valyala/fasttemplate v1.2.2
## explicit; go 1.12 ## explicit; go 1.12
github.com/valyala/fasttemplate github.com/valyala/fasttemplate
# golang.org/x/crypto v0.28.0 # golang.org/x/crypto v0.30.0
## explicit; go 1.20 ## explicit; go 1.20
golang.org/x/crypto/acme golang.org/x/crypto/acme
golang.org/x/crypto/acme/autocert golang.org/x/crypto/acme/autocert
# golang.org/x/net v0.30.0 # golang.org/x/net v0.32.0
## explicit; go 1.18 ## explicit; go 1.18
golang.org/x/net/http/httpguts golang.org/x/net/http/httpguts
golang.org/x/net/http2 golang.org/x/net/http2
@ -77,10 +77,10 @@ golang.org/x/net/http2/h2c
golang.org/x/net/http2/hpack golang.org/x/net/http2/hpack
golang.org/x/net/idna golang.org/x/net/idna
golang.org/x/net/websocket golang.org/x/net/websocket
# golang.org/x/sys v0.26.0 # golang.org/x/sys v0.28.0
## explicit; go 1.18 ## explicit; go 1.18
golang.org/x/sys/unix golang.org/x/sys/unix
# golang.org/x/text v0.19.0 # golang.org/x/text v0.21.0
## explicit; go 1.18 ## explicit; go 1.18
golang.org/x/text/secure/bidirule golang.org/x/text/secure/bidirule
golang.org/x/text/transform golang.org/x/text/transform