Commit 5bc30653 authored by Erik Wilson's avatar Erik Wilson

Bump cri-tools to v1.17.0-k3s1

parent 3b1d6560
...@@ -24,7 +24,7 @@ replace ( ...@@ -24,7 +24,7 @@ replace (
github.com/golangci/gosec => github.com/golangci/gosec v0.0.0-20190211064107-66fb7fc33547 github.com/golangci/gosec => github.com/golangci/gosec v0.0.0-20190211064107-66fb7fc33547
github.com/golangci/ineffassign => github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc github.com/golangci/ineffassign => github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc
github.com/golangci/lint-1 => github.com/golangci/lint-1 v0.0.0-20190420132249-ee948d087217 github.com/golangci/lint-1 => github.com/golangci/lint-1 v0.0.0-20190420132249-ee948d087217
github.com/kubernetes-sigs/cri-tools => github.com/rancher/cri-tools v1.16.1-k3s.1 github.com/kubernetes-sigs/cri-tools => github.com/erikwilson/rancher-cri-tools v1.17.0-k3s1
github.com/matryer/moq => github.com/rancher/moq v0.0.0-20190404221404-ee5226d43009 github.com/matryer/moq => github.com/rancher/moq v0.0.0-20190404221404-ee5226d43009
github.com/opencontainers/runtime-spec => github.com/opencontainers/runtime-spec v0.0.0-20180911193056-5684b8af48c1 github.com/opencontainers/runtime-spec => github.com/opencontainers/runtime-spec v0.0.0-20180911193056-5684b8af48c1
github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2 github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2
...@@ -77,7 +77,7 @@ require ( ...@@ -77,7 +77,7 @@ require (
github.com/coreos/flannel v0.11.0 github.com/coreos/flannel v0.11.0
github.com/coreos/go-iptables v0.4.2 github.com/coreos/go-iptables v0.4.2
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f
github.com/docker/docker v0.7.3-0.20190731001754-589f1dad8dad github.com/docker/docker v1.4.2-0.20191205034852-d163fbba3c82
github.com/docker/go-metrics v0.0.1 // indirect github.com/docker/go-metrics v0.0.1 // indirect
github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 // indirect github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible github.com/go-bindata/go-bindata v3.1.2+incompatible
...@@ -110,12 +110,12 @@ require ( ...@@ -110,12 +110,12 @@ require (
github.com/theckman/go-flock v0.7.1 // indirect github.com/theckman/go-flock v0.7.1 // indirect
github.com/urfave/cli v1.22.2 github.com/urfave/cli v1.22.2
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 golang.org/x/net v0.0.0-20191204025024-5ee1b9f4859a
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e
google.golang.org/grpc v1.24.0 google.golang.org/grpc v1.25.1
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect gopkg.in/robfig/cron.v2 v2.0.0-20150107220207-be2e0b0deed5 // indirect
gopkg.in/yaml.v2 v2.2.4 gopkg.in/yaml.v2 v2.2.7
k8s.io/api v0.17.0 k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.0 k8s.io/apimachinery v0.17.0
k8s.io/apiserver v0.0.0 k8s.io/apiserver v0.0.0
......
...@@ -2995,16 +2995,10 @@ definitions: ...@@ -2995,16 +2995,10 @@ definitions:
description: "Runtime is the type of runtime specified for the task executor." description: "Runtime is the type of runtime specified for the task executor."
type: "string" type: "string"
Networks: Networks:
description: "Specifies which networks the service should attach to."
type: "array" type: "array"
items: items:
type: "object" $ref: "#/definitions/NetworkAttachmentConfig"
properties:
Target:
type: "string"
Aliases:
type: "array"
items:
type: "string"
LogDriver: LogDriver:
description: "Specifies the log driver to use for tasks created from this spec. If not present, the default one for the swarm will be used, finally falling back to the engine default if not specified." description: "Specifies the log driver to use for tasks created from this spec. If not present, the default one for the swarm will be used, finally falling back to the engine default if not specified."
type: "object" type: "object"
...@@ -3250,17 +3244,11 @@ definitions: ...@@ -3250,17 +3244,11 @@ definitions:
- "stop-first" - "stop-first"
- "start-first" - "start-first"
Networks: Networks:
description: "Array of network names or IDs to attach the service to." description: "Specifies which networks the service should attach to."
type: "array" type: "array"
items: items:
type: "object" $ref: "#/definitions/NetworkAttachmentConfig"
properties:
Target:
type: "string"
Aliases:
type: "array"
items:
type: "string"
EndpointSpec: EndpointSpec:
$ref: "#/definitions/EndpointSpec" $ref: "#/definitions/EndpointSpec"
...@@ -3287,7 +3275,7 @@ definitions: ...@@ -3287,7 +3275,7 @@ definitions:
<p><br /></p> <p><br /></p>
- "ingress" makes the target port accessible on on every node, - "ingress" makes the target port accessible on every node,
regardless of whether there is a task for the service running on regardless of whether there is a task for the service running on
that node or not. that node or not.
- "host" bypasses the routing mesh and publish the port directly on - "host" bypasses the routing mesh and publish the port directly on
...@@ -3369,6 +3357,27 @@ definitions: ...@@ -3369,6 +3357,27 @@ definitions:
format: "dateTime" format: "dateTime"
Message: Message:
type: "string" type: "string"
ServiceStatus:
description: |
The status of the service's tasks. Provided only when requested as
part of a ServiceList operation.
type: "object"
properties:
RunningTasks:
description: "The number of tasks for the service currently in the Running state"
type: "integer"
format: "uint64"
example: 7
DesiredTasks:
description: |
The number of tasks for the service desired to be running.
For replicated services, this is the replica count from the
service spec. For global services, this is computed by taking
count of all tasks for the service with a Desired State other
than Shutdown.
type: "integer"
format: "uint64"
example: 10
example: example:
ID: "9mnpnzenvg8p8tdbtq4wvbkcz" ID: "9mnpnzenvg8p8tdbtq4wvbkcz"
Version: Version:
...@@ -4443,6 +4452,24 @@ definitions: ...@@ -4443,6 +4452,24 @@ definitions:
IP address and ports at which this node can be reached. IP address and ports at which this node can be reached.
type: "string" type: "string"
NetworkAttachmentConfig:
description: "Specifies how a service should be attached to a particular network."
type: "object"
properties:
Target:
description: "The target network for attachment. Must be a network name or ID."
type: "string"
Aliases:
description: "Discoverable alternate names for the service on this network."
type: "array"
items:
type: "string"
DriverOpts:
description: "Driver attachment options for the network target"
type: "object"
additionalProperties:
type: "string"
paths: paths:
/containers/json: /containers/json:
get: get:
...@@ -4873,7 +4900,7 @@ paths: ...@@ -4873,7 +4900,7 @@ paths:
Note that a running container can be _paused_. The `Running` and `Paused` Note that a running container can be _paused_. The `Running` and `Paused`
booleans are not mutually exclusive: booleans are not mutually exclusive:
When pausing a container (on Linux), the cgroups freezer is used to suspend When pausing a container (on Linux), the freezer cgroup is used to suspend
all processes in the container. Freezing the process requires the process to all processes in the container. Freezing the process requires the process to
be running. As a result, paused containers are both `Running` _and_ `Paused`. be running. As a result, paused containers are both `Running` _and_ `Paused`.
...@@ -4924,6 +4951,8 @@ paths: ...@@ -4924,6 +4951,8 @@ paths:
type: "integer" type: "integer"
Driver: Driver:
type: "string" type: "string"
Platform:
type: "string"
MountLabel: MountLabel:
type: "string" type: "string"
ProcessLabel: ProcessLabel:
...@@ -5764,9 +5793,9 @@ paths: ...@@ -5764,9 +5793,9 @@ paths:
post: post:
summary: "Pause a container" summary: "Pause a container"
description: | description: |
Use the cgroups freezer to suspend all processes in a container. Use the freezer cgroup to suspend all processes in a container.
Traditionally, when suspending a process the `SIGSTOP` signal is used, which is observable by the process being suspended. With the cgroups freezer the process is unaware, and unable to capture, that it is being suspended, and subsequently resumed. Traditionally, when suspending a process the `SIGSTOP` signal is used, which is observable by the process being suspended. With the freezer cgroup the process is unaware, and unable to capture, that it is being suspended, and subsequently resumed.
operationId: "ContainerPause" operationId: "ContainerPause"
responses: responses:
204: 204:
...@@ -9316,6 +9345,10 @@ paths: ...@@ -9316,6 +9345,10 @@ paths:
- `label=<service label>` - `label=<service label>`
- `mode=["replicated"|"global"]` - `mode=["replicated"|"global"]`
- `name=<service name>` - `name=<service name>`
- name: "status"
in: "query"
type: "boolean"
description: "Include service status, with count of running and desired tasks"
tags: ["Service"] tags: ["Service"]
/services/create: /services/create:
post: post:
...@@ -10414,9 +10447,6 @@ paths: ...@@ -10414,9 +10447,6 @@ paths:
description: | description: |
Start a new interactive session with a server. Session allows server to call back to the client for advanced capabilities. Start a new interactive session with a server. Session allows server to call back to the client for advanced capabilities.
> **Note**: This endpoint is *experimental* and only available if the daemon is started with experimental
> features enabled. The specifications for this endpoint may still change in a future version of the API.
### Hijacking ### Hijacking
This endpoint hijacks the HTTP connection to HTTP2 transport that allows the client to expose gPRC services on that connection. This endpoint hijacks the HTTP connection to HTTP2 transport that allows the client to expose gPRC services on that connection.
...@@ -10450,4 +10480,4 @@ paths: ...@@ -10450,4 +10480,4 @@ paths:
description: "server error" description: "server error"
schema: schema:
$ref: "#/definitions/ErrorResponse" $ref: "#/definitions/ErrorResponse"
tags: ["Session (experimental)"] tags: ["Session"]
...@@ -363,6 +363,10 @@ type ServiceUpdateOptions struct { ...@@ -363,6 +363,10 @@ type ServiceUpdateOptions struct {
// ServiceListOptions holds parameters to list services with. // ServiceListOptions holds parameters to list services with.
type ServiceListOptions struct { type ServiceListOptions struct {
Filters filters.Args Filters filters.Args
// Status indicates whether the server should include the service task
// count of running and desired tasks.
Status bool
} }
// ServiceInspectOptions holds parameters related to the "service inspect" // ServiceInspectOptions holds parameters related to the "service inspect"
......
package container // import "github.com/docker/docker/api/types/container" package container // import "github.com/docker/docker/api/types/container"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
package container // import "github.com/docker/docker/api/types/container" package container // import "github.com/docker/docker/api/types/container"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
package container // import "github.com/docker/docker/api/types/container" package container // import "github.com/docker/docker/api/types/container"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
package container // import "github.com/docker/docker/api/types/container" package container // import "github.com/docker/docker/api/types/container"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
package container // import "github.com/docker/docker/api/types/container" package container // import "github.com/docker/docker/api/types/container"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/strslice" "github.com/docker/docker/api/types/strslice"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
"github.com/docker/go-units" units "github.com/docker/go-units"
) )
// CgroupnsMode represents the cgroup namespace mode of the container // CgroupnsMode represents the cgroup namespace mode of the container
......
...@@ -36,6 +36,15 @@ func NewArgs(initialArgs ...KeyValuePair) Args { ...@@ -36,6 +36,15 @@ func NewArgs(initialArgs ...KeyValuePair) Args {
return args return args
} }
// Keys returns all the keys in list of Args
func (args Args) Keys() []string {
keys := make([]string, 0, len(args.fields))
for k := range args.fields {
keys = append(keys, k)
}
return keys
}
// MarshalJSON returns a JSON byte representation of the Args // MarshalJSON returns a JSON byte representation of the Args
func (args Args) MarshalJSON() ([]byte, error) { func (args Args) MarshalJSON() ([]byte, error) {
if len(args.fields) == 0 { if len(args.fields) == 0 {
...@@ -57,7 +66,7 @@ func ToJSON(a Args) (string, error) { ...@@ -57,7 +66,7 @@ func ToJSON(a Args) (string, error) {
// then the encoded format will use an older legacy format where the values are a // then the encoded format will use an older legacy format where the values are a
// list of strings, instead of a set. // list of strings, instead of a set.
// //
// Deprecated: Use ToJSON // Deprecated: do not use in any new code; use ToJSON instead
func ToParamWithVersion(version string, a Args) (string, error) { func ToParamWithVersion(version string, a Args) (string, error) {
if a.Len() == 0 { if a.Len() == 0 {
return "", nil return "", nil
......
package image // import "github.com/docker/docker/api/types/image" package image // import "github.com/docker/docker/api/types/image"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"encoding/json" "encoding/json"
"net" "net"
"github.com/opencontainers/image-spec/specs-go/v1" v1 "github.com/opencontainers/image-spec/specs-go/v1"
) )
// ServiceConfig stores daemon registry services configuration. // ServiceConfig stores daemon registry services configuration.
......
...@@ -10,6 +10,13 @@ type Service struct { ...@@ -10,6 +10,13 @@ type Service struct {
PreviousSpec *ServiceSpec `json:",omitempty"` PreviousSpec *ServiceSpec `json:",omitempty"`
Endpoint Endpoint `json:",omitempty"` Endpoint Endpoint `json:",omitempty"`
UpdateStatus *UpdateStatus `json:",omitempty"` UpdateStatus *UpdateStatus `json:",omitempty"`
// ServiceStatus is an optional, extra field indicating the number of
// desired and running tasks. It is provided primarily as a shortcut to
// calculating these values client-side, which otherwise would require
// listing all tasks for a service, an operation that could be
// computation and network expensive.
ServiceStatus *ServiceStatus `json:",omitempty"`
} }
// ServiceSpec represents the spec of a service. // ServiceSpec represents the spec of a service.
...@@ -122,3 +129,17 @@ type UpdateConfig struct { ...@@ -122,3 +129,17 @@ type UpdateConfig struct {
// started, or the new task is started before the old task is shut down. // started, or the new task is started before the old task is shut down.
Order string Order string
} }
// ServiceStatus represents the number of running tasks in a service and the
// number of tasks desired to be running.
type ServiceStatus struct {
// RunningTasks is the number of tasks for the service actually in the
// Running state
RunningTasks uint64
// DesiredTasks is the number of tasks desired to be running by the
// service. For replicated services, this is the replica count. For global
// services, this is computed by taking the number of tasks with desired
// state of not-Shutdown.
DesiredTasks uint64
}
...@@ -39,6 +39,7 @@ type ImageInspect struct { ...@@ -39,6 +39,7 @@ type ImageInspect struct {
Author string Author string
Config *container.Config Config *container.Config
Architecture string Architecture string
Variant string `json:",omitempty"`
Os string Os string
OsVersion string `json:",omitempty"` OsVersion string `json:",omitempty"`
Size int64 Size int64
......
package volume // import "github.com/docker/docker/api/types/volume" package volume // import "github.com/docker/docker/api/types/volume"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
package volume // import "github.com/docker/docker/api/types/volume" package volume // import "github.com/docker/docker/api/types/volume"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// DO NOT EDIT THIS FILE // Code generated by `swagger generate operation`. DO NOT EDIT.
// This file was generated by `swagger generate operation`
// //
// See hack/generate-swagger-api.sh // See hack/generate-swagger-api.sh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -252,7 +252,8 @@ func (cli *Client) DaemonHost() string { ...@@ -252,7 +252,8 @@ func (cli *Client) DaemonHost() string {
// HTTPClient returns a copy of the HTTP client bound to the server // HTTPClient returns a copy of the HTTP client bound to the server
func (cli *Client) HTTPClient() *http.Client { func (cli *Client) HTTPClient() *http.Client {
return &*cli.client c := *cli.client
return &c
} }
// ParseHostURL parses a url string, validates the string is a host url, and // ParseHostURL parses a url string, validates the string is a host url, and
......
...@@ -35,6 +35,7 @@ func (cli *Client) ContainerList(ctx context.Context, options types.ContainerLis ...@@ -35,6 +35,7 @@ func (cli *Client) ContainerList(ctx context.Context, options types.ContainerLis
} }
if options.Filters.Len() > 0 { if options.Filters.Len() > 0 {
//nolint:staticcheck // ignore SA1019 for old code
filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
if err != nil { if err != nil {
......
...@@ -90,6 +90,7 @@ func buildEventsQueryParams(cliVersion string, options types.EventsOptions) (url ...@@ -90,6 +90,7 @@ func buildEventsQueryParams(cliVersion string, options types.EventsOptions) (url
} }
if options.Filters.Len() > 0 { if options.Filters.Len() > 0 {
//nolint:staticcheck // ignore SA1019 for old code
filterJSON, err := filters.ToParamWithVersion(cliVersion, options.Filters) filterJSON, err := filters.ToParamWithVersion(cliVersion, options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -24,7 +24,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu ...@@ -24,7 +24,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu
} }
apiPath := cli.getAPIPath(ctx, path, query) apiPath := cli.getAPIPath(ctx, path, query)
req, err := http.NewRequest("POST", apiPath, bodyEncoded) req, err := http.NewRequest(http.MethodPost, apiPath, bodyEncoded)
if err != nil { if err != nil {
return types.HijackedResponse{}, err return types.HijackedResponse{}, err
} }
...@@ -40,7 +40,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu ...@@ -40,7 +40,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu
// DialHijack returns a hijacked connection with negotiated protocol proto. // DialHijack returns a hijacked connection with negotiated protocol proto.
func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) { func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) {
req, err := http.NewRequest("POST", url, nil) req, err := http.NewRequest(http.MethodPost, url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -87,6 +87,8 @@ func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto ...@@ -87,6 +87,8 @@ func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto
// Server hijacks the connection, error 'connection closed' expected // Server hijacks the connection, error 'connection closed' expected
resp, err := clientconn.Do(req) resp, err := clientconn.Do(req)
//nolint:staticcheck // ignore SA1019 for connecting to old (pre go1.8) daemons
if err != httputil.ErrPersistEOF { if err != httputil.ErrPersistEOF {
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -24,6 +24,7 @@ func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions ...@@ -24,6 +24,7 @@ func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions
} }
} }
if optionFilters.Len() > 0 { if optionFilters.Len() > 0 {
//nolint:staticcheck // ignore SA1019 for old code
filterJSON, err := filters.ToParamWithVersion(cli.version, optionFilters) filterJSON, err := filters.ToParamWithVersion(cli.version, optionFilters)
if err != nil { if err != nil {
return images, err return images, err
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
func (cli *Client) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { func (cli *Client) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
query := url.Values{} query := url.Values{}
if options.Filters.Len() > 0 { if options.Filters.Len() > 0 {
//nolint:staticcheck // ignore SA1019 for old code
filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters) filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -19,7 +19,7 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { ...@@ -19,7 +19,7 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
// Using cli.buildRequest() + cli.doRequest() instead of cli.sendRequest() // Using cli.buildRequest() + cli.doRequest() instead of cli.sendRequest()
// because ping requests are used during API version negotiation, so we want // because ping requests are used during API version negotiation, so we want
// to hit the non-versioned /_ping endpoint, not /v1.xx/_ping // to hit the non-versioned /_ping endpoint, not /v1.xx/_ping
req, err := cli.buildRequest("HEAD", path.Join(cli.basePath, "/_ping"), nil, nil) req, err := cli.buildRequest(http.MethodHead, path.Join(cli.basePath, "/_ping"), nil, nil)
if err != nil { if err != nil {
return ping, err return ping, err
} }
...@@ -35,7 +35,7 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) { ...@@ -35,7 +35,7 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
return ping, err return ping, err
} }
req, err = cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil) req, err = cli.buildRequest(http.MethodGet, path.Join(cli.basePath, "/_ping"), nil, nil)
if err != nil { if err != nil {
return ping, err return ping, err
} }
......
...@@ -15,6 +15,7 @@ func (cli *Client) PluginList(ctx context.Context, filter filters.Args) (types.P ...@@ -15,6 +15,7 @@ func (cli *Client) PluginList(ctx context.Context, filter filters.Args) (types.P
query := url.Values{} query := url.Values{}
if filter.Len() > 0 { if filter.Len() > 0 {
//nolint:staticcheck // ignore SA1019 for old code
filterJSON, err := filters.ToParamWithVersion(cli.version, filter) filterJSON, err := filters.ToParamWithVersion(cli.version, filter)
if err != nil { if err != nil {
return plugins, err return plugins, err
......
...@@ -29,12 +29,12 @@ type serverResponse struct { ...@@ -29,12 +29,12 @@ type serverResponse struct {
// head sends an http request to the docker API using the method HEAD. // head sends an http request to the docker API using the method HEAD.
func (cli *Client) head(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) { func (cli *Client) head(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
return cli.sendRequest(ctx, "HEAD", path, query, nil, headers) return cli.sendRequest(ctx, http.MethodHead, path, query, nil, headers)
} }
// get sends an http request to the docker API using the method GET with a specific Go context. // get sends an http request to the docker API using the method GET with a specific Go context.
func (cli *Client) get(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) { func (cli *Client) get(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
return cli.sendRequest(ctx, "GET", path, query, nil, headers) return cli.sendRequest(ctx, http.MethodGet, path, query, nil, headers)
} }
// post sends an http request to the docker API using the method POST with a specific Go context. // post sends an http request to the docker API using the method POST with a specific Go context.
...@@ -43,30 +43,21 @@ func (cli *Client) post(ctx context.Context, path string, query url.Values, obj ...@@ -43,30 +43,21 @@ func (cli *Client) post(ctx context.Context, path string, query url.Values, obj
if err != nil { if err != nil {
return serverResponse{}, err return serverResponse{}, err
} }
return cli.sendRequest(ctx, "POST", path, query, body, headers) return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers)
} }
func (cli *Client) postRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) { func (cli *Client) postRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
return cli.sendRequest(ctx, "POST", path, query, body, headers) return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers)
}
// put sends an http request to the docker API using the method PUT.
func (cli *Client) put(ctx context.Context, path string, query url.Values, obj interface{}, headers map[string][]string) (serverResponse, error) {
body, headers, err := encodeBody(obj, headers)
if err != nil {
return serverResponse{}, err
}
return cli.sendRequest(ctx, "PUT", path, query, body, headers)
} }
// putRaw sends an http request to the docker API using the method PUT. // putRaw sends an http request to the docker API using the method PUT.
func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) { func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
return cli.sendRequest(ctx, "PUT", path, query, body, headers) return cli.sendRequest(ctx, http.MethodPut, path, query, body, headers)
} }
// delete sends an http request to the docker API using the method DELETE. // delete sends an http request to the docker API using the method DELETE.
func (cli *Client) delete(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) { func (cli *Client) delete(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
return cli.sendRequest(ctx, "DELETE", path, query, nil, headers) return cli.sendRequest(ctx, http.MethodDelete, path, query, nil, headers)
} }
type headers map[string][]string type headers map[string][]string
...@@ -88,7 +79,7 @@ func encodeBody(obj interface{}, headers headers) (io.Reader, headers, error) { ...@@ -88,7 +79,7 @@ func encodeBody(obj interface{}, headers headers) (io.Reader, headers, error) {
} }
func (cli *Client) buildRequest(method, path string, body io.Reader, headers headers) (*http.Request, error) { func (cli *Client) buildRequest(method, path string, body io.Reader, headers headers) (*http.Request, error) {
expectedPayload := (method == "POST" || method == "PUT") expectedPayload := (method == http.MethodPost || method == http.MethodPut)
if expectedPayload && body == nil { if expectedPayload && body == nil {
body = bytes.NewReader([]byte{}) body = bytes.NewReader([]byte{})
} }
...@@ -178,7 +169,13 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp ...@@ -178,7 +169,13 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
// this is localised - for example in French the error would be // this is localised - for example in French the error would be
// `open //./pipe/docker_engine: Le fichier spécifié est introuvable.` // `open //./pipe/docker_engine: Le fichier spécifié est introuvable.`
if strings.Contains(err.Error(), `open //./pipe/docker_engine`) { if strings.Contains(err.Error(), `open //./pipe/docker_engine`) {
err = errors.New(err.Error() + " In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.") // Checks if client is running with elevated privileges
if f, elevatedErr := os.Open("\\\\.\\PHYSICALDRIVE0"); elevatedErr == nil {
err = errors.Wrap(err, "In the default daemon configuration on Windows, the docker client must be run with elevated privileges to connect.")
} else {
f.Close()
err = errors.Wrap(err, "This error may indicate that the docker daemon is not running.")
}
} }
return serverResp, errors.Wrap(err, "error during connect") return serverResp, errors.Wrap(err, "error during connect")
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"github.com/docker/distribution/reference" "github.com/docker/distribution/reference"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/opencontainers/go-digest" digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
......
...@@ -23,6 +23,10 @@ func (cli *Client) ServiceList(ctx context.Context, options types.ServiceListOpt ...@@ -23,6 +23,10 @@ func (cli *Client) ServiceList(ctx context.Context, options types.ServiceListOpt
query.Set("filters", filterJSON) query.Set("filters", filterJSON)
} }
if options.Status {
query.Set("status", "true")
}
resp, err := cli.get(ctx, "/services", query, nil) resp, err := cli.get(ctx, "/services", query, nil)
defer ensureReaderClosed(resp) defer ensureReaderClosed(resp)
if err != nil { if err != nil {
......
...@@ -15,6 +15,7 @@ func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumet ...@@ -15,6 +15,7 @@ func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (volumet
query := url.Values{} query := url.Values{}
if filter.Len() > 0 { if filter.Len() > 0 {
//nolint:staticcheck // ignore SA1019 for old code
filterJSON, err := filters.ToParamWithVersion(cli.version, filter) filterJSON, err := filters.ToParamWithVersion(cli.version, filter)
if err != nil { if err != nil {
return volumes, err return volumes, err
......
...@@ -59,7 +59,7 @@ func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting ...@@ -59,7 +59,7 @@ func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting
paths = append(paths, dirPath) paths = append(paths, dirPath)
} }
} }
if err := system.MkdirAll(path, mode, ""); err != nil { if err := system.MkdirAll(path, mode); err != nil {
return err return err
} }
} else { } else {
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
// Ownership is handled elsewhere, but in the future could be support here // Ownership is handled elsewhere, but in the future could be support here
// too. // too.
func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting bool) error { func mkdirAs(path string, mode os.FileMode, owner Identity, mkAll, chownExisting bool) error {
if err := system.MkdirAll(path, mode, ""); err != nil { if err := system.MkdirAll(path, mode); err != nil {
return err return err
} }
return nil return nil
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/term"
"github.com/docker/go-units" units "github.com/docker/go-units"
"github.com/morikuni/aec" "github.com/morikuni/aec"
) )
...@@ -139,13 +139,13 @@ type JSONMessage struct { ...@@ -139,13 +139,13 @@ type JSONMessage struct {
Stream string `json:"stream,omitempty"` Stream string `json:"stream,omitempty"`
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
Progress *JSONProgress `json:"progressDetail,omitempty"` Progress *JSONProgress `json:"progressDetail,omitempty"`
ProgressMessage string `json:"progress,omitempty"` //deprecated ProgressMessage string `json:"progress,omitempty"` // deprecated
ID string `json:"id,omitempty"` ID string `json:"id,omitempty"`
From string `json:"from,omitempty"` From string `json:"from,omitempty"`
Time int64 `json:"time,omitempty"` Time int64 `json:"time,omitempty"`
TimeNano int64 `json:"timeNano,omitempty"` TimeNano int64 `json:"timeNano,omitempty"`
Error *JSONError `json:"errorDetail,omitempty"` Error *JSONError `json:"errorDetail,omitempty"`
ErrorMessage string `json:"error,omitempty"` //deprecated ErrorMessage string `json:"error,omitempty"` // deprecated
// Aux contains out-of-band data, such as digests for push signing and image id after building. // Aux contains out-of-band data, such as digests for push signing and image id after building.
Aux *json.RawMessage `json:"aux,omitempty"` Aux *json.RawMessage `json:"aux,omitempty"`
} }
...@@ -177,7 +177,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error { ...@@ -177,7 +177,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
if isTerminal && jm.Stream == "" && jm.Progress != nil { if isTerminal && jm.Stream == "" && jm.Progress != nil {
clearLine(out) clearLine(out)
endl = "\r" endl = "\r"
fmt.Fprintf(out, endl) fmt.Fprint(out, endl)
} else if jm.Progress != nil && jm.Progress.String() != "" { //disable progressbar in non-terminal } else if jm.Progress != nil && jm.Progress.String() != "" { //disable progressbar in non-terminal
return nil return nil
} }
...@@ -194,7 +194,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error { ...@@ -194,7 +194,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
} }
if jm.Progress != nil && isTerminal { if jm.Progress != nil && isTerminal {
fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl) fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl)
} else if jm.ProgressMessage != "" { //deprecated } else if jm.ProgressMessage != "" { // deprecated
fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl) fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)
} else if jm.Stream != "" { } else if jm.Stream != "" {
fmt.Fprintf(out, "%s%s", jm.Stream, endl) fmt.Fprintf(out, "%s%s", jm.Stream, endl)
......
...@@ -90,7 +90,6 @@ func parseInfoFile(r io.Reader, filter FilterFunc) ([]*Info, error) { ...@@ -90,7 +90,6 @@ func parseInfoFile(r io.Reader, filter FilterFunc) ([]*Info, error) {
mount propagation flags in fields[6]. The correct mount propagation flags in fields[6]. The correct
behavior is to ignore any unknown optional fields. behavior is to ignore any unknown optional fields.
*/ */
break
} }
} }
if i == numFields { if i == numFields {
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"os" "os"
"strings" "strings"
"github.com/mattn/go-shellwords" shellwords "github.com/mattn/go-shellwords"
) )
var ( var (
......
...@@ -3,25 +3,25 @@ ...@@ -3,25 +3,25 @@
package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem" package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatingsystem"
import ( import (
"bytes"
"errors" "errors"
"fmt"
"os/exec" "golang.org/x/sys/unix"
) )
// GetOperatingSystem gets the name of the current operating system. // GetOperatingSystem gets the name of the current operating system.
func GetOperatingSystem() (string, error) { func GetOperatingSystem() (string, error) {
cmd := exec.Command("uname", "-s") utsname := &unix.Utsname{}
osName, err := cmd.Output() if err := unix.Uname(utsname); err != nil {
if err != nil {
return "", err return "", err
} }
return string(osName), nil return string(utsname.Machine[:bytes.IndexByte(utsname.Sysname[:], 0)]), nil
} }
// GetOperatingSystemVersion gets the version of the current operating system, as a string. // GetOperatingSystemVersion gets the version of the current operating system, as a string.
func GetOperatingSystemVersion() (string, error) { func GetOperatingSystemVersion() (string, error) {
// there's no standard unix way of getting this, sadly... // there's no standard unix way of getting this, sadly...
return "", fmt.Error("Unsupported on generic unix") return "", errors.New("Unsupported on generic unix")
} }
// IsContainerized returns true if we are running inside a container. // IsContainerized returns true if we are running inside a container.
......
...@@ -8,14 +8,14 @@ import ( ...@@ -8,14 +8,14 @@ import (
"path/filepath" "path/filepath"
) )
// MkdirAllWithACL is a wrapper for MkdirAll on unix systems. // MkdirAllWithACL is a wrapper for os.MkdirAll on unix systems.
func MkdirAllWithACL(path string, perm os.FileMode, sddl string) error { func MkdirAllWithACL(path string, perm os.FileMode, sddl string) error {
return MkdirAll(path, perm, sddl) return os.MkdirAll(path, perm)
} }
// MkdirAll creates a directory named path along with any necessary parents, // MkdirAll creates a directory named path along with any necessary parents,
// with permission specified by attribute perm for all dir created. // with permission specified by attribute perm for all dir created.
func MkdirAll(path string, perm os.FileMode, sddl string) error { func MkdirAll(path string, perm os.FileMode) error {
return os.MkdirAll(path, perm) return os.MkdirAll(path, perm)
} }
......
...@@ -11,7 +11,6 @@ import ( ...@@ -11,7 +11,6 @@ import (
"time" "time"
"unsafe" "unsafe"
winio "github.com/Microsoft/go-winio"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
...@@ -26,9 +25,10 @@ func MkdirAllWithACL(path string, perm os.FileMode, sddl string) error { ...@@ -26,9 +25,10 @@ func MkdirAllWithACL(path string, perm os.FileMode, sddl string) error {
return mkdirall(path, true, sddl) return mkdirall(path, true, sddl)
} }
// MkdirAll implementation that is volume path aware for Windows. // MkdirAll implementation that is volume path aware for Windows. It can be used
func MkdirAll(path string, _ os.FileMode, sddl string) error { // as a drop-in replacement for os.MkdirAll()
return mkdirall(path, false, sddl) func MkdirAll(path string, _ os.FileMode) error {
return mkdirall(path, false, "")
} }
// mkdirall is a custom version of os.MkdirAll modified for use on Windows // mkdirall is a custom version of os.MkdirAll modified for use on Windows
...@@ -102,13 +102,13 @@ func mkdirall(path string, applyACL bool, sddl string) error { ...@@ -102,13 +102,13 @@ func mkdirall(path string, applyACL bool, sddl string) error {
// and Local System. // and Local System.
func mkdirWithACL(name string, sddl string) error { func mkdirWithACL(name string, sddl string) error {
sa := windows.SecurityAttributes{Length: 0} sa := windows.SecurityAttributes{Length: 0}
sd, err := winio.SddlToSecurityDescriptor(sddl) sd, err := windows.SecurityDescriptorFromString(sddl)
if err != nil { if err != nil {
return &os.PathError{Op: "mkdir", Path: name, Err: err} return &os.PathError{Op: "mkdir", Path: name, Err: err}
} }
sa.Length = uint32(unsafe.Sizeof(sa)) sa.Length = uint32(unsafe.Sizeof(sa))
sa.InheritHandle = 1 sa.InheritHandle = 1
sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0])) sa.SecurityDescriptor = sd
namep, err := windows.UTF16PtrFromString(name) namep, err := windows.UTF16PtrFromString(name)
if err != nil { if err != nil {
......
...@@ -18,8 +18,7 @@ var ( ...@@ -18,8 +18,7 @@ var (
// InitLCOW sets whether LCOW is supported or not. Requires RS5+ // InitLCOW sets whether LCOW is supported or not. Requires RS5+
func InitLCOW(experimental bool) { func InitLCOW(experimental bool) {
v := GetOSVersion() if experimental && osversion.Build() >= osversion.RS5 {
if experimental && v.Build >= osversion.RS5 {
lcowSupported = true lcowSupported = true
} }
} }
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/docker/go-units" units "github.com/docker/go-units"
) )
// ReadMemInfo retrieves memory statistics of the host system and returns a // ReadMemInfo retrieves memory statistics of the host system and returns a
......
...@@ -5,8 +5,6 @@ import ( ...@@ -5,8 +5,6 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
"github.com/containerd/continuity/pathdriver"
) )
const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" const defaultUnixPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
...@@ -27,6 +25,12 @@ func DefaultPathEnv(os string) string { ...@@ -27,6 +25,12 @@ func DefaultPathEnv(os string) string {
} }
// PathVerifier defines the subset of a PathDriver that CheckSystemDriveAndRemoveDriveLetter
// actually uses in order to avoid system depending on containerd/continuity.
type PathVerifier interface {
IsAbs(string) bool
}
// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter, // CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
// is the system drive. // is the system drive.
// On Linux: this is a no-op. // On Linux: this is a no-op.
...@@ -42,7 +46,7 @@ func DefaultPathEnv(os string) string { ...@@ -42,7 +46,7 @@ func DefaultPathEnv(os string) string {
// a --> a // a --> a
// /a --> \a // /a --> \a
// d:\ --> Fail // d:\ --> Fail
func CheckSystemDriveAndRemoveDriveLetter(path string, driver pathdriver.PathDriver) (string, error) { func CheckSystemDriveAndRemoveDriveLetter(path string, driver PathVerifier) (string, error) {
if runtime.GOOS != "windows" || LCOWSupported() { if runtime.GOOS != "windows" || LCOWSupported() {
return path, nil return path, nil
} }
......
...@@ -8,7 +8,8 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) { ...@@ -8,7 +8,8 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
mode: s.Mode, mode: s.Mode,
uid: s.Uid, uid: s.Uid,
gid: s.Gid, gid: s.Gid,
rdev: s.Rdev, // the type is 32bit on mips
rdev: uint64(s.Rdev), // nolint: unconvert
mtim: s.Mtim}, nil mtim: s.Mtim}, nil
} }
......
package system // import "github.com/docker/docker/pkg/system"
import "syscall"
// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
func fromStatT(s *syscall.Stat_t) (*StatT, error) {
return &StatT{size: s.Size,
mode: uint32(s.Mode),
uid: s.Uid,
gid: s.Gid,
rdev: uint64(s.Rdev),
mtim: s.Mtim}, nil
}
package system // import "github.com/docker/docker/pkg/system" package system // import "github.com/docker/docker/pkg/system"
import ( import (
"fmt"
"syscall" "syscall"
"unsafe" "unsafe"
"github.com/Microsoft/hcsshim/osversion"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
...@@ -61,12 +61,7 @@ var ( ...@@ -61,12 +61,7 @@ var (
// OSVersion is a wrapper for Windows version information // OSVersion is a wrapper for Windows version information
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
type OSVersion struct { type OSVersion = osversion.OSVersion
Version uint32
MajorVersion uint8
MinorVersion uint8
Build uint16
}
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx
type osVersionInfoEx struct { type osVersionInfoEx struct {
...@@ -84,23 +79,10 @@ type osVersionInfoEx struct { ...@@ -84,23 +79,10 @@ type osVersionInfoEx struct {
} }
// GetOSVersion gets the operating system version on Windows. Note that // GetOSVersion gets the operating system version on Windows. Note that
// docker.exe must be manifested to get the correct version information. // dockerd.exe must be manifested to get the correct version information.
// Deprecated: use github.com/Microsoft/hcsshim/osversion.Get() instead
func GetOSVersion() OSVersion { func GetOSVersion() OSVersion {
var err error return osversion.Get()
osv := OSVersion{}
osv.Version, err = windows.GetVersion()
if err != nil {
// GetVersion never fails.
panic(err)
}
osv.MajorVersion = uint8(osv.Version & 0xFF)
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
osv.Build = uint16(osv.Version >> 16)
return osv
}
func (osv OSVersion) ToString() string {
return fmt.Sprintf("%d.%d.%d", osv.MajorVersion, osv.MinorVersion, osv.Build)
} }
// IsWindowsClient returns true if the SKU is client // IsWindowsClient returns true if the SKU is client
......
package system // import "github.com/docker/docker/pkg/system"
import (
"syscall"
"unsafe"
"golang.org/x/sys/unix"
)
// LUtimesNano is used to change access and modification time of the specified path.
// It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm.
func LUtimesNano(path string, ts []syscall.Timespec) error {
atFdCwd := unix.AT_FDCWD
var _path *byte
_path, err := unix.BytePtrFromString(path)
if err != nil {
return err
}
if _, _, err := unix.Syscall6(unix.SYS_UTIMENSAT, uintptr(atFdCwd), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), unix.AT_SYMLINK_NOFOLLOW, 0, 0); err != 0 && err != unix.ENOSYS {
return err
}
return nil
}
// +build linux freebsd
package system // import "github.com/docker/docker/pkg/system" package system // import "github.com/docker/docker/pkg/system"
import ( import (
"syscall" "syscall"
"unsafe"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
...@@ -10,13 +11,12 @@ import ( ...@@ -10,13 +11,12 @@ import (
// LUtimesNano is used to change access and modification time of the specified path. // LUtimesNano is used to change access and modification time of the specified path.
// It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm. // It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm.
func LUtimesNano(path string, ts []syscall.Timespec) error { func LUtimesNano(path string, ts []syscall.Timespec) error {
var _path *byte uts := []unix.Timespec{
_path, err := unix.BytePtrFromString(path) unix.NsecToTimespec(syscall.TimespecToNsec(ts[0])),
if err != nil { unix.NsecToTimespec(syscall.TimespecToNsec(ts[1])),
return err
} }
err := unix.UtimesNanoAt(unix.AT_FDCWD, path, uts, unix.AT_SYMLINK_NOFOLLOW)
if _, _, err := unix.Syscall(unix.SYS_LUTIMES, uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), 0); err != 0 && err != unix.ENOSYS { if err != nil && err != unix.ENOSYS {
return err return err
} }
......
...@@ -6,19 +6,28 @@ import "golang.org/x/sys/unix" ...@@ -6,19 +6,28 @@ import "golang.org/x/sys/unix"
// and associated with the given path in the file system. // and associated with the given path in the file system.
// It will returns a nil slice and nil error if the xattr is not set. // It will returns a nil slice and nil error if the xattr is not set.
func Lgetxattr(path string, attr string) ([]byte, error) { func Lgetxattr(path string, attr string) ([]byte, error) {
// Start with a 128 length byte array
dest := make([]byte, 128) dest := make([]byte, 128)
sz, errno := unix.Lgetxattr(path, attr, dest) sz, errno := unix.Lgetxattr(path, attr, dest)
if errno == unix.ENODATA {
switch {
case errno == unix.ENODATA:
return nil, nil return nil, nil
} case errno == unix.ERANGE:
if errno == unix.ERANGE { // 128 byte array might just not be good enough. A dummy buffer is used
// to get the real size of the xattrs on disk
sz, errno = unix.Lgetxattr(path, attr, []byte{})
if errno != nil {
return nil, errno
}
dest = make([]byte, sz) dest = make([]byte, sz)
sz, errno = unix.Lgetxattr(path, attr, dest) sz, errno = unix.Lgetxattr(path, attr, dest)
} if errno != nil {
if errno != nil { return nil, errno
}
case errno != nil:
return nil, errno return nil, errno
} }
return dest[:sz], nil return dest[:sz], nil
} }
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"syscall" // used for STD_INPUT_HANDLE, STD_OUTPUT_HANDLE and STD_ERROR_HANDLE "syscall" // used for STD_INPUT_HANDLE, STD_OUTPUT_HANDLE and STD_ERROR_HANDLE
"github.com/Azure/go-ansiterm/winterm" "github.com/Azure/go-ansiterm/winterm"
"github.com/docker/docker/pkg/term/windows" windowsconsole "github.com/docker/docker/pkg/term/windows"
) )
// State holds the console mode for the terminal. // State holds the console mode for the terminal.
......
// +build windows
// These files implement ANSI-aware input and output streams for use by the Docker Windows client. // These files implement ANSI-aware input and output streams for use by the Docker Windows client.
// When asked for the set of standard streams (e.g., stdin, stdout, stderr), the code will create // When asked for the set of standard streams (e.g., stdin, stdout, stderr), the code will create
// and return pseudo-streams that convert ANSI sequences to / from Windows Console API calls. // and return pseudo-streams that convert ANSI sequences to / from Windows Console API calls.
...@@ -9,7 +10,7 @@ import ( ...@@ -9,7 +10,7 @@ import (
"os" "os"
"sync" "sync"
"github.com/Azure/go-ansiterm" ansiterm "github.com/Azure/go-ansiterm"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
......
...@@ -95,7 +95,7 @@ var completionCommand = cli.Command{ ...@@ -95,7 +95,7 @@ var completionCommand = cli.Command{
Name: "completion", Name: "completion",
Usage: "Output shell completion code", Usage: "Output shell completion code",
ArgsUsage: "SHELL", ArgsUsage: "SHELL",
Description: `Output shell completion code for bash or zsh. Description: `Output shell completion code for bash, zsh or fish.
Examples: Examples:
...@@ -104,6 +104,9 @@ Examples: ...@@ -104,6 +104,9 @@ Examples:
# Installing zsh completion on Linux # Installing zsh completion on Linux
source <(crictl completion zsh) source <(crictl completion zsh)
# Installing fish completion on Linux
crictl completion fish | source
`, `,
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
// select bash by default for backwards compatibility // select bash by default for backwards compatibility
...@@ -118,10 +121,21 @@ Examples: ...@@ -118,10 +121,21 @@ Examples:
switch c.Args().First() { switch c.Args().First() {
case "bash": case "bash":
return bashCompletion(c) return bashCompletion(c)
case "fish":
return fishCompletion(c)
case "zsh": case "zsh":
return zshCompletion(c) return zshCompletion(c)
default: default:
return fmt.Errorf("only bash and zsh supported") return fmt.Errorf("only bash, zsh or fish are supported")
} }
}, },
} }
func fishCompletion(c *cli.Context) error {
completion, err := c.App.ToFishCompletion()
if err != nil {
return err
}
fmt.Fprintln(c.App.Writer, completion)
return nil
}
...@@ -304,7 +304,7 @@ var removeContainerCommand = cli.Command{ ...@@ -304,7 +304,7 @@ var removeContainerCommand = cli.Command{
} }
if resp.GetStatus().GetState() == pb.ContainerState_CONTAINER_RUNNING { if resp.GetStatus().GetState() == pb.ContainerState_CONTAINER_RUNNING {
if ctx.Bool("force") { if ctx.Bool("force") {
if err := RemoveContainer(runtimeClient, id); err != nil { if err := StopContainer(runtimeClient, id, 0); err != nil {
logrus.Errorf("stopping the container %q failed: %v", id, err) logrus.Errorf("stopping the container %q failed: %v", id, err)
errored = true errored = true
continue continue
...@@ -859,10 +859,6 @@ func ListContainers(runtimeClient pb.RuntimeServiceClient, imageClient pb.ImageS ...@@ -859,10 +859,6 @@ func ListContainers(runtimeClient pb.RuntimeServiceClient, imageClient pb.ImageS
display.AddRow([]string{columnContainer, columnImage, columnCreated, columnState, columnName, columnAttempt, columnPodID}) display.AddRow([]string{columnContainer, columnImage, columnCreated, columnState, columnName, columnAttempt, columnPodID})
} }
for _, c := range r.Containers { for _, c := range r.Containers {
// Filter by pod name/namespace regular expressions.
if !matchesRegex(opts.nameRegexp, c.Metadata.Name) {
continue
}
if match, err := matchesImage(imageClient, opts.image, c.GetImage().GetImage()); err != nil { if match, err := matchesImage(imageClient, opts.image, c.GetImage().GetImage()); err != nil {
return fmt.Errorf("failed to check image match %v", err) return fmt.Errorf("failed to check image match %v", err)
} else if !match { } else if !match {
...@@ -941,8 +937,16 @@ func convertContainerState(state pb.ContainerState) string { ...@@ -941,8 +937,16 @@ func convertContainerState(state pb.ContainerState) string {
} }
func getContainersList(containersList []*pb.Container, opts listOptions) []*pb.Container { func getContainersList(containersList []*pb.Container, opts listOptions) []*pb.Container {
sort.Sort(containerByCreated(containersList)) filtered := []*pb.Container{}
n := len(containersList) for _, c := range containersList {
// Filter by pod name/namespace regular expressions.
if matchesRegex(opts.nameRegexp, c.Metadata.Name) {
filtered = append(filtered, c)
}
}
sort.Sort(containerByCreated(filtered))
n := len(filtered)
if opts.latest { if opts.latest {
n = 1 n = 1
} }
...@@ -954,7 +958,7 @@ func getContainersList(containersList []*pb.Container, opts listOptions) []*pb.C ...@@ -954,7 +958,7 @@ func getContainersList(containersList []*pb.Container, opts listOptions) []*pb.C
return a return a
} }
return b return b
}(n, len(containersList)) }(n, len(filtered))
return containersList[:n] return filtered[:n]
} }
...@@ -60,9 +60,10 @@ var pullImageCommand = cli.Command{ ...@@ -60,9 +60,10 @@ var pullImageCommand = cli.Command{
Usage: "Use `AUTH_STRING` for accessing the registry. AUTH_STRING is a base64 encoded 'USERNAME[:PASSWORD]'", Usage: "Use `AUTH_STRING` for accessing the registry. AUTH_STRING is a base64 encoded 'USERNAME[:PASSWORD]'",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "pod-config", Name: "pod-config",
Value: "", Value: "",
Usage: "Use `pod-config.[json|yaml]` to override the the pull context", Usage: "Use `pod-config.[json|yaml]` to override the the pull context",
TakesFile: true,
}, },
}, },
ArgsUsage: "NAME[:TAG|@DIGEST]", ArgsUsage: "NAME[:TAG|@DIGEST]",
...@@ -295,6 +296,10 @@ var removeImageCommand = cli.Command{ ...@@ -295,6 +296,10 @@ var removeImageCommand = cli.Command{
Name: "all, a", Name: "all, a",
Usage: "Remove all images", Usage: "Remove all images",
}, },
cli.BoolFlag{
Name: "prune, p",
Usage: "Remove all unused images",
},
}, },
Action: func(ctx *cli.Context) error { Action: func(ctx *cli.Context) error {
imageClient, conn, err := getImageClient(ctx) imageClient, conn, err := getImageClient(ctx)
...@@ -303,25 +308,69 @@ var removeImageCommand = cli.Command{ ...@@ -303,25 +308,69 @@ var removeImageCommand = cli.Command{
} }
defer closeConnection(ctx, conn) defer closeConnection(ctx, conn)
ids := ctx.Args() ids := map[string]bool{}
if ctx.Bool("all") { for _, id := range ctx.Args() {
logrus.Debugf("User specified image to be removed: %v", id)
ids[id] = true
}
all := ctx.Bool("all")
prune := ctx.Bool("prune")
// Add all available images to the ID selector
if all || prune {
r, err := imageClient.ListImages(context.Background(), r, err := imageClient.ListImages(context.Background(),
&pb.ListImagesRequest{}) &pb.ListImagesRequest{})
if err != nil { if err != nil {
return err return err
} }
ids = nil
for _, img := range r.GetImages() { for _, img := range r.GetImages() {
ids = append(ids, img.GetId()) logrus.Debugf("Adding image to be removed: %v", img.GetId())
ids[img.GetId()] = true
}
}
// On prune, remove images which are in use from the ID selector
if prune {
runtimeClient, conn, err := getRuntimeClient(ctx)
if err != nil {
return err
}
defer closeConnection(ctx, conn)
// Container images
c, err := runtimeClient.ListContainers(
context.Background(), &pb.ListContainersRequest{},
)
if err != nil {
return err
}
for _, container := range c.GetContainers() {
img := container.GetImage().Image
imageStatus, err := ImageStatus(imageClient, img, false)
if err != nil {
logrus.Errorf(
"image status request for %q failed: %v",
img, err,
)
continue
}
id := imageStatus.GetImage().GetId()
logrus.Debugf("Excluding in use container image: %v", id)
ids[id] = false
} }
} }
if len(ids) == 0 { if len(ids) == 0 {
return cli.ShowSubcommandHelp(ctx) logrus.Info("No images to remove")
return nil
} }
errored := false errored := false
for _, id := range ids { for id, remove := range ids {
if !remove {
continue
}
status, err := ImageStatus(imageClient, id, false) status, err := ImageStatus(imageClient, id, false)
if err != nil { if err != nil {
logrus.Errorf("image status request for %q failed: %v", id, err) logrus.Errorf("image status request for %q failed: %v", id, err)
...@@ -336,8 +385,12 @@ var removeImageCommand = cli.Command{ ...@@ -336,8 +385,12 @@ var removeImageCommand = cli.Command{
_, err = RemoveImage(imageClient, id) _, err = RemoveImage(imageClient, id)
if err != nil { if err != nil {
logrus.Errorf("error of removing image %q: %v", id, err) // We ignore further errors on prune because there might be
errored = true // races
if !prune {
logrus.Errorf("error of removing image %q: %v", id, err)
errored = true
}
continue continue
} }
for _, repoTag := range status.Image.RepoTags { for _, repoTag := range status.Image.RepoTags {
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"strings"
"time" "time"
timetypes "github.com/docker/docker/api/types/time" timetypes "github.com/docker/docker/api/types/time"
...@@ -40,6 +41,10 @@ var logsCommand = cli.Command{ ...@@ -40,6 +41,10 @@ var logsCommand = cli.Command{
Name: "follow, f", Name: "follow, f",
Usage: "Follow log output", Usage: "Follow log output",
}, },
cli.BoolFlag{
Name: "previous, p",
Usage: "Print the logs for the previous instance of the container in a pod if it exists",
},
cli.Int64Flag{ cli.Int64Flag{
Name: "tail", Name: "tail",
Value: -1, Value: -1,
...@@ -77,6 +82,7 @@ var logsCommand = cli.Command{ ...@@ -77,6 +82,7 @@ var logsCommand = cli.Command{
return err return err
} }
timestamp := ctx.Bool("timestamps") timestamp := ctx.Bool("timestamps")
previous := ctx.Bool("previous")
logOptions := logs.NewLogOptions(&v1.PodLogOptions{ logOptions := logs.NewLogOptions(&v1.PodLogOptions{
Follow: ctx.Bool("follow"), Follow: ctx.Bool("follow"),
TailLines: &tailLines, TailLines: &tailLines,
...@@ -92,6 +98,14 @@ var logsCommand = cli.Command{ ...@@ -92,6 +98,14 @@ var logsCommand = cli.Command{
if logPath == "" { if logPath == "" {
return fmt.Errorf("The container has not set log path") return fmt.Errorf("The container has not set log path")
} }
if previous {
containerAttempt := status.GetMetadata().Attempt
if containerAttempt == uint32(0) {
return fmt.Errorf("Previous terminated container %s not found", status.GetMetadata().Name)
}
logPath = fmt.Sprintf("%s%s%s", logPath[:strings.LastIndex(logPath, "/")+1], fmt.Sprint(containerAttempt-1),
logPath[strings.LastIndex(logPath, "."):])
}
return logs.ReadLogs(context.Background(), logPath, status.GetId(), logOptions, runtimeService, os.Stdout, os.Stderr) return logs.ReadLogs(context.Background(), logPath, status.GetId(), logOptions, runtimeService, os.Stdout, os.Stderr)
}, },
} }
......
...@@ -127,10 +127,11 @@ func Main() { ...@@ -127,10 +127,11 @@ func Main() {
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "config, c", Name: "config, c",
EnvVar: "CRI_CONFIG_FILE", EnvVar: "CRI_CONFIG_FILE",
Value: defaultConfigPath, Value: defaultConfigPath,
Usage: "Location of the client config file. If not specified and the default does not exist, the program's directory is searched as well", Usage: "Location of the client config file. If not specified and the default does not exist, the program's directory is searched as well",
TakesFile: true,
}, },
cli.StringFlag{ cli.StringFlag{
Name: "runtime-endpoint, r", Name: "runtime-endpoint, r",
......
...@@ -486,7 +486,7 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error { ...@@ -486,7 +486,7 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error {
case "json": case "json":
return outputProtobufObjAsJSON(r) return outputProtobufObjAsJSON(r)
case "yaml": case "yaml":
return outputProtobufObjAsJSON(r) return outputProtobufObjAsYAML(r)
case "table", "": case "table", "":
// continue; output will be generated after the switch block ends. // continue; output will be generated after the switch block ends.
default: default:
...@@ -498,14 +498,6 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error { ...@@ -498,14 +498,6 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error {
display.AddRow([]string{columnPodID, columnCreated, columnState, columnName, columnNamespace, columnAttempt}) display.AddRow([]string{columnPodID, columnCreated, columnState, columnName, columnNamespace, columnAttempt})
} }
for _, pod := range r.Items { for _, pod := range r.Items {
// Filter by pod name/namespace regular expressions.
if !matchesRegex(opts.nameRegexp, pod.Metadata.Name) {
continue
}
if !matchesRegex(opts.podNamespaceRegexp, pod.Metadata.Namespace) {
continue
}
if opts.quiet { if opts.quiet {
fmt.Printf("%s\n", pod.Id) fmt.Printf("%s\n", pod.Id)
continue continue
...@@ -572,8 +564,17 @@ func convertPodState(state pb.PodSandboxState) string { ...@@ -572,8 +564,17 @@ func convertPodState(state pb.PodSandboxState) string {
} }
func getSandboxesList(sandboxesList []*pb.PodSandbox, opts listOptions) []*pb.PodSandbox { func getSandboxesList(sandboxesList []*pb.PodSandbox, opts listOptions) []*pb.PodSandbox {
sort.Sort(sandboxByCreated(sandboxesList)) filtered := []*pb.PodSandbox{}
n := len(sandboxesList) for _, p := range sandboxesList {
// Filter by pod name/namespace regular expressions.
if matchesRegex(opts.nameRegexp, p.Metadata.Name) &&
matchesRegex(opts.podNamespaceRegexp, p.Metadata.Namespace) {
filtered = append(filtered, p)
}
}
sort.Sort(sandboxByCreated(filtered))
n := len(filtered)
if opts.latest { if opts.latest {
n = 1 n = 1
} }
...@@ -585,7 +586,7 @@ func getSandboxesList(sandboxesList []*pb.PodSandbox, opts listOptions) []*pb.Po ...@@ -585,7 +586,7 @@ func getSandboxesList(sandboxesList []*pb.PodSandbox, opts listOptions) []*pb.Po
return a return a
} }
return b return b
}(n, len(sandboxesList)) }(n, len(filtered))
return sandboxesList[:n] return filtered[:n]
} }
...@@ -172,7 +172,6 @@ var svgAttributeAdjustments = map[string]string{ ...@@ -172,7 +172,6 @@ var svgAttributeAdjustments = map[string]string{
"diffuseconstant": "diffuseConstant", "diffuseconstant": "diffuseConstant",
"edgemode": "edgeMode", "edgemode": "edgeMode",
"externalresourcesrequired": "externalResourcesRequired", "externalresourcesrequired": "externalResourcesRequired",
"filterres": "filterRes",
"filterunits": "filterUnits", "filterunits": "filterUnits",
"glyphref": "glyphRef", "glyphref": "glyphRef",
"gradienttransform": "gradientTransform", "gradienttransform": "gradientTransform",
......
...@@ -881,7 +881,7 @@ func inBodyIM(p *parser) bool { ...@@ -881,7 +881,7 @@ func inBodyIM(p *parser) bool {
p.addElement() p.addElement()
p.im = inFramesetIM p.im = inFramesetIM
return true return true
case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul: case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Main, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul:
p.popUntil(buttonScope, a.P) p.popUntil(buttonScope, a.P)
p.addElement() p.addElement()
case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6: case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
...@@ -1137,7 +1137,7 @@ func inBodyIM(p *parser) bool { ...@@ -1137,7 +1137,7 @@ func inBodyIM(p *parser) bool {
return false return false
} }
return true return true
case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul: case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dialog, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Main, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul:
p.popUntil(defaultScope, p.tok.DataAtom) p.popUntil(defaultScope, p.tok.DataAtom)
case a.Form: case a.Form:
if p.oe.contains(a.Template) { if p.oe.contains(a.Template) {
...@@ -2136,28 +2136,31 @@ func parseForeignContent(p *parser) bool { ...@@ -2136,28 +2136,31 @@ func parseForeignContent(p *parser) bool {
Data: p.tok.Data, Data: p.tok.Data,
}) })
case StartTagToken: case StartTagToken:
b := breakout[p.tok.Data] if !p.fragment {
if p.tok.DataAtom == a.Font { b := breakout[p.tok.Data]
loop: if p.tok.DataAtom == a.Font {
for _, attr := range p.tok.Attr { loop:
switch attr.Key { for _, attr := range p.tok.Attr {
case "color", "face", "size": switch attr.Key {
b = true case "color", "face", "size":
break loop b = true
break loop
}
} }
} }
} if b {
if b { for i := len(p.oe) - 1; i >= 0; i-- {
for i := len(p.oe) - 1; i >= 0; i-- { n := p.oe[i]
n := p.oe[i] if n.Namespace == "" || htmlIntegrationPoint(n) || mathMLTextIntegrationPoint(n) {
if n.Namespace == "" || htmlIntegrationPoint(n) || mathMLTextIntegrationPoint(n) { p.oe = p.oe[:i+1]
p.oe = p.oe[:i+1] break
break }
} }
return false
} }
return false
} }
switch p.top().Namespace { current := p.adjustedCurrentNode()
switch current.Namespace {
case "math": case "math":
adjustAttributeNames(p.tok.Attr, mathMLAttributeAdjustments) adjustAttributeNames(p.tok.Attr, mathMLAttributeAdjustments)
case "svg": case "svg":
...@@ -2172,7 +2175,7 @@ func parseForeignContent(p *parser) bool { ...@@ -2172,7 +2175,7 @@ func parseForeignContent(p *parser) bool {
panic("html: bad parser state: unexpected namespace") panic("html: bad parser state: unexpected namespace")
} }
adjustForeignAttributes(p.tok.Attr) adjustForeignAttributes(p.tok.Attr)
namespace := p.top().Namespace namespace := current.Namespace
p.addElement() p.addElement()
p.top().Namespace = namespace p.top().Namespace = namespace
if namespace != "" { if namespace != "" {
...@@ -2201,12 +2204,20 @@ func parseForeignContent(p *parser) bool { ...@@ -2201,12 +2204,20 @@ func parseForeignContent(p *parser) bool {
return true return true
} }
// Section 12.2.4.2.
func (p *parser) adjustedCurrentNode() *Node {
if len(p.oe) == 1 && p.fragment && p.context != nil {
return p.context
}
return p.oe.top()
}
// Section 12.2.6. // Section 12.2.6.
func (p *parser) inForeignContent() bool { func (p *parser) inForeignContent() bool {
if len(p.oe) == 0 { if len(p.oe) == 0 {
return false return false
} }
n := p.oe[len(p.oe)-1] n := p.adjustedCurrentNode()
if n.Namespace == "" { if n.Namespace == "" {
return false return false
} }
...@@ -2364,7 +2375,6 @@ func ParseFragmentWithOptions(r io.Reader, context *Node, opts ...ParseOption) ( ...@@ -2364,7 +2375,6 @@ func ParseFragmentWithOptions(r io.Reader, context *Node, opts ...ParseOption) (
contextTag = context.DataAtom.String() contextTag = context.DataAtom.String()
} }
p := &parser{ p := &parser{
tokenizer: NewTokenizerFragment(r, contextTag),
doc: &Node{ doc: &Node{
Type: DocumentNode, Type: DocumentNode,
}, },
...@@ -2372,6 +2382,11 @@ func ParseFragmentWithOptions(r io.Reader, context *Node, opts ...ParseOption) ( ...@@ -2372,6 +2382,11 @@ func ParseFragmentWithOptions(r io.Reader, context *Node, opts ...ParseOption) (
fragment: true, fragment: true,
context: context, context: context,
} }
if context != nil && context.Namespace != "" {
p.tokenizer = NewTokenizer(r)
} else {
p.tokenizer = NewTokenizerFragment(r, contextTag)
}
for _, f := range opts { for _, f := range opts {
f(p) f(p)
......
...@@ -347,6 +347,7 @@ loop: ...@@ -347,6 +347,7 @@ loop:
break loop break loop
} }
if c != '/' { if c != '/' {
z.raw.end--
continue loop continue loop
} }
if z.readRawEndTag() || z.err != nil { if z.readRawEndTag() || z.err != nil {
...@@ -1067,6 +1068,11 @@ loop: ...@@ -1067,6 +1068,11 @@ loop:
// Raw returns the unmodified text of the current token. Calling Next, Token, // Raw returns the unmodified text of the current token. Calling Next, Token,
// Text, TagName or TagAttr may change the contents of the returned slice. // Text, TagName or TagAttr may change the contents of the returned slice.
//
// The token stream's raw bytes partition the byte stream (up until an
// ErrorToken). There are no overlaps or gaps between two consecutive token's
// raw bytes. One implication is that the byte offset of the current token is
// the sum of the lengths of all previous tokens' raw bytes.
func (z *Tokenizer) Raw() []byte { func (z *Tokenizer) Raw() []byte {
return z.buf[z.raw.start:z.raw.end] return z.buf[z.raw.start:z.raw.end]
} }
......
...@@ -150,7 +150,7 @@ func appendIndexed(dst []byte, i uint64) []byte { ...@@ -150,7 +150,7 @@ func appendIndexed(dst []byte, i uint64) []byte {
// extended buffer. // extended buffer.
// //
// If f.Sensitive is true, "Never Indexed" representation is used. If // If f.Sensitive is true, "Never Indexed" representation is used. If
// f.Sensitive is false and indexing is true, "Inremental Indexing" // f.Sensitive is false and indexing is true, "Incremental Indexing"
// representation is used. // representation is used.
func appendNewName(dst []byte, f HeaderField, indexing bool) []byte { func appendNewName(dst []byte, f HeaderField, indexing bool) []byte {
dst = append(dst, encodeTypeByte(indexing, f.Sensitive)) dst = append(dst, encodeTypeByte(indexing, f.Sensitive))
......
...@@ -17,6 +17,7 @@ type pipe struct { ...@@ -17,6 +17,7 @@ type pipe struct {
mu sync.Mutex mu sync.Mutex
c sync.Cond // c.L lazily initialized to &p.mu c sync.Cond // c.L lazily initialized to &p.mu
b pipeBuffer // nil when done reading b pipeBuffer // nil when done reading
unread int // bytes unread when done
err error // read error once empty. non-nil means closed. err error // read error once empty. non-nil means closed.
breakErr error // immediate read error (caller doesn't see rest of b) breakErr error // immediate read error (caller doesn't see rest of b)
donec chan struct{} // closed on error donec chan struct{} // closed on error
...@@ -33,7 +34,7 @@ func (p *pipe) Len() int { ...@@ -33,7 +34,7 @@ func (p *pipe) Len() int {
p.mu.Lock() p.mu.Lock()
defer p.mu.Unlock() defer p.mu.Unlock()
if p.b == nil { if p.b == nil {
return 0 return p.unread
} }
return p.b.Len() return p.b.Len()
} }
...@@ -80,6 +81,7 @@ func (p *pipe) Write(d []byte) (n int, err error) { ...@@ -80,6 +81,7 @@ func (p *pipe) Write(d []byte) (n int, err error) {
return 0, errClosedPipeWrite return 0, errClosedPipeWrite
} }
if p.breakErr != nil { if p.breakErr != nil {
p.unread += len(d)
return len(d), nil // discard when there is no reader return len(d), nil // discard when there is no reader
} }
return p.b.Write(d) return p.b.Write(d)
...@@ -117,6 +119,9 @@ func (p *pipe) closeWithError(dst *error, err error, fn func()) { ...@@ -117,6 +119,9 @@ func (p *pipe) closeWithError(dst *error, err error, fn func()) {
} }
p.readFn = fn p.readFn = fn
if dst == &p.breakErr { if dst == &p.breakErr {
if p.b != nil {
p.unread += p.b.Len()
}
p.b = nil p.b = nil
} }
*dst = err *dst = err
......
...@@ -252,7 +252,7 @@ func ConfigureServer(s *http.Server, conf *Server) error { ...@@ -252,7 +252,7 @@ func ConfigureServer(s *http.Server, conf *Server) error {
} }
} }
if !haveRequired { if !haveRequired {
return fmt.Errorf("http2: TLSConfig.CipherSuites is missing an HTTP/2-required AES_128_GCM_SHA256 cipher.") return fmt.Errorf("http2: TLSConfig.CipherSuites is missing an HTTP/2-required AES_128_GCM_SHA256 cipher (need at least one of TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 or TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256).")
} }
} }
...@@ -322,7 +322,7 @@ type ServeConnOpts struct { ...@@ -322,7 +322,7 @@ type ServeConnOpts struct {
} }
func (o *ServeConnOpts) context() context.Context { func (o *ServeConnOpts) context() context.Context {
if o.Context != nil { if o != nil && o.Context != nil {
return o.Context return o.Context
} }
return context.Background() return context.Background()
...@@ -2415,7 +2415,11 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { ...@@ -2415,7 +2415,11 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) {
clen = strconv.Itoa(len(p)) clen = strconv.Itoa(len(p))
} }
_, hasContentType := rws.snapHeader["Content-Type"] _, hasContentType := rws.snapHeader["Content-Type"]
if !hasContentType && bodyAllowedForStatus(rws.status) && len(p) > 0 { // If the Content-Encoding is non-blank, we shouldn't
// sniff the body. See Issue golang.org/issue/31753.
ce := rws.snapHeader.Get("Content-Encoding")
hasCE := len(ce) > 0
if !hasCE && !hasContentType && bodyAllowedForStatus(rws.status) && len(p) > 0 {
ctype = http.DetectContentType(p) ctype = http.DetectContentType(p)
} }
var date string var date string
...@@ -2524,7 +2528,7 @@ const TrailerPrefix = "Trailer:" ...@@ -2524,7 +2528,7 @@ const TrailerPrefix = "Trailer:"
// trailers. That worked for a while, until we found the first major // trailers. That worked for a while, until we found the first major
// user of Trailers in the wild: gRPC (using them only over http2), // user of Trailers in the wild: gRPC (using them only over http2),
// and gRPC libraries permit setting trailers mid-stream without // and gRPC libraries permit setting trailers mid-stream without
// predeclarnig them. So: change of plans. We still permit the old // predeclaring them. So: change of plans. We still permit the old
// way, but we also permit this hack: if a Header() key begins with // way, but we also permit this hack: if a Header() key begins with
// "Trailer:", the suffix of that key is a Trailer. Because ':' is an // "Trailer:", the suffix of that key is a Trailer. Because ':' is an
// invalid token byte anyway, there is no ambiguity. (And it's already // invalid token byte anyway, there is no ambiguity. (And it's already
...@@ -2824,7 +2828,7 @@ func (sc *serverConn) startPush(msg *startPushRequest) { ...@@ -2824,7 +2828,7 @@ func (sc *serverConn) startPush(msg *startPushRequest) {
// PUSH_PROMISE frames MUST only be sent on a peer-initiated stream that // PUSH_PROMISE frames MUST only be sent on a peer-initiated stream that
// is in either the "open" or "half-closed (remote)" state. // is in either the "open" or "half-closed (remote)" state.
if msg.parent.state != stateOpen && msg.parent.state != stateHalfClosedRemote { if msg.parent.state != stateOpen && msg.parent.state != stateHalfClosedRemote {
// responseWriter.Push checks that the stream is peer-initiaed. // responseWriter.Push checks that the stream is peer-initiated.
msg.done <- errStreamClosed msg.done <- errStreamClosed
return return
} }
......
...@@ -227,6 +227,7 @@ type ClientConn struct { ...@@ -227,6 +227,7 @@ type ClientConn struct {
br *bufio.Reader br *bufio.Reader
fr *Framer fr *Framer
lastActive time.Time lastActive time.Time
lastIdle time.Time // time last idle
// Settings from peer: (also guarded by mu) // Settings from peer: (also guarded by mu)
maxFrameSize uint32 maxFrameSize uint32
maxConcurrentStreams uint32 maxConcurrentStreams uint32
...@@ -603,7 +604,7 @@ func (t *Transport) expectContinueTimeout() time.Duration { ...@@ -603,7 +604,7 @@ func (t *Transport) expectContinueTimeout() time.Duration {
} }
func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) {
return t.newClientConn(c, false) return t.newClientConn(c, t.disableKeepAlives())
} }
func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) { func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) {
...@@ -736,7 +737,8 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) { ...@@ -736,7 +737,8 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
} }
st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay && st.canTakeNewRequest = cc.goAway == nil && !cc.closed && !cc.closing && maxConcurrentOkay &&
int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 int64(cc.nextStreamID)+2*int64(cc.pendingRequests) < math.MaxInt32 &&
!cc.tooIdleLocked()
st.freshConn = cc.nextStreamID == 1 && st.canTakeNewRequest st.freshConn = cc.nextStreamID == 1 && st.canTakeNewRequest
return return
} }
...@@ -746,6 +748,16 @@ func (cc *ClientConn) canTakeNewRequestLocked() bool { ...@@ -746,6 +748,16 @@ func (cc *ClientConn) canTakeNewRequestLocked() bool {
return st.canTakeNewRequest return st.canTakeNewRequest
} }
// tooIdleLocked reports whether this connection has been been sitting idle
// for too much wall time.
func (cc *ClientConn) tooIdleLocked() bool {
// The Round(0) strips the monontonic clock reading so the
// times are compared based on their wall time. We don't want
// to reuse a connection that's been sitting idle during
// VM/laptop suspend if monotonic time was also frozen.
return cc.idleTimeout != 0 && !cc.lastIdle.IsZero() && time.Since(cc.lastIdle.Round(0)) > cc.idleTimeout
}
// onIdleTimeout is called from a time.AfterFunc goroutine. It will // onIdleTimeout is called from a time.AfterFunc goroutine. It will
// only be called when we're idle, but because we're coming from a new // only be called when we're idle, but because we're coming from a new
// goroutine, there could be a new request coming in at the same time, // goroutine, there could be a new request coming in at the same time,
...@@ -1150,6 +1162,7 @@ func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error { ...@@ -1150,6 +1162,7 @@ func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error {
} }
return errClientConnUnusable return errClientConnUnusable
} }
cc.lastIdle = time.Time{}
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) { if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
if waitingForConn != nil { if waitingForConn != nil {
close(waitingForConn) close(waitingForConn)
...@@ -1216,6 +1229,8 @@ var ( ...@@ -1216,6 +1229,8 @@ var (
// abort request body write, but send stream reset of cancel. // abort request body write, but send stream reset of cancel.
errStopReqBodyWriteAndCancel = errors.New("http2: canceling request") errStopReqBodyWriteAndCancel = errors.New("http2: canceling request")
errReqBodyTooLong = errors.New("http2: request body larger than specified content length")
) )
func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (err error) { func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (err error) {
...@@ -1238,10 +1253,32 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) ( ...@@ -1238,10 +1253,32 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (
req := cs.req req := cs.req
hasTrailers := req.Trailer != nil hasTrailers := req.Trailer != nil
remainLen := actualContentLength(req)
hasContentLen := remainLen != -1
var sawEOF bool var sawEOF bool
for !sawEOF { for !sawEOF {
n, err := body.Read(buf) n, err := body.Read(buf[:len(buf)-1])
if hasContentLen {
remainLen -= int64(n)
if remainLen == 0 && err == nil {
// The request body's Content-Length was predeclared and
// we just finished reading it all, but the underlying io.Reader
// returned the final chunk with a nil error (which is one of
// the two valid things a Reader can do at EOF). Because we'd prefer
// to send the END_STREAM bit early, double-check that we're actually
// at EOF. Subsequent reads should return (0, EOF) at this point.
// If either value is different, we return an error in one of two ways below.
var n1 int
n1, err = body.Read(buf[n:])
remainLen -= int64(n1)
}
if remainLen < 0 {
err = errReqBodyTooLong
cc.writeStreamReset(cs.ID, ErrCodeCancel, err)
return err
}
}
if err == io.EOF { if err == io.EOF {
sawEOF = true sawEOF = true
err = nil err = nil
...@@ -1454,7 +1491,29 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail ...@@ -1454,7 +1491,29 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
if vv[0] == "" { if vv[0] == "" {
continue continue
} }
} else if strings.EqualFold(k, "cookie") {
// Per 8.1.2.5 To allow for better compression efficiency, the
// Cookie header field MAY be split into separate header fields,
// each with one or more cookie-pairs.
for _, v := range vv {
for {
p := strings.IndexByte(v, ';')
if p < 0 {
break
}
f("cookie", v[:p])
p++
// strip space after semicolon if any.
for p+1 <= len(v) && v[p] == ' ' {
p++
}
v = v[p:]
}
if len(v) > 0 {
f("cookie", v)
}
}
continue
} }
for _, v := range vv { for _, v := range vv {
...@@ -1592,6 +1651,7 @@ func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream { ...@@ -1592,6 +1651,7 @@ func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream {
delete(cc.streams, id) delete(cc.streams, id)
if len(cc.streams) == 0 && cc.idleTimer != nil { if len(cc.streams) == 0 && cc.idleTimer != nil {
cc.idleTimer.Reset(cc.idleTimeout) cc.idleTimer.Reset(cc.idleTimeout)
cc.lastIdle = time.Now()
} }
close(cs.done) close(cs.done)
// Wake up checkResetOrDone via clientStream.awaitFlowControl and // Wake up checkResetOrDone via clientStream.awaitFlowControl and
......
...@@ -149,7 +149,7 @@ func (n *priorityNode) addBytes(b int64) { ...@@ -149,7 +149,7 @@ func (n *priorityNode) addBytes(b int64) {
} }
// walkReadyInOrder iterates over the tree in priority order, calling f for each node // walkReadyInOrder iterates over the tree in priority order, calling f for each node
// with a non-empty write queue. When f returns true, this funcion returns true and the // with a non-empty write queue. When f returns true, this function returns true and the
// walk halts. tmp is used as scratch space for sorting. // walk halts. tmp is used as scratch space for sorting.
// //
// f(n, openParent) takes two arguments: the node to visit, n, and a bool that is true // f(n, openParent) takes two arguments: the node to visit, n, and a bool that is true
......
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT. // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// +build go1.13 // +build go1.13,!go1.14
package idna package idna
......
This source diff could not be displayed because it is too large. You can view the blob instead.
// Copyright 2019 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.
// +build !race
package socket
func (m *Message) raceRead() {
}
func (m *Message) raceWrite() {
}
// Copyright 2019 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.
// +build race
package socket
import (
"runtime"
"unsafe"
)
// This package reads and writes the Message buffers using a
// direct system call, which the race detector can't see.
// These functions tell the race detector what is going on during the syscall.
func (m *Message) raceRead() {
for _, b := range m.Buffers {
if len(b) > 0 {
runtime.RaceReadRange(unsafe.Pointer(&b[0]), len(b))
}
}
if b := m.OOB; len(b) > 0 {
runtime.RaceReadRange(unsafe.Pointer(&b[0]), len(b))
}
}
func (m *Message) raceWrite() {
for _, b := range m.Buffers {
if len(b) > 0 {
runtime.RaceWriteRange(unsafe.Pointer(&b[0]), len(b))
}
}
if b := m.OOB; len(b) > 0 {
runtime.RaceWriteRange(unsafe.Pointer(&b[0]), len(b))
}
}
...@@ -13,6 +13,9 @@ import ( ...@@ -13,6 +13,9 @@ import (
) )
func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) { func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
for i := range ms {
ms[i].raceWrite()
}
hs := make(mmsghdrs, len(ms)) hs := make(mmsghdrs, len(ms))
var parseFn func([]byte, string) (net.Addr, error) var parseFn func([]byte, string) (net.Addr, error)
if c.network != "tcp" { if c.network != "tcp" {
...@@ -43,6 +46,9 @@ func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) { ...@@ -43,6 +46,9 @@ func (c *Conn) recvMsgs(ms []Message, flags int) (int, error) {
} }
func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) { func (c *Conn) sendMsgs(ms []Message, flags int) (int, error) {
for i := range ms {
ms[i].raceRead()
}
hs := make(mmsghdrs, len(ms)) hs := make(mmsghdrs, len(ms))
var marshalFn func(net.Addr) []byte var marshalFn func(net.Addr) []byte
if c.network != "tcp" { if c.network != "tcp" {
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
) )
func (c *Conn) recvMsg(m *Message, flags int) error { func (c *Conn) recvMsg(m *Message, flags int) error {
m.raceWrite()
var h msghdr var h msghdr
vs := make([]iovec, len(m.Buffers)) vs := make([]iovec, len(m.Buffers))
var sa []byte var sa []byte
...@@ -48,6 +49,7 @@ func (c *Conn) recvMsg(m *Message, flags int) error { ...@@ -48,6 +49,7 @@ func (c *Conn) recvMsg(m *Message, flags int) error {
} }
func (c *Conn) sendMsg(m *Message, flags int) error { func (c *Conn) sendMsg(m *Message, flags int) error {
m.raceRead()
var h msghdr var h msghdr
vs := make([]iovec, len(m.Buffers)) vs := make([]iovec, len(m.Buffers))
var sa []byte var sa []byte
......
...@@ -4,4 +4,29 @@ ...@@ -4,4 +4,29 @@
package socket package socket
func probeProtocolStack() int { return 4 } import (
"sync"
"syscall"
"unsafe"
)
// See version list in https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/param.h
var (
osreldateOnce sync.Once
osreldate uint32
)
// First __DragonFly_version after September 2019 ABI changes
// http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html
const _dragonflyABIChangeVersion = 500705
func probeProtocolStack() int {
osreldateOnce.Do(func() { osreldate, _ = syscall.SysctlUint32("kern.osreldate") })
var p uintptr
if int(unsafe.Sizeof(p)) == 8 && osreldate >= _dragonflyABIChangeVersion {
return int(unsafe.Sizeof(p))
}
// 64-bit Dragonfly before the September 2019 ABI changes still requires
// 32-bit aligned access to network subsystem.
return 4
}
...@@ -53,7 +53,6 @@ type sockaddrInet6 struct { ...@@ -53,7 +53,6 @@ type sockaddrInet6 struct {
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x30 sizeofMsghdr = 0x30
sizeofMmsghdr = 0x38
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -47,7 +47,6 @@ type sockaddrInet6 struct { ...@@ -47,7 +47,6 @@ type sockaddrInet6 struct {
const ( const (
sizeofIovec = 0x8 sizeofIovec = 0x8
sizeofMsghdr = 0x1c sizeofMsghdr = 0x1c
sizeofMmsghdr = 0x20
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -50,7 +50,6 @@ type sockaddrInet6 struct { ...@@ -50,7 +50,6 @@ type sockaddrInet6 struct {
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -45,9 +45,9 @@ type sockaddrInet6 struct { ...@@ -45,9 +45,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x8 sizeofIovec = 0x8
sizeofMsghdr = 0x1c sizeofMsghdr = 0x1c
sizeofMmsghdr = 0x20
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -48,9 +48,9 @@ type sockaddrInet6 struct { ...@@ -48,9 +48,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -45,9 +45,9 @@ type sockaddrInet6 struct { ...@@ -45,9 +45,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x8 sizeofIovec = 0x8
sizeofMsghdr = 0x1c sizeofMsghdr = 0x1c
sizeofMmsghdr = 0x20
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -48,9 +48,9 @@ type sockaddrInet6 struct { ...@@ -48,9 +48,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -48,9 +48,9 @@ type sockaddrInet6 struct { ...@@ -48,9 +48,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -45,9 +45,9 @@ type sockaddrInet6 struct { ...@@ -45,9 +45,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x8 sizeofIovec = 0x8
sizeofMsghdr = 0x1c sizeofMsghdr = 0x1c
sizeofMmsghdr = 0x20
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -48,9 +48,9 @@ type sockaddrInet6 struct { ...@@ -48,9 +48,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -48,9 +48,9 @@ type sockaddrInet6 struct { ...@@ -48,9 +48,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -49,9 +49,9 @@ type sockaddrInet6 struct { ...@@ -49,9 +49,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -48,9 +48,9 @@ type sockaddrInet6 struct { ...@@ -48,9 +48,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x38 sizeofMsghdr = 0x38
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0x10 sizeofCmsghdr = 0x10
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -47,9 +47,9 @@ type sockaddrInet6 struct { ...@@ -47,9 +47,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x8 sizeofIovec = 0x8
sizeofMsghdr = 0x1c sizeofMsghdr = 0x1c
sizeofMmsghdr = 0x20
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -50,9 +50,9 @@ type sockaddrInet6 struct { ...@@ -50,9 +50,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x30 sizeofMsghdr = 0x30
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -47,9 +47,9 @@ type sockaddrInet6 struct { ...@@ -47,9 +47,9 @@ type sockaddrInet6 struct {
} }
const ( const (
sizeofIovec = 0x8 sizeofIovec = 0x8
sizeofMsghdr = 0x1c sizeofMsghdr = 0x1c
sizeofMmsghdr = 0x20
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -52,7 +52,6 @@ type sockaddrInet6 struct { ...@@ -52,7 +52,6 @@ type sockaddrInet6 struct {
const ( const (
sizeofIovec = 0x10 sizeofIovec = 0x10
sizeofMsghdr = 0x30 sizeofMsghdr = 0x30
sizeofMmsghdr = 0x40
sizeofCmsghdr = 0xc sizeofCmsghdr = 0xc
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
......
...@@ -127,7 +127,7 @@ type Dialer struct { ...@@ -127,7 +127,7 @@ type Dialer struct {
// establishing the transport connection. // establishing the transport connection.
ProxyDial func(context.Context, string, string) (net.Conn, error) ProxyDial func(context.Context, string, string) (net.Conn, error)
// AuthMethods specifies the list of request authention // AuthMethods specifies the list of request authentication
// methods. // methods.
// If empty, SOCKS client requests only AuthMethodNotRequired. // If empty, SOCKS client requests only AuthMethodNotRequired.
AuthMethods []AuthMethod AuthMethods []AuthMethod
......
...@@ -403,9 +403,9 @@ func (ts *timeSeries) extract(l *tsLevel, start, finish time.Time, num int, resu ...@@ -403,9 +403,9 @@ func (ts *timeSeries) extract(l *tsLevel, start, finish time.Time, num int, resu
// Where should scanning start? // Where should scanning start?
if dstStart.After(srcStart) { if dstStart.After(srcStart) {
advance := dstStart.Sub(srcStart) / srcInterval advance := int(dstStart.Sub(srcStart) / srcInterval)
srcIndex += int(advance) srcIndex += advance
srcStart = srcStart.Add(advance * srcInterval) srcStart = srcStart.Add(time.Duration(advance) * srcInterval)
} }
// The i'th value is computed as show below. // The i'th value is computed as show below.
......
...@@ -35,6 +35,7 @@ func marshalInterface(b []byte, cm *ControlMessage) []byte { ...@@ -35,6 +35,7 @@ func marshalInterface(b []byte, cm *ControlMessage) []byte {
} }
func parseInterface(cm *ControlMessage, b []byte) { func parseInterface(cm *ControlMessage, b []byte) {
sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0])) var sadl syscall.SockaddrDatalink
copy((*[unsafe.Sizeof(sadl)]byte)(unsafe.Pointer(&sadl))[:], b)
cm.IfIndex = int(sadl.Index) cm.IfIndex = int(sadl.Index)
} }
...@@ -11,13 +11,14 @@ import ( ...@@ -11,13 +11,14 @@ import (
"golang.org/x/net/bpf" "golang.org/x/net/bpf"
"golang.org/x/net/internal/socket" "golang.org/x/net/internal/socket"
"golang.org/x/sys/unix"
) )
func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error { func (so *sockOpt) setAttachFilter(c *socket.Conn, f []bpf.RawInstruction) error {
prog := sockFProg{ prog := unix.SockFprog{
Len: uint16(len(f)), Len: uint16(len(f)),
Filter: (*sockFilter)(unsafe.Pointer(&f[0])), Filter: (*unix.SockFilter)(unsafe.Pointer(&f[0])),
} }
b := (*[sizeofSockFprog]byte)(unsafe.Pointer(&prog))[:sizeofSockFprog] b := (*[unix.SizeofSockFprog]byte)(unsafe.Pointer(&prog))[:unix.SizeofSockFprog]
return so.Set(c, b) return so.Set(c, b)
} }
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"golang.org/x/net/internal/iana" "golang.org/x/net/internal/iana"
"golang.org/x/net/internal/socket" "golang.org/x/net/internal/socket"
"golang.org/x/sys/unix"
) )
var ( var (
...@@ -35,7 +36,7 @@ var ( ...@@ -35,7 +36,7 @@ var (
ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, ssoLeaveSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, ssoBlockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq}, ssoUnblockSourceGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: sysMCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
ssoAttachFilter: {Option: socket.Option{Level: sysSOL_SOCKET, Name: sysSO_ATTACH_FILTER, Len: sizeofSockFprog}}, ssoAttachFilter: {Option: socket.Option{Level: unix.SOL_SOCKET, Name: unix.SO_ATTACH_FILTER, Len: unix.SizeofSockFprog}},
} }
) )
......
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
// cgo -godefs defs_freebsd.go
package ipv4
const (
sysIP_OPTIONS = 0x1
sysIP_HDRINCL = 0x2
sysIP_TOS = 0x3
sysIP_TTL = 0x4
sysIP_RECVOPTS = 0x5
sysIP_RECVRETOPTS = 0x6
sysIP_RECVDSTADDR = 0x7
sysIP_SENDSRCADDR = 0x7
sysIP_RETOPTS = 0x8
sysIP_RECVIF = 0x14
sysIP_ONESBCAST = 0x17
sysIP_BINDANY = 0x18
sysIP_RECVTTL = 0x41
sysIP_MINTTL = 0x42
sysIP_DONTFRAG = 0x43
sysIP_RECVTOS = 0x44
sysIP_MULTICAST_IF = 0x9
sysIP_MULTICAST_TTL = 0xa
sysIP_MULTICAST_LOOP = 0xb
sysIP_ADD_MEMBERSHIP = 0xc
sysIP_DROP_MEMBERSHIP = 0xd
sysIP_MULTICAST_VIF = 0xe
sysIP_ADD_SOURCE_MEMBERSHIP = 0x46
sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
sysIP_BLOCK_SOURCE = 0x48
sysIP_UNBLOCK_SOURCE = 0x49
sysMCAST_JOIN_GROUP = 0x50
sysMCAST_LEAVE_GROUP = 0x51
sysMCAST_JOIN_SOURCE_GROUP = 0x52
sysMCAST_LEAVE_SOURCE_GROUP = 0x53
sysMCAST_BLOCK_SOURCE = 0x54
sysMCAST_UNBLOCK_SOURCE = 0x55
sizeofSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10
sizeofIPMreq = 0x8
sizeofIPMreqn = 0xc
sizeofIPMreqSource = 0xc
sizeofGroupReq = 0x88
sizeofGroupSourceReq = 0x108
)
type sockaddrStorage struct {
Len uint8
Family uint8
X__ss_pad1 [6]uint8
X__ss_align int64
X__ss_pad2 [112]uint8
}
type sockaddrInet struct {
Len uint8
Family uint8
Port uint16
Addr [4]byte /* in_addr */
Zero [8]uint8
}
type ipMreq struct {
Multiaddr [4]byte /* in_addr */
Interface [4]byte /* in_addr */
}
type ipMreqn struct {
Multiaddr [4]byte /* in_addr */
Address [4]byte /* in_addr */
Ifindex int32
}
type ipMreqSource struct {
Multiaddr [4]byte /* in_addr */
Sourceaddr [4]byte /* in_addr */
Interface [4]byte /* in_addr */
}
type groupReq struct {
Interface uint32
Group sockaddrStorage
}
type groupSourceReq struct {
Interface uint32
Group sockaddrStorage
Source sockaddrStorage
}
...@@ -55,9 +55,6 @@ const ( ...@@ -55,9 +55,6 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSOL_SOCKET = 0x1
sysSO_ATTACH_FILTER = 0x1a
sizeofKernelSockaddrStorage = 0x80 sizeofKernelSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
sizeofInetPktinfo = 0xc sizeofInetPktinfo = 0xc
...@@ -70,8 +67,6 @@ const ( ...@@ -70,8 +67,6 @@ const (
sizeofGroupSourceReq = 0x104 sizeofGroupSourceReq = 0x104
sizeofICMPFilter = 0x4 sizeofICMPFilter = 0x4
sizeofSockFprog = 0x8
) )
type kernelSockaddrStorage struct { type kernelSockaddrStorage struct {
...@@ -133,16 +128,3 @@ type groupSourceReq struct { ...@@ -133,16 +128,3 @@ type groupSourceReq struct {
type icmpFilter struct { type icmpFilter struct {
Data uint32 Data uint32
} }
type sockFProg struct {
Len uint16
Pad_cgo_0 [2]byte
Filter *sockFilter
}
type sockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
...@@ -55,9 +55,6 @@ const ( ...@@ -55,9 +55,6 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSOL_SOCKET = 0x1
sysSO_ATTACH_FILTER = 0x1a
sizeofKernelSockaddrStorage = 0x80 sizeofKernelSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
sizeofInetPktinfo = 0xc sizeofInetPktinfo = 0xc
...@@ -70,8 +67,6 @@ const ( ...@@ -70,8 +67,6 @@ const (
sizeofGroupSourceReq = 0x108 sizeofGroupSourceReq = 0x108
sizeofICMPFilter = 0x4 sizeofICMPFilter = 0x4
sizeofSockFprog = 0x10
) )
type kernelSockaddrStorage struct { type kernelSockaddrStorage struct {
...@@ -135,16 +130,3 @@ type groupSourceReq struct { ...@@ -135,16 +130,3 @@ type groupSourceReq struct {
type icmpFilter struct { type icmpFilter struct {
Data uint32 Data uint32
} }
type sockFProg struct {
Len uint16
Pad_cgo_0 [6]byte
Filter *sockFilter
}
type sockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
...@@ -55,9 +55,6 @@ const ( ...@@ -55,9 +55,6 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSOL_SOCKET = 0x1
sysSO_ATTACH_FILTER = 0x1a
sizeofKernelSockaddrStorage = 0x80 sizeofKernelSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
sizeofInetPktinfo = 0xc sizeofInetPktinfo = 0xc
...@@ -70,8 +67,6 @@ const ( ...@@ -70,8 +67,6 @@ const (
sizeofGroupSourceReq = 0x104 sizeofGroupSourceReq = 0x104
sizeofICMPFilter = 0x4 sizeofICMPFilter = 0x4
sizeofSockFprog = 0x8
) )
type kernelSockaddrStorage struct { type kernelSockaddrStorage struct {
...@@ -133,16 +128,3 @@ type groupSourceReq struct { ...@@ -133,16 +128,3 @@ type groupSourceReq struct {
type icmpFilter struct { type icmpFilter struct {
Data uint32 Data uint32
} }
type sockFProg struct {
Len uint16
Pad_cgo_0 [2]byte
Filter *sockFilter
}
type sockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
...@@ -55,9 +55,6 @@ const ( ...@@ -55,9 +55,6 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSOL_SOCKET = 0x1
sysSO_ATTACH_FILTER = 0x1a
sizeofKernelSockaddrStorage = 0x80 sizeofKernelSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
sizeofInetPktinfo = 0xc sizeofInetPktinfo = 0xc
...@@ -70,8 +67,6 @@ const ( ...@@ -70,8 +67,6 @@ const (
sizeofGroupSourceReq = 0x108 sizeofGroupSourceReq = 0x108
sizeofICMPFilter = 0x4 sizeofICMPFilter = 0x4
sizeofSockFprog = 0x10
) )
type kernelSockaddrStorage struct { type kernelSockaddrStorage struct {
...@@ -135,16 +130,3 @@ type groupSourceReq struct { ...@@ -135,16 +130,3 @@ type groupSourceReq struct {
type icmpFilter struct { type icmpFilter struct {
Data uint32 Data uint32
} }
type sockFProg struct {
Len uint16
Pad_cgo_0 [6]byte
Filter *sockFilter
}
type sockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
...@@ -55,9 +55,6 @@ const ( ...@@ -55,9 +55,6 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSOL_SOCKET = 0x1
sysSO_ATTACH_FILTER = 0x1a
sizeofKernelSockaddrStorage = 0x80 sizeofKernelSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
sizeofInetPktinfo = 0xc sizeofInetPktinfo = 0xc
...@@ -70,8 +67,6 @@ const ( ...@@ -70,8 +67,6 @@ const (
sizeofGroupSourceReq = 0x104 sizeofGroupSourceReq = 0x104
sizeofICMPFilter = 0x4 sizeofICMPFilter = 0x4
sizeofSockFprog = 0x8
) )
type kernelSockaddrStorage struct { type kernelSockaddrStorage struct {
...@@ -133,16 +128,3 @@ type groupSourceReq struct { ...@@ -133,16 +128,3 @@ type groupSourceReq struct {
type icmpFilter struct { type icmpFilter struct {
Data uint32 Data uint32
} }
type sockFProg struct {
Len uint16
Pad_cgo_0 [2]byte
Filter *sockFilter
}
type sockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
...@@ -55,9 +55,6 @@ const ( ...@@ -55,9 +55,6 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSOL_SOCKET = 0x1
sysSO_ATTACH_FILTER = 0x1a
sizeofKernelSockaddrStorage = 0x80 sizeofKernelSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
sizeofInetPktinfo = 0xc sizeofInetPktinfo = 0xc
...@@ -70,8 +67,6 @@ const ( ...@@ -70,8 +67,6 @@ const (
sizeofGroupSourceReq = 0x108 sizeofGroupSourceReq = 0x108
sizeofICMPFilter = 0x4 sizeofICMPFilter = 0x4
sizeofSockFprog = 0x10
) )
type kernelSockaddrStorage struct { type kernelSockaddrStorage struct {
...@@ -135,16 +130,3 @@ type groupSourceReq struct { ...@@ -135,16 +130,3 @@ type groupSourceReq struct {
type icmpFilter struct { type icmpFilter struct {
Data uint32 Data uint32
} }
type sockFProg struct {
Len uint16
Pad_cgo_0 [6]byte
Filter *sockFilter
}
type sockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
...@@ -55,9 +55,6 @@ const ( ...@@ -55,9 +55,6 @@ const (
sysSO_EE_ORIGIN_TXSTATUS = 0x4 sysSO_EE_ORIGIN_TXSTATUS = 0x4
sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
sysSOL_SOCKET = 0x1
sysSO_ATTACH_FILTER = 0x1a
sizeofKernelSockaddrStorage = 0x80 sizeofKernelSockaddrStorage = 0x80
sizeofSockaddrInet = 0x10 sizeofSockaddrInet = 0x10
sizeofInetPktinfo = 0xc sizeofInetPktinfo = 0xc
...@@ -70,8 +67,6 @@ const ( ...@@ -70,8 +67,6 @@ const (
sizeofGroupSourceReq = 0x108 sizeofGroupSourceReq = 0x108
sizeofICMPFilter = 0x4 sizeofICMPFilter = 0x4
sizeofSockFprog = 0x10
) )
type kernelSockaddrStorage struct { type kernelSockaddrStorage struct {
...@@ -135,16 +130,3 @@ type groupSourceReq struct { ...@@ -135,16 +130,3 @@ type groupSourceReq struct {
type icmpFilter struct { type icmpFilter struct {
Data uint32 Data uint32
} }
type sockFProg struct {
Len uint16
Pad_cgo_0 [6]byte
Filter *sockFilter
}
type sockFilter struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment