mirror of https://github.com/docker/cli.git
Merge pull request #5427 from thaJeztah/bump_docker_deps
vendor: update various dependencies
This commit is contained in:
commit
b0333da63c
24
vendor.mod
24
vendor.mod
|
@ -7,7 +7,7 @@ module github.com/docker/cli
|
||||||
go 1.21.0
|
go 1.21.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
dario.cat/mergo v1.0.0
|
dario.cat/mergo v1.0.1
|
||||||
github.com/containerd/platforms v0.2.1
|
github.com/containerd/platforms v0.2.1
|
||||||
github.com/creack/pty v1.1.21
|
github.com/creack/pty v1.1.21
|
||||||
github.com/distribution/reference v0.6.0
|
github.com/distribution/reference v0.6.0
|
||||||
|
@ -47,13 +47,13 @@ require (
|
||||||
go.opentelemetry.io/otel/sdk v1.21.0
|
go.opentelemetry.io/otel/sdk v1.21.0
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.21.0
|
go.opentelemetry.io/otel/sdk/metric v1.21.0
|
||||||
go.opentelemetry.io/otel/trace v1.21.0
|
go.opentelemetry.io/otel/trace v1.21.0
|
||||||
golang.org/x/sync v0.7.0
|
golang.org/x/sync v0.8.0
|
||||||
golang.org/x/sys v0.22.0
|
golang.org/x/sys v0.24.0
|
||||||
golang.org/x/term v0.20.0
|
golang.org/x/term v0.23.0
|
||||||
golang.org/x/text v0.15.0
|
golang.org/x/text v0.17.0
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
gotest.tools/v3 v3.5.1
|
gotest.tools/v3 v3.5.1
|
||||||
tags.cncf.io/container-device-interface v0.7.2
|
tags.cncf.io/container-device-interface v0.8.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
@ -94,11 +94,11 @@ require (
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
||||||
golang.org/x/crypto v0.23.0 // indirect
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
golang.org/x/net v0.25.0 // indirect
|
golang.org/x/net v0.28.0 // indirect
|
||||||
golang.org/x/time v0.3.0 // indirect
|
golang.org/x/time v0.6.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||||
google.golang.org/grpc v1.60.1 // indirect
|
google.golang.org/grpc v1.62.0 // indirect
|
||||||
google.golang.org/protobuf v1.33.0 // indirect
|
google.golang.org/protobuf v1.33.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
56
vendor.sum
56
vendor.sum
|
@ -1,5 +1,5 @@
|
||||||
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
|
||||||
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
|
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
|
||||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
||||||
|
@ -105,8 +105,8 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo=
|
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
|
||||||
github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
|
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
@ -334,8 +334,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
||||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
@ -351,8 +351,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
||||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||||
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-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
@ -361,8 +361,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
|
||||||
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=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
@ -383,26 +383,26 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
|
golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
|
||||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
|
||||||
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.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
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-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/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=
|
||||||
|
@ -414,15 +414,15 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 h1:1hfbdAfFbkmpg41000wDVqr7jUpK/Yo+LPnIxxGzmkg=
|
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 h1:KAeGQVN3M9nD0/bQXnr/ClcEMJ968gUXJQ9pwfSynuQ=
|
||||||
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3/go.mod h1:5RBcpGRxr25RbDzY5w+dmaqpSEvl8Gwl1x2CICf60ic=
|
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f h1:2yNACc1O40tTnrsbk9Cv6oxiW8pxI/pXj0wRtdlYmgY=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 h1:Lj5rbfG876hIAYFjqiJnPHfhXbv+nzTWfm04Fg/XSVU=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f/go.mod h1:Uy9bTZJqmfrw2rIBxgGLnamc78euZULUBrLZ9XTITKI=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
|
||||||
google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||||
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
|
google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk=
|
||||||
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
|
google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||||
|
@ -454,5 +454,5 @@ gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
||||||
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
|
||||||
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
|
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
|
||||||
k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||||
tags.cncf.io/container-device-interface v0.7.2 h1:MLqGnWfOr1wB7m08ieI4YJ3IoLKKozEnnNYBtacDPQU=
|
tags.cncf.io/container-device-interface v0.8.0 h1:8bCFo/g9WODjWx3m6EYl3GfUG31eKJbaggyBDxEldRc=
|
||||||
tags.cncf.io/container-device-interface v0.7.2/go.mod h1:Xb1PvXv2BhfNb3tla4r9JL129ck1Lxv9KuU6eVOfKto=
|
tags.cncf.io/container-device-interface v0.8.0/go.mod h1:Apb7N4VdILW0EVdEMRYXIDVRZfNJZ+kmEUss2kRRQ6Y=
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
|
# Golang/Intellij
|
||||||
|
.idea
|
||||||
|
|
||||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||||
.glide/
|
.glide/
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,21 @@ Also a lovely [comune](http://en.wikipedia.org/wiki/Mergo) (municipality) in the
|
||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
It is ready for production use. [It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, Microsoft, etc](https://github.com/imdario/mergo#mergo-in-the-wild).
|
Mergo is stable and frozen, ready for production. Check a short list of the projects using at large scale it [here](https://github.com/imdario/mergo#mergo-in-the-wild).
|
||||||
|
|
||||||
|
No new features are accepted. They will be considered for a future v2 that improves the implementation and fixes bugs for corner cases.
|
||||||
|
|
||||||
### Important notes
|
### Important notes
|
||||||
|
|
||||||
#### 1.0.0
|
#### 1.0.0
|
||||||
|
|
||||||
In [1.0.0](//github.com/imdario/mergo/releases/tag/1.0.0) Mergo moves to a vanity URL `dario.cat/mergo`.
|
In [1.0.0](//github.com/imdario/mergo/releases/tag/1.0.0) Mergo moves to a vanity URL `dario.cat/mergo`. No more v1 versions will be released.
|
||||||
|
|
||||||
|
If the vanity URL is causing issues in your project due to a dependency pulling Mergo - it isn't a direct dependency in your project - it is recommended to use [replace](https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive) to pin the version to the last one with the old import URL:
|
||||||
|
|
||||||
|
```
|
||||||
|
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.16
|
||||||
|
```
|
||||||
|
|
||||||
#### 0.3.9
|
#### 0.3.9
|
||||||
|
|
||||||
|
@ -64,55 +72,24 @@ If you were using Mergo before April 6th, 2015, please check your project works
|
||||||
|
|
||||||
If Mergo is useful to you, consider buying me a coffee, a beer, or making a monthly donation to allow me to keep building great free software. :heart_eyes:
|
If Mergo is useful to you, consider buying me a coffee, a beer, or making a monthly donation to allow me to keep building great free software. :heart_eyes:
|
||||||
|
|
||||||
<a href='https://ko-fi.com/B0B58839' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
|
||||||
<a href="https://liberapay.com/dario/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>
|
<a href="https://liberapay.com/dario/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>
|
||||||
<a href='https://github.com/sponsors/imdario' target='_blank'><img alt="Become my sponsor" src="https://img.shields.io/github/sponsors/imdario?style=for-the-badge" /></a>
|
<a href='https://github.com/sponsors/imdario' target='_blank'><img alt="Become my sponsor" src="https://img.shields.io/github/sponsors/imdario?style=for-the-badge" /></a>
|
||||||
|
|
||||||
### Mergo in the wild
|
### Mergo in the wild
|
||||||
|
|
||||||
- [moby/moby](https://github.com/moby/moby)
|
Mergo is used by [thousands](https://deps.dev/go/dario.cat%2Fmergo/v1.0.0/dependents) [of](https://deps.dev/go/github.com%2Fimdario%2Fmergo/v0.3.16/dependents) [projects](https://deps.dev/go/github.com%2Fimdario%2Fmergo/v0.3.12), including:
|
||||||
- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
|
|
||||||
- [vmware/dispatch](https://github.com/vmware/dispatch)
|
* [containerd/containerd](https://github.com/containerd/containerd)
|
||||||
- [Shopify/themekit](https://github.com/Shopify/themekit)
|
* [datadog/datadog-agent](https://github.com/datadog/datadog-agent)
|
||||||
- [imdario/zas](https://github.com/imdario/zas)
|
* [docker/cli/](https://github.com/docker/cli/)
|
||||||
- [matcornic/hermes](https://github.com/matcornic/hermes)
|
* [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser)
|
||||||
- [OpenBazaar/openbazaar-go](https://github.com/OpenBazaar/openbazaar-go)
|
* [go-micro/go-micro](https://github.com/go-micro/go-micro)
|
||||||
- [kataras/iris](https://github.com/kataras/iris)
|
* [grafana/loki](https://github.com/grafana/loki)
|
||||||
- [michaelsauter/crane](https://github.com/michaelsauter/crane)
|
* [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
|
||||||
- [go-task/task](https://github.com/go-task/task)
|
* [masterminds/sprig](github.com/Masterminds/sprig)
|
||||||
- [sensu/uchiwa](https://github.com/sensu/uchiwa)
|
* [moby/moby](https://github.com/moby/moby)
|
||||||
- [ory/hydra](https://github.com/ory/hydra)
|
* [slackhq/nebula](https://github.com/slackhq/nebula)
|
||||||
- [sisatech/vcli](https://github.com/sisatech/vcli)
|
* [volcano-sh/volcano](https://github.com/volcano-sh/volcano)
|
||||||
- [dairycart/dairycart](https://github.com/dairycart/dairycart)
|
|
||||||
- [projectcalico/felix](https://github.com/projectcalico/felix)
|
|
||||||
- [resin-os/balena](https://github.com/resin-os/balena)
|
|
||||||
- [go-kivik/kivik](https://github.com/go-kivik/kivik)
|
|
||||||
- [Telefonica/govice](https://github.com/Telefonica/govice)
|
|
||||||
- [supergiant/supergiant](supergiant/supergiant)
|
|
||||||
- [SergeyTsalkov/brooce](https://github.com/SergeyTsalkov/brooce)
|
|
||||||
- [soniah/dnsmadeeasy](https://github.com/soniah/dnsmadeeasy)
|
|
||||||
- [ohsu-comp-bio/funnel](https://github.com/ohsu-comp-bio/funnel)
|
|
||||||
- [EagerIO/Stout](https://github.com/EagerIO/Stout)
|
|
||||||
- [lynndylanhurley/defsynth-api](https://github.com/lynndylanhurley/defsynth-api)
|
|
||||||
- [russross/canvasassignments](https://github.com/russross/canvasassignments)
|
|
||||||
- [rdegges/cryptly-api](https://github.com/rdegges/cryptly-api)
|
|
||||||
- [casualjim/exeggutor](https://github.com/casualjim/exeggutor)
|
|
||||||
- [divshot/gitling](https://github.com/divshot/gitling)
|
|
||||||
- [RWJMurphy/gorl](https://github.com/RWJMurphy/gorl)
|
|
||||||
- [andrerocker/deploy42](https://github.com/andrerocker/deploy42)
|
|
||||||
- [elwinar/rambler](https://github.com/elwinar/rambler)
|
|
||||||
- [tmaiaroto/gopartman](https://github.com/tmaiaroto/gopartman)
|
|
||||||
- [jfbus/impressionist](https://github.com/jfbus/impressionist)
|
|
||||||
- [Jmeyering/zealot](https://github.com/Jmeyering/zealot)
|
|
||||||
- [godep-migrator/rigger-host](https://github.com/godep-migrator/rigger-host)
|
|
||||||
- [Dronevery/MultiwaySwitch-Go](https://github.com/Dronevery/MultiwaySwitch-Go)
|
|
||||||
- [thoas/picfit](https://github.com/thoas/picfit)
|
|
||||||
- [mantasmatelis/whooplist-server](https://github.com/mantasmatelis/whooplist-server)
|
|
||||||
- [jnuthong/item_search](https://github.com/jnuthong/item_search)
|
|
||||||
- [bukalapak/snowboard](https://github.com/bukalapak/snowboard)
|
|
||||||
- [containerssh/containerssh](https://github.com/containerssh/containerssh)
|
|
||||||
- [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser)
|
|
||||||
- [tjpnz/structbot](https://github.com/tjpnz/structbot)
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
@ -141,6 +118,39 @@ if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you need to override pointers, so the source pointer's value is assigned to the destination's pointer, you must use `WithoutDereference`:
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"dario.cat/mergo"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Foo struct {
|
||||||
|
A *string
|
||||||
|
B int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
first := "first"
|
||||||
|
second := "second"
|
||||||
|
src := Foo{
|
||||||
|
A: &first,
|
||||||
|
B: 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
dest := Foo{
|
||||||
|
A: &second,
|
||||||
|
B: 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
mergo.Merge(&dest, src, mergo.WithOverride, mergo.WithoutDereference)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Additionally, you can map a `map[string]interface{}` to a struct (and otherwise, from struct to map), following the same restrictions as in `Merge()`. Keys are capitalized to find each corresponding exported field.
|
Additionally, you can map a `map[string]interface{}` to a struct (and otherwise, from struct to map), following the same restrictions as in `Merge()`. Keys are capitalized to find each corresponding exported field.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
|
|
@ -58,7 +58,7 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
|
||||||
}
|
}
|
||||||
fieldName := field.Name
|
fieldName := field.Name
|
||||||
fieldName = changeInitialCase(fieldName, unicode.ToLower)
|
fieldName = changeInitialCase(fieldName, unicode.ToLower)
|
||||||
if v, ok := dstMap[fieldName]; !ok || (isEmptyValue(reflect.ValueOf(v), !config.ShouldNotDereference) || overwrite) {
|
if _, ok := dstMap[fieldName]; !ok || (!isEmptyValue(reflect.ValueOf(src.Field(i).Interface()), !config.ShouldNotDereference) && overwrite) || config.overwriteWithEmptyValue {
|
||||||
dstMap[fieldName] = src.Field(i).Interface()
|
dstMap[fieldName] = src.Field(i).Interface()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
|
||||||
if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
|
if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else if src.Elem().Kind() != reflect.Struct {
|
||||||
if overwriteWithEmptySrc || (overwrite && !src.IsNil()) || dst.IsNil() {
|
if overwriteWithEmptySrc || (overwrite && !src.IsNil()) || dst.IsNil() {
|
||||||
dst.Set(src)
|
dst.Set(src)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,531 +0,0 @@
|
||||||
// Copyright 2015 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 jsonpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"math"
|
|
||||||
"reflect"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
|
||||||
protoV2 "google.golang.org/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
)
|
|
||||||
|
|
||||||
const wrapJSONUnmarshalV2 = false
|
|
||||||
|
|
||||||
// UnmarshalNext unmarshals the next JSON object from d into m.
|
|
||||||
func UnmarshalNext(d *json.Decoder, m proto.Message) error {
|
|
||||||
return new(Unmarshaler).UnmarshalNext(d, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal unmarshals a JSON object from r into m.
|
|
||||||
func Unmarshal(r io.Reader, m proto.Message) error {
|
|
||||||
return new(Unmarshaler).Unmarshal(r, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalString unmarshals a JSON object from s into m.
|
|
||||||
func UnmarshalString(s string, m proto.Message) error {
|
|
||||||
return new(Unmarshaler).Unmarshal(strings.NewReader(s), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshaler is a configurable object for converting from a JSON
|
|
||||||
// representation to a protocol buffer object.
|
|
||||||
type Unmarshaler struct {
|
|
||||||
// AllowUnknownFields specifies whether to allow messages to contain
|
|
||||||
// unknown JSON fields, as opposed to failing to unmarshal.
|
|
||||||
AllowUnknownFields bool
|
|
||||||
|
|
||||||
// AnyResolver is used to resolve the google.protobuf.Any well-known type.
|
|
||||||
// If unset, the global registry is used by default.
|
|
||||||
AnyResolver AnyResolver
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONPBUnmarshaler is implemented by protobuf messages that customize the way
|
|
||||||
// they are unmarshaled from JSON. Messages that implement this should also
|
|
||||||
// implement JSONPBMarshaler so that the custom format can be produced.
|
|
||||||
//
|
|
||||||
// The JSON unmarshaling must follow the JSON to proto specification:
|
|
||||||
//
|
|
||||||
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
|
||||||
//
|
|
||||||
// Deprecated: Custom types should implement protobuf reflection instead.
|
|
||||||
type JSONPBUnmarshaler interface {
|
|
||||||
UnmarshalJSONPB(*Unmarshaler, []byte) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal unmarshals a JSON object from r into m.
|
|
||||||
func (u *Unmarshaler) Unmarshal(r io.Reader, m proto.Message) error {
|
|
||||||
return u.UnmarshalNext(json.NewDecoder(r), m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalNext unmarshals the next JSON object from d into m.
|
|
||||||
func (u *Unmarshaler) UnmarshalNext(d *json.Decoder, m proto.Message) error {
|
|
||||||
if m == nil {
|
|
||||||
return errors.New("invalid nil message")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the next JSON object from the stream.
|
|
||||||
raw := json.RawMessage{}
|
|
||||||
if err := d.Decode(&raw); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for custom unmarshalers first since they may not properly
|
|
||||||
// implement protobuf reflection that the logic below relies on.
|
|
||||||
if jsu, ok := m.(JSONPBUnmarshaler); ok {
|
|
||||||
return jsu.UnmarshalJSONPB(u, raw)
|
|
||||||
}
|
|
||||||
|
|
||||||
mr := proto.MessageReflect(m)
|
|
||||||
|
|
||||||
// NOTE: For historical reasons, a top-level null is treated as a noop.
|
|
||||||
// This is incorrect, but kept for compatibility.
|
|
||||||
if string(raw) == "null" && mr.Descriptor().FullName() != "google.protobuf.Value" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if wrapJSONUnmarshalV2 {
|
|
||||||
// NOTE: If input message is non-empty, we need to preserve merge semantics
|
|
||||||
// of the old jsonpb implementation. These semantics are not supported by
|
|
||||||
// the protobuf JSON specification.
|
|
||||||
isEmpty := true
|
|
||||||
mr.Range(func(protoreflect.FieldDescriptor, protoreflect.Value) bool {
|
|
||||||
isEmpty = false // at least one iteration implies non-empty
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
if !isEmpty {
|
|
||||||
// Perform unmarshaling into a newly allocated, empty message.
|
|
||||||
mr = mr.New()
|
|
||||||
|
|
||||||
// Use a defer to copy all unmarshaled fields into the original message.
|
|
||||||
dst := proto.MessageReflect(m)
|
|
||||||
defer mr.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
|
||||||
dst.Set(fd, v)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unmarshal using the v2 JSON unmarshaler.
|
|
||||||
opts := protojson.UnmarshalOptions{
|
|
||||||
DiscardUnknown: u.AllowUnknownFields,
|
|
||||||
}
|
|
||||||
if u.AnyResolver != nil {
|
|
||||||
opts.Resolver = anyResolver{u.AnyResolver}
|
|
||||||
}
|
|
||||||
return opts.Unmarshal(raw, mr.Interface())
|
|
||||||
} else {
|
|
||||||
if err := u.unmarshalMessage(mr, raw); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return protoV2.CheckInitialized(mr.Interface())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *Unmarshaler) unmarshalMessage(m protoreflect.Message, in []byte) error {
|
|
||||||
md := m.Descriptor()
|
|
||||||
fds := md.Fields()
|
|
||||||
|
|
||||||
if jsu, ok := proto.MessageV1(m.Interface()).(JSONPBUnmarshaler); ok {
|
|
||||||
return jsu.UnmarshalJSONPB(u, in)
|
|
||||||
}
|
|
||||||
|
|
||||||
if string(in) == "null" && md.FullName() != "google.protobuf.Value" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
switch wellKnownType(md.FullName()) {
|
|
||||||
case "Any":
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
rawTypeURL, ok := jsonObject["@type"]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("Any JSON doesn't have '@type'")
|
|
||||||
}
|
|
||||||
typeURL, err := unquoteString(string(rawTypeURL))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("can't unmarshal Any's '@type': %q", rawTypeURL)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfString(typeURL))
|
|
||||||
|
|
||||||
var m2 protoreflect.Message
|
|
||||||
if u.AnyResolver != nil {
|
|
||||||
mi, err := u.AnyResolver.Resolve(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = proto.MessageReflect(mi)
|
|
||||||
} else {
|
|
||||||
mt, err := protoregistry.GlobalTypes.FindMessageByURL(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
if err == protoregistry.NotFound {
|
|
||||||
return fmt.Errorf("could not resolve Any message type: %v", typeURL)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = mt.New()
|
|
||||||
}
|
|
||||||
|
|
||||||
if wellKnownType(m2.Descriptor().FullName()) != "" {
|
|
||||||
rawValue, ok := jsonObject["value"]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("Any JSON doesn't have 'value'")
|
|
||||||
}
|
|
||||||
if err := u.unmarshalMessage(m2, rawValue); err != nil {
|
|
||||||
return fmt.Errorf("can't unmarshal Any nested proto %v: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
delete(jsonObject, "@type")
|
|
||||||
rawJSON, err := json.Marshal(jsonObject)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("can't generate JSON for Any's nested proto to be unmarshaled: %v", err)
|
|
||||||
}
|
|
||||||
if err = u.unmarshalMessage(m2, rawJSON); err != nil {
|
|
||||||
return fmt.Errorf("can't unmarshal Any nested proto %v: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rawWire, err := protoV2.Marshal(m2.Interface())
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("can't marshal proto %v into Any.Value: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfBytes(rawWire))
|
|
||||||
return nil
|
|
||||||
case "BoolValue", "BytesValue", "StringValue",
|
|
||||||
"Int32Value", "UInt32Value", "FloatValue",
|
|
||||||
"Int64Value", "UInt64Value", "DoubleValue":
|
|
||||||
fd := fds.ByNumber(1)
|
|
||||||
v, err := u.unmarshalValue(m.NewField(fd), in, fd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Set(fd, v)
|
|
||||||
return nil
|
|
||||||
case "Duration":
|
|
||||||
v, err := unquoteString(string(in))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
d, err := time.ParseDuration(v)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("bad Duration: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
sec := d.Nanoseconds() / 1e9
|
|
||||||
nsec := d.Nanoseconds() % 1e9
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfInt64(int64(sec)))
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfInt32(int32(nsec)))
|
|
||||||
return nil
|
|
||||||
case "Timestamp":
|
|
||||||
v, err := unquoteString(string(in))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
t, err := time.Parse(time.RFC3339Nano, v)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("bad Timestamp: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
sec := t.Unix()
|
|
||||||
nsec := t.Nanosecond()
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfInt64(int64(sec)))
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfInt32(int32(nsec)))
|
|
||||||
return nil
|
|
||||||
case "Value":
|
|
||||||
switch {
|
|
||||||
case string(in) == "null":
|
|
||||||
m.Set(fds.ByNumber(1), protoreflect.ValueOfEnum(0))
|
|
||||||
case string(in) == "true":
|
|
||||||
m.Set(fds.ByNumber(4), protoreflect.ValueOfBool(true))
|
|
||||||
case string(in) == "false":
|
|
||||||
m.Set(fds.ByNumber(4), protoreflect.ValueOfBool(false))
|
|
||||||
case hasPrefixAndSuffix('"', in, '"'):
|
|
||||||
s, err := unquoteString(string(in))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unrecognized type for Value %q", in)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(3), protoreflect.ValueOfString(s))
|
|
||||||
case hasPrefixAndSuffix('[', in, ']'):
|
|
||||||
v := m.Mutable(fds.ByNumber(6))
|
|
||||||
return u.unmarshalMessage(v.Message(), in)
|
|
||||||
case hasPrefixAndSuffix('{', in, '}'):
|
|
||||||
v := m.Mutable(fds.ByNumber(5))
|
|
||||||
return u.unmarshalMessage(v.Message(), in)
|
|
||||||
default:
|
|
||||||
f, err := strconv.ParseFloat(string(in), 0)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unrecognized type for Value %q", in)
|
|
||||||
}
|
|
||||||
m.Set(fds.ByNumber(2), protoreflect.ValueOfFloat64(f))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case "ListValue":
|
|
||||||
var jsonArray []json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonArray); err != nil {
|
|
||||||
return fmt.Errorf("bad ListValue: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
lv := m.Mutable(fds.ByNumber(1)).List()
|
|
||||||
for _, raw := range jsonArray {
|
|
||||||
ve := lv.NewElement()
|
|
||||||
if err := u.unmarshalMessage(ve.Message(), raw); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
lv.Append(ve)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
case "Struct":
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return fmt.Errorf("bad StructValue: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
mv := m.Mutable(fds.ByNumber(1)).Map()
|
|
||||||
for key, raw := range jsonObject {
|
|
||||||
kv := protoreflect.ValueOf(key).MapKey()
|
|
||||||
vv := mv.NewValue()
|
|
||||||
if err := u.unmarshalMessage(vv.Message(), raw); err != nil {
|
|
||||||
return fmt.Errorf("bad value in StructValue for key %q: %v", key, err)
|
|
||||||
}
|
|
||||||
mv.Set(kv, vv)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle known fields.
|
|
||||||
for i := 0; i < fds.Len(); i++ {
|
|
||||||
fd := fds.Get(i)
|
|
||||||
if fd.IsWeak() && fd.Message().IsPlaceholder() {
|
|
||||||
continue // weak reference is not linked in
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for any raw JSON value associated with this field.
|
|
||||||
var raw json.RawMessage
|
|
||||||
name := string(fd.Name())
|
|
||||||
if fd.Kind() == protoreflect.GroupKind {
|
|
||||||
name = string(fd.Message().Name())
|
|
||||||
}
|
|
||||||
if v, ok := jsonObject[name]; ok {
|
|
||||||
delete(jsonObject, name)
|
|
||||||
raw = v
|
|
||||||
}
|
|
||||||
name = string(fd.JSONName())
|
|
||||||
if v, ok := jsonObject[name]; ok {
|
|
||||||
delete(jsonObject, name)
|
|
||||||
raw = v
|
|
||||||
}
|
|
||||||
|
|
||||||
field := m.NewField(fd)
|
|
||||||
// Unmarshal the field value.
|
|
||||||
if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd) && !isSingularJSONPBUnmarshaler(field, fd)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
v, err := u.unmarshalValue(field, raw, fd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Set(fd, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle extension fields.
|
|
||||||
for name, raw := range jsonObject {
|
|
||||||
if !strings.HasPrefix(name, "[") || !strings.HasSuffix(name, "]") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resolve the extension field by name.
|
|
||||||
xname := protoreflect.FullName(name[len("[") : len(name)-len("]")])
|
|
||||||
xt, _ := protoregistry.GlobalTypes.FindExtensionByName(xname)
|
|
||||||
if xt == nil && isMessageSet(md) {
|
|
||||||
xt, _ = protoregistry.GlobalTypes.FindExtensionByName(xname.Append("message_set_extension"))
|
|
||||||
}
|
|
||||||
if xt == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
delete(jsonObject, name)
|
|
||||||
fd := xt.TypeDescriptor()
|
|
||||||
if fd.ContainingMessage().FullName() != m.Descriptor().FullName() {
|
|
||||||
return fmt.Errorf("extension field %q does not extend message %q", xname, m.Descriptor().FullName())
|
|
||||||
}
|
|
||||||
|
|
||||||
field := m.NewField(fd)
|
|
||||||
// Unmarshal the field value.
|
|
||||||
if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd) && !isSingularJSONPBUnmarshaler(field, fd)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
v, err := u.unmarshalValue(field, raw, fd)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.Set(fd, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !u.AllowUnknownFields && len(jsonObject) > 0 {
|
|
||||||
for name := range jsonObject {
|
|
||||||
return fmt.Errorf("unknown field %q in %v", name, md.FullName())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func isSingularWellKnownValue(fd protoreflect.FieldDescriptor) bool {
|
|
||||||
if fd.Cardinality() == protoreflect.Repeated {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if md := fd.Message(); md != nil {
|
|
||||||
return md.FullName() == "google.protobuf.Value"
|
|
||||||
}
|
|
||||||
if ed := fd.Enum(); ed != nil {
|
|
||||||
return ed.FullName() == "google.protobuf.NullValue"
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func isSingularJSONPBUnmarshaler(v protoreflect.Value, fd protoreflect.FieldDescriptor) bool {
|
|
||||||
if fd.Message() != nil && fd.Cardinality() != protoreflect.Repeated {
|
|
||||||
_, ok := proto.MessageV1(v.Interface()).(JSONPBUnmarshaler)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *Unmarshaler) unmarshalValue(v protoreflect.Value, in []byte, fd protoreflect.FieldDescriptor) (protoreflect.Value, error) {
|
|
||||||
switch {
|
|
||||||
case fd.IsList():
|
|
||||||
var jsonArray []json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonArray); err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
lv := v.List()
|
|
||||||
for _, raw := range jsonArray {
|
|
||||||
ve, err := u.unmarshalSingularValue(lv.NewElement(), raw, fd)
|
|
||||||
if err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
lv.Append(ve)
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
case fd.IsMap():
|
|
||||||
var jsonObject map[string]json.RawMessage
|
|
||||||
if err := json.Unmarshal(in, &jsonObject); err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
kfd := fd.MapKey()
|
|
||||||
vfd := fd.MapValue()
|
|
||||||
mv := v.Map()
|
|
||||||
for key, raw := range jsonObject {
|
|
||||||
var kv protoreflect.MapKey
|
|
||||||
if kfd.Kind() == protoreflect.StringKind {
|
|
||||||
kv = protoreflect.ValueOf(key).MapKey()
|
|
||||||
} else {
|
|
||||||
v, err := u.unmarshalSingularValue(kfd.Default(), []byte(key), kfd)
|
|
||||||
if err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
kv = v.MapKey()
|
|
||||||
}
|
|
||||||
|
|
||||||
vv, err := u.unmarshalSingularValue(mv.NewValue(), raw, vfd)
|
|
||||||
if err != nil {
|
|
||||||
return v, err
|
|
||||||
}
|
|
||||||
mv.Set(kv, vv)
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
default:
|
|
||||||
return u.unmarshalSingularValue(v, in, fd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var nonFinite = map[string]float64{
|
|
||||||
`"NaN"`: math.NaN(),
|
|
||||||
`"Infinity"`: math.Inf(+1),
|
|
||||||
`"-Infinity"`: math.Inf(-1),
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *Unmarshaler) unmarshalSingularValue(v protoreflect.Value, in []byte, fd protoreflect.FieldDescriptor) (protoreflect.Value, error) {
|
|
||||||
switch fd.Kind() {
|
|
||||||
case protoreflect.BoolKind:
|
|
||||||
return unmarshalValue(in, new(bool))
|
|
||||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(int32))
|
|
||||||
case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(int64))
|
|
||||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(uint32))
|
|
||||||
case protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
|
||||||
return unmarshalValue(trimQuote(in), new(uint64))
|
|
||||||
case protoreflect.FloatKind:
|
|
||||||
if f, ok := nonFinite[string(in)]; ok {
|
|
||||||
return protoreflect.ValueOfFloat32(float32(f)), nil
|
|
||||||
}
|
|
||||||
return unmarshalValue(trimQuote(in), new(float32))
|
|
||||||
case protoreflect.DoubleKind:
|
|
||||||
if f, ok := nonFinite[string(in)]; ok {
|
|
||||||
return protoreflect.ValueOfFloat64(float64(f)), nil
|
|
||||||
}
|
|
||||||
return unmarshalValue(trimQuote(in), new(float64))
|
|
||||||
case protoreflect.StringKind:
|
|
||||||
return unmarshalValue(in, new(string))
|
|
||||||
case protoreflect.BytesKind:
|
|
||||||
return unmarshalValue(in, new([]byte))
|
|
||||||
case protoreflect.EnumKind:
|
|
||||||
if hasPrefixAndSuffix('"', in, '"') {
|
|
||||||
vd := fd.Enum().Values().ByName(protoreflect.Name(trimQuote(in)))
|
|
||||||
if vd == nil {
|
|
||||||
return v, fmt.Errorf("unknown value %q for enum %s", in, fd.Enum().FullName())
|
|
||||||
}
|
|
||||||
return protoreflect.ValueOfEnum(vd.Number()), nil
|
|
||||||
}
|
|
||||||
return unmarshalValue(in, new(protoreflect.EnumNumber))
|
|
||||||
case protoreflect.MessageKind, protoreflect.GroupKind:
|
|
||||||
err := u.unmarshalMessage(v.Message(), in)
|
|
||||||
return v, err
|
|
||||||
default:
|
|
||||||
panic(fmt.Sprintf("invalid kind %v", fd.Kind()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func unmarshalValue(in []byte, v interface{}) (protoreflect.Value, error) {
|
|
||||||
err := json.Unmarshal(in, v)
|
|
||||||
return protoreflect.ValueOf(reflect.ValueOf(v).Elem().Interface()), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func unquoteString(in string) (out string, err error) {
|
|
||||||
err = json.Unmarshal([]byte(in), &out)
|
|
||||||
return out, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func hasPrefixAndSuffix(prefix byte, in []byte, suffix byte) bool {
|
|
||||||
if len(in) >= 2 && in[0] == prefix && in[len(in)-1] == suffix {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// trimQuote is like unquoteString but simply strips surrounding quotes.
|
|
||||||
// This is incorrect, but is behavior done by the legacy implementation.
|
|
||||||
func trimQuote(in []byte) []byte {
|
|
||||||
if len(in) >= 2 && in[0] == '"' && in[len(in)-1] == '"' {
|
|
||||||
in = in[1 : len(in)-1]
|
|
||||||
}
|
|
||||||
return in
|
|
||||||
}
|
|
|
@ -1,560 +0,0 @@
|
||||||
// Copyright 2015 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 jsonpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"math"
|
|
||||||
"reflect"
|
|
||||||
"sort"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
|
||||||
protoV2 "google.golang.org/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
)
|
|
||||||
|
|
||||||
const wrapJSONMarshalV2 = false
|
|
||||||
|
|
||||||
// Marshaler is a configurable object for marshaling protocol buffer messages
|
|
||||||
// to the specified JSON representation.
|
|
||||||
type Marshaler struct {
|
|
||||||
// OrigName specifies whether to use the original protobuf name for fields.
|
|
||||||
OrigName bool
|
|
||||||
|
|
||||||
// EnumsAsInts specifies whether to render enum values as integers,
|
|
||||||
// as opposed to string values.
|
|
||||||
EnumsAsInts bool
|
|
||||||
|
|
||||||
// EmitDefaults specifies whether to render fields with zero values.
|
|
||||||
EmitDefaults bool
|
|
||||||
|
|
||||||
// Indent controls whether the output is compact or not.
|
|
||||||
// If empty, the output is compact JSON. Otherwise, every JSON object
|
|
||||||
// entry and JSON array value will be on its own line.
|
|
||||||
// Each line will be preceded by repeated copies of Indent, where the
|
|
||||||
// number of copies is the current indentation depth.
|
|
||||||
Indent string
|
|
||||||
|
|
||||||
// AnyResolver is used to resolve the google.protobuf.Any well-known type.
|
|
||||||
// If unset, the global registry is used by default.
|
|
||||||
AnyResolver AnyResolver
|
|
||||||
}
|
|
||||||
|
|
||||||
// JSONPBMarshaler is implemented by protobuf messages that customize the
|
|
||||||
// way they are marshaled to JSON. Messages that implement this should also
|
|
||||||
// implement JSONPBUnmarshaler so that the custom format can be parsed.
|
|
||||||
//
|
|
||||||
// The JSON marshaling must follow the proto to JSON specification:
|
|
||||||
//
|
|
||||||
// https://developers.google.com/protocol-buffers/docs/proto3#json
|
|
||||||
//
|
|
||||||
// Deprecated: Custom types should implement protobuf reflection instead.
|
|
||||||
type JSONPBMarshaler interface {
|
|
||||||
MarshalJSONPB(*Marshaler) ([]byte, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Marshal serializes a protobuf message as JSON into w.
|
|
||||||
func (jm *Marshaler) Marshal(w io.Writer, m proto.Message) error {
|
|
||||||
b, err := jm.marshal(m)
|
|
||||||
if len(b) > 0 {
|
|
||||||
if _, err := w.Write(b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalToString serializes a protobuf message as JSON in string form.
|
|
||||||
func (jm *Marshaler) MarshalToString(m proto.Message) (string, error) {
|
|
||||||
b, err := jm.marshal(m)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return string(b), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (jm *Marshaler) marshal(m proto.Message) ([]byte, error) {
|
|
||||||
v := reflect.ValueOf(m)
|
|
||||||
if m == nil || (v.Kind() == reflect.Ptr && v.IsNil()) {
|
|
||||||
return nil, errors.New("Marshal called with nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for custom marshalers first since they may not properly
|
|
||||||
// implement protobuf reflection that the logic below relies on.
|
|
||||||
if jsm, ok := m.(JSONPBMarshaler); ok {
|
|
||||||
return jsm.MarshalJSONPB(jm)
|
|
||||||
}
|
|
||||||
|
|
||||||
if wrapJSONMarshalV2 {
|
|
||||||
opts := protojson.MarshalOptions{
|
|
||||||
UseProtoNames: jm.OrigName,
|
|
||||||
UseEnumNumbers: jm.EnumsAsInts,
|
|
||||||
EmitUnpopulated: jm.EmitDefaults,
|
|
||||||
Indent: jm.Indent,
|
|
||||||
}
|
|
||||||
if jm.AnyResolver != nil {
|
|
||||||
opts.Resolver = anyResolver{jm.AnyResolver}
|
|
||||||
}
|
|
||||||
return opts.Marshal(proto.MessageReflect(m).Interface())
|
|
||||||
} else {
|
|
||||||
// Check for unpopulated required fields first.
|
|
||||||
m2 := proto.MessageReflect(m)
|
|
||||||
if err := protoV2.CheckInitialized(m2.Interface()); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
w := jsonWriter{Marshaler: jm}
|
|
||||||
err := w.marshalMessage(m2, "", "")
|
|
||||||
return w.buf, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type jsonWriter struct {
|
|
||||||
*Marshaler
|
|
||||||
buf []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) write(s string) {
|
|
||||||
w.buf = append(w.buf, s...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalMessage(m protoreflect.Message, indent, typeURL string) error {
|
|
||||||
if jsm, ok := proto.MessageV1(m.Interface()).(JSONPBMarshaler); ok {
|
|
||||||
b, err := jsm.MarshalJSONPB(w.Marshaler)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if typeURL != "" {
|
|
||||||
// we are marshaling this object to an Any type
|
|
||||||
var js map[string]*json.RawMessage
|
|
||||||
if err = json.Unmarshal(b, &js); err != nil {
|
|
||||||
return fmt.Errorf("type %T produced invalid JSON: %v", m.Interface(), err)
|
|
||||||
}
|
|
||||||
turl, err := json.Marshal(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to marshal type URL %q to JSON: %v", typeURL, err)
|
|
||||||
}
|
|
||||||
js["@type"] = (*json.RawMessage)(&turl)
|
|
||||||
if b, err = json.Marshal(js); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
md := m.Descriptor()
|
|
||||||
fds := md.Fields()
|
|
||||||
|
|
||||||
// Handle well-known types.
|
|
||||||
const secondInNanos = int64(time.Second / time.Nanosecond)
|
|
||||||
switch wellKnownType(md.FullName()) {
|
|
||||||
case "Any":
|
|
||||||
return w.marshalAny(m, indent)
|
|
||||||
case "BoolValue", "BytesValue", "StringValue",
|
|
||||||
"Int32Value", "UInt32Value", "FloatValue",
|
|
||||||
"Int64Value", "UInt64Value", "DoubleValue":
|
|
||||||
fd := fds.ByNumber(1)
|
|
||||||
return w.marshalValue(fd, m.Get(fd), indent)
|
|
||||||
case "Duration":
|
|
||||||
const maxSecondsInDuration = 315576000000
|
|
||||||
// "Generated output always contains 0, 3, 6, or 9 fractional digits,
|
|
||||||
// depending on required precision."
|
|
||||||
s := m.Get(fds.ByNumber(1)).Int()
|
|
||||||
ns := m.Get(fds.ByNumber(2)).Int()
|
|
||||||
if s < -maxSecondsInDuration || s > maxSecondsInDuration {
|
|
||||||
return fmt.Errorf("seconds out of range %v", s)
|
|
||||||
}
|
|
||||||
if ns <= -secondInNanos || ns >= secondInNanos {
|
|
||||||
return fmt.Errorf("ns out of range (%v, %v)", -secondInNanos, secondInNanos)
|
|
||||||
}
|
|
||||||
if (s > 0 && ns < 0) || (s < 0 && ns > 0) {
|
|
||||||
return errors.New("signs of seconds and nanos do not match")
|
|
||||||
}
|
|
||||||
var sign string
|
|
||||||
if s < 0 || ns < 0 {
|
|
||||||
sign, s, ns = "-", -1*s, -1*ns
|
|
||||||
}
|
|
||||||
x := fmt.Sprintf("%s%d.%09d", sign, s, ns)
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, ".000")
|
|
||||||
w.write(fmt.Sprintf(`"%vs"`, x))
|
|
||||||
return nil
|
|
||||||
case "Timestamp":
|
|
||||||
// "RFC 3339, where generated output will always be Z-normalized
|
|
||||||
// and uses 0, 3, 6 or 9 fractional digits."
|
|
||||||
s := m.Get(fds.ByNumber(1)).Int()
|
|
||||||
ns := m.Get(fds.ByNumber(2)).Int()
|
|
||||||
if ns < 0 || ns >= secondInNanos {
|
|
||||||
return fmt.Errorf("ns out of range [0, %v)", secondInNanos)
|
|
||||||
}
|
|
||||||
t := time.Unix(s, ns).UTC()
|
|
||||||
// time.RFC3339Nano isn't exactly right (we need to get 3/6/9 fractional digits).
|
|
||||||
x := t.Format("2006-01-02T15:04:05.000000000")
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, "000")
|
|
||||||
x = strings.TrimSuffix(x, ".000")
|
|
||||||
w.write(fmt.Sprintf(`"%vZ"`, x))
|
|
||||||
return nil
|
|
||||||
case "Value":
|
|
||||||
// JSON value; which is a null, number, string, bool, object, or array.
|
|
||||||
od := md.Oneofs().Get(0)
|
|
||||||
fd := m.WhichOneof(od)
|
|
||||||
if fd == nil {
|
|
||||||
return errors.New("nil Value")
|
|
||||||
}
|
|
||||||
return w.marshalValue(fd, m.Get(fd), indent)
|
|
||||||
case "Struct", "ListValue":
|
|
||||||
// JSON object or array.
|
|
||||||
fd := fds.ByNumber(1)
|
|
||||||
return w.marshalValue(fd, m.Get(fd), indent)
|
|
||||||
}
|
|
||||||
|
|
||||||
w.write("{")
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
firstField := true
|
|
||||||
if typeURL != "" {
|
|
||||||
if err := w.marshalTypeURL(indent, typeURL); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
firstField = false
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < fds.Len(); {
|
|
||||||
fd := fds.Get(i)
|
|
||||||
if od := fd.ContainingOneof(); od != nil {
|
|
||||||
fd = m.WhichOneof(od)
|
|
||||||
i += od.Fields().Len()
|
|
||||||
if fd == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
v := m.Get(fd)
|
|
||||||
|
|
||||||
if !m.Has(fd) {
|
|
||||||
if !w.EmitDefaults || fd.ContainingOneof() != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if fd.Cardinality() != protoreflect.Repeated && (fd.Message() != nil || fd.Syntax() == protoreflect.Proto2) {
|
|
||||||
v = protoreflect.Value{} // use "null" for singular messages or proto2 scalars
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !firstField {
|
|
||||||
w.writeComma()
|
|
||||||
}
|
|
||||||
if err := w.marshalField(fd, v, indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
firstField = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle proto2 extensions.
|
|
||||||
if md.ExtensionRanges().Len() > 0 {
|
|
||||||
// Collect a sorted list of all extension descriptor and values.
|
|
||||||
type ext struct {
|
|
||||||
desc protoreflect.FieldDescriptor
|
|
||||||
val protoreflect.Value
|
|
||||||
}
|
|
||||||
var exts []ext
|
|
||||||
m.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
|
||||||
if fd.IsExtension() {
|
|
||||||
exts = append(exts, ext{fd, v})
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
sort.Slice(exts, func(i, j int) bool {
|
|
||||||
return exts[i].desc.Number() < exts[j].desc.Number()
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, ext := range exts {
|
|
||||||
if !firstField {
|
|
||||||
w.writeComma()
|
|
||||||
}
|
|
||||||
if err := w.marshalField(ext.desc, ext.val, indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
firstField = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
}
|
|
||||||
w.write("}")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) writeComma() {
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(",\n")
|
|
||||||
} else {
|
|
||||||
w.write(",")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalAny(m protoreflect.Message, indent string) error {
|
|
||||||
// "If the Any contains a value that has a special JSON mapping,
|
|
||||||
// it will be converted as follows: {"@type": xxx, "value": yyy}.
|
|
||||||
// Otherwise, the value will be converted into a JSON object,
|
|
||||||
// and the "@type" field will be inserted to indicate the actual data type."
|
|
||||||
md := m.Descriptor()
|
|
||||||
typeURL := m.Get(md.Fields().ByNumber(1)).String()
|
|
||||||
rawVal := m.Get(md.Fields().ByNumber(2)).Bytes()
|
|
||||||
|
|
||||||
var m2 protoreflect.Message
|
|
||||||
if w.AnyResolver != nil {
|
|
||||||
mi, err := w.AnyResolver.Resolve(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = proto.MessageReflect(mi)
|
|
||||||
} else {
|
|
||||||
mt, err := protoregistry.GlobalTypes.FindMessageByURL(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m2 = mt.New()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := protoV2.Unmarshal(rawVal, m2.Interface()); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if wellKnownType(m2.Descriptor().FullName()) == "" {
|
|
||||||
return w.marshalMessage(m2, indent, typeURL)
|
|
||||||
}
|
|
||||||
|
|
||||||
w.write("{")
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
}
|
|
||||||
if err := w.marshalTypeURL(indent, typeURL); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.writeComma()
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
w.write(`"value": `)
|
|
||||||
} else {
|
|
||||||
w.write(`"value":`)
|
|
||||||
}
|
|
||||||
if err := w.marshalMessage(m2, indent+w.Indent, ""); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
}
|
|
||||||
w.write("}")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalTypeURL(indent, typeURL string) error {
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write(`"@type":`)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(" ")
|
|
||||||
}
|
|
||||||
b, err := json.Marshal(typeURL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// marshalField writes field description and value to the Writer.
|
|
||||||
func (w *jsonWriter) marshalField(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error {
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write(`"`)
|
|
||||||
switch {
|
|
||||||
case fd.IsExtension():
|
|
||||||
// For message set, use the fname of the message as the extension name.
|
|
||||||
name := string(fd.FullName())
|
|
||||||
if isMessageSet(fd.ContainingMessage()) {
|
|
||||||
name = strings.TrimSuffix(name, ".message_set_extension")
|
|
||||||
}
|
|
||||||
|
|
||||||
w.write("[" + name + "]")
|
|
||||||
case w.OrigName:
|
|
||||||
name := string(fd.Name())
|
|
||||||
if fd.Kind() == protoreflect.GroupKind {
|
|
||||||
name = string(fd.Message().Name())
|
|
||||||
}
|
|
||||||
w.write(name)
|
|
||||||
default:
|
|
||||||
w.write(string(fd.JSONName()))
|
|
||||||
}
|
|
||||||
w.write(`":`)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(" ")
|
|
||||||
}
|
|
||||||
return w.marshalValue(fd, v, indent)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalValue(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error {
|
|
||||||
switch {
|
|
||||||
case fd.IsList():
|
|
||||||
w.write("[")
|
|
||||||
comma := ""
|
|
||||||
lv := v.List()
|
|
||||||
for i := 0; i < lv.Len(); i++ {
|
|
||||||
w.write(comma)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
if err := w.marshalSingularValue(fd, lv.Get(i), indent+w.Indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
comma = ","
|
|
||||||
}
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write("]")
|
|
||||||
return nil
|
|
||||||
case fd.IsMap():
|
|
||||||
kfd := fd.MapKey()
|
|
||||||
vfd := fd.MapValue()
|
|
||||||
mv := v.Map()
|
|
||||||
|
|
||||||
// Collect a sorted list of all map keys and values.
|
|
||||||
type entry struct{ key, val protoreflect.Value }
|
|
||||||
var entries []entry
|
|
||||||
mv.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool {
|
|
||||||
entries = append(entries, entry{k.Value(), v})
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
sort.Slice(entries, func(i, j int) bool {
|
|
||||||
switch kfd.Kind() {
|
|
||||||
case protoreflect.BoolKind:
|
|
||||||
return !entries[i].key.Bool() && entries[j].key.Bool()
|
|
||||||
case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind, protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind:
|
|
||||||
return entries[i].key.Int() < entries[j].key.Int()
|
|
||||||
case protoreflect.Uint32Kind, protoreflect.Fixed32Kind, protoreflect.Uint64Kind, protoreflect.Fixed64Kind:
|
|
||||||
return entries[i].key.Uint() < entries[j].key.Uint()
|
|
||||||
case protoreflect.StringKind:
|
|
||||||
return entries[i].key.String() < entries[j].key.String()
|
|
||||||
default:
|
|
||||||
panic("invalid kind")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
w.write(`{`)
|
|
||||||
comma := ""
|
|
||||||
for _, entry := range entries {
|
|
||||||
w.write(comma)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
|
|
||||||
s := fmt.Sprint(entry.key.Interface())
|
|
||||||
b, err := json.Marshal(s)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
|
|
||||||
w.write(`:`)
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write(` `)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := w.marshalSingularValue(vfd, entry.val, indent+w.Indent); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
comma = ","
|
|
||||||
}
|
|
||||||
if w.Indent != "" {
|
|
||||||
w.write("\n")
|
|
||||||
w.write(indent)
|
|
||||||
w.write(w.Indent)
|
|
||||||
}
|
|
||||||
w.write(`}`)
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return w.marshalSingularValue(fd, v, indent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *jsonWriter) marshalSingularValue(fd protoreflect.FieldDescriptor, v protoreflect.Value, indent string) error {
|
|
||||||
switch {
|
|
||||||
case !v.IsValid():
|
|
||||||
w.write("null")
|
|
||||||
return nil
|
|
||||||
case fd.Message() != nil:
|
|
||||||
return w.marshalMessage(v.Message(), indent+w.Indent, "")
|
|
||||||
case fd.Enum() != nil:
|
|
||||||
if fd.Enum().FullName() == "google.protobuf.NullValue" {
|
|
||||||
w.write("null")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
vd := fd.Enum().Values().ByNumber(v.Enum())
|
|
||||||
if vd == nil || w.EnumsAsInts {
|
|
||||||
w.write(strconv.Itoa(int(v.Enum())))
|
|
||||||
} else {
|
|
||||||
w.write(`"` + string(vd.Name()) + `"`)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
switch v.Interface().(type) {
|
|
||||||
case float32, float64:
|
|
||||||
switch {
|
|
||||||
case math.IsInf(v.Float(), +1):
|
|
||||||
w.write(`"Infinity"`)
|
|
||||||
return nil
|
|
||||||
case math.IsInf(v.Float(), -1):
|
|
||||||
w.write(`"-Infinity"`)
|
|
||||||
return nil
|
|
||||||
case math.IsNaN(v.Float()):
|
|
||||||
w.write(`"NaN"`)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
case int64, uint64:
|
|
||||||
w.write(fmt.Sprintf(`"%d"`, v.Interface()))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
b, err := json.Marshal(v.Interface())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.write(string(b))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
// Copyright 2015 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 jsonpb provides functionality to marshal and unmarshal between a
|
|
||||||
// protocol buffer message and JSON. It follows the specification at
|
|
||||||
// https://developers.google.com/protocol-buffers/docs/proto3#json.
|
|
||||||
//
|
|
||||||
// Do not rely on the default behavior of the standard encoding/json package
|
|
||||||
// when called on generated message types as it does not operate correctly.
|
|
||||||
//
|
|
||||||
// Deprecated: Use the "google.golang.org/protobuf/encoding/protojson"
|
|
||||||
// package instead.
|
|
||||||
package jsonpb
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
"google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AnyResolver takes a type URL, present in an Any message,
|
|
||||||
// and resolves it into an instance of the associated message.
|
|
||||||
type AnyResolver interface {
|
|
||||||
Resolve(typeURL string) (proto.Message, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type anyResolver struct{ AnyResolver }
|
|
||||||
|
|
||||||
func (r anyResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) {
|
|
||||||
return r.FindMessageByURL(string(message))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r anyResolver) FindMessageByURL(url string) (protoreflect.MessageType, error) {
|
|
||||||
m, err := r.Resolve(url)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return protoimpl.X.MessageTypeOf(m), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r anyResolver) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error) {
|
|
||||||
return protoregistry.GlobalTypes.FindExtensionByName(field)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r anyResolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) {
|
|
||||||
return protoregistry.GlobalTypes.FindExtensionByNumber(message, field)
|
|
||||||
}
|
|
||||||
|
|
||||||
func wellKnownType(s protoreflect.FullName) string {
|
|
||||||
if s.Parent() == "google.protobuf" {
|
|
||||||
switch s.Name() {
|
|
||||||
case "Empty", "Any",
|
|
||||||
"BoolValue", "BytesValue", "StringValue",
|
|
||||||
"Int32Value", "UInt32Value", "FloatValue",
|
|
||||||
"Int64Value", "UInt64Value", "DoubleValue",
|
|
||||||
"Duration", "Timestamp",
|
|
||||||
"NullValue", "Struct", "Value", "ListValue":
|
|
||||||
return string(s.Name())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func isMessageSet(md protoreflect.MessageDescriptor) bool {
|
|
||||||
ms, ok := md.(interface{ IsMessageSet() bool })
|
|
||||||
return ok && ms.IsMessageSet()
|
|
||||||
}
|
|
|
@ -1,180 +0,0 @@
|
||||||
// Copyright 2016 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 ptypes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
"google.golang.org/protobuf/reflect/protoregistry"
|
|
||||||
|
|
||||||
anypb "github.com/golang/protobuf/ptypes/any"
|
|
||||||
)
|
|
||||||
|
|
||||||
const urlPrefix = "type.googleapis.com/"
|
|
||||||
|
|
||||||
// AnyMessageName returns the message name contained in an anypb.Any message.
|
|
||||||
// Most type assertions should use the Is function instead.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the any.MessageName method instead.
|
|
||||||
func AnyMessageName(any *anypb.Any) (string, error) {
|
|
||||||
name, err := anyMessageName(any)
|
|
||||||
return string(name), err
|
|
||||||
}
|
|
||||||
func anyMessageName(any *anypb.Any) (protoreflect.FullName, error) {
|
|
||||||
if any == nil {
|
|
||||||
return "", fmt.Errorf("message is nil")
|
|
||||||
}
|
|
||||||
name := protoreflect.FullName(any.TypeUrl)
|
|
||||||
if i := strings.LastIndex(any.TypeUrl, "/"); i >= 0 {
|
|
||||||
name = name[i+len("/"):]
|
|
||||||
}
|
|
||||||
if !name.IsValid() {
|
|
||||||
return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl)
|
|
||||||
}
|
|
||||||
return name, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalAny marshals the given message m into an anypb.Any message.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the anypb.New function instead.
|
|
||||||
func MarshalAny(m proto.Message) (*anypb.Any, error) {
|
|
||||||
switch dm := m.(type) {
|
|
||||||
case DynamicAny:
|
|
||||||
m = dm.Message
|
|
||||||
case *DynamicAny:
|
|
||||||
if dm == nil {
|
|
||||||
return nil, proto.ErrNil
|
|
||||||
}
|
|
||||||
m = dm.Message
|
|
||||||
}
|
|
||||||
b, err := proto.Marshal(m)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &anypb.Any{TypeUrl: urlPrefix + proto.MessageName(m), Value: b}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Empty returns a new message of the type specified in an anypb.Any message.
|
|
||||||
// It returns protoregistry.NotFound if the corresponding message type could not
|
|
||||||
// be resolved in the global registry.
|
|
||||||
//
|
|
||||||
// Deprecated: Use protoregistry.GlobalTypes.FindMessageByName instead
|
|
||||||
// to resolve the message name and create a new instance of it.
|
|
||||||
func Empty(any *anypb.Any) (proto.Message, error) {
|
|
||||||
name, err := anyMessageName(any)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
mt, err := protoregistry.GlobalTypes.FindMessageByName(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return proto.MessageV1(mt.New().Interface()), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalAny unmarshals the encoded value contained in the anypb.Any message
|
|
||||||
// into the provided message m. It returns an error if the target message
|
|
||||||
// does not match the type in the Any message or if an unmarshal error occurs.
|
|
||||||
//
|
|
||||||
// The target message m may be a *DynamicAny message. If the underlying message
|
|
||||||
// type could not be resolved, then this returns protoregistry.NotFound.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the any.UnmarshalTo method instead.
|
|
||||||
func UnmarshalAny(any *anypb.Any, m proto.Message) error {
|
|
||||||
if dm, ok := m.(*DynamicAny); ok {
|
|
||||||
if dm.Message == nil {
|
|
||||||
var err error
|
|
||||||
dm.Message, err = Empty(any)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m = dm.Message
|
|
||||||
}
|
|
||||||
|
|
||||||
anyName, err := AnyMessageName(any)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
msgName := proto.MessageName(m)
|
|
||||||
if anyName != msgName {
|
|
||||||
return fmt.Errorf("mismatched message type: got %q want %q", anyName, msgName)
|
|
||||||
}
|
|
||||||
return proto.Unmarshal(any.Value, m)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is reports whether the Any message contains a message of the specified type.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the any.MessageIs method instead.
|
|
||||||
func Is(any *anypb.Any, m proto.Message) bool {
|
|
||||||
if any == nil || m == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
name := proto.MessageName(m)
|
|
||||||
if !strings.HasSuffix(any.TypeUrl, name) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return len(any.TypeUrl) == len(name) || any.TypeUrl[len(any.TypeUrl)-len(name)-1] == '/'
|
|
||||||
}
|
|
||||||
|
|
||||||
// DynamicAny is a value that can be passed to UnmarshalAny to automatically
|
|
||||||
// allocate a proto.Message for the type specified in an anypb.Any message.
|
|
||||||
// The allocated message is stored in the embedded proto.Message.
|
|
||||||
//
|
|
||||||
// Example:
|
|
||||||
//
|
|
||||||
// var x ptypes.DynamicAny
|
|
||||||
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
|
|
||||||
// fmt.Printf("unmarshaled message: %v", x.Message)
|
|
||||||
//
|
|
||||||
// Deprecated: Use the any.UnmarshalNew method instead to unmarshal
|
|
||||||
// the any message contents into a new instance of the underlying message.
|
|
||||||
type DynamicAny struct{ proto.Message }
|
|
||||||
|
|
||||||
func (m DynamicAny) String() string {
|
|
||||||
if m.Message == nil {
|
|
||||||
return "<nil>"
|
|
||||||
}
|
|
||||||
return m.Message.String()
|
|
||||||
}
|
|
||||||
func (m DynamicAny) Reset() {
|
|
||||||
if m.Message == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Message.Reset()
|
|
||||||
}
|
|
||||||
func (m DynamicAny) ProtoMessage() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
func (m DynamicAny) ProtoReflect() protoreflect.Message {
|
|
||||||
if m.Message == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return dynamicAny{proto.MessageReflect(m.Message)}
|
|
||||||
}
|
|
||||||
|
|
||||||
type dynamicAny struct{ protoreflect.Message }
|
|
||||||
|
|
||||||
func (m dynamicAny) Type() protoreflect.MessageType {
|
|
||||||
return dynamicAnyType{m.Message.Type()}
|
|
||||||
}
|
|
||||||
func (m dynamicAny) New() protoreflect.Message {
|
|
||||||
return dynamicAnyType{m.Message.Type()}.New()
|
|
||||||
}
|
|
||||||
func (m dynamicAny) Interface() protoreflect.ProtoMessage {
|
|
||||||
return DynamicAny{proto.MessageV1(m.Message.Interface())}
|
|
||||||
}
|
|
||||||
|
|
||||||
type dynamicAnyType struct{ protoreflect.MessageType }
|
|
||||||
|
|
||||||
func (t dynamicAnyType) New() protoreflect.Message {
|
|
||||||
return dynamicAny{t.MessageType.New()}
|
|
||||||
}
|
|
||||||
func (t dynamicAnyType) Zero() protoreflect.Message {
|
|
||||||
return dynamicAny{t.MessageType.Zero()}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// source: github.com/golang/protobuf/ptypes/any/any.proto
|
|
||||||
|
|
||||||
package any
|
|
||||||
|
|
||||||
import (
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
|
||||||
reflect "reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Symbols defined in public import of google/protobuf/any.proto.
|
|
||||||
|
|
||||||
type Any = anypb.Any
|
|
||||||
|
|
||||||
var File_github_com_golang_protobuf_ptypes_any_any_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
|
|
||||||
0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
|
|
||||||
0x70, 0x65, 0x73, 0x2f, 0x61, 0x6e, 0x79, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
|
||||||
0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
|
||||||
0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x2b, 0x5a, 0x29,
|
|
||||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e,
|
|
||||||
0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65,
|
|
||||||
0x73, 0x2f, 0x61, 0x6e, 0x79, 0x3b, 0x61, 0x6e, 0x79, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
|
||||||
0x74, 0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_github_com_golang_protobuf_ptypes_any_any_proto_goTypes = []interface{}{}
|
|
||||||
var file_github_com_golang_protobuf_ptypes_any_any_proto_depIdxs = []int32{
|
|
||||||
0, // [0:0] is the sub-list for method output_type
|
|
||||||
0, // [0:0] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_github_com_golang_protobuf_ptypes_any_any_proto_init() }
|
|
||||||
func file_github_com_golang_protobuf_ptypes_any_any_proto_init() {
|
|
||||||
if File_github_com_golang_protobuf_ptypes_any_any_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 0,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_github_com_golang_protobuf_ptypes_any_any_proto_goTypes,
|
|
||||||
DependencyIndexes: file_github_com_golang_protobuf_ptypes_any_any_proto_depIdxs,
|
|
||||||
}.Build()
|
|
||||||
File_github_com_golang_protobuf_ptypes_any_any_proto = out.File
|
|
||||||
file_github_com_golang_protobuf_ptypes_any_any_proto_rawDesc = nil
|
|
||||||
file_github_com_golang_protobuf_ptypes_any_any_proto_goTypes = nil
|
|
||||||
file_github_com_golang_protobuf_ptypes_any_any_proto_depIdxs = nil
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
// Copyright 2016 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 ptypes provides functionality for interacting with well-known types.
|
|
||||||
//
|
|
||||||
// Deprecated: Well-known types have specialized functionality directly
|
|
||||||
// injected into the generated packages for each message type.
|
|
||||||
// See the deprecation notice for each function for the suggested alternative.
|
|
||||||
package ptypes
|
|
|
@ -1,76 +0,0 @@
|
||||||
// Copyright 2016 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 ptypes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
durationpb "github.com/golang/protobuf/ptypes/duration"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Range of google.protobuf.Duration as specified in duration.proto.
|
|
||||||
// This is about 10,000 years in seconds.
|
|
||||||
const (
|
|
||||||
maxSeconds = int64(10000 * 365.25 * 24 * 60 * 60)
|
|
||||||
minSeconds = -maxSeconds
|
|
||||||
)
|
|
||||||
|
|
||||||
// Duration converts a durationpb.Duration to a time.Duration.
|
|
||||||
// Duration returns an error if dur is invalid or overflows a time.Duration.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the dur.AsDuration and dur.CheckValid methods instead.
|
|
||||||
func Duration(dur *durationpb.Duration) (time.Duration, error) {
|
|
||||||
if err := validateDuration(dur); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
d := time.Duration(dur.Seconds) * time.Second
|
|
||||||
if int64(d/time.Second) != dur.Seconds {
|
|
||||||
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", dur)
|
|
||||||
}
|
|
||||||
if dur.Nanos != 0 {
|
|
||||||
d += time.Duration(dur.Nanos) * time.Nanosecond
|
|
||||||
if (d < 0) != (dur.Nanos < 0) {
|
|
||||||
return 0, fmt.Errorf("duration: %v is out of range for time.Duration", dur)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return d, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DurationProto converts a time.Duration to a durationpb.Duration.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the durationpb.New function instead.
|
|
||||||
func DurationProto(d time.Duration) *durationpb.Duration {
|
|
||||||
nanos := d.Nanoseconds()
|
|
||||||
secs := nanos / 1e9
|
|
||||||
nanos -= secs * 1e9
|
|
||||||
return &durationpb.Duration{
|
|
||||||
Seconds: int64(secs),
|
|
||||||
Nanos: int32(nanos),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// validateDuration determines whether the durationpb.Duration is valid
|
|
||||||
// according to the definition in google/protobuf/duration.proto.
|
|
||||||
// A valid durpb.Duration may still be too large to fit into a time.Duration
|
|
||||||
// Note that the range of durationpb.Duration is about 10,000 years,
|
|
||||||
// while the range of time.Duration is about 290 years.
|
|
||||||
func validateDuration(dur *durationpb.Duration) error {
|
|
||||||
if dur == nil {
|
|
||||||
return errors.New("duration: nil Duration")
|
|
||||||
}
|
|
||||||
if dur.Seconds < minSeconds || dur.Seconds > maxSeconds {
|
|
||||||
return fmt.Errorf("duration: %v: seconds out of range", dur)
|
|
||||||
}
|
|
||||||
if dur.Nanos <= -1e9 || dur.Nanos >= 1e9 {
|
|
||||||
return fmt.Errorf("duration: %v: nanos out of range", dur)
|
|
||||||
}
|
|
||||||
// Seconds and Nanos must have the same sign, unless d.Nanos is zero.
|
|
||||||
if (dur.Seconds < 0 && dur.Nanos > 0) || (dur.Seconds > 0 && dur.Nanos < 0) {
|
|
||||||
return fmt.Errorf("duration: %v: seconds and nanos have different signs", dur)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// source: github.com/golang/protobuf/ptypes/duration/duration.proto
|
|
||||||
|
|
||||||
package duration
|
|
||||||
|
|
||||||
import (
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
durationpb "google.golang.org/protobuf/types/known/durationpb"
|
|
||||||
reflect "reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Symbols defined in public import of google/protobuf/duration.proto.
|
|
||||||
|
|
||||||
type Duration = durationpb.Duration
|
|
||||||
|
|
||||||
var File_github_com_golang_protobuf_ptypes_duration_duration_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
|
|
||||||
0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
|
|
||||||
0x70, 0x65, 0x73, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x64, 0x75, 0x72,
|
|
||||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f,
|
|
||||||
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72,
|
|
||||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x35, 0x5a, 0x33, 0x67,
|
|
||||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67,
|
|
||||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73,
|
|
||||||
0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69,
|
|
||||||
0x6f, 0x6e, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_github_com_golang_protobuf_ptypes_duration_duration_proto_goTypes = []interface{}{}
|
|
||||||
var file_github_com_golang_protobuf_ptypes_duration_duration_proto_depIdxs = []int32{
|
|
||||||
0, // [0:0] is the sub-list for method output_type
|
|
||||||
0, // [0:0] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_github_com_golang_protobuf_ptypes_duration_duration_proto_init() }
|
|
||||||
func file_github_com_golang_protobuf_ptypes_duration_duration_proto_init() {
|
|
||||||
if File_github_com_golang_protobuf_ptypes_duration_duration_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 0,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_github_com_golang_protobuf_ptypes_duration_duration_proto_goTypes,
|
|
||||||
DependencyIndexes: file_github_com_golang_protobuf_ptypes_duration_duration_proto_depIdxs,
|
|
||||||
}.Build()
|
|
||||||
File_github_com_golang_protobuf_ptypes_duration_duration_proto = out.File
|
|
||||||
file_github_com_golang_protobuf_ptypes_duration_duration_proto_rawDesc = nil
|
|
||||||
file_github_com_golang_protobuf_ptypes_duration_duration_proto_goTypes = nil
|
|
||||||
file_github_com_golang_protobuf_ptypes_duration_duration_proto_depIdxs = nil
|
|
||||||
}
|
|
|
@ -1,112 +0,0 @@
|
||||||
// Copyright 2016 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 ptypes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
timestamppb "github.com/golang/protobuf/ptypes/timestamp"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Range of google.protobuf.Duration as specified in timestamp.proto.
|
|
||||||
const (
|
|
||||||
// Seconds field of the earliest valid Timestamp.
|
|
||||||
// This is time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
|
|
||||||
minValidSeconds = -62135596800
|
|
||||||
// Seconds field just after the latest valid Timestamp.
|
|
||||||
// This is time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC).Unix().
|
|
||||||
maxValidSeconds = 253402300800
|
|
||||||
)
|
|
||||||
|
|
||||||
// Timestamp converts a timestamppb.Timestamp to a time.Time.
|
|
||||||
// It returns an error if the argument is invalid.
|
|
||||||
//
|
|
||||||
// Unlike most Go functions, if Timestamp returns an error, the first return
|
|
||||||
// value is not the zero time.Time. Instead, it is the value obtained from the
|
|
||||||
// time.Unix function when passed the contents of the Timestamp, in the UTC
|
|
||||||
// locale. This may or may not be a meaningful time; many invalid Timestamps
|
|
||||||
// do map to valid time.Times.
|
|
||||||
//
|
|
||||||
// A nil Timestamp returns an error. The first return value in that case is
|
|
||||||
// undefined.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the ts.AsTime and ts.CheckValid methods instead.
|
|
||||||
func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
|
|
||||||
// Don't return the zero value on error, because corresponds to a valid
|
|
||||||
// timestamp. Instead return whatever time.Unix gives us.
|
|
||||||
var t time.Time
|
|
||||||
if ts == nil {
|
|
||||||
t = time.Unix(0, 0).UTC() // treat nil like the empty Timestamp
|
|
||||||
} else {
|
|
||||||
t = time.Unix(ts.Seconds, int64(ts.Nanos)).UTC()
|
|
||||||
}
|
|
||||||
return t, validateTimestamp(ts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TimestampNow returns a google.protobuf.Timestamp for the current time.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the timestamppb.Now function instead.
|
|
||||||
func TimestampNow() *timestamppb.Timestamp {
|
|
||||||
ts, err := TimestampProto(time.Now())
|
|
||||||
if err != nil {
|
|
||||||
panic("ptypes: time.Now() out of Timestamp range")
|
|
||||||
}
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
|
|
||||||
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
|
|
||||||
// It returns an error if the resulting Timestamp is invalid.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the timestamppb.New function instead.
|
|
||||||
func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
|
|
||||||
ts := ×tamppb.Timestamp{
|
|
||||||
Seconds: t.Unix(),
|
|
||||||
Nanos: int32(t.Nanosecond()),
|
|
||||||
}
|
|
||||||
if err := validateTimestamp(ts); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return ts, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TimestampString returns the RFC 3339 string for valid Timestamps.
|
|
||||||
// For invalid Timestamps, it returns an error message in parentheses.
|
|
||||||
//
|
|
||||||
// Deprecated: Call the ts.AsTime method instead,
|
|
||||||
// followed by a call to the Format method on the time.Time value.
|
|
||||||
func TimestampString(ts *timestamppb.Timestamp) string {
|
|
||||||
t, err := Timestamp(ts)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Sprintf("(%v)", err)
|
|
||||||
}
|
|
||||||
return t.Format(time.RFC3339Nano)
|
|
||||||
}
|
|
||||||
|
|
||||||
// validateTimestamp determines whether a Timestamp is valid.
|
|
||||||
// A valid timestamp represents a time in the range [0001-01-01, 10000-01-01)
|
|
||||||
// and has a Nanos field in the range [0, 1e9).
|
|
||||||
//
|
|
||||||
// If the Timestamp is valid, validateTimestamp returns nil.
|
|
||||||
// Otherwise, it returns an error that describes the problem.
|
|
||||||
//
|
|
||||||
// Every valid Timestamp can be represented by a time.Time,
|
|
||||||
// but the converse is not true.
|
|
||||||
func validateTimestamp(ts *timestamppb.Timestamp) error {
|
|
||||||
if ts == nil {
|
|
||||||
return errors.New("timestamp: nil Timestamp")
|
|
||||||
}
|
|
||||||
if ts.Seconds < minValidSeconds {
|
|
||||||
return fmt.Errorf("timestamp: %v before 0001-01-01", ts)
|
|
||||||
}
|
|
||||||
if ts.Seconds >= maxValidSeconds {
|
|
||||||
return fmt.Errorf("timestamp: %v after 10000-01-01", ts)
|
|
||||||
}
|
|
||||||
if ts.Nanos < 0 || ts.Nanos >= 1e9 {
|
|
||||||
return fmt.Errorf("timestamp: %v: nanos not in range [0, 1e9)", ts)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// source: github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
|
|
||||||
|
|
||||||
package timestamp
|
|
||||||
|
|
||||||
import (
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
|
||||||
reflect "reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Symbols defined in public import of google/protobuf/timestamp.proto.
|
|
||||||
|
|
||||||
type Timestamp = timestamppb.Timestamp
|
|
||||||
|
|
||||||
var File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
|
|
||||||
0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
|
|
||||||
0x70, 0x65, 0x73, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x74, 0x69,
|
|
||||||
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67,
|
|
||||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74,
|
|
||||||
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x37,
|
|
||||||
0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
|
|
||||||
0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79,
|
|
||||||
0x70, 0x65, 0x73, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x3b, 0x74, 0x69,
|
|
||||||
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
|
||||||
0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes = []interface{}{}
|
|
||||||
var file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs = []int32{
|
|
||||||
0, // [0:0] is the sub-list for method output_type
|
|
||||||
0, // [0:0] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_init() }
|
|
||||||
func file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_init() {
|
|
||||||
if File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 0,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes,
|
|
||||||
DependencyIndexes: file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs,
|
|
||||||
}.Build()
|
|
||||||
File_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto = out.File
|
|
||||||
file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_rawDesc = nil
|
|
||||||
file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_goTypes = nil
|
|
||||||
file_github_com_golang_protobuf_ptypes_timestamp_timestamp_proto_depIdxs = nil
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
// operations with the same key more efficient. This package refers to the RFC
|
// operations with the same key more efficient. This package refers to the RFC
|
||||||
// 8032 private key as the “seed”.
|
// 8032 private key as the “seed”.
|
||||||
//
|
//
|
||||||
// Beginning with Go 1.13, the functionality of this package was moved to the
|
// This package is a wrapper around the standard library crypto/ed25519 package.
|
||||||
// standard library as crypto/ed25519. This package only acts as a compatibility
|
|
||||||
// wrapper.
|
|
||||||
package ed25519
|
package ed25519
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -16,7 +16,7 @@ Hash Functions SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 for HMAC. To
|
||||||
choose, you can pass the `New` functions from the different SHA packages to
|
choose, you can pass the `New` functions from the different SHA packages to
|
||||||
pbkdf2.Key.
|
pbkdf2.Key.
|
||||||
*/
|
*/
|
||||||
package pbkdf2 // import "golang.org/x/crypto/pbkdf2"
|
package pbkdf2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/hmac"
|
"crypto/hmac"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package http2 // import "golang.org/x/net/http2"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -26,6 +27,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/http/httpguts"
|
"golang.org/x/net/http/httpguts"
|
||||||
)
|
)
|
||||||
|
@ -210,12 +212,6 @@ type stringWriter interface {
|
||||||
WriteString(s string) (n int, err error)
|
WriteString(s string) (n int, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// A gate lets two goroutines coordinate their activities.
|
|
||||||
type gate chan struct{}
|
|
||||||
|
|
||||||
func (g gate) Done() { g <- struct{}{} }
|
|
||||||
func (g gate) Wait() { <-g }
|
|
||||||
|
|
||||||
// A closeWaiter is like a sync.WaitGroup but only goes 1 to 0 (open to closed).
|
// A closeWaiter is like a sync.WaitGroup but only goes 1 to 0 (open to closed).
|
||||||
type closeWaiter chan struct{}
|
type closeWaiter chan struct{}
|
||||||
|
|
||||||
|
@ -383,3 +379,14 @@ func validPseudoPath(v string) bool {
|
||||||
// makes that struct also non-comparable, and generally doesn't add
|
// makes that struct also non-comparable, and generally doesn't add
|
||||||
// any size (as long as it's first).
|
// any size (as long as it's first).
|
||||||
type incomparable [0]func()
|
type incomparable [0]func()
|
||||||
|
|
||||||
|
// synctestGroupInterface is the methods of synctestGroup used by Server and Transport.
|
||||||
|
// It's defined as an interface here to let us keep synctestGroup entirely test-only
|
||||||
|
// and not a part of non-test builds.
|
||||||
|
type synctestGroupInterface interface {
|
||||||
|
Join()
|
||||||
|
Now() time.Time
|
||||||
|
NewTimer(d time.Duration) timer
|
||||||
|
AfterFunc(d time.Duration, f func()) timer
|
||||||
|
ContextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc)
|
||||||
|
}
|
||||||
|
|
|
@ -154,6 +154,39 @@ type Server struct {
|
||||||
// so that we don't embed a Mutex in this struct, which will make the
|
// so that we don't embed a Mutex in this struct, which will make the
|
||||||
// struct non-copyable, which might break some callers.
|
// struct non-copyable, which might break some callers.
|
||||||
state *serverInternalState
|
state *serverInternalState
|
||||||
|
|
||||||
|
// Synchronization group used for testing.
|
||||||
|
// Outside of tests, this is nil.
|
||||||
|
group synctestGroupInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) markNewGoroutine() {
|
||||||
|
if s.group != nil {
|
||||||
|
s.group.Join()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) now() time.Time {
|
||||||
|
if s.group != nil {
|
||||||
|
return s.group.Now()
|
||||||
|
}
|
||||||
|
return time.Now()
|
||||||
|
}
|
||||||
|
|
||||||
|
// newTimer creates a new time.Timer, or a synthetic timer in tests.
|
||||||
|
func (s *Server) newTimer(d time.Duration) timer {
|
||||||
|
if s.group != nil {
|
||||||
|
return s.group.NewTimer(d)
|
||||||
|
}
|
||||||
|
return timeTimer{time.NewTimer(d)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// afterFunc creates a new time.AfterFunc timer, or a synthetic timer in tests.
|
||||||
|
func (s *Server) afterFunc(d time.Duration, f func()) timer {
|
||||||
|
if s.group != nil {
|
||||||
|
return s.group.AfterFunc(d, f)
|
||||||
|
}
|
||||||
|
return timeTimer{time.AfterFunc(d, f)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) initialConnRecvWindowSize() int32 {
|
func (s *Server) initialConnRecvWindowSize() int32 {
|
||||||
|
@ -400,6 +433,10 @@ func (o *ServeConnOpts) handler() http.Handler {
|
||||||
//
|
//
|
||||||
// The opts parameter is optional. If nil, default values are used.
|
// The opts parameter is optional. If nil, default values are used.
|
||||||
func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) {
|
func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) {
|
||||||
|
s.serveConn(c, opts, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverConn)) {
|
||||||
baseCtx, cancel := serverConnBaseContext(c, opts)
|
baseCtx, cancel := serverConnBaseContext(c, opts)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -426,6 +463,9 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) {
|
||||||
pushEnabled: true,
|
pushEnabled: true,
|
||||||
sawClientPreface: opts.SawClientPreface,
|
sawClientPreface: opts.SawClientPreface,
|
||||||
}
|
}
|
||||||
|
if newf != nil {
|
||||||
|
newf(sc)
|
||||||
|
}
|
||||||
|
|
||||||
s.state.registerConn(sc)
|
s.state.registerConn(sc)
|
||||||
defer s.state.unregisterConn(sc)
|
defer s.state.unregisterConn(sc)
|
||||||
|
@ -599,8 +639,8 @@ type serverConn struct {
|
||||||
inFrameScheduleLoop bool // whether we're in the scheduleFrameWrite loop
|
inFrameScheduleLoop bool // whether we're in the scheduleFrameWrite loop
|
||||||
needToSendGoAway bool // we need to schedule a GOAWAY frame write
|
needToSendGoAway bool // we need to schedule a GOAWAY frame write
|
||||||
goAwayCode ErrCode
|
goAwayCode ErrCode
|
||||||
shutdownTimer *time.Timer // nil until used
|
shutdownTimer timer // nil until used
|
||||||
idleTimer *time.Timer // nil if unused
|
idleTimer timer // nil if unused
|
||||||
|
|
||||||
// Owned by the writeFrameAsync goroutine:
|
// Owned by the writeFrameAsync goroutine:
|
||||||
headerWriteBuf bytes.Buffer
|
headerWriteBuf bytes.Buffer
|
||||||
|
@ -652,8 +692,8 @@ type stream struct {
|
||||||
resetQueued bool // RST_STREAM queued for write; set by sc.resetStream
|
resetQueued bool // RST_STREAM queued for write; set by sc.resetStream
|
||||||
gotTrailerHeader bool // HEADER frame for trailers was seen
|
gotTrailerHeader bool // HEADER frame for trailers was seen
|
||||||
wroteHeaders bool // whether we wrote headers (not status 100)
|
wroteHeaders bool // whether we wrote headers (not status 100)
|
||||||
readDeadline *time.Timer // nil if unused
|
readDeadline timer // nil if unused
|
||||||
writeDeadline *time.Timer // nil if unused
|
writeDeadline timer // nil if unused
|
||||||
closeErr error // set before cw is closed
|
closeErr error // set before cw is closed
|
||||||
|
|
||||||
trailer http.Header // accumulated trailers
|
trailer http.Header // accumulated trailers
|
||||||
|
@ -811,8 +851,9 @@ type readFrameResult struct {
|
||||||
// consumer is done with the frame.
|
// consumer is done with the frame.
|
||||||
// It's run on its own goroutine.
|
// It's run on its own goroutine.
|
||||||
func (sc *serverConn) readFrames() {
|
func (sc *serverConn) readFrames() {
|
||||||
gate := make(gate)
|
sc.srv.markNewGoroutine()
|
||||||
gateDone := gate.Done
|
gate := make(chan struct{})
|
||||||
|
gateDone := func() { gate <- struct{}{} }
|
||||||
for {
|
for {
|
||||||
f, err := sc.framer.ReadFrame()
|
f, err := sc.framer.ReadFrame()
|
||||||
select {
|
select {
|
||||||
|
@ -843,6 +884,7 @@ type frameWriteResult struct {
|
||||||
// At most one goroutine can be running writeFrameAsync at a time per
|
// At most one goroutine can be running writeFrameAsync at a time per
|
||||||
// serverConn.
|
// serverConn.
|
||||||
func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest, wd *writeData) {
|
func (sc *serverConn) writeFrameAsync(wr FrameWriteRequest, wd *writeData) {
|
||||||
|
sc.srv.markNewGoroutine()
|
||||||
var err error
|
var err error
|
||||||
if wd == nil {
|
if wd == nil {
|
||||||
err = wr.write.writeFrame(sc)
|
err = wr.write.writeFrame(sc)
|
||||||
|
@ -922,13 +964,13 @@ func (sc *serverConn) serve() {
|
||||||
sc.setConnState(http.StateIdle)
|
sc.setConnState(http.StateIdle)
|
||||||
|
|
||||||
if sc.srv.IdleTimeout > 0 {
|
if sc.srv.IdleTimeout > 0 {
|
||||||
sc.idleTimer = time.AfterFunc(sc.srv.IdleTimeout, sc.onIdleTimer)
|
sc.idleTimer = sc.srv.afterFunc(sc.srv.IdleTimeout, sc.onIdleTimer)
|
||||||
defer sc.idleTimer.Stop()
|
defer sc.idleTimer.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
go sc.readFrames() // closed by defer sc.conn.Close above
|
go sc.readFrames() // closed by defer sc.conn.Close above
|
||||||
|
|
||||||
settingsTimer := time.AfterFunc(firstSettingsTimeout, sc.onSettingsTimer)
|
settingsTimer := sc.srv.afterFunc(firstSettingsTimeout, sc.onSettingsTimer)
|
||||||
defer settingsTimer.Stop()
|
defer settingsTimer.Stop()
|
||||||
|
|
||||||
loopNum := 0
|
loopNum := 0
|
||||||
|
@ -1057,10 +1099,10 @@ func (sc *serverConn) readPreface() error {
|
||||||
errc <- nil
|
errc <- nil
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
timer := time.NewTimer(prefaceTimeout) // TODO: configurable on *Server?
|
timer := sc.srv.newTimer(prefaceTimeout) // TODO: configurable on *Server?
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C():
|
||||||
return errPrefaceTimeout
|
return errPrefaceTimeout
|
||||||
case err := <-errc:
|
case err := <-errc:
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -1425,7 +1467,7 @@ func (sc *serverConn) goAway(code ErrCode) {
|
||||||
|
|
||||||
func (sc *serverConn) shutDownIn(d time.Duration) {
|
func (sc *serverConn) shutDownIn(d time.Duration) {
|
||||||
sc.serveG.check()
|
sc.serveG.check()
|
||||||
sc.shutdownTimer = time.AfterFunc(d, sc.onShutdownTimer)
|
sc.shutdownTimer = sc.srv.afterFunc(d, sc.onShutdownTimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *serverConn) resetStream(se StreamError) {
|
func (sc *serverConn) resetStream(se StreamError) {
|
||||||
|
@ -1639,7 +1681,7 @@ func (sc *serverConn) closeStream(st *stream, err error) {
|
||||||
delete(sc.streams, st.id)
|
delete(sc.streams, st.id)
|
||||||
if len(sc.streams) == 0 {
|
if len(sc.streams) == 0 {
|
||||||
sc.setConnState(http.StateIdle)
|
sc.setConnState(http.StateIdle)
|
||||||
if sc.srv.IdleTimeout > 0 {
|
if sc.srv.IdleTimeout > 0 && sc.idleTimer != nil {
|
||||||
sc.idleTimer.Reset(sc.srv.IdleTimeout)
|
sc.idleTimer.Reset(sc.srv.IdleTimeout)
|
||||||
}
|
}
|
||||||
if h1ServerKeepAlivesDisabled(sc.hs) {
|
if h1ServerKeepAlivesDisabled(sc.hs) {
|
||||||
|
@ -1661,6 +1703,7 @@ func (sc *serverConn) closeStream(st *stream, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
st.closeErr = err
|
st.closeErr = err
|
||||||
|
st.cancelCtx()
|
||||||
st.cw.Close() // signals Handler's CloseNotifier, unblocks writes, etc
|
st.cw.Close() // signals Handler's CloseNotifier, unblocks writes, etc
|
||||||
sc.writeSched.CloseStream(st.id)
|
sc.writeSched.CloseStream(st.id)
|
||||||
}
|
}
|
||||||
|
@ -2021,7 +2064,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error {
|
||||||
// (in Go 1.8), though. That's a more sane option anyway.
|
// (in Go 1.8), though. That's a more sane option anyway.
|
||||||
if sc.hs.ReadTimeout > 0 {
|
if sc.hs.ReadTimeout > 0 {
|
||||||
sc.conn.SetReadDeadline(time.Time{})
|
sc.conn.SetReadDeadline(time.Time{})
|
||||||
st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
|
st.readDeadline = sc.srv.afterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sc.scheduleHandler(id, rw, req, handler)
|
return sc.scheduleHandler(id, rw, req, handler)
|
||||||
|
@ -2119,7 +2162,7 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream
|
||||||
st.flow.add(sc.initialStreamSendWindowSize)
|
st.flow.add(sc.initialStreamSendWindowSize)
|
||||||
st.inflow.init(sc.srv.initialStreamRecvWindowSize())
|
st.inflow.init(sc.srv.initialStreamRecvWindowSize())
|
||||||
if sc.hs.WriteTimeout > 0 {
|
if sc.hs.WriteTimeout > 0 {
|
||||||
st.writeDeadline = time.AfterFunc(sc.hs.WriteTimeout, st.onWriteTimeout)
|
st.writeDeadline = sc.srv.afterFunc(sc.hs.WriteTimeout, st.onWriteTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
sc.streams[id] = st
|
sc.streams[id] = st
|
||||||
|
@ -2343,6 +2386,7 @@ func (sc *serverConn) handlerDone() {
|
||||||
|
|
||||||
// Run on its own goroutine.
|
// Run on its own goroutine.
|
||||||
func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) {
|
func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) {
|
||||||
|
sc.srv.markNewGoroutine()
|
||||||
defer sc.sendServeMsg(handlerDoneMsg)
|
defer sc.sendServeMsg(handlerDoneMsg)
|
||||||
didPanic := true
|
didPanic := true
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -2639,7 +2683,7 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) {
|
||||||
var date string
|
var date string
|
||||||
if _, ok := rws.snapHeader["Date"]; !ok {
|
if _, ok := rws.snapHeader["Date"]; !ok {
|
||||||
// TODO(bradfitz): be faster here, like net/http? measure.
|
// TODO(bradfitz): be faster here, like net/http? measure.
|
||||||
date = time.Now().UTC().Format(http.TimeFormat)
|
date = rws.conn.srv.now().UTC().Format(http.TimeFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range rws.snapHeader["Trailer"] {
|
for _, v := range rws.snapHeader["Trailer"] {
|
||||||
|
@ -2761,7 +2805,7 @@ func (rws *responseWriterState) promoteUndeclaredTrailers() {
|
||||||
|
|
||||||
func (w *responseWriter) SetReadDeadline(deadline time.Time) error {
|
func (w *responseWriter) SetReadDeadline(deadline time.Time) error {
|
||||||
st := w.rws.stream
|
st := w.rws.stream
|
||||||
if !deadline.IsZero() && deadline.Before(time.Now()) {
|
if !deadline.IsZero() && deadline.Before(w.rws.conn.srv.now()) {
|
||||||
// If we're setting a deadline in the past, reset the stream immediately
|
// If we're setting a deadline in the past, reset the stream immediately
|
||||||
// so writes after SetWriteDeadline returns will fail.
|
// so writes after SetWriteDeadline returns will fail.
|
||||||
st.onReadTimeout()
|
st.onReadTimeout()
|
||||||
|
@ -2777,9 +2821,9 @@ func (w *responseWriter) SetReadDeadline(deadline time.Time) error {
|
||||||
if deadline.IsZero() {
|
if deadline.IsZero() {
|
||||||
st.readDeadline = nil
|
st.readDeadline = nil
|
||||||
} else if st.readDeadline == nil {
|
} else if st.readDeadline == nil {
|
||||||
st.readDeadline = time.AfterFunc(deadline.Sub(time.Now()), st.onReadTimeout)
|
st.readDeadline = sc.srv.afterFunc(deadline.Sub(sc.srv.now()), st.onReadTimeout)
|
||||||
} else {
|
} else {
|
||||||
st.readDeadline.Reset(deadline.Sub(time.Now()))
|
st.readDeadline.Reset(deadline.Sub(sc.srv.now()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
@ -2787,7 +2831,7 @@ func (w *responseWriter) SetReadDeadline(deadline time.Time) error {
|
||||||
|
|
||||||
func (w *responseWriter) SetWriteDeadline(deadline time.Time) error {
|
func (w *responseWriter) SetWriteDeadline(deadline time.Time) error {
|
||||||
st := w.rws.stream
|
st := w.rws.stream
|
||||||
if !deadline.IsZero() && deadline.Before(time.Now()) {
|
if !deadline.IsZero() && deadline.Before(w.rws.conn.srv.now()) {
|
||||||
// If we're setting a deadline in the past, reset the stream immediately
|
// If we're setting a deadline in the past, reset the stream immediately
|
||||||
// so writes after SetWriteDeadline returns will fail.
|
// so writes after SetWriteDeadline returns will fail.
|
||||||
st.onWriteTimeout()
|
st.onWriteTimeout()
|
||||||
|
@ -2803,9 +2847,9 @@ func (w *responseWriter) SetWriteDeadline(deadline time.Time) error {
|
||||||
if deadline.IsZero() {
|
if deadline.IsZero() {
|
||||||
st.writeDeadline = nil
|
st.writeDeadline = nil
|
||||||
} else if st.writeDeadline == nil {
|
} else if st.writeDeadline == nil {
|
||||||
st.writeDeadline = time.AfterFunc(deadline.Sub(time.Now()), st.onWriteTimeout)
|
st.writeDeadline = sc.srv.afterFunc(deadline.Sub(sc.srv.now()), st.onWriteTimeout)
|
||||||
} else {
|
} else {
|
||||||
st.writeDeadline.Reset(deadline.Sub(time.Now()))
|
st.writeDeadline.Reset(deadline.Sub(sc.srv.now()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,331 +0,0 @@
|
||||||
// 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 (
|
|
||||||
"context"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// testSyncHooks coordinates goroutines in tests.
|
|
||||||
//
|
|
||||||
// For example, a call to ClientConn.RoundTrip involves several goroutines, including:
|
|
||||||
// - the goroutine running RoundTrip;
|
|
||||||
// - the clientStream.doRequest goroutine, which writes the request; and
|
|
||||||
// - the clientStream.readLoop goroutine, which reads the response.
|
|
||||||
//
|
|
||||||
// Using testSyncHooks, a test can start a RoundTrip and identify when all these goroutines
|
|
||||||
// are blocked waiting for some condition such as reading the Request.Body or waiting for
|
|
||||||
// flow control to become available.
|
|
||||||
//
|
|
||||||
// The testSyncHooks also manage timers and synthetic time in tests.
|
|
||||||
// This permits us to, for example, start a request and cause it to time out waiting for
|
|
||||||
// response headers without resorting to time.Sleep calls.
|
|
||||||
type testSyncHooks struct {
|
|
||||||
// active/inactive act as a mutex and condition variable.
|
|
||||||
//
|
|
||||||
// - neither chan contains a value: testSyncHooks is locked.
|
|
||||||
// - active contains a value: unlocked, and at least one goroutine is not blocked
|
|
||||||
// - inactive contains a value: unlocked, and all goroutines are blocked
|
|
||||||
active chan struct{}
|
|
||||||
inactive chan struct{}
|
|
||||||
|
|
||||||
// goroutine counts
|
|
||||||
total int // total goroutines
|
|
||||||
condwait map[*sync.Cond]int // blocked in sync.Cond.Wait
|
|
||||||
blocked []*testBlockedGoroutine // otherwise blocked
|
|
||||||
|
|
||||||
// fake time
|
|
||||||
now time.Time
|
|
||||||
timers []*fakeTimer
|
|
||||||
|
|
||||||
// Transport testing: Report various events.
|
|
||||||
newclientconn func(*ClientConn)
|
|
||||||
newstream func(*clientStream)
|
|
||||||
}
|
|
||||||
|
|
||||||
// testBlockedGoroutine is a blocked goroutine.
|
|
||||||
type testBlockedGoroutine struct {
|
|
||||||
f func() bool // blocked until f returns true
|
|
||||||
ch chan struct{} // closed when unblocked
|
|
||||||
}
|
|
||||||
|
|
||||||
func newTestSyncHooks() *testSyncHooks {
|
|
||||||
h := &testSyncHooks{
|
|
||||||
active: make(chan struct{}, 1),
|
|
||||||
inactive: make(chan struct{}, 1),
|
|
||||||
condwait: map[*sync.Cond]int{},
|
|
||||||
}
|
|
||||||
h.inactive <- struct{}{}
|
|
||||||
h.now = time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
|
|
||||||
return h
|
|
||||||
}
|
|
||||||
|
|
||||||
// lock acquires the testSyncHooks mutex.
|
|
||||||
func (h *testSyncHooks) lock() {
|
|
||||||
select {
|
|
||||||
case <-h.active:
|
|
||||||
case <-h.inactive:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// waitInactive waits for all goroutines to become inactive.
|
|
||||||
func (h *testSyncHooks) waitInactive() {
|
|
||||||
for {
|
|
||||||
<-h.inactive
|
|
||||||
if !h.unlock() {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// unlock releases the testSyncHooks mutex.
|
|
||||||
// It reports whether any goroutines are active.
|
|
||||||
func (h *testSyncHooks) unlock() (active bool) {
|
|
||||||
// Look for a blocked goroutine which can be unblocked.
|
|
||||||
blocked := h.blocked[:0]
|
|
||||||
unblocked := false
|
|
||||||
for _, b := range h.blocked {
|
|
||||||
if !unblocked && b.f() {
|
|
||||||
unblocked = true
|
|
||||||
close(b.ch)
|
|
||||||
} else {
|
|
||||||
blocked = append(blocked, b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h.blocked = blocked
|
|
||||||
|
|
||||||
// Count goroutines blocked on condition variables.
|
|
||||||
condwait := 0
|
|
||||||
for _, count := range h.condwait {
|
|
||||||
condwait += count
|
|
||||||
}
|
|
||||||
|
|
||||||
if h.total > condwait+len(blocked) {
|
|
||||||
h.active <- struct{}{}
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
h.inactive <- struct{}{}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// goRun starts a new goroutine.
|
|
||||||
func (h *testSyncHooks) goRun(f func()) {
|
|
||||||
h.lock()
|
|
||||||
h.total++
|
|
||||||
h.unlock()
|
|
||||||
go func() {
|
|
||||||
defer func() {
|
|
||||||
h.lock()
|
|
||||||
h.total--
|
|
||||||
h.unlock()
|
|
||||||
}()
|
|
||||||
f()
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
// blockUntil indicates that a goroutine is blocked waiting for some condition to become true.
|
|
||||||
// It waits until f returns true before proceeding.
|
|
||||||
//
|
|
||||||
// Example usage:
|
|
||||||
//
|
|
||||||
// h.blockUntil(func() bool {
|
|
||||||
// // Is the context done yet?
|
|
||||||
// select {
|
|
||||||
// case <-ctx.Done():
|
|
||||||
// default:
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// return true
|
|
||||||
// })
|
|
||||||
// // Wait for the context to become done.
|
|
||||||
// <-ctx.Done()
|
|
||||||
//
|
|
||||||
// The function f passed to blockUntil must be non-blocking and idempotent.
|
|
||||||
func (h *testSyncHooks) blockUntil(f func() bool) {
|
|
||||||
if f() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ch := make(chan struct{})
|
|
||||||
h.lock()
|
|
||||||
h.blocked = append(h.blocked, &testBlockedGoroutine{
|
|
||||||
f: f,
|
|
||||||
ch: ch,
|
|
||||||
})
|
|
||||||
h.unlock()
|
|
||||||
<-ch
|
|
||||||
}
|
|
||||||
|
|
||||||
// broadcast is sync.Cond.Broadcast.
|
|
||||||
func (h *testSyncHooks) condBroadcast(cond *sync.Cond) {
|
|
||||||
h.lock()
|
|
||||||
delete(h.condwait, cond)
|
|
||||||
h.unlock()
|
|
||||||
cond.Broadcast()
|
|
||||||
}
|
|
||||||
|
|
||||||
// broadcast is sync.Cond.Wait.
|
|
||||||
func (h *testSyncHooks) condWait(cond *sync.Cond) {
|
|
||||||
h.lock()
|
|
||||||
h.condwait[cond]++
|
|
||||||
h.unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// newTimer creates a new fake timer.
|
|
||||||
func (h *testSyncHooks) newTimer(d time.Duration) timer {
|
|
||||||
h.lock()
|
|
||||||
defer h.unlock()
|
|
||||||
t := &fakeTimer{
|
|
||||||
hooks: h,
|
|
||||||
when: h.now.Add(d),
|
|
||||||
c: make(chan time.Time),
|
|
||||||
}
|
|
||||||
h.timers = append(h.timers, t)
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
// afterFunc creates a new fake AfterFunc timer.
|
|
||||||
func (h *testSyncHooks) afterFunc(d time.Duration, f func()) timer {
|
|
||||||
h.lock()
|
|
||||||
defer h.unlock()
|
|
||||||
t := &fakeTimer{
|
|
||||||
hooks: h,
|
|
||||||
when: h.now.Add(d),
|
|
||||||
f: f,
|
|
||||||
}
|
|
||||||
h.timers = append(h.timers, t)
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *testSyncHooks) contextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) {
|
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
|
||||||
t := h.afterFunc(d, cancel)
|
|
||||||
return ctx, func() {
|
|
||||||
t.Stop()
|
|
||||||
cancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *testSyncHooks) timeUntilEvent() time.Duration {
|
|
||||||
h.lock()
|
|
||||||
defer h.unlock()
|
|
||||||
var next time.Time
|
|
||||||
for _, t := range h.timers {
|
|
||||||
if next.IsZero() || t.when.Before(next) {
|
|
||||||
next = t.when
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if d := next.Sub(h.now); d > 0 {
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// advance advances time and causes synthetic timers to fire.
|
|
||||||
func (h *testSyncHooks) advance(d time.Duration) {
|
|
||||||
h.lock()
|
|
||||||
defer h.unlock()
|
|
||||||
h.now = h.now.Add(d)
|
|
||||||
timers := h.timers[:0]
|
|
||||||
for _, t := range h.timers {
|
|
||||||
t := t // remove after go.mod depends on go1.22
|
|
||||||
t.mu.Lock()
|
|
||||||
switch {
|
|
||||||
case t.when.After(h.now):
|
|
||||||
timers = append(timers, t)
|
|
||||||
case t.when.IsZero():
|
|
||||||
// stopped timer
|
|
||||||
default:
|
|
||||||
t.when = time.Time{}
|
|
||||||
if t.c != nil {
|
|
||||||
close(t.c)
|
|
||||||
}
|
|
||||||
if t.f != nil {
|
|
||||||
h.total++
|
|
||||||
go func() {
|
|
||||||
defer func() {
|
|
||||||
h.lock()
|
|
||||||
h.total--
|
|
||||||
h.unlock()
|
|
||||||
}()
|
|
||||||
t.f()
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t.mu.Unlock()
|
|
||||||
}
|
|
||||||
h.timers = timers
|
|
||||||
}
|
|
||||||
|
|
||||||
// A timer wraps a time.Timer, or a synthetic equivalent in tests.
|
|
||||||
// Unlike time.Timer, timer is single-use: The timer channel is closed when the timer expires.
|
|
||||||
type timer interface {
|
|
||||||
C() <-chan time.Time
|
|
||||||
Stop() bool
|
|
||||||
Reset(d time.Duration) bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// timeTimer implements timer using real time.
|
|
||||||
type timeTimer struct {
|
|
||||||
t *time.Timer
|
|
||||||
c chan time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
// newTimeTimer creates a new timer using real time.
|
|
||||||
func newTimeTimer(d time.Duration) timer {
|
|
||||||
ch := make(chan time.Time)
|
|
||||||
t := time.AfterFunc(d, func() {
|
|
||||||
close(ch)
|
|
||||||
})
|
|
||||||
return &timeTimer{t, ch}
|
|
||||||
}
|
|
||||||
|
|
||||||
// newTimeAfterFunc creates an AfterFunc timer using real time.
|
|
||||||
func newTimeAfterFunc(d time.Duration, f func()) timer {
|
|
||||||
return &timeTimer{
|
|
||||||
t: time.AfterFunc(d, f),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t timeTimer) C() <-chan time.Time { return t.c }
|
|
||||||
func (t timeTimer) Stop() bool { return t.t.Stop() }
|
|
||||||
func (t timeTimer) Reset(d time.Duration) bool { return t.t.Reset(d) }
|
|
||||||
|
|
||||||
// fakeTimer implements timer using fake time.
|
|
||||||
type fakeTimer struct {
|
|
||||||
hooks *testSyncHooks
|
|
||||||
|
|
||||||
mu sync.Mutex
|
|
||||||
when time.Time // when the timer will fire
|
|
||||||
c chan time.Time // closed when the timer fires; mutually exclusive with f
|
|
||||||
f func() // called when the timer fires; mutually exclusive with c
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *fakeTimer) C() <-chan time.Time { return t.c }
|
|
||||||
|
|
||||||
func (t *fakeTimer) Stop() bool {
|
|
||||||
t.mu.Lock()
|
|
||||||
defer t.mu.Unlock()
|
|
||||||
stopped := t.when.IsZero()
|
|
||||||
t.when = time.Time{}
|
|
||||||
return stopped
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *fakeTimer) Reset(d time.Duration) bool {
|
|
||||||
if t.c != nil || t.f == nil {
|
|
||||||
panic("fakeTimer only supports Reset on AfterFunc timers")
|
|
||||||
}
|
|
||||||
t.mu.Lock()
|
|
||||||
defer t.mu.Unlock()
|
|
||||||
t.hooks.lock()
|
|
||||||
defer t.hooks.unlock()
|
|
||||||
active := !t.when.IsZero()
|
|
||||||
t.when = t.hooks.now.Add(d)
|
|
||||||
if !active {
|
|
||||||
t.hooks.timers = append(t.hooks.timers, t)
|
|
||||||
}
|
|
||||||
return active
|
|
||||||
}
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// 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 "time"
|
||||||
|
|
||||||
|
// A timer is a time.Timer, as an interface which can be replaced in tests.
|
||||||
|
type timer = interface {
|
||||||
|
C() <-chan time.Time
|
||||||
|
Reset(d time.Duration) bool
|
||||||
|
Stop() bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// timeTimer adapts a time.Timer to the timer interface.
|
||||||
|
type timeTimer struct {
|
||||||
|
*time.Timer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t timeTimer) C() <-chan time.Time { return t.Timer.C }
|
|
@ -185,7 +185,45 @@ type Transport struct {
|
||||||
connPoolOnce sync.Once
|
connPoolOnce sync.Once
|
||||||
connPoolOrDef ClientConnPool // non-nil version of ConnPool
|
connPoolOrDef ClientConnPool // non-nil version of ConnPool
|
||||||
|
|
||||||
syncHooks *testSyncHooks
|
*transportTestHooks
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook points used for testing.
|
||||||
|
// Outside of tests, t.transportTestHooks is nil and these all have minimal implementations.
|
||||||
|
// Inside tests, see the testSyncHooks function docs.
|
||||||
|
|
||||||
|
type transportTestHooks struct {
|
||||||
|
newclientconn func(*ClientConn)
|
||||||
|
group synctestGroupInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Transport) markNewGoroutine() {
|
||||||
|
if t != nil && t.transportTestHooks != nil {
|
||||||
|
t.transportTestHooks.group.Join()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// newTimer creates a new time.Timer, or a synthetic timer in tests.
|
||||||
|
func (t *Transport) newTimer(d time.Duration) timer {
|
||||||
|
if t.transportTestHooks != nil {
|
||||||
|
return t.transportTestHooks.group.NewTimer(d)
|
||||||
|
}
|
||||||
|
return timeTimer{time.NewTimer(d)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// afterFunc creates a new time.AfterFunc timer, or a synthetic timer in tests.
|
||||||
|
func (t *Transport) afterFunc(d time.Duration, f func()) timer {
|
||||||
|
if t.transportTestHooks != nil {
|
||||||
|
return t.transportTestHooks.group.AfterFunc(d, f)
|
||||||
|
}
|
||||||
|
return timeTimer{time.AfterFunc(d, f)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Transport) contextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) {
|
||||||
|
if t.transportTestHooks != nil {
|
||||||
|
return t.transportTestHooks.group.ContextWithTimeout(ctx, d)
|
||||||
|
}
|
||||||
|
return context.WithTimeout(ctx, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) maxHeaderListSize() uint32 {
|
func (t *Transport) maxHeaderListSize() uint32 {
|
||||||
|
@ -352,60 +390,6 @@ type ClientConn struct {
|
||||||
werr error // first write error that has occurred
|
werr error // first write error that has occurred
|
||||||
hbuf bytes.Buffer // HPACK encoder writes into this
|
hbuf bytes.Buffer // HPACK encoder writes into this
|
||||||
henc *hpack.Encoder
|
henc *hpack.Encoder
|
||||||
|
|
||||||
syncHooks *testSyncHooks // can be nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook points used for testing.
|
|
||||||
// Outside of tests, cc.syncHooks is nil and these all have minimal implementations.
|
|
||||||
// Inside tests, see the testSyncHooks function docs.
|
|
||||||
|
|
||||||
// goRun starts a new goroutine.
|
|
||||||
func (cc *ClientConn) goRun(f func()) {
|
|
||||||
if cc.syncHooks != nil {
|
|
||||||
cc.syncHooks.goRun(f)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go f()
|
|
||||||
}
|
|
||||||
|
|
||||||
// condBroadcast is cc.cond.Broadcast.
|
|
||||||
func (cc *ClientConn) condBroadcast() {
|
|
||||||
if cc.syncHooks != nil {
|
|
||||||
cc.syncHooks.condBroadcast(cc.cond)
|
|
||||||
}
|
|
||||||
cc.cond.Broadcast()
|
|
||||||
}
|
|
||||||
|
|
||||||
// condWait is cc.cond.Wait.
|
|
||||||
func (cc *ClientConn) condWait() {
|
|
||||||
if cc.syncHooks != nil {
|
|
||||||
cc.syncHooks.condWait(cc.cond)
|
|
||||||
}
|
|
||||||
cc.cond.Wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
// newTimer creates a new time.Timer, or a synthetic timer in tests.
|
|
||||||
func (cc *ClientConn) newTimer(d time.Duration) timer {
|
|
||||||
if cc.syncHooks != nil {
|
|
||||||
return cc.syncHooks.newTimer(d)
|
|
||||||
}
|
|
||||||
return newTimeTimer(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
// afterFunc creates a new time.AfterFunc timer, or a synthetic timer in tests.
|
|
||||||
func (cc *ClientConn) afterFunc(d time.Duration, f func()) timer {
|
|
||||||
if cc.syncHooks != nil {
|
|
||||||
return cc.syncHooks.afterFunc(d, f)
|
|
||||||
}
|
|
||||||
return newTimeAfterFunc(d, f)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cc *ClientConn) contextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) {
|
|
||||||
if cc.syncHooks != nil {
|
|
||||||
return cc.syncHooks.contextWithTimeout(ctx, d)
|
|
||||||
}
|
|
||||||
return context.WithTimeout(ctx, d)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// clientStream is the state for a single HTTP/2 stream. One of these
|
// clientStream is the state for a single HTTP/2 stream. One of these
|
||||||
|
@ -487,7 +471,7 @@ func (cs *clientStream) abortStreamLocked(err error) {
|
||||||
// TODO(dneil): Clean up tests where cs.cc.cond is nil.
|
// TODO(dneil): Clean up tests where cs.cc.cond is nil.
|
||||||
if cs.cc.cond != nil {
|
if cs.cc.cond != nil {
|
||||||
// Wake up writeRequestBody if it is waiting on flow control.
|
// Wake up writeRequestBody if it is waiting on flow control.
|
||||||
cs.cc.condBroadcast()
|
cs.cc.cond.Broadcast()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +481,7 @@ func (cs *clientStream) abortRequestBodyWrite() {
|
||||||
defer cc.mu.Unlock()
|
defer cc.mu.Unlock()
|
||||||
if cs.reqBody != nil && cs.reqBodyClosed == nil {
|
if cs.reqBody != nil && cs.reqBodyClosed == nil {
|
||||||
cs.closeReqBodyLocked()
|
cs.closeReqBodyLocked()
|
||||||
cc.condBroadcast()
|
cc.cond.Broadcast()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,10 +491,11 @@ func (cs *clientStream) closeReqBodyLocked() {
|
||||||
}
|
}
|
||||||
cs.reqBodyClosed = make(chan struct{})
|
cs.reqBodyClosed = make(chan struct{})
|
||||||
reqBodyClosed := cs.reqBodyClosed
|
reqBodyClosed := cs.reqBodyClosed
|
||||||
cs.cc.goRun(func() {
|
go func() {
|
||||||
|
cs.cc.t.markNewGoroutine()
|
||||||
cs.reqBody.Close()
|
cs.reqBody.Close()
|
||||||
close(reqBodyClosed)
|
close(reqBodyClosed)
|
||||||
})
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
type stickyErrWriter struct {
|
type stickyErrWriter struct {
|
||||||
|
@ -626,21 +611,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
|
||||||
backoff := float64(uint(1) << (uint(retry) - 1))
|
backoff := float64(uint(1) << (uint(retry) - 1))
|
||||||
backoff += backoff * (0.1 * mathrand.Float64())
|
backoff += backoff * (0.1 * mathrand.Float64())
|
||||||
d := time.Second * time.Duration(backoff)
|
d := time.Second * time.Duration(backoff)
|
||||||
var tm timer
|
tm := t.newTimer(d)
|
||||||
if t.syncHooks != nil {
|
|
||||||
tm = t.syncHooks.newTimer(d)
|
|
||||||
t.syncHooks.blockUntil(func() bool {
|
|
||||||
select {
|
|
||||||
case <-tm.C():
|
|
||||||
case <-req.Context().Done():
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
tm = newTimeTimer(d)
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case <-tm.C():
|
case <-tm.C():
|
||||||
t.vlogf("RoundTrip retrying after failure: %v", roundTripErr)
|
t.vlogf("RoundTrip retrying after failure: %v", roundTripErr)
|
||||||
|
@ -725,8 +696,8 @@ func canRetryError(err error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse bool) (*ClientConn, error) {
|
func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse bool) (*ClientConn, error) {
|
||||||
if t.syncHooks != nil {
|
if t.transportTestHooks != nil {
|
||||||
return t.newClientConn(nil, singleUse, t.syncHooks)
|
return t.newClientConn(nil, singleUse)
|
||||||
}
|
}
|
||||||
host, _, err := net.SplitHostPort(addr)
|
host, _, err := net.SplitHostPort(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -736,7 +707,7 @@ func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse b
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return t.newClientConn(tconn, singleUse, nil)
|
return t.newClientConn(tconn, singleUse)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) newTLSConfig(host string) *tls.Config {
|
func (t *Transport) newTLSConfig(host string) *tls.Config {
|
||||||
|
@ -802,10 +773,10 @@ func (t *Transport) maxEncoderHeaderTableSize() uint32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) {
|
func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) {
|
||||||
return t.newClientConn(c, t.disableKeepAlives(), nil)
|
return t.newClientConn(c, t.disableKeepAlives())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) newClientConn(c net.Conn, singleUse bool, hooks *testSyncHooks) (*ClientConn, error) {
|
func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) {
|
||||||
cc := &ClientConn{
|
cc := &ClientConn{
|
||||||
t: t,
|
t: t,
|
||||||
tconn: c,
|
tconn: c,
|
||||||
|
@ -820,16 +791,12 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool, hooks *testSyncHoo
|
||||||
wantSettingsAck: true,
|
wantSettingsAck: true,
|
||||||
pings: make(map[[8]byte]chan struct{}),
|
pings: make(map[[8]byte]chan struct{}),
|
||||||
reqHeaderMu: make(chan struct{}, 1),
|
reqHeaderMu: make(chan struct{}, 1),
|
||||||
syncHooks: hooks,
|
|
||||||
}
|
}
|
||||||
if hooks != nil {
|
if t.transportTestHooks != nil {
|
||||||
hooks.newclientconn(cc)
|
t.markNewGoroutine()
|
||||||
|
t.transportTestHooks.newclientconn(cc)
|
||||||
c = cc.tconn
|
c = cc.tconn
|
||||||
}
|
}
|
||||||
if d := t.idleConnTimeout(); d != 0 {
|
|
||||||
cc.idleTimeout = d
|
|
||||||
cc.idleTimer = cc.afterFunc(d, cc.onIdleTimeout)
|
|
||||||
}
|
|
||||||
if VerboseLogs {
|
if VerboseLogs {
|
||||||
t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr())
|
t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr())
|
||||||
}
|
}
|
||||||
|
@ -860,10 +827,6 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool, hooks *testSyncHoo
|
||||||
cc.henc.SetMaxDynamicTableSizeLimit(t.maxEncoderHeaderTableSize())
|
cc.henc.SetMaxDynamicTableSizeLimit(t.maxEncoderHeaderTableSize())
|
||||||
cc.peerMaxHeaderTableSize = initialHeaderTableSize
|
cc.peerMaxHeaderTableSize = initialHeaderTableSize
|
||||||
|
|
||||||
if t.AllowHTTP {
|
|
||||||
cc.nextStreamID = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
if cs, ok := c.(connectionStater); ok {
|
if cs, ok := c.(connectionStater); ok {
|
||||||
state := cs.ConnectionState()
|
state := cs.ConnectionState()
|
||||||
cc.tlsState = &state
|
cc.tlsState = &state
|
||||||
|
@ -893,7 +856,13 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool, hooks *testSyncHoo
|
||||||
return nil, cc.werr
|
return nil, cc.werr
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.goRun(cc.readLoop)
|
// Start the idle timer after the connection is fully initialized.
|
||||||
|
if d := t.idleConnTimeout(); d != 0 {
|
||||||
|
cc.idleTimeout = d
|
||||||
|
cc.idleTimer = t.afterFunc(d, cc.onIdleTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
go cc.readLoop()
|
||||||
return cc, nil
|
return cc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,7 +870,7 @@ func (cc *ClientConn) healthCheck() {
|
||||||
pingTimeout := cc.t.pingTimeout()
|
pingTimeout := cc.t.pingTimeout()
|
||||||
// We don't need to periodically ping in the health check, because the readLoop of ClientConn will
|
// We don't need to periodically ping in the health check, because the readLoop of ClientConn will
|
||||||
// trigger the healthCheck again if there is no frame received.
|
// trigger the healthCheck again if there is no frame received.
|
||||||
ctx, cancel := cc.contextWithTimeout(context.Background(), pingTimeout)
|
ctx, cancel := cc.t.contextWithTimeout(context.Background(), pingTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
cc.vlogf("http2: Transport sending health check")
|
cc.vlogf("http2: Transport sending health check")
|
||||||
err := cc.Ping(ctx)
|
err := cc.Ping(ctx)
|
||||||
|
@ -1144,7 +1113,8 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error {
|
||||||
// Wait for all in-flight streams to complete or connection to close
|
// Wait for all in-flight streams to complete or connection to close
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
cancelled := false // guarded by cc.mu
|
cancelled := false // guarded by cc.mu
|
||||||
cc.goRun(func() {
|
go func() {
|
||||||
|
cc.t.markNewGoroutine()
|
||||||
cc.mu.Lock()
|
cc.mu.Lock()
|
||||||
defer cc.mu.Unlock()
|
defer cc.mu.Unlock()
|
||||||
for {
|
for {
|
||||||
|
@ -1156,9 +1126,9 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error {
|
||||||
if cancelled {
|
if cancelled {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
cc.condWait()
|
cc.cond.Wait()
|
||||||
}
|
}
|
||||||
})
|
}()
|
||||||
shutdownEnterWaitStateHook()
|
shutdownEnterWaitStateHook()
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
|
@ -1168,7 +1138,7 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error {
|
||||||
cc.mu.Lock()
|
cc.mu.Lock()
|
||||||
// Free the goroutine above
|
// Free the goroutine above
|
||||||
cancelled = true
|
cancelled = true
|
||||||
cc.condBroadcast()
|
cc.cond.Broadcast()
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
@ -1206,7 +1176,7 @@ func (cc *ClientConn) closeForError(err error) {
|
||||||
for _, cs := range cc.streams {
|
for _, cs := range cc.streams {
|
||||||
cs.abortStreamLocked(err)
|
cs.abortStreamLocked(err)
|
||||||
}
|
}
|
||||||
cc.condBroadcast()
|
cc.cond.Broadcast()
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
cc.closeConn()
|
cc.closeConn()
|
||||||
}
|
}
|
||||||
|
@ -1321,23 +1291,30 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream))
|
||||||
respHeaderRecv: make(chan struct{}),
|
respHeaderRecv: make(chan struct{}),
|
||||||
donec: make(chan struct{}),
|
donec: make(chan struct{}),
|
||||||
}
|
}
|
||||||
cc.goRun(func() {
|
|
||||||
cs.doRequest(req)
|
// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
|
||||||
})
|
if !cc.t.disableCompression() &&
|
||||||
|
req.Header.Get("Accept-Encoding") == "" &&
|
||||||
|
req.Header.Get("Range") == "" &&
|
||||||
|
!cs.isHead {
|
||||||
|
// Request gzip only, not deflate. Deflate is ambiguous and
|
||||||
|
// not as universally supported anyway.
|
||||||
|
// See: https://zlib.net/zlib_faq.html#faq39
|
||||||
|
//
|
||||||
|
// Note that we don't request this for HEAD requests,
|
||||||
|
// due to a bug in nginx:
|
||||||
|
// http://trac.nginx.org/nginx/ticket/358
|
||||||
|
// https://golang.org/issue/5522
|
||||||
|
//
|
||||||
|
// We don't request gzip if the request is for a range, since
|
||||||
|
// auto-decoding a portion of a gzipped document will just fail
|
||||||
|
// anyway. See https://golang.org/issue/8923
|
||||||
|
cs.requestedGzip = true
|
||||||
|
}
|
||||||
|
|
||||||
|
go cs.doRequest(req, streamf)
|
||||||
|
|
||||||
waitDone := func() error {
|
waitDone := func() error {
|
||||||
if cc.syncHooks != nil {
|
|
||||||
cc.syncHooks.blockUntil(func() bool {
|
|
||||||
select {
|
|
||||||
case <-cs.donec:
|
|
||||||
case <-ctx.Done():
|
|
||||||
case <-cs.reqCancel:
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case <-cs.donec:
|
case <-cs.donec:
|
||||||
return nil
|
return nil
|
||||||
|
@ -1398,24 +1375,7 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if streamf != nil {
|
|
||||||
streamf(cs)
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if cc.syncHooks != nil {
|
|
||||||
cc.syncHooks.blockUntil(func() bool {
|
|
||||||
select {
|
|
||||||
case <-cs.respHeaderRecv:
|
|
||||||
case <-cs.abort:
|
|
||||||
case <-ctx.Done():
|
|
||||||
case <-cs.reqCancel:
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case <-cs.respHeaderRecv:
|
case <-cs.respHeaderRecv:
|
||||||
return handleResponseHeaders()
|
return handleResponseHeaders()
|
||||||
|
@ -1445,8 +1405,9 @@ func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream))
|
||||||
// doRequest runs for the duration of the request lifetime.
|
// doRequest runs for the duration of the request lifetime.
|
||||||
//
|
//
|
||||||
// It sends the request and performs post-request cleanup (closing Request.Body, etc.).
|
// It sends the request and performs post-request cleanup (closing Request.Body, etc.).
|
||||||
func (cs *clientStream) doRequest(req *http.Request) {
|
func (cs *clientStream) doRequest(req *http.Request, streamf func(*clientStream)) {
|
||||||
err := cs.writeRequest(req)
|
cs.cc.t.markNewGoroutine()
|
||||||
|
err := cs.writeRequest(req, streamf)
|
||||||
cs.cleanupWriteRequest(err)
|
cs.cleanupWriteRequest(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1457,7 +1418,7 @@ func (cs *clientStream) doRequest(req *http.Request) {
|
||||||
//
|
//
|
||||||
// It returns non-nil if the request ends otherwise.
|
// It returns non-nil if the request ends otherwise.
|
||||||
// If the returned error is StreamError, the error Code may be used in resetting the stream.
|
// If the returned error is StreamError, the error Code may be used in resetting the stream.
|
||||||
func (cs *clientStream) writeRequest(req *http.Request) (err error) {
|
func (cs *clientStream) writeRequest(req *http.Request, streamf func(*clientStream)) (err error) {
|
||||||
cc := cs.cc
|
cc := cs.cc
|
||||||
ctx := cs.ctx
|
ctx := cs.ctx
|
||||||
|
|
||||||
|
@ -1471,21 +1432,6 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) {
|
||||||
if cc.reqHeaderMu == nil {
|
if cc.reqHeaderMu == nil {
|
||||||
panic("RoundTrip on uninitialized ClientConn") // for tests
|
panic("RoundTrip on uninitialized ClientConn") // for tests
|
||||||
}
|
}
|
||||||
var newStreamHook func(*clientStream)
|
|
||||||
if cc.syncHooks != nil {
|
|
||||||
newStreamHook = cc.syncHooks.newstream
|
|
||||||
cc.syncHooks.blockUntil(func() bool {
|
|
||||||
select {
|
|
||||||
case cc.reqHeaderMu <- struct{}{}:
|
|
||||||
<-cc.reqHeaderMu
|
|
||||||
case <-cs.reqCancel:
|
|
||||||
case <-ctx.Done():
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case cc.reqHeaderMu <- struct{}{}:
|
case cc.reqHeaderMu <- struct{}{}:
|
||||||
case <-cs.reqCancel:
|
case <-cs.reqCancel:
|
||||||
|
@ -1510,28 +1456,8 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) {
|
||||||
}
|
}
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
|
|
||||||
if newStreamHook != nil {
|
if streamf != nil {
|
||||||
newStreamHook(cs)
|
streamf(cs)
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
|
|
||||||
if !cc.t.disableCompression() &&
|
|
||||||
req.Header.Get("Accept-Encoding") == "" &&
|
|
||||||
req.Header.Get("Range") == "" &&
|
|
||||||
!cs.isHead {
|
|
||||||
// Request gzip only, not deflate. Deflate is ambiguous and
|
|
||||||
// not as universally supported anyway.
|
|
||||||
// See: https://zlib.net/zlib_faq.html#faq39
|
|
||||||
//
|
|
||||||
// Note that we don't request this for HEAD requests,
|
|
||||||
// due to a bug in nginx:
|
|
||||||
// http://trac.nginx.org/nginx/ticket/358
|
|
||||||
// https://golang.org/issue/5522
|
|
||||||
//
|
|
||||||
// We don't request gzip if the request is for a range, since
|
|
||||||
// auto-decoding a portion of a gzipped document will just fail
|
|
||||||
// anyway. See https://golang.org/issue/8923
|
|
||||||
cs.requestedGzip = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
continueTimeout := cc.t.expectContinueTimeout()
|
continueTimeout := cc.t.expectContinueTimeout()
|
||||||
|
@ -1594,7 +1520,7 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) {
|
||||||
var respHeaderTimer <-chan time.Time
|
var respHeaderTimer <-chan time.Time
|
||||||
var respHeaderRecv chan struct{}
|
var respHeaderRecv chan struct{}
|
||||||
if d := cc.responseHeaderTimeout(); d != 0 {
|
if d := cc.responseHeaderTimeout(); d != 0 {
|
||||||
timer := cc.newTimer(d)
|
timer := cc.t.newTimer(d)
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
respHeaderTimer = timer.C()
|
respHeaderTimer = timer.C()
|
||||||
respHeaderRecv = cs.respHeaderRecv
|
respHeaderRecv = cs.respHeaderRecv
|
||||||
|
@ -1603,21 +1529,6 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) {
|
||||||
// or until the request is aborted (via context, error, or otherwise),
|
// or until the request is aborted (via context, error, or otherwise),
|
||||||
// whichever comes first.
|
// whichever comes first.
|
||||||
for {
|
for {
|
||||||
if cc.syncHooks != nil {
|
|
||||||
cc.syncHooks.blockUntil(func() bool {
|
|
||||||
select {
|
|
||||||
case <-cs.peerClosed:
|
|
||||||
case <-respHeaderTimer:
|
|
||||||
case <-respHeaderRecv:
|
|
||||||
case <-cs.abort:
|
|
||||||
case <-ctx.Done():
|
|
||||||
case <-cs.reqCancel:
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case <-cs.peerClosed:
|
case <-cs.peerClosed:
|
||||||
return nil
|
return nil
|
||||||
|
@ -1766,7 +1677,7 @@ func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cc.pendingRequests++
|
cc.pendingRequests++
|
||||||
cc.condWait()
|
cc.cond.Wait()
|
||||||
cc.pendingRequests--
|
cc.pendingRequests--
|
||||||
select {
|
select {
|
||||||
case <-cs.abort:
|
case <-cs.abort:
|
||||||
|
@ -2028,7 +1939,7 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error)
|
||||||
cs.flow.take(take)
|
cs.flow.take(take)
|
||||||
return take, nil
|
return take, nil
|
||||||
}
|
}
|
||||||
cc.condWait()
|
cc.cond.Wait()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2311,7 +2222,7 @@ func (cc *ClientConn) forgetStreamID(id uint32) {
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
cc.condBroadcast()
|
cc.cond.Broadcast()
|
||||||
|
|
||||||
closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil
|
closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil
|
||||||
if closeOnIdle && cc.streamsReserved == 0 && len(cc.streams) == 0 {
|
if closeOnIdle && cc.streamsReserved == 0 && len(cc.streams) == 0 {
|
||||||
|
@ -2333,6 +2244,7 @@ type clientConnReadLoop struct {
|
||||||
|
|
||||||
// readLoop runs in its own goroutine and reads and dispatches frames.
|
// readLoop runs in its own goroutine and reads and dispatches frames.
|
||||||
func (cc *ClientConn) readLoop() {
|
func (cc *ClientConn) readLoop() {
|
||||||
|
cc.t.markNewGoroutine()
|
||||||
rl := &clientConnReadLoop{cc: cc}
|
rl := &clientConnReadLoop{cc: cc}
|
||||||
defer rl.cleanup()
|
defer rl.cleanup()
|
||||||
cc.readerErr = rl.run()
|
cc.readerErr = rl.run()
|
||||||
|
@ -2399,7 +2311,7 @@ func (rl *clientConnReadLoop) cleanup() {
|
||||||
cs.abortStreamLocked(err)
|
cs.abortStreamLocked(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cc.condBroadcast()
|
cc.cond.Broadcast()
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2436,7 +2348,7 @@ func (rl *clientConnReadLoop) run() error {
|
||||||
readIdleTimeout := cc.t.ReadIdleTimeout
|
readIdleTimeout := cc.t.ReadIdleTimeout
|
||||||
var t timer
|
var t timer
|
||||||
if readIdleTimeout != 0 {
|
if readIdleTimeout != 0 {
|
||||||
t = cc.afterFunc(readIdleTimeout, cc.healthCheck)
|
t = cc.t.afterFunc(readIdleTimeout, cc.healthCheck)
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
f, err := cc.fr.ReadFrame()
|
f, err := cc.fr.ReadFrame()
|
||||||
|
@ -3034,7 +2946,7 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
|
||||||
for _, cs := range cc.streams {
|
for _, cs := range cc.streams {
|
||||||
cs.flow.add(delta)
|
cs.flow.add(delta)
|
||||||
}
|
}
|
||||||
cc.condBroadcast()
|
cc.cond.Broadcast()
|
||||||
|
|
||||||
cc.initialWindowSize = s.Val
|
cc.initialWindowSize = s.Val
|
||||||
case SettingHeaderTableSize:
|
case SettingHeaderTableSize:
|
||||||
|
@ -3089,7 +3001,7 @@ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
|
||||||
|
|
||||||
return ConnectionError(ErrCodeFlowControl)
|
return ConnectionError(ErrCodeFlowControl)
|
||||||
}
|
}
|
||||||
cc.condBroadcast()
|
cc.cond.Broadcast()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3133,7 +3045,8 @@ func (cc *ClientConn) Ping(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
var pingError error
|
var pingError error
|
||||||
errc := make(chan struct{})
|
errc := make(chan struct{})
|
||||||
cc.goRun(func() {
|
go func() {
|
||||||
|
cc.t.markNewGoroutine()
|
||||||
cc.wmu.Lock()
|
cc.wmu.Lock()
|
||||||
defer cc.wmu.Unlock()
|
defer cc.wmu.Unlock()
|
||||||
if pingError = cc.fr.WritePing(false, p); pingError != nil {
|
if pingError = cc.fr.WritePing(false, p); pingError != nil {
|
||||||
|
@ -3144,20 +3057,7 @@ func (cc *ClientConn) Ping(ctx context.Context) error {
|
||||||
close(errc)
|
close(errc)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
}()
|
||||||
if cc.syncHooks != nil {
|
|
||||||
cc.syncHooks.blockUntil(func() bool {
|
|
||||||
select {
|
|
||||||
case <-c:
|
|
||||||
case <-errc:
|
|
||||||
case <-ctx.Done():
|
|
||||||
case <-cc.readerDone:
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case <-c:
|
case <-c:
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -443,8 +443,8 @@ func (ws *priorityWriteScheduler) addClosedOrIdleNode(list *[]*priorityNode, max
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *priorityWriteScheduler) removeNode(n *priorityNode) {
|
func (ws *priorityWriteScheduler) removeNode(n *priorityNode) {
|
||||||
for k := n.kids; k != nil; k = k.next {
|
for n.kids != nil {
|
||||||
k.setParent(n.parent)
|
n.kids.setParent(n.parent)
|
||||||
}
|
}
|
||||||
n.setParent(nil)
|
n.setParent(nil)
|
||||||
delete(ws.nodes, n.id)
|
delete(ws.nodes, n.id)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ includes_Darwin='
|
||||||
#define _DARWIN_USE_64_BIT_INODE
|
#define _DARWIN_USE_64_BIT_INODE
|
||||||
#define __APPLE_USE_RFC_3542
|
#define __APPLE_USE_RFC_3542
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <sys/stdio.h>
|
||||||
#include <sys/attr.h>
|
#include <sys/attr.h>
|
||||||
#include <sys/clonefile.h>
|
#include <sys/clonefile.h>
|
||||||
#include <sys/kern_control.h>
|
#include <sys/kern_control.h>
|
||||||
|
|
|
@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error {
|
||||||
return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq))
|
return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys renamexNp(from string, to string, flag uint32) (err error)
|
||||||
|
|
||||||
|
func RenamexNp(from string, to string, flag uint32) (err error) {
|
||||||
|
return renamexNp(from, to, flag)
|
||||||
|
}
|
||||||
|
|
||||||
|
//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error)
|
||||||
|
|
||||||
|
func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) {
|
||||||
|
return renameatxNp(fromfd, from, tofd, to, flag)
|
||||||
|
}
|
||||||
|
|
||||||
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
|
||||||
|
|
||||||
func Uname(uname *Utsname) error {
|
func Uname(uname *Utsname) error {
|
||||||
|
|
|
@ -2592,3 +2592,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
|
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
|
||||||
|
//sys Mseal(b []byte, flags uint) (err error)
|
||||||
|
|
|
@ -293,6 +293,7 @@ func Uname(uname *Utsname) error {
|
||||||
//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
|
//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
|
||||||
//sys Mknod(path string, mode uint32, dev int) (err error)
|
//sys Mknod(path string, mode uint32, dev int) (err error)
|
||||||
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
|
||||||
|
//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error)
|
||||||
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
|
||||||
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
//sys Open(path string, mode int, perm uint32) (fd int, err error)
|
||||||
//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
|
//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
|
||||||
|
|
|
@ -1169,6 +1169,11 @@ const (
|
||||||
PT_WRITE_D = 0x5
|
PT_WRITE_D = 0x5
|
||||||
PT_WRITE_I = 0x4
|
PT_WRITE_I = 0x4
|
||||||
PT_WRITE_U = 0x6
|
PT_WRITE_U = 0x6
|
||||||
|
RENAME_EXCL = 0x4
|
||||||
|
RENAME_NOFOLLOW_ANY = 0x10
|
||||||
|
RENAME_RESERVED1 = 0x8
|
||||||
|
RENAME_SECLUDE = 0x1
|
||||||
|
RENAME_SWAP = 0x2
|
||||||
RLIMIT_AS = 0x5
|
RLIMIT_AS = 0x5
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
|
|
|
@ -1169,6 +1169,11 @@ const (
|
||||||
PT_WRITE_D = 0x5
|
PT_WRITE_D = 0x5
|
||||||
PT_WRITE_I = 0x4
|
PT_WRITE_I = 0x4
|
||||||
PT_WRITE_U = 0x6
|
PT_WRITE_U = 0x6
|
||||||
|
RENAME_EXCL = 0x4
|
||||||
|
RENAME_NOFOLLOW_ANY = 0x10
|
||||||
|
RENAME_RESERVED1 = 0x8
|
||||||
|
RENAME_SECLUDE = 0x1
|
||||||
|
RENAME_SWAP = 0x2
|
||||||
RLIMIT_AS = 0x5
|
RLIMIT_AS = 0x5
|
||||||
RLIMIT_CORE = 0x4
|
RLIMIT_CORE = 0x4
|
||||||
RLIMIT_CPU = 0x0
|
RLIMIT_CPU = 0x0
|
||||||
|
|
|
@ -457,6 +457,7 @@ const (
|
||||||
B600 = 0x8
|
B600 = 0x8
|
||||||
B75 = 0x2
|
B75 = 0x2
|
||||||
B9600 = 0xd
|
B9600 = 0xd
|
||||||
|
BCACHEFS_SUPER_MAGIC = 0xca451a4e
|
||||||
BDEVFS_MAGIC = 0x62646576
|
BDEVFS_MAGIC = 0x62646576
|
||||||
BINDERFS_SUPER_MAGIC = 0x6c6f6f70
|
BINDERFS_SUPER_MAGIC = 0x6c6f6f70
|
||||||
BINFMTFS_MAGIC = 0x42494e4d
|
BINFMTFS_MAGIC = 0x42494e4d
|
||||||
|
@ -928,6 +929,7 @@ const (
|
||||||
EPOLL_CTL_ADD = 0x1
|
EPOLL_CTL_ADD = 0x1
|
||||||
EPOLL_CTL_DEL = 0x2
|
EPOLL_CTL_DEL = 0x2
|
||||||
EPOLL_CTL_MOD = 0x3
|
EPOLL_CTL_MOD = 0x3
|
||||||
|
EPOLL_IOC_TYPE = 0x8a
|
||||||
EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2
|
EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2
|
||||||
ESP_V4_FLOW = 0xa
|
ESP_V4_FLOW = 0xa
|
||||||
ESP_V6_FLOW = 0xc
|
ESP_V6_FLOW = 0xc
|
||||||
|
@ -941,9 +943,6 @@ const (
|
||||||
ETHTOOL_FEC_OFF = 0x4
|
ETHTOOL_FEC_OFF = 0x4
|
||||||
ETHTOOL_FEC_RS = 0x8
|
ETHTOOL_FEC_RS = 0x8
|
||||||
ETHTOOL_FLAG_ALL = 0x7
|
ETHTOOL_FLAG_ALL = 0x7
|
||||||
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
|
|
||||||
ETHTOOL_FLAG_OMIT_REPLY = 0x2
|
|
||||||
ETHTOOL_FLAG_STATS = 0x4
|
|
||||||
ETHTOOL_FLASHDEV = 0x33
|
ETHTOOL_FLASHDEV = 0x33
|
||||||
ETHTOOL_FLASH_MAX_FILENAME = 0x80
|
ETHTOOL_FLASH_MAX_FILENAME = 0x80
|
||||||
ETHTOOL_FWVERS_LEN = 0x20
|
ETHTOOL_FWVERS_LEN = 0x20
|
||||||
|
@ -1705,6 +1704,7 @@ const (
|
||||||
KEXEC_ARCH_S390 = 0x160000
|
KEXEC_ARCH_S390 = 0x160000
|
||||||
KEXEC_ARCH_SH = 0x2a0000
|
KEXEC_ARCH_SH = 0x2a0000
|
||||||
KEXEC_ARCH_X86_64 = 0x3e0000
|
KEXEC_ARCH_X86_64 = 0x3e0000
|
||||||
|
KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8
|
||||||
KEXEC_FILE_DEBUG = 0x8
|
KEXEC_FILE_DEBUG = 0x8
|
||||||
KEXEC_FILE_NO_INITRAMFS = 0x4
|
KEXEC_FILE_NO_INITRAMFS = 0x4
|
||||||
KEXEC_FILE_ON_CRASH = 0x2
|
KEXEC_FILE_ON_CRASH = 0x2
|
||||||
|
@ -1780,6 +1780,7 @@ const (
|
||||||
KEY_SPEC_USER_KEYRING = -0x4
|
KEY_SPEC_USER_KEYRING = -0x4
|
||||||
KEY_SPEC_USER_SESSION_KEYRING = -0x5
|
KEY_SPEC_USER_SESSION_KEYRING = -0x5
|
||||||
LANDLOCK_ACCESS_FS_EXECUTE = 0x1
|
LANDLOCK_ACCESS_FS_EXECUTE = 0x1
|
||||||
|
LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000
|
||||||
LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800
|
LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800
|
||||||
LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40
|
LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40
|
||||||
LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80
|
LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80
|
||||||
|
@ -1861,6 +1862,19 @@ const (
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
MAP_FIXED_NOREPLACE = 0x100000
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
|
MAP_HUGE_16GB = 0x88000000
|
||||||
|
MAP_HUGE_16KB = 0x38000000
|
||||||
|
MAP_HUGE_16MB = 0x60000000
|
||||||
|
MAP_HUGE_1GB = 0x78000000
|
||||||
|
MAP_HUGE_1MB = 0x50000000
|
||||||
|
MAP_HUGE_256MB = 0x70000000
|
||||||
|
MAP_HUGE_2GB = 0x7c000000
|
||||||
|
MAP_HUGE_2MB = 0x54000000
|
||||||
|
MAP_HUGE_32MB = 0x64000000
|
||||||
|
MAP_HUGE_512KB = 0x4c000000
|
||||||
|
MAP_HUGE_512MB = 0x74000000
|
||||||
|
MAP_HUGE_64KB = 0x40000000
|
||||||
|
MAP_HUGE_8MB = 0x5c000000
|
||||||
MAP_HUGE_MASK = 0x3f
|
MAP_HUGE_MASK = 0x3f
|
||||||
MAP_HUGE_SHIFT = 0x1a
|
MAP_HUGE_SHIFT = 0x1a
|
||||||
MAP_PRIVATE = 0x2
|
MAP_PRIVATE = 0x2
|
||||||
|
@ -2498,6 +2512,23 @@ const (
|
||||||
PR_PAC_GET_ENABLED_KEYS = 0x3d
|
PR_PAC_GET_ENABLED_KEYS = 0x3d
|
||||||
PR_PAC_RESET_KEYS = 0x36
|
PR_PAC_RESET_KEYS = 0x36
|
||||||
PR_PAC_SET_ENABLED_KEYS = 0x3c
|
PR_PAC_SET_ENABLED_KEYS = 0x3c
|
||||||
|
PR_PPC_DEXCR_CTRL_CLEAR = 0x4
|
||||||
|
PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10
|
||||||
|
PR_PPC_DEXCR_CTRL_EDITABLE = 0x1
|
||||||
|
PR_PPC_DEXCR_CTRL_MASK = 0x1f
|
||||||
|
PR_PPC_DEXCR_CTRL_SET = 0x2
|
||||||
|
PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8
|
||||||
|
PR_PPC_DEXCR_IBRTPD = 0x1
|
||||||
|
PR_PPC_DEXCR_NPHIE = 0x3
|
||||||
|
PR_PPC_DEXCR_SBHE = 0x0
|
||||||
|
PR_PPC_DEXCR_SRAPD = 0x2
|
||||||
|
PR_PPC_GET_DEXCR = 0x48
|
||||||
|
PR_PPC_SET_DEXCR = 0x49
|
||||||
|
PR_RISCV_CTX_SW_FENCEI_OFF = 0x1
|
||||||
|
PR_RISCV_CTX_SW_FENCEI_ON = 0x0
|
||||||
|
PR_RISCV_SCOPE_PER_PROCESS = 0x0
|
||||||
|
PR_RISCV_SCOPE_PER_THREAD = 0x1
|
||||||
|
PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47
|
||||||
PR_RISCV_V_GET_CONTROL = 0x46
|
PR_RISCV_V_GET_CONTROL = 0x46
|
||||||
PR_RISCV_V_SET_CONTROL = 0x45
|
PR_RISCV_V_SET_CONTROL = 0x45
|
||||||
PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3
|
PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3
|
||||||
|
@ -3192,6 +3223,7 @@ const (
|
||||||
STATX_MTIME = 0x40
|
STATX_MTIME = 0x40
|
||||||
STATX_NLINK = 0x4
|
STATX_NLINK = 0x4
|
||||||
STATX_SIZE = 0x200
|
STATX_SIZE = 0x200
|
||||||
|
STATX_SUBVOL = 0x8000
|
||||||
STATX_TYPE = 0x1
|
STATX_TYPE = 0x1
|
||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x80088a02
|
||||||
|
EPIOCSPARAMS = 0x40088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x80088a02
|
||||||
|
EPIOCSPARAMS = 0x40088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x80088a02
|
||||||
|
EPIOCSPARAMS = 0x40088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x80088a02
|
||||||
|
EPIOCSPARAMS = 0x40088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
ESR_MAGIC = 0x45535201
|
ESR_MAGIC = 0x45535201
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x80088a02
|
||||||
|
EPIOCSPARAMS = 0x40088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x80
|
EFD_NONBLOCK = 0x80
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x80
|
EFD_NONBLOCK = 0x80
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x80
|
EFD_NONBLOCK = 0x80
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x80
|
EFD_NONBLOCK = 0x80
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x20
|
ECHOPRT = 0x20
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000000
|
EXTPROC = 0x10000000
|
||||||
FF1 = 0x4000
|
FF1 = 0x4000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x20
|
ECHOPRT = 0x20
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000000
|
EXTPROC = 0x10000000
|
||||||
FF1 = 0x4000
|
FF1 = 0x4000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x20
|
ECHOPRT = 0x20
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000000
|
EXTPROC = 0x10000000
|
||||||
FF1 = 0x4000
|
FF1 = 0x4000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x80088a02
|
||||||
|
EPIOCSPARAMS = 0x40088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -78,6 +78,8 @@ const (
|
||||||
ECHOPRT = 0x400
|
ECHOPRT = 0x400
|
||||||
EFD_CLOEXEC = 0x80000
|
EFD_CLOEXEC = 0x80000
|
||||||
EFD_NONBLOCK = 0x800
|
EFD_NONBLOCK = 0x800
|
||||||
|
EPIOCGPARAMS = 0x80088a02
|
||||||
|
EPIOCSPARAMS = 0x40088a01
|
||||||
EPOLL_CLOEXEC = 0x80000
|
EPOLL_CLOEXEC = 0x80000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -82,6 +82,8 @@ const (
|
||||||
EFD_CLOEXEC = 0x400000
|
EFD_CLOEXEC = 0x400000
|
||||||
EFD_NONBLOCK = 0x4000
|
EFD_NONBLOCK = 0x4000
|
||||||
EMT_TAGOVF = 0x1
|
EMT_TAGOVF = 0x1
|
||||||
|
EPIOCGPARAMS = 0x40088a02
|
||||||
|
EPIOCSPARAMS = 0x80088a01
|
||||||
EPOLL_CLOEXEC = 0x400000
|
EPOLL_CLOEXEC = 0x400000
|
||||||
EXTPROC = 0x10000
|
EXTPROC = 0x10000
|
||||||
FF1 = 0x8000
|
FF1 = 0x8000
|
||||||
|
|
|
@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (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 renamexNp(from string, to string, flag uint32) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(from)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(to)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_renamex_np_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(from)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(to)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_renameatx_np_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
|
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
|
||||||
var _p0 unsafe.Pointer
|
var _p0 unsafe.Pointer
|
||||||
if len(mib) > 0 {
|
if len(mib) > 0 {
|
||||||
|
|
|
@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8
|
||||||
DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB)
|
DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_renamex_np(SB)
|
||||||
|
GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_renameatx_np(SB)
|
||||||
|
GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_sysctl(SB)
|
JMP libc_sysctl(SB)
|
||||||
GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8
|
||||||
|
|
|
@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (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 renamexNp(from string, to string, flag uint32) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(from)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(to)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_renamex_np_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(from)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(to)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_renameatx_np_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
|
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
|
||||||
var _p0 unsafe.Pointer
|
var _p0 unsafe.Pointer
|
||||||
if len(mib) > 0 {
|
if len(mib) > 0 {
|
||||||
|
|
|
@ -223,6 +223,16 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8
|
||||||
DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB)
|
DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_renamex_np(SB)
|
||||||
|
GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_renameatx_np(SB)
|
||||||
|
GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_sysctl(SB)
|
JMP libc_sysctl(SB)
|
||||||
GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8
|
||||||
|
|
|
@ -2229,3 +2229,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Mseal(b []byte, flags uint) (err error) {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(b) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&b[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr
|
||||||
|
|
||||||
// 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 Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(fsType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(dir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_mount_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_mount mount "libc.so"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
||||||
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
|
|
@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4
|
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4
|
||||||
DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB)
|
DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_mount(SB)
|
||||||
|
GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4
|
||||||
|
DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_nanosleep(SB)
|
JMP libc_nanosleep(SB)
|
||||||
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4
|
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4
|
||||||
|
|
|
@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr
|
||||||
|
|
||||||
// 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 Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(fsType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(dir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_mount_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_mount mount "libc.so"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
||||||
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
|
|
@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
||||||
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_mount(SB)
|
||||||
|
GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_nanosleep(SB)
|
JMP libc_nanosleep(SB)
|
||||||
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
||||||
|
|
|
@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr
|
||||||
|
|
||||||
// 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 Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(fsType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(dir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_mount_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_mount mount "libc.so"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
||||||
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
|
|
@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4
|
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4
|
||||||
DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB)
|
DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_mount(SB)
|
||||||
|
GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4
|
||||||
|
DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_nanosleep(SB)
|
JMP libc_nanosleep(SB)
|
||||||
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4
|
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4
|
||||||
|
|
|
@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr
|
||||||
|
|
||||||
// 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 Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(fsType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(dir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_mount_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_mount mount "libc.so"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
||||||
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
|
|
@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
||||||
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_mount(SB)
|
||||||
|
GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_nanosleep(SB)
|
JMP libc_nanosleep(SB)
|
||||||
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
||||||
|
|
|
@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr
|
||||||
|
|
||||||
// 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 Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(fsType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(dir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_mount_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_mount mount "libc.so"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
||||||
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
|
|
@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
||||||
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_mount(SB)
|
||||||
|
GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_nanosleep(SB)
|
JMP libc_nanosleep(SB)
|
||||||
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
||||||
|
|
|
@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr
|
||||||
|
|
||||||
// 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 Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(fsType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(dir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_mount_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_mount mount "libc.so"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
||||||
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
|
|
@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
||||||
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
CALL libc_mount(SB)
|
||||||
|
RET
|
||||||
|
GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
CALL libc_nanosleep(SB)
|
CALL libc_nanosleep(SB)
|
||||||
RET
|
RET
|
||||||
|
|
|
@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr
|
||||||
|
|
||||||
// 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 Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(fsType)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(dir)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_mount_trampoline_addr uintptr
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_mount mount "libc.so"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
|
||||||
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
_, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
|
|
@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8
|
||||||
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_mount(SB)
|
||||||
|
GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB)
|
||||||
|
|
||||||
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
JMP libc_nanosleep(SB)
|
JMP libc_nanosleep(SB)
|
||||||
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8
|
||||||
|
|
|
@ -457,4 +457,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -379,4 +379,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -421,4 +421,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -324,4 +324,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -318,4 +318,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -441,4 +441,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 4459
|
SYS_LSM_GET_SELF_ATTR = 4459
|
||||||
SYS_LSM_SET_SELF_ATTR = 4460
|
SYS_LSM_SET_SELF_ATTR = 4460
|
||||||
SYS_LSM_LIST_MODULES = 4461
|
SYS_LSM_LIST_MODULES = 4461
|
||||||
|
SYS_MSEAL = 4462
|
||||||
)
|
)
|
||||||
|
|
|
@ -371,4 +371,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 5459
|
SYS_LSM_GET_SELF_ATTR = 5459
|
||||||
SYS_LSM_SET_SELF_ATTR = 5460
|
SYS_LSM_SET_SELF_ATTR = 5460
|
||||||
SYS_LSM_LIST_MODULES = 5461
|
SYS_LSM_LIST_MODULES = 5461
|
||||||
|
SYS_MSEAL = 5462
|
||||||
)
|
)
|
||||||
|
|
|
@ -371,4 +371,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 5459
|
SYS_LSM_GET_SELF_ATTR = 5459
|
||||||
SYS_LSM_SET_SELF_ATTR = 5460
|
SYS_LSM_SET_SELF_ATTR = 5460
|
||||||
SYS_LSM_LIST_MODULES = 5461
|
SYS_LSM_LIST_MODULES = 5461
|
||||||
|
SYS_MSEAL = 5462
|
||||||
)
|
)
|
||||||
|
|
|
@ -441,4 +441,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 4459
|
SYS_LSM_GET_SELF_ATTR = 4459
|
||||||
SYS_LSM_SET_SELF_ATTR = 4460
|
SYS_LSM_SET_SELF_ATTR = 4460
|
||||||
SYS_LSM_LIST_MODULES = 4461
|
SYS_LSM_LIST_MODULES = 4461
|
||||||
|
SYS_MSEAL = 4462
|
||||||
)
|
)
|
||||||
|
|
|
@ -448,4 +448,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -420,4 +420,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -420,4 +420,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -325,4 +325,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -386,4 +386,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -399,4 +399,5 @@ const (
|
||||||
SYS_LSM_GET_SELF_ATTR = 459
|
SYS_LSM_GET_SELF_ATTR = 459
|
||||||
SYS_LSM_SET_SELF_ATTR = 460
|
SYS_LSM_SET_SELF_ATTR = 460
|
||||||
SYS_LSM_LIST_MODULES = 461
|
SYS_LSM_LIST_MODULES = 461
|
||||||
|
SYS_MSEAL = 462
|
||||||
)
|
)
|
||||||
|
|
|
@ -110,7 +110,8 @@ type Statx_t struct {
|
||||||
Mnt_id uint64
|
Mnt_id uint64
|
||||||
Dio_mem_align uint32
|
Dio_mem_align uint32
|
||||||
Dio_offset_align uint32
|
Dio_offset_align uint32
|
||||||
_ [12]uint64
|
Subvol uint64
|
||||||
|
_ [11]uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Fsid struct {
|
type Fsid struct {
|
||||||
|
@ -3473,7 +3474,7 @@ const (
|
||||||
DEVLINK_PORT_FN_ATTR_STATE = 0x2
|
DEVLINK_PORT_FN_ATTR_STATE = 0x2
|
||||||
DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3
|
DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3
|
||||||
DEVLINK_PORT_FN_ATTR_CAPS = 0x4
|
DEVLINK_PORT_FN_ATTR_CAPS = 0x4
|
||||||
DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5
|
DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6
|
||||||
)
|
)
|
||||||
|
|
||||||
type FsverityDigest struct {
|
type FsverityDigest struct {
|
||||||
|
@ -3806,6 +3807,9 @@ const (
|
||||||
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 = 0x2b
|
ETHTOOL_MSG_KERNEL_MAX = 0x2b
|
||||||
|
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
|
||||||
|
ETHTOOL_FLAG_OMIT_REPLY = 0x2
|
||||||
|
ETHTOOL_FLAG_STATS = 0x4
|
||||||
ETHTOOL_A_HEADER_UNSPEC = 0x0
|
ETHTOOL_A_HEADER_UNSPEC = 0x0
|
||||||
ETHTOOL_A_HEADER_DEV_INDEX = 0x1
|
ETHTOOL_A_HEADER_DEV_INDEX = 0x1
|
||||||
ETHTOOL_A_HEADER_DEV_NAME = 0x2
|
ETHTOOL_A_HEADER_DEV_NAME = 0x2
|
||||||
|
@ -3975,7 +3979,7 @@ const (
|
||||||
ETHTOOL_A_TSINFO_TX_TYPES = 0x3
|
ETHTOOL_A_TSINFO_TX_TYPES = 0x3
|
||||||
ETHTOOL_A_TSINFO_RX_FILTERS = 0x4
|
ETHTOOL_A_TSINFO_RX_FILTERS = 0x4
|
||||||
ETHTOOL_A_TSINFO_PHC_INDEX = 0x5
|
ETHTOOL_A_TSINFO_PHC_INDEX = 0x5
|
||||||
ETHTOOL_A_TSINFO_MAX = 0x5
|
ETHTOOL_A_TSINFO_MAX = 0x6
|
||||||
ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0
|
ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0
|
||||||
ETHTOOL_A_CABLE_TEST_HEADER = 0x1
|
ETHTOOL_A_CABLE_TEST_HEADER = 0x1
|
||||||
ETHTOOL_A_CABLE_TEST_MAX = 0x1
|
ETHTOOL_A_CABLE_TEST_MAX = 0x1
|
||||||
|
|
|
@ -1179,7 +1179,7 @@ type OBJECTS_AND_NAME struct {
|
||||||
//sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD
|
//sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD
|
||||||
|
|
||||||
//sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW
|
//sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW
|
||||||
//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce
|
//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce
|
||||||
|
|
||||||
// Control returns the security descriptor control bits.
|
// Control returns the security descriptor control bits.
|
||||||
func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) {
|
func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) {
|
||||||
|
|
|
@ -17,8 +17,10 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Handle uintptr
|
type (
|
||||||
type HWND uintptr
|
Handle uintptr
|
||||||
|
HWND uintptr
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
InvalidHandle = ^Handle(0)
|
InvalidHandle = ^Handle(0)
|
||||||
|
@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
||||||
//sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error)
|
//sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error)
|
||||||
//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW
|
//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW
|
||||||
//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId
|
//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId
|
||||||
|
//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW
|
||||||
|
//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout
|
||||||
|
//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout
|
||||||
|
//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx
|
||||||
//sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow
|
//sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow
|
||||||
//sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW
|
//sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW
|
||||||
//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx
|
//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx
|
||||||
|
@ -1368,9 +1374,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) {
|
||||||
func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) {
|
func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) {
|
||||||
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4)
|
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) {
|
func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) {
|
||||||
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq)))
|
return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) {
|
func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) {
|
||||||
return syscall.EWINDOWS
|
return syscall.EWINDOWS
|
||||||
}
|
}
|
||||||
|
|
|
@ -2003,7 +2003,21 @@ const (
|
||||||
MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
|
MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
|
||||||
)
|
)
|
||||||
|
|
||||||
const GAA_FLAG_INCLUDE_PREFIX = 0x00000010
|
// Flags for GetAdaptersAddresses, see
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses.
|
||||||
|
const (
|
||||||
|
GAA_FLAG_SKIP_UNICAST = 0x1
|
||||||
|
GAA_FLAG_SKIP_ANYCAST = 0x2
|
||||||
|
GAA_FLAG_SKIP_MULTICAST = 0x4
|
||||||
|
GAA_FLAG_SKIP_DNS_SERVER = 0x8
|
||||||
|
GAA_FLAG_INCLUDE_PREFIX = 0x10
|
||||||
|
GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20
|
||||||
|
GAA_FLAG_INCLUDE_WINS_INFO = 0x40
|
||||||
|
GAA_FLAG_INCLUDE_GATEWAYS = 0x80
|
||||||
|
GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100
|
||||||
|
GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200
|
||||||
|
GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IF_TYPE_OTHER = 1
|
IF_TYPE_OTHER = 1
|
||||||
|
@ -2017,6 +2031,50 @@ const (
|
||||||
IF_TYPE_IEEE1394 = 144
|
IF_TYPE_IEEE1394 = 144
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin
|
||||||
|
const (
|
||||||
|
IpPrefixOriginOther = 0
|
||||||
|
IpPrefixOriginManual = 1
|
||||||
|
IpPrefixOriginWellKnown = 2
|
||||||
|
IpPrefixOriginDhcp = 3
|
||||||
|
IpPrefixOriginRouterAdvertisement = 4
|
||||||
|
IpPrefixOriginUnchanged = 1 << 4
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin
|
||||||
|
const (
|
||||||
|
NlsoOther = 0
|
||||||
|
NlsoManual = 1
|
||||||
|
NlsoWellKnown = 2
|
||||||
|
NlsoDhcp = 3
|
||||||
|
NlsoLinkLayerAddress = 4
|
||||||
|
NlsoRandom = 5
|
||||||
|
IpSuffixOriginOther = 0
|
||||||
|
IpSuffixOriginManual = 1
|
||||||
|
IpSuffixOriginWellKnown = 2
|
||||||
|
IpSuffixOriginDhcp = 3
|
||||||
|
IpSuffixOriginLinkLayerAddress = 4
|
||||||
|
IpSuffixOriginRandom = 5
|
||||||
|
IpSuffixOriginUnchanged = 1 << 4
|
||||||
|
)
|
||||||
|
|
||||||
|
// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state
|
||||||
|
const (
|
||||||
|
NldsInvalid = 0
|
||||||
|
NldsTentative = 1
|
||||||
|
NldsDuplicate = 2
|
||||||
|
NldsDeprecated = 3
|
||||||
|
NldsPreferred = 4
|
||||||
|
IpDadStateInvalid = 0
|
||||||
|
IpDadStateTentative = 1
|
||||||
|
IpDadStateDuplicate = 2
|
||||||
|
IpDadStateDeprecated = 3
|
||||||
|
IpDadStatePreferred = 4
|
||||||
|
)
|
||||||
|
|
||||||
type SocketAddress struct {
|
type SocketAddress struct {
|
||||||
Sockaddr *syscall.RawSockaddrAny
|
Sockaddr *syscall.RawSockaddrAny
|
||||||
SockaddrLength int32
|
SockaddrLength int32
|
||||||
|
@ -3404,3 +3462,14 @@ type DCB struct {
|
||||||
EvtChar byte
|
EvtChar byte
|
||||||
wReserved1 uint16
|
wReserved1 uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keyboard Layout Flags.
|
||||||
|
// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw
|
||||||
|
const (
|
||||||
|
KLF_ACTIVATE = 0x00000001
|
||||||
|
KLF_SUBSTITUTE_OK = 0x00000002
|
||||||
|
KLF_REORDER = 0x00000008
|
||||||
|
KLF_REPLACELANG = 0x00000010
|
||||||
|
KLF_NOTELLSHELL = 0x00000080
|
||||||
|
KLF_SETFORPROCESS = 0x00000100
|
||||||
|
)
|
||||||
|
|
|
@ -478,12 +478,16 @@ var (
|
||||||
procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow")
|
procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow")
|
||||||
procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow")
|
procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow")
|
||||||
procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo")
|
procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo")
|
||||||
|
procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout")
|
||||||
procGetShellWindow = moduser32.NewProc("GetShellWindow")
|
procGetShellWindow = moduser32.NewProc("GetShellWindow")
|
||||||
procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
|
procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
|
||||||
procIsWindow = moduser32.NewProc("IsWindow")
|
procIsWindow = moduser32.NewProc("IsWindow")
|
||||||
procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode")
|
procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode")
|
||||||
procIsWindowVisible = moduser32.NewProc("IsWindowVisible")
|
procIsWindowVisible = moduser32.NewProc("IsWindowVisible")
|
||||||
|
procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW")
|
||||||
procMessageBoxW = moduser32.NewProc("MessageBoxW")
|
procMessageBoxW = moduser32.NewProc("MessageBoxW")
|
||||||
|
procToUnicodeEx = moduser32.NewProc("ToUnicodeEx")
|
||||||
|
procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout")
|
||||||
procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
|
procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
|
||||||
procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
|
procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
|
||||||
procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
|
procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
|
||||||
|
@ -789,6 +793,14 @@ func FreeSid(sid *SID) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce)))
|
||||||
|
if r1 == 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetLengthSid(sid *SID) (len uint32) {
|
func GetLengthSid(sid *SID) (len uint32) {
|
||||||
r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
|
r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
|
||||||
len = uint32(r0)
|
len = uint32(r0)
|
||||||
|
@ -1225,14 +1237,6 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) {
|
|
||||||
r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce)))
|
|
||||||
if r0 == 0 {
|
|
||||||
ret = GetLastError()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) {
|
func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor)))
|
r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor)))
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
|
@ -4082,6 +4086,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetKeyboardLayout(tid uint32) (hkl Handle) {
|
||||||
|
r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0)
|
||||||
|
hkl = Handle(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetShellWindow() (shellWindow HWND) {
|
func GetShellWindow() (shellWindow HWND) {
|
||||||
r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0)
|
r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0)
|
||||||
shellWindow = HWND(r0)
|
shellWindow = HWND(r0)
|
||||||
|
@ -4115,6 +4125,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) {
|
||||||
|
r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0)
|
||||||
|
hkl = Handle(r0)
|
||||||
|
if hkl == 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
|
func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
|
||||||
r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
|
r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
|
||||||
ret = int32(r0)
|
ret = int32(r0)
|
||||||
|
@ -4124,6 +4143,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) {
|
||||||
|
r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0)
|
||||||
|
ret = int32(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func UnloadKeyboardLayout(hkl Handle) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
|
func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
|
||||||
var _p0 uint32
|
var _p0 uint32
|
||||||
if inheritExisting {
|
if inheritExisting {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
|
@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer.
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
in the documentation and/or other materials provided with the
|
in the documentation and/or other materials provided with the
|
||||||
distribution.
|
distribution.
|
||||||
* Neither the name of Google Inc. nor the names of its
|
* Neither the name of Google LLC nor the names of its
|
||||||
contributors may be used to endorse or promote products derived from
|
contributors may be used to endorse or promote products derived from
|
||||||
this software without specific prior written permission.
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ func Every(interval time.Duration) Limit {
|
||||||
// or its associated context.Context is canceled.
|
// or its associated context.Context is canceled.
|
||||||
//
|
//
|
||||||
// The methods AllowN, ReserveN, and WaitN consume n tokens.
|
// The methods AllowN, ReserveN, and WaitN consume n tokens.
|
||||||
|
//
|
||||||
|
// Limiter is safe for simultaneous use by multiple goroutines.
|
||||||
type Limiter struct {
|
type Limiter struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
limit Limit
|
limit Limit
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.31.0
|
// protoc-gen-go v1.32.0
|
||||||
// protoc v4.22.0
|
// protoc v4.25.2
|
||||||
// source: grpc/binlog/v1/binarylog.proto
|
// source: grpc/binlog/v1/binarylog.proto
|
||||||
|
|
||||||
package grpc_binarylog_v1
|
package grpc_binarylog_v1
|
||||||
|
@ -430,7 +430,7 @@ type ClientHeader struct {
|
||||||
MethodName string `protobuf:"bytes,2,opt,name=method_name,json=methodName,proto3" json:"method_name,omitempty"`
|
MethodName string `protobuf:"bytes,2,opt,name=method_name,json=methodName,proto3" json:"method_name,omitempty"`
|
||||||
// A single process may be used to run multiple virtual
|
// A single process may be used to run multiple virtual
|
||||||
// servers with different identities.
|
// servers with different identities.
|
||||||
// The authority is the name of such a server identitiy.
|
// The authority is the name of such a server identity.
|
||||||
// It is typically a portion of the URI in the form of
|
// It is typically a portion of the URI in the form of
|
||||||
// <host> or <host>:<port> .
|
// <host> or <host>:<port> .
|
||||||
Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"`
|
Authority string `protobuf:"bytes,3,opt,name=authority,proto3" json:"authority,omitempty"`
|
||||||
|
|
|
@ -1860,27 +1860,15 @@ func (cc *ClientConn) determineAuthority() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
endpoint := cc.parsedTarget.Endpoint()
|
endpoint := cc.parsedTarget.Endpoint()
|
||||||
target := cc.target
|
if authorityFromDialOption != "" {
|
||||||
switch {
|
|
||||||
case authorityFromDialOption != "":
|
|
||||||
cc.authority = authorityFromDialOption
|
cc.authority = authorityFromDialOption
|
||||||
case authorityFromCreds != "":
|
} else if authorityFromCreds != "" {
|
||||||
cc.authority = authorityFromCreds
|
cc.authority = authorityFromCreds
|
||||||
case strings.HasPrefix(target, "unix:") || strings.HasPrefix(target, "unix-abstract:"):
|
} else if auth, ok := cc.resolverBuilder.(resolver.AuthorityOverrider); ok {
|
||||||
// TODO: remove when the unix resolver implements optional interface to
|
cc.authority = auth.OverrideAuthority(cc.parsedTarget)
|
||||||
// return channel authority.
|
} else if strings.HasPrefix(endpoint, ":") {
|
||||||
cc.authority = "localhost"
|
|
||||||
case strings.HasPrefix(endpoint, ":"):
|
|
||||||
cc.authority = "localhost" + endpoint
|
cc.authority = "localhost" + endpoint
|
||||||
default:
|
} else {
|
||||||
// TODO: Define an optional interface on the resolver builder to return
|
|
||||||
// the channel authority given the user's dial target. For resolvers
|
|
||||||
// which don't implement this interface, we will use the endpoint from
|
|
||||||
// "scheme://authority/endpoint" as the default authority.
|
|
||||||
// Escape the endpoint to handle use cases where the endpoint
|
|
||||||
// might not be a valid authority by default.
|
|
||||||
// For example an endpoint which has multiple paths like
|
|
||||||
// 'a/b/c', which is not a valid authority by default.
|
|
||||||
cc.authority = encodeAuthority(endpoint)
|
cc.authority = encodeAuthority(endpoint)
|
||||||
}
|
}
|
||||||
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)
|
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)
|
||||||
|
|
|
@ -23,8 +23,9 @@ package proto
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/grpc/encoding"
|
"google.golang.org/grpc/encoding"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
"google.golang.org/protobuf/protoadapt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Name is the name registered for the proto compressor.
|
// Name is the name registered for the proto compressor.
|
||||||
|
@ -38,21 +39,34 @@ func init() {
|
||||||
type codec struct{}
|
type codec struct{}
|
||||||
|
|
||||||
func (codec) Marshal(v any) ([]byte, error) {
|
func (codec) Marshal(v any) ([]byte, error) {
|
||||||
vv, ok := v.(proto.Message)
|
vv := messageV2Of(v)
|
||||||
if !ok {
|
if vv == nil {
|
||||||
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
|
return nil, fmt.Errorf("failed to marshal, message is %T, want proto.Message", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return proto.Marshal(vv)
|
return proto.Marshal(vv)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (codec) Unmarshal(data []byte, v any) error {
|
func (codec) Unmarshal(data []byte, v any) error {
|
||||||
vv, ok := v.(proto.Message)
|
vv := messageV2Of(v)
|
||||||
if !ok {
|
if vv == nil {
|
||||||
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
|
return fmt.Errorf("failed to unmarshal, message is %T, want proto.Message", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return proto.Unmarshal(data, vv)
|
return proto.Unmarshal(data, vv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func messageV2Of(v any) proto.Message {
|
||||||
|
switch v := v.(type) {
|
||||||
|
case protoadapt.MessageV1:
|
||||||
|
return protoadapt.MessageV2Of(v)
|
||||||
|
case protoadapt.MessageV2:
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (codec) Name() string {
|
func (codec) Name() string {
|
||||||
return Name
|
return Name
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.31.0
|
// protoc-gen-go v1.32.0
|
||||||
// protoc v4.22.0
|
// protoc v4.25.2
|
||||||
// source: grpc/health/v1/health.proto
|
// source: grpc/health/v1/health.proto
|
||||||
|
|
||||||
package grpc_health_v1
|
package grpc_health_v1
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.3.0
|
// - protoc-gen-go-grpc v1.3.0
|
||||||
// - protoc v4.22.0
|
// - protoc v4.25.2
|
||||||
// source: grpc/health/v1/health.proto
|
// source: grpc/health/v1/health.proto
|
||||||
|
|
||||||
package grpc_health_v1
|
package grpc_health_v1
|
||||||
|
|
|
@ -25,11 +25,12 @@ import (
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/golang/protobuf/ptypes"
|
|
||||||
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
"google.golang.org/protobuf/types/known/durationpb"
|
||||||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type callIDGenerator struct {
|
type callIDGenerator struct {
|
||||||
|
@ -88,7 +89,7 @@ func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger {
|
||||||
// in TruncatingMethodLogger as possible.
|
// in TruncatingMethodLogger as possible.
|
||||||
func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry {
|
func (ml *TruncatingMethodLogger) Build(c LogEntryConfig) *binlogpb.GrpcLogEntry {
|
||||||
m := c.toProto()
|
m := c.toProto()
|
||||||
timestamp, _ := ptypes.TimestampProto(time.Now())
|
timestamp := timestamppb.Now()
|
||||||
m.Timestamp = timestamp
|
m.Timestamp = timestamp
|
||||||
m.CallId = ml.callID
|
m.CallId = ml.callID
|
||||||
m.SequenceIdWithinCall = ml.idWithinCallGen.next()
|
m.SequenceIdWithinCall = ml.idWithinCallGen.next()
|
||||||
|
@ -178,7 +179,7 @@ func (c *ClientHeader) toProto() *binlogpb.GrpcLogEntry {
|
||||||
Authority: c.Authority,
|
Authority: c.Authority,
|
||||||
}
|
}
|
||||||
if c.Timeout > 0 {
|
if c.Timeout > 0 {
|
||||||
clientHeader.Timeout = ptypes.DurationProto(c.Timeout)
|
clientHeader.Timeout = durationpb.New(c.Timeout)
|
||||||
}
|
}
|
||||||
ret := &binlogpb.GrpcLogEntry{
|
ret := &binlogpb.GrpcLogEntry{
|
||||||
Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER,
|
Type: binlogpb.GrpcLogEntry_EVENT_TYPE_CLIENT_HEADER,
|
||||||
|
|
|
@ -25,8 +25,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
binlogpb "google.golang.org/grpc/binarylog/grpc_binarylog_v1"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue