From d00d6db1f3b261ca3b67f0c5125566c54f7e4c98 Mon Sep 17 00:00:00 2001 From: Alex Kristiansen Date: Wed, 18 Dec 2019 11:27:16 -0800 Subject: [PATCH 01/21] initial commit of system/network_summary --- metricbeat/docs/fields.asciidoc | 57 +++++++++ metricbeat/docs/modules/system.asciidoc | 4 + .../modules/system/network_summary.asciidoc | 23 ++++ metricbeat/docs/modules_list.asciidoc | 3 +- metricbeat/include/list_common.go | 1 + metricbeat/module/system/fields.go | 2 +- .../system/network_summary/_meta/data.json | 19 +++ .../network_summary/_meta/docs.asciidoc | 6 + .../system/network_summary/_meta/fields.yml | 26 ++++ .../module/system/network_summary/data.go | 51 ++++++++ .../system/network_summary/network_summary.go | 96 +++++++++++++++ .../network_summary/network_summary_test.go | 27 +++++ .../elastic/go-sysinfo/CHANGELOG.md | 18 ++- .../github.com/elastic/go-sysinfo/NOTICE.txt | 5 + .../github.com/elastic/go-sysinfo/README.md | 1 + vendor/github.com/elastic/go-sysinfo/go.mod | 4 +- vendor/github.com/elastic/go-sysinfo/go.sum | 4 +- .../go-sysinfo/providers/linux/container.go | 2 +- .../go-sysinfo/providers/linux/host_linux.go | 23 ++++ .../go-sysinfo/providers/linux/machineid.go | 8 +- .../elastic/go-sysinfo/providers/linux/os.go | 2 +- .../go-sysinfo/providers/linux/procnet.go | 112 ++++++++++++++++++ .../providers/windows/process_windows.go | 12 +- .../elastic/go-sysinfo/types/host.go | 27 +++++ vendor/vendor.json | 64 +++++----- 25 files changed, 545 insertions(+), 52 deletions(-) create mode 100644 metricbeat/docs/modules/system/network_summary.asciidoc create mode 100644 metricbeat/module/system/network_summary/_meta/data.json create mode 100644 metricbeat/module/system/network_summary/_meta/docs.asciidoc create mode 100644 metricbeat/module/system/network_summary/_meta/fields.yml create mode 100644 metricbeat/module/system/network_summary/data.go create mode 100644 metricbeat/module/system/network_summary/network_summary.go create mode 100644 metricbeat/module/system/network_summary/network_summary_test.go create mode 100644 vendor/github.com/elastic/go-sysinfo/NOTICE.txt create mode 100644 vendor/github.com/elastic/go-sysinfo/providers/linux/procnet.go diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index db8ce6a2092..1415fbe2be6 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -31357,6 +31357,63 @@ type: long -- +[float] +=== network_summary + +Metrics relating to global network activity + + + +*`system.network_summary.ip.*`*:: ++ +-- +IP protocol counters + + +type: object + +-- + +*`system.network_summary.tcp.*`*:: ++ +-- +TCP protocol counters + + +type: object + +-- + +*`system.network_summary.udp.*`*:: ++ +-- +UDP protocol counters + + +type: object + +-- + +*`system.network_summary.udpLite.*`*:: ++ +-- +UDP Lite protocol counters + + +type: object + +-- + +*`system.network_summary.icmp.*`*:: ++ +-- +ICMP protocol counters + + +type: object + +-- + [float] === process diff --git a/metricbeat/docs/modules/system.asciidoc b/metricbeat/docs/modules/system.asciidoc index f2d5751014e..2fb31f242ea 100644 --- a/metricbeat/docs/modules/system.asciidoc +++ b/metricbeat/docs/modules/system.asciidoc @@ -135,6 +135,8 @@ The following metricsets are available: * <> +* <> + * <> * <> @@ -167,6 +169,8 @@ include::system/memory.asciidoc[] include::system/network.asciidoc[] +include::system/network_summary.asciidoc[] + include::system/process.asciidoc[] include::system/process_summary.asciidoc[] diff --git a/metricbeat/docs/modules/system/network_summary.asciidoc b/metricbeat/docs/modules/system/network_summary.asciidoc new file mode 100644 index 00000000000..fd68d6b7bc5 --- /dev/null +++ b/metricbeat/docs/modules/system/network_summary.asciidoc @@ -0,0 +1,23 @@ +//// +This file is generated! See scripts/mage/docs_collector.go +//// + +[[metricbeat-metricset-system-network_summary]] +=== System network_summary metricset + +beta[] + +include::../../../module/system/network_summary/_meta/docs.asciidoc[] + + +==== Fields + +For a description of each field in the metricset, see the +<> section. + +Here is an example document generated by this metricset: + +[source,json] +---- +include::../../../module/system/network_summary/_meta/data.json[] +---- diff --git a/metricbeat/docs/modules_list.asciidoc b/metricbeat/docs/modules_list.asciidoc index 760693efef3..e0794b44ac1 100644 --- a/metricbeat/docs/modules_list.asciidoc +++ b/metricbeat/docs/modules_list.asciidoc @@ -187,7 +187,7 @@ This file is generated! See scripts/mage/docs_collector.go |<> beta[] |image:./images/icon-no.png[No prebuilt dashboards] | .1+| .1+| |<> beta[] |<> |image:./images/icon-yes.png[Prebuilt dashboards are available] | -.16+| .16+| |<> +.17+| .17+| |<> |<> |<> |<> @@ -196,6 +196,7 @@ This file is generated! See scripts/mage/docs_collector.go |<> |<> |<> +|<> beta[] |<> |<> |<> diff --git a/metricbeat/include/list_common.go b/metricbeat/include/list_common.go index 26db25d5744..17318c683e8 100644 --- a/metricbeat/include/list_common.go +++ b/metricbeat/include/list_common.go @@ -138,6 +138,7 @@ import ( _ "github.com/elastic/beats/metricbeat/module/system/load" _ "github.com/elastic/beats/metricbeat/module/system/memory" _ "github.com/elastic/beats/metricbeat/module/system/network" + _ "github.com/elastic/beats/metricbeat/module/system/network_summary" _ "github.com/elastic/beats/metricbeat/module/system/process" _ "github.com/elastic/beats/metricbeat/module/system/process_summary" _ "github.com/elastic/beats/metricbeat/module/system/raid" diff --git a/metricbeat/module/system/fields.go b/metricbeat/module/system/fields.go index 33d5716ea79..9de3747c201 100644 --- a/metricbeat/module/system/fields.go +++ b/metricbeat/module/system/fields.go @@ -32,5 +32,5 @@ func init() { // AssetSystem returns asset data. // This is the base64 encoded gzipped contents of ../metricbeat/module/system. func AssetSystem() string { - return "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" + return "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" } diff --git a/metricbeat/module/system/network_summary/_meta/data.json b/metricbeat/module/system/network_summary/_meta/data.json new file mode 100644 index 00000000000..acebf255aae --- /dev/null +++ b/metricbeat/module/system/network_summary/_meta/data.json @@ -0,0 +1,19 @@ +{ + "@timestamp":"2016-05-23T08:05:34.853Z", + "beat":{ + "hostname":"beathost", + "name":"beathost" + }, + "metricset":{ + "host":"localhost", + "module":"system", + "name":"network_summary", + "rtt":44269 + }, + "system":{ + "network_summary":{ + "example": "network_summary" + } + }, + "type":"metricsets" +} diff --git a/metricbeat/module/system/network_summary/_meta/docs.asciidoc b/metricbeat/module/system/network_summary/_meta/docs.asciidoc new file mode 100644 index 00000000000..854a377dc6b --- /dev/null +++ b/metricbeat/module/system/network_summary/_meta/docs.asciidoc @@ -0,0 +1,6 @@ +The System `network_summary` metricset provides network IO metrics collected from the +operating system. These events are global and sorted by protocol. + +This metricset is available on: + +- Linux diff --git a/metricbeat/module/system/network_summary/_meta/fields.yml b/metricbeat/module/system/network_summary/_meta/fields.yml new file mode 100644 index 00000000000..e0708873f68 --- /dev/null +++ b/metricbeat/module/system/network_summary/_meta/fields.yml @@ -0,0 +1,26 @@ +- name: network_summary + type: group + release: beta + description: > + Metrics relating to global network activity + fields: + - name: ip.* + type: object + description: > + IP protocol counters + - name: tcp.* + type: object + description: > + TCP protocol counters + - name: udp.* + type: object + description: > + UDP protocol counters + - name: udpLite.* + type: object + description: > + UDP Lite protocol counters + - name: icmp.* + type: object + description: > + ICMP protocol counters diff --git a/metricbeat/module/system/network_summary/data.go b/metricbeat/module/system/network_summary/data.go new file mode 100644 index 00000000000..ee8c57b8c5d --- /dev/null +++ b/metricbeat/module/system/network_summary/data.go @@ -0,0 +1,51 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package network_summary + +import ( + "github.com/elastic/beats/libbeat/common" + sysinfotypes "github.com/elastic/go-sysinfo/types" +) + +// eventMapping maps the network counters to a MapStr that wil be sent to report.Event +func eventMapping(raw *sysinfotypes.NetworkCountersInfo) common.MapStr { + + eventByProto := common.MapStr{ + "ip": combineMap(raw.Netstat.IPExt, raw.SNMP.IP), + "tcp": combineMap(raw.Netstat.TCPExt, raw.SNMP.TCP), + "udp": raw.SNMP.UDP, + "udpLite": raw.SNMP.UDPLite, + "icmp": combineMap(raw.SNMP.ICMPMsg, raw.SNMP.ICMP), + } + + return eventByProto +} + +func combineMap(map1, map2 map[string]int64) map[string]int64 { + + var compMap map[string]int64 + + for k, v := range map1 { + compMap[k] = v + } + + for k, v := range map2 { + compMap[k] = v + } + return compMap +} diff --git a/metricbeat/module/system/network_summary/network_summary.go b/metricbeat/module/system/network_summary/network_summary.go new file mode 100644 index 00000000000..382c423e4aa --- /dev/null +++ b/metricbeat/module/system/network_summary/network_summary.go @@ -0,0 +1,96 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package network_summary + +import ( + "github.com/pkg/errors" + + "github.com/elastic/beats/libbeat/common/cfgwarn" + "github.com/elastic/beats/metricbeat/mb" + sysinfo "github.com/elastic/go-sysinfo" + sysinfotypes "github.com/elastic/go-sysinfo/types" +) + +// init registers the MetricSet with the central registry as soon as the program +// starts. The New function will be called later to instantiate an instance of +// the MetricSet for each host defined in the module's configuration. After the +// MetricSet has been created then Fetch will begin to be called periodically. +func init() { + mb.Registry.MustAddMetricSet("system", "network_summary", New) +} + +// MetricSet holds any configuration or state information. It must implement +// the mb.MetricSet interface. And this is best achieved by embedding +// mb.BaseMetricSet because it implements all of the required mb.MetricSet +// interface methods except for Fetch. +type MetricSet struct { + mb.BaseMetricSet +} + +// New creates a new instance of the MetricSet. New is responsible for unpacking +// any MetricSet specific configuration options if there are any. +func New(base mb.BaseMetricSet) (mb.MetricSet, error) { + cfgwarn.Beta("The system network_summary metricset is beta.") + + config := struct{}{} + if err := base.Module().UnpackConfig(&config); err != nil { + return nil, err + } + + return &MetricSet{ + BaseMetricSet: base, + }, nil +} + +// Fetch methods implements the data gathering and data conversion to the right +// format. It publishes the event which is then forwarded to the output. In case +// of an error set the Error field of mb.Event or simply call report.Error(). +func (m *MetricSet) Fetch(report mb.ReporterV2) error { + + counterInfo, err := fetchNetStats() + if err != nil { + return errors.Wrap(err, "Error fetching stats") + } + if counterInfo == nil { + return errors.New("NetworkCounters not available on this platform") + } + + report.Event(mb.Event{ + MetricSetFields: eventMapping(counterInfo), + }) + + return nil +} + +// fetchNetStats wraps the go-sysinfo commands, and returns a NetworkCountersInfo struct if one is available +func fetchNetStats() (*sysinfotypes.NetworkCountersInfo, error) { + h, err := sysinfo.Host() + if err != nil { + return nil, errors.Wrap(err, "failed to read self process information") + } + + if vmstatHandle, ok := h.(sysinfotypes.NetworkCounters); ok { + info, err := vmstatHandle.NetworkCounters() + if err != nil { + return nil, errors.Wrap(err, "error getting network counters") + } + return info, nil + } + + return nil, nil +} diff --git a/metricbeat/module/system/network_summary/network_summary_test.go b/metricbeat/module/system/network_summary/network_summary_test.go new file mode 100644 index 00000000000..dde9c99ad9e --- /dev/null +++ b/metricbeat/module/system/network_summary/network_summary_test.go @@ -0,0 +1,27 @@ +package network_summary + +import ( + "testing" + + mbtest "github.com/elastic/beats/metricbeat/mb/testing" + "github.com/stretchr/testify/assert" +) + +func TestFetch(t *testing.T) { + f := mbtest.NewReportingMetricSetV2Error(t, getConfig()) + events, errs := mbtest.ReportingFetchV2Error(f) + + assert.Empty(t, errs) + if !assert.NotEmpty(t, events) { + t.FailNow() + } + t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), + events[0].BeatEvent("system", "memory").Fields.StringToPrint()) +} + +func getConfig() map[string]interface{} { + return map[string]interface{}{ + "module": "system", + "metricsets": []string{"network_summary"}, + } +} diff --git a/vendor/github.com/elastic/go-sysinfo/CHANGELOG.md b/vendor/github.com/elastic/go-sysinfo/CHANGELOG.md index 280c2269ca2..fe7d895e5be 100644 --- a/vendor/github.com/elastic/go-sysinfo/CHANGELOG.md +++ b/vendor/github.com/elastic/go-sysinfo/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), @@ -16,7 +17,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -### Security +## [1.2.0] - 2019-12-09 + +### Added + +- Added detection of systemd cgroups to the `IsContainerized` check. [#71](https://github.com/elastic/go-sysinfo/pull/71) +- Added networking counters for Linux hosts. [#72](https://github.com/elastic/go-sysinfo/pull/72) + +## [1.1.1] - 2019-10-29 + +### Fixed + +- Fixed an issue determining the Linux distribution for Fedora 30. [#69](https://github.com/elastic/go-sysinfo/pull/69) ## [1.1.0] - 2019-08-22 @@ -57,7 +69,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changed the host containerized check to reduce false positives. [#42](https://github.com/elastic/go-sysinfo/pull/42) [#43](https://github.com/elastic/go-sysinfo/pull/43) -[Unreleased]: https://github.com/elastic/go-sysinfo/compare/v1.1.0...HEAD +[Unreleased]: https://github.com/elastic/go-sysinfo/compare/v1.2.0...HEAD +[1.2.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.2.0 +[1.1.1]: https://github.com/elastic/go-sysinfo/releases/tag/v1.1.0 [1.1.0]: https://github.com/elastic/go-sysinfo/releases/tag/v1.1.0 [1.0.2]: https://github.com/elastic/go-sysinfo/releases/tag/v1.0.2 [1.0.1]: https://github.com/elastic/go-sysinfo/releases/tag/v1.0.1 diff --git a/vendor/github.com/elastic/go-sysinfo/NOTICE.txt b/vendor/github.com/elastic/go-sysinfo/NOTICE.txt new file mode 100644 index 00000000000..c813ad58275 --- /dev/null +++ b/vendor/github.com/elastic/go-sysinfo/NOTICE.txt @@ -0,0 +1,5 @@ +Elastic go-sysinfo +Copyright 2017-2019 Elasticsearch B.V. + +This product includes software developed at +Elasticsearch, B.V. (https://www.elastic.co/). diff --git a/vendor/github.com/elastic/go-sysinfo/README.md b/vendor/github.com/elastic/go-sysinfo/README.md index 958f11c235f..d80c5bf13ac 100644 --- a/vendor/github.com/elastic/go-sysinfo/README.md +++ b/vendor/github.com/elastic/go-sysinfo/README.md @@ -37,6 +37,7 @@ that are implemented. | `Memory()` | x | x | x | | `CPUTimer` | x | x | x | | `VMStat` | | x | | +| `NetworkCounters`| | x | | | `Process` Features | Darwin | Linux | Windows | |------------------------|--------|-------|---------| diff --git a/vendor/github.com/elastic/go-sysinfo/go.mod b/vendor/github.com/elastic/go-sysinfo/go.mod index 068a0d14842..cd78dc5758b 100644 --- a/vendor/github.com/elastic/go-sysinfo/go.mod +++ b/vendor/github.com/elastic/go-sysinfo/go.mod @@ -6,6 +6,8 @@ require ( github.com/pkg/errors v0.8.1 github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 github.com/stretchr/testify v1.3.0 - golang.org/x/sys v0.0.0-20190425145619-16072639606e + golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae howett.net/plist v0.0.0-20181124034731-591f970eefbb ) + +go 1.13 diff --git a/vendor/github.com/elastic/go-sysinfo/go.sum b/vendor/github.com/elastic/go-sysinfo/go.sum index c84ee0158d0..49a2b6037a8 100644 --- a/vendor/github.com/elastic/go-sysinfo/go.sum +++ b/vendor/github.com/elastic/go-sysinfo/go.sum @@ -18,8 +18,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190425145619-16072639606e h1:4ktJgTV34+N3qOZUc5fAaG3Pb11qzMm3PkAoTAgUZ2I= -golang.org/x/sys v0.0.0-20190425145619-16072639606e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae h1:QoJmnb9uyPCrH8GIg9uRLn4Ta45yhcQtpymCd0AavO8= +golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go index 6081e0c4132..3cf06281d45 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/container.go @@ -49,7 +49,7 @@ func isContainerizedCgroup(data []byte) (bool, error) { // Following a suggestion on Stack Overflow on how to detect // being inside a container: https://stackoverflow.com/a/20012536/235203 - if bytes.Contains(line, []byte("docker")) || bytes.Contains(line, []byte("lxc")) { + if bytes.Contains(line, []byte("docker")) || bytes.Contains(line, []byte(".slice")) || bytes.Contains(line, []byte("lxc")) { return true, nil } } diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/host_linux.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/host_linux.go index 19325b02d36..7727e722dd7 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/host_linux.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/host_linux.go @@ -81,6 +81,29 @@ func (h *host) VMStat() (*types.VMStatInfo, error) { return parseVMStat(content) } +// NetworkCounters reports data from /proc/net on linux +func (h *host) NetworkCounters() (*types.NetworkCountersInfo, error) { + snmpRaw, err := ioutil.ReadFile(h.procFS.path("net/snmp")) + if err != nil { + return nil, err + } + snmp, err := getNetSnmpStats(snmpRaw) + if err != nil { + return nil, err + } + + netstatRaw, err := ioutil.ReadFile(h.procFS.path("net/netstat")) + if err != nil { + return nil, err + } + netstat, err := getNetstatStats(netstatRaw) + if err != nil { + return nil, err + } + + return &types.NetworkCountersInfo{SNMP: snmp, Netstat: netstat}, nil +} + func (h *host) CPUTime() (types.CPUTimes, error) { stat, err := h.procFS.NewStat() if err != nil { diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go index a84d085c9ea..7a6b8a70939 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/machineid.go @@ -27,11 +27,9 @@ import ( "github.com/elastic/go-sysinfo/types" ) -var ( - // Possible (current and historic) locations of the machine-id file. - // These will be searched in order. - machineIDFiles = []string{"/etc/machine-id", "/var/lib/dbus/machine-id", "/var/db/dbus/machine-id"} -) +// Possible (current and historic) locations of the machine-id file. +// These will be searched in order. +var machineIDFiles = []string{"/etc/machine-id", "/var/lib/dbus/machine-id", "/var/db/dbus/machine-id"} func MachineID() (string, error) { var contents []byte diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go index d4daedd506f..9cda73a5456 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/os.go @@ -205,7 +205,7 @@ func findDistribRelease(baseDir string) (*types.OSInfo, error) { } info, err := os.Lstat(path) - if err != nil || !info.Mode().IsRegular() || info.Size() == 0 { + if err != nil || info.Size() == 0 { continue } diff --git a/vendor/github.com/elastic/go-sysinfo/providers/linux/procnet.go b/vendor/github.com/elastic/go-sysinfo/providers/linux/procnet.go new file mode 100644 index 00000000000..685d780497e --- /dev/null +++ b/vendor/github.com/elastic/go-sysinfo/providers/linux/procnet.go @@ -0,0 +1,112 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package linux + +import ( + "fmt" + "reflect" + "strconv" + "strings" + + "github.com/pkg/errors" + + "github.com/elastic/go-sysinfo/types" +) + +// fillStruct is some reflection work that can dynamically fill one of our tagged `netstat` structs with netstat data +func fillStruct(str interface{}, data map[string]map[string]int64) { + val := reflect.ValueOf(str).Elem() + typ := reflect.TypeOf(str).Elem() + + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + if tag := field.Tag.Get("netstat"); tag != "" { + if values, ok := data[tag]; ok { + val.Field(i).Set(reflect.ValueOf(values)) + } + } + } +} + +// parseEntry parses two lines from the net files, the first line being keys, the second being values +func parseEntry(line1, line2 string) (map[string]int64, error) { + keyArr := strings.Split(strings.TrimSpace(line1), " ") + valueArr := strings.Split(strings.TrimSpace(line2), " ") + + if len(keyArr) != len(valueArr) { + return nil, errors.New("key and value lines are mismatched") + } + + counters := make(map[string]int64, len(valueArr)) + for iter, value := range valueArr { + parsed, err := strconv.ParseInt(value, 10, 64) + if err != nil { + return nil, errors.Wrapf(err, "error parsing string to int in line: %#v", valueArr) + } + counters[keyArr[iter]] = parsed + } + return counters, nil +} + +// parseNetFile parses an entire file, and returns a 2D map, representing how files are sorted by protocol +func parseNetFile(body string) (map[string]map[string]int64, error) { + fileMetrics := make(map[string]map[string]int64) + bodySplit := strings.Split(strings.TrimSpace(body), "\n") + // There should be an even number of lines. If not, something is wrong. + if len(bodySplit)%2 != 0 { + return nil, fmt.Errorf("badly parsed body: %s", body) + } + // in the network counters, data is divided into two-line sections: a line of keys, and a line of values + // With each line + for index := 0; index < len(bodySplit); index += 2 { + keysSplit := strings.Split(bodySplit[index], ":") + valuesSplit := strings.Split(bodySplit[index+1], ":") + if len(keysSplit) != 2 || len(valuesSplit) != 2 { + return nil, fmt.Errorf("wrong number of keys: %#v", keysSplit) + } + valMap, err := parseEntry(keysSplit[1], valuesSplit[1]) + if err != nil { + return nil, errors.Wrap(err, "error parsing lines") + } + fileMetrics[valuesSplit[0]] = valMap + } + return fileMetrics, nil +} + +// getNetSnmpStats pulls snmp stats from /proc/net +func getNetSnmpStats(raw []byte) (types.SNMP, error) { + snmpData, err := parseNetFile(string(raw)) + if err != nil { + return types.SNMP{}, errors.Wrap(err, "error parsing SNMP") + } + output := types.SNMP{} + fillStruct(&output, snmpData) + + return output, nil +} + +// getNetstatStats pulls netstat stats from /proc/net +func getNetstatStats(raw []byte) (types.Netstat, error) { + netstatData, err := parseNetFile(string(raw)) + if err != nil { + return types.Netstat{}, errors.Wrap(err, "error parsing netstat") + } + output := types.Netstat{} + fillStruct(&output, netstatData) + return output, nil +} diff --git a/vendor/github.com/elastic/go-sysinfo/providers/windows/process_windows.go b/vendor/github.com/elastic/go-sysinfo/providers/windows/process_windows.go index 5dfd0905772..6c4f64eb455 100644 --- a/vendor/github.com/elastic/go-sysinfo/providers/windows/process_windows.go +++ b/vendor/github.com/elastic/go-sysinfo/providers/windows/process_windows.go @@ -304,18 +304,18 @@ func (p *process) User() (types.UserInfo, error) { return types.UserInfo{}, errors.Wrap(err, "GetTokenUser failed") } - sid, err := tokenUser.User.Sid.String() - if err != nil { - return types.UserInfo{}, errors.Wrap(err, "failed to look up user SID") + sid := tokenUser.User.Sid.String() + if sid == "" { + return types.UserInfo{}, errors.New("failed to look up user SID") } tokenGroup, err := accessToken.GetTokenPrimaryGroup() if err != nil { return types.UserInfo{}, errors.Wrap(err, "GetTokenPrimaryGroup failed") } - gsid, err := tokenGroup.PrimaryGroup.String() - if err != nil { - return types.UserInfo{}, errors.Wrap(err, "failed to look up primary group SID") + gsid := tokenGroup.PrimaryGroup.String() + if gsid == "" { + return types.UserInfo{}, errors.New("failed to look up primary group SID") } return types.UserInfo{ diff --git a/vendor/github.com/elastic/go-sysinfo/types/host.go b/vendor/github.com/elastic/go-sysinfo/types/host.go index bf5b80cdcc0..80db2c8a629 100644 --- a/vendor/github.com/elastic/go-sysinfo/types/host.go +++ b/vendor/github.com/elastic/go-sysinfo/types/host.go @@ -26,6 +26,33 @@ type Host interface { Memory() (*HostMemoryInfo, error) } +// NetworkCounters represents network stats from /proc/net +type NetworkCounters interface { + NetworkCounters() (*NetworkCountersInfo, error) +} + +// SNMP represents the data from /proc/net/snmp +type SNMP struct { + IP map[string]int64 `json:"ip" netstat:"Ip"` + ICMP map[string]int64 `json:"icmp" netstat:"Icmp"` + ICMPMsg map[string]int64 `json:"icmp_msg" netstat:"IcmpMsg"` + TCP map[string]int64 `json:"tcp" netstat:"Tcp"` + UDP map[string]int64 `json:"udp" netstat:"Udp"` + UDPLite map[string]int64 `json:"udp_lite" netstat:"UdpLite"` +} + +// Netstat represents the data from /proc/net/netstat +type Netstat struct { + TCPExt map[string]int64 `json:"tcp_ext" netstat:"TcpExt"` + IPExt map[string]int64 `json:"ip_ext" netstat:"IpExt"` +} + +// NetworkCountersInfo represents available network counters from /proc/net +type NetworkCountersInfo struct { + SNMP SNMP `json:"snmp"` + Netstat Netstat `json:"netstat"` +} + // VMStat is the interface wrapper for platforms that support /proc/vmstat. type VMStat interface { VMStat() (*VMStatInfo, error) diff --git a/vendor/vendor.json b/vendor/vendor.json index 86e0045ecbd..18d66923444 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1878,60 +1878,60 @@ "versionExact": "v0.0.6" }, { - "checksumSHA1": "rfr1yBSyYTHNU3p1NKftIyzr/eQ=", + "checksumSHA1": "rQiXI5O9NmODCPE2GZllkZMZPn8=", "path": "github.com/elastic/go-sysinfo", - "revision": "51d9d1362d77a4792dfb39a7a19f056cdf1b9840", - "revisionTime": "2019-08-22T16:44:40Z", - "version": "v1.1.0", - "versionExact": "v1.1.0" + "revision": "bd0a84193268134cbe6cdd21b0a5618aee1f5791", + "revisionTime": "2019-12-09T20:02:09Z", + "version": "v1.2.0", + "versionExact": "v1.2.0" }, { "checksumSHA1": "GiZCjX17K265TtamGZZw4R2Jwbk=", "path": "github.com/elastic/go-sysinfo/internal/registry", - "revision": "51d9d1362d77a4792dfb39a7a19f056cdf1b9840", - "revisionTime": "2019-08-22T16:44:40Z", - "version": "v1.1.0", - "versionExact": "v1.1.0" + "revision": "bd0a84193268134cbe6cdd21b0a5618aee1f5791", + "revisionTime": "2019-12-09T20:02:09Z", + "version": "v1.2.0", + "versionExact": "v1.2.0" }, { "checksumSHA1": "dVSTUnZHCLNd0tYIENqdj05RyI8=", "path": "github.com/elastic/go-sysinfo/providers/darwin", - "revision": "51d9d1362d77a4792dfb39a7a19f056cdf1b9840", - "revisionTime": "2019-08-22T16:44:40Z", - "version": "v1.1.0", - "versionExact": "v1.1.0" + "revision": "bd0a84193268134cbe6cdd21b0a5618aee1f5791", + "revisionTime": "2019-12-09T20:02:09Z", + "version": "v1.2.0", + "versionExact": "v1.2.0" }, { - "checksumSHA1": "7Spkw81dzevqmPbUGZO1UM3K3oc=", + "checksumSHA1": "Kc5GlAf7iwLd/d1X68JFM8b12GM=", "path": "github.com/elastic/go-sysinfo/providers/linux", - "revision": "51d9d1362d77a4792dfb39a7a19f056cdf1b9840", - "revisionTime": "2019-08-22T16:44:40Z", - "version": "v1.1.0", - "versionExact": "v1.1.0" + "revision": "bd0a84193268134cbe6cdd21b0a5618aee1f5791", + "revisionTime": "2019-12-09T20:02:09Z", + "version": "v1.2.0", + "versionExact": "v1.2.0" }, { "checksumSHA1": "RWLvcP1w9ynKbuCqiW6prwd+EDU=", "path": "github.com/elastic/go-sysinfo/providers/shared", - "revision": "51d9d1362d77a4792dfb39a7a19f056cdf1b9840", - "revisionTime": "2019-08-22T16:44:40Z", - "version": "v1.1.0", - "versionExact": "v1.1.0" + "revision": "bd0a84193268134cbe6cdd21b0a5618aee1f5791", + "revisionTime": "2019-12-09T20:02:09Z", + "version": "v1.2.0", + "versionExact": "v1.2.0" }, { - "checksumSHA1": "E+yrwS/aZemnWUvwTvEhiczYuD8=", + "checksumSHA1": "UbfUc6ZEYJHftvL7r/Ph5/8Tkvc=", "path": "github.com/elastic/go-sysinfo/providers/windows", - "revision": "51d9d1362d77a4792dfb39a7a19f056cdf1b9840", - "revisionTime": "2019-08-22T16:44:40Z", - "version": "v1.1.0", - "versionExact": "v1.1.0" + "revision": "bd0a84193268134cbe6cdd21b0a5618aee1f5791", + "revisionTime": "2019-12-09T20:02:09Z", + "version": "v1.2.0", + "versionExact": "v1.2.0" }, { - "checksumSHA1": "u2RbbYcB7B4uhi/eJ01qiiBa41E=", + "checksumSHA1": "dtxTdCkTAMgGmJS7Bn5jDXsQ8nA=", "path": "github.com/elastic/go-sysinfo/types", - "revision": "51d9d1362d77a4792dfb39a7a19f056cdf1b9840", - "revisionTime": "2019-08-22T16:44:40Z", - "version": "v1.1.0", - "versionExact": "v1.1.0" + "revision": "bd0a84193268134cbe6cdd21b0a5618aee1f5791", + "revisionTime": "2019-12-09T20:02:09Z", + "version": "v1.2.0", + "versionExact": "v1.2.0" }, { "checksumSHA1": "bNf3GDGhZh86bfCIMM5c5AYfo3g=", From 2c37aa405fdbd6313db73e098d4a3e2078c12bef Mon Sep 17 00:00:00 2001 From: Alex Kristiansen Date: Wed, 18 Dec 2019 12:52:06 -0800 Subject: [PATCH 02/21] add tests, clean up --- .../system/network_summary/_meta/data.json | 256 +++++++++++++++++- .../module/system/network_summary/data.go | 9 +- .../system/network_summary/network_summary.go | 1 - .../network_summary/network_summary_test.go | 62 ++++- 4 files changed, 299 insertions(+), 29 deletions(-) diff --git a/metricbeat/module/system/network_summary/_meta/data.json b/metricbeat/module/system/network_summary/_meta/data.json index acebf255aae..905e26ac4be 100644 --- a/metricbeat/module/system/network_summary/_meta/data.json +++ b/metricbeat/module/system/network_summary/_meta/data.json @@ -1,19 +1,245 @@ { - "@timestamp":"2016-05-23T08:05:34.853Z", - "beat":{ - "hostname":"beathost", - "name":"beathost" + "@timestamp": "2017-10-12T08:05:34.853Z", + "event": { + "dataset": "system.network_summary", + "duration": 115000, + "module": "system" }, - "metricset":{ - "host":"localhost", - "module":"system", - "name":"network_summary", - "rtt":44269 + "metricset": { + "name": "network_summary", + "period": 10000 }, - "system":{ - "network_summary":{ - "example": "network_summary" - } + "service": { + "type": "system" }, - "type":"metricsets" -} + "system": { + "network_summary": { + "icmp": { + "InAddrMaskReps": 0, + "InAddrMasks": 0, + "InCsumErrors": 0, + "InDestUnreachs": 835, + "InEchoReps": 0, + "InEchos": 1, + "InErrors": 20, + "InMsgs": 836, + "InParmProbs": 0, + "InRedirects": 0, + "InSrcQuenchs": 0, + "InTimeExcds": 0, + "InTimestampReps": 0, + "InTimestamps": 0, + "InType3": 835, + "InType8": 1, + "OutAddrMaskReps": 0, + "OutAddrMasks": 0, + "OutDestUnreachs": 940, + "OutEchoReps": 1, + "OutEchos": 0, + "OutErrors": 0, + "OutMsgs": 941, + "OutParmProbs": 0, + "OutRedirects": 0, + "OutSrcQuenchs": 0, + "OutTimeExcds": 0, + "OutTimestampReps": 0, + "OutTimestamps": 0, + "OutType0": 1, + "OutType3": 940 + }, + "ip": { + "DefaultTTL": 64, + "ForwDatagrams": 33389, + "Forwarding": 1, + "FragCreates": 0, + "FragFails": 0, + "FragOKs": 0, + "InAddrErrors": 19, + "InBcastOctets": 431773621, + "InBcastPkts": 1686995, + "InCEPkts": 0, + "InCsumErrors": 0, + "InDelivers": 38037698, + "InDiscards": 0, + "InECT0Pkts": 3160941, + "InECT1Pkts": 0, + "InHdrErrors": 0, + "InMcastOctets": 0, + "InMcastPkts": 0, + "InNoECTPkts": 129521210, + "InNoRoutes": 0, + "InOctets": 167733588581, + "InReceives": 41266648, + "InTruncatedPkts": 0, + "InUnknownProtos": 0, + "OutBcastOctets": 0, + "OutBcastPkts": 0, + "OutDiscards": 1, + "OutMcastOctets": 0, + "OutMcastPkts": 0, + "OutNoRoutes": 4, + "OutOctets": 75001958794, + "OutRequests": 29261852, + "ReasmFails": 0, + "ReasmOKs": 0, + "ReasmOverlaps": 0, + "ReasmReqds": 0, + "ReasmTimeout": 0 + }, + "tcp": { + "ActiveOpens": 6172, + "ArpFilter": 0, + "AttemptFails": 1488, + "BusyPollRxPackets": 0, + "CurrEstab": 9, + "DelayedACKLocked": 111, + "DelayedACKLost": 1587, + "DelayedACKs": 516004, + "EmbryonicRsts": 2, + "EstabResets": 404, + "IPReversePathFilter": 0, + "InCsumErrors": 0, + "InErrs": 4, + "InSegs": 38005498, + "ListenDrops": 0, + "ListenOverflows": 0, + "LockDroppedIcmps": 0, + "MaxConn": -1, + "OfoPruned": 0, + "OutOfWindowIcmps": 39, + "OutRsts": 10739, + "OutSegs": 66991971, + "PAWSActive": 0, + "PAWSEstab": 19, + "PFMemallocDrop": 0, + "PassiveOpens": 1411, + "PruneCalled": 0, + "RcvPruned": 0, + "RetransSegs": 15996, + "RtoAlgorithm": 1, + "RtoMax": 120000, + "RtoMin": 200, + "SyncookiesFailed": 2, + "SyncookiesRecv": 0, + "SyncookiesSent": 0, + "TCPACKSkippedChallenge": 2, + "TCPACKSkippedFinWait2": 0, + "TCPACKSkippedPAWS": 1, + "TCPACKSkippedSeq": 4, + "TCPACKSkippedSynRecv": 8, + "TCPACKSkippedTimeWait": 0, + "TCPAbortFailed": 0, + "TCPAbortOnClose": 321, + "TCPAbortOnData": 2613, + "TCPAbortOnLinger": 0, + "TCPAbortOnMemory": 0, + "TCPAbortOnTimeout": 84, + "TCPAckCompressed": 232116, + "TCPAutoCorking": 162, + "TCPBacklogCoalesce": 509441, + "TCPBacklogDrop": 0, + "TCPChallengeACK": 2, + "TCPDSACKIgnoredNoUndo": 4623, + "TCPDSACKIgnoredOld": 242, + "TCPDSACKOfoRecv": 2, + "TCPDSACKOfoSent": 15, + "TCPDSACKOldSent": 1668, + "TCPDSACKRecv": 8205, + "TCPDSACKUndo": 36, + "TCPDeferAcceptDrop": 0, + "TCPDelivered": 54733743, + "TCPDeliveredCE": 0, + "TCPFastOpenActive": 0, + "TCPFastOpenActiveFail": 0, + "TCPFastOpenBlackhole": 0, + "TCPFastOpenCookieReqd": 0, + "TCPFastOpenListenOverflow": 0, + "TCPFastOpenPassive": 0, + "TCPFastOpenPassiveFail": 0, + "TCPFastRetrans": 5324, + "TCPFromZeroWindowAdv": 977, + "TCPFullUndo": 3, + "TCPHPAcks": 4648338, + "TCPHPHits": 22005367, + "TCPHystartDelayCwnd": 3535, + "TCPHystartDelayDetect": 24, + "TCPHystartTrainCwnd": 4609, + "TCPHystartTrainDetect": 205, + "TCPKeepAlive": 312560, + "TCPLossFailures": 1, + "TCPLossProbeRecovery": 387, + "TCPLossProbes": 12748, + "TCPLossUndo": 437, + "TCPLostRetransmit": 1499, + "TCPMD5Failure": 0, + "TCPMD5NotFound": 0, + "TCPMD5Unexpected": 0, + "TCPMTUPFail": 0, + "TCPMTUPSuccess": 0, + "TCPMemoryPressures": 0, + "TCPMemoryPressuresChrono": 0, + "TCPMinTTLDrop": 0, + "TCPOFODrop": 0, + "TCPOFOMerge": 13, + "TCPOFOQueue": 266342, + "TCPOrigDataSent": 54724129, + "TCPPartialUndo": 145, + "TCPPureAcks": 6490261, + "TCPRcvCoalesce": 5762438, + "TCPRcvCollapsed": 0, + "TCPRcvQDrop": 0, + "TCPRenoFailures": 0, + "TCPRenoRecovery": 0, + "TCPRenoRecoveryFail": 0, + "TCPRenoReorder": 0, + "TCPReqQFullDoCookies": 0, + "TCPReqQFullDrop": 0, + "TCPRetransFail": 0, + "TCPSACKDiscard": 123, + "TCPSACKReneging": 0, + "TCPSACKReorder": 2707, + "TCPSYNChallenge": 4, + "TCPSackFailures": 5, + "TCPSackMerged": 13758, + "TCPSackRecovery": 241, + "TCPSackRecoveryFail": 3, + "TCPSackShiftFallback": 1455, + "TCPSackShifted": 37107, + "TCPSlowStartRetrans": 2, + "TCPSpuriousRTOs": 3, + "TCPSpuriousRtxHostQueues": 16, + "TCPSynRetrans": 346, + "TCPTSReorder": 732, + "TCPTimeWaitOverflow": 0, + "TCPTimeouts": 2178, + "TCPToZeroWindowAdv": 977, + "TCPWantZeroWindowAdv": 109048, + "TCPWinProbe": 0, + "TCPZeroWindowDrop": 0, + "TW": 1443, + "TWKilled": 0, + "TWRecycled": 0 + }, + "udp": { + "IgnoredMulti": 0, + "InCsumErrors": 0, + "InDatagrams": 31359, + "InErrors": 0, + "NoPorts": 61, + "OutDatagrams": 31756, + "RcvbufErrors": 0, + "SndbufErrors": 0 + }, + "udpLite": { + "IgnoredMulti": 0, + "InCsumErrors": 0, + "InDatagrams": 0, + "InErrors": 0, + "NoPorts": 0, + "OutDatagrams": 0, + "RcvbufErrors": 0, + "SndbufErrors": 0 + } + } + } +} \ No newline at end of file diff --git a/metricbeat/module/system/network_summary/data.go b/metricbeat/module/system/network_summary/data.go index ee8c57b8c5d..305b0c97834 100644 --- a/metricbeat/module/system/network_summary/data.go +++ b/metricbeat/module/system/network_summary/data.go @@ -18,13 +18,15 @@ package network_summary import ( + "fmt" + "github.com/elastic/beats/libbeat/common" sysinfotypes "github.com/elastic/go-sysinfo/types" ) // eventMapping maps the network counters to a MapStr that wil be sent to report.Event func eventMapping(raw *sysinfotypes.NetworkCountersInfo) common.MapStr { - + fmt.Printf("%#v\n", raw) eventByProto := common.MapStr{ "ip": combineMap(raw.Netstat.IPExt, raw.SNMP.IP), "tcp": combineMap(raw.Netstat.TCPExt, raw.SNMP.TCP), @@ -36,14 +38,13 @@ func eventMapping(raw *sysinfotypes.NetworkCountersInfo) common.MapStr { return eventByProto } +// combineMap concatinates two given maps func combineMap(map1, map2 map[string]int64) map[string]int64 { - - var compMap map[string]int64 + var compMap = make(map[string]int64) for k, v := range map1 { compMap[k] = v } - for k, v := range map2 { compMap[k] = v } diff --git a/metricbeat/module/system/network_summary/network_summary.go b/metricbeat/module/system/network_summary/network_summary.go index 382c423e4aa..8b8e5b02969 100644 --- a/metricbeat/module/system/network_summary/network_summary.go +++ b/metricbeat/module/system/network_summary/network_summary.go @@ -61,7 +61,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { // format. It publishes the event which is then forwarded to the output. In case // of an error set the Error field of mb.Event or simply call report.Error(). func (m *MetricSet) Fetch(report mb.ReporterV2) error { - counterInfo, err := fetchNetStats() if err != nil { return errors.Wrap(err, "Error fetching stats") diff --git a/metricbeat/module/system/network_summary/network_summary_test.go b/metricbeat/module/system/network_summary/network_summary_test.go index dde9c99ad9e..a920814ff50 100644 --- a/metricbeat/module/system/network_summary/network_summary_test.go +++ b/metricbeat/module/system/network_summary/network_summary_test.go @@ -1,22 +1,66 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package network_summary import ( "testing" - mbtest "github.com/elastic/beats/metricbeat/mb/testing" "github.com/stretchr/testify/assert" + + "github.com/elastic/beats/libbeat/common" + mbtest "github.com/elastic/beats/metricbeat/mb/testing" + "github.com/elastic/go-sysinfo/types" ) -func TestFetch(t *testing.T) { - f := mbtest.NewReportingMetricSetV2Error(t, getConfig()) - events, errs := mbtest.ReportingFetchV2Error(f) +func TestMapping(t *testing.T) { + + example := &types.NetworkCountersInfo{ + SNMP: types.SNMP{ + IP: map[string]int64{"DefaultTTL": 64}, + ICMP: map[string]int64{"InAddrMaskReps": 5}, + ICMPMsg: map[string]int64{"InType3": 835}, + UDP: map[string]int64{"IgnoredMulti": 10}, + UDPLite: map[string]int64{"IgnoredMulti": 0}, + }, + Netstat: types.Netstat{ + TCPExt: map[string]int64{"DelayedACKLocked": 111, "DelayedACKLost": 1587, "DelayedACKs": 516004}, + IPExt: map[string]int64{"InBcastOctets": 431773621, "InBcastPkts": 1686995, "InCEPkts": 0}, + }, + } + + exampleOut := common.MapStr{ + "icmp": map[string]int64{"InAddrMaskReps": 5, "InType3": 835}, + "ip": map[string]int64{"DefaultTTL": 64, "InBcastOctets": 431773621, "InBcastPkts": 1686995, "InCEPkts": 0}, + "tcp": map[string]int64{"DelayedACKLocked": 111, "DelayedACKLost": 1587, "DelayedACKs": 516004}, + "udp": map[string]int64{"IgnoredMulti": 10}, + "udpLite": map[string]int64{"IgnoredMulti": 0}} + + out := eventMapping(example) + assert.Equal(t, exampleOut, out) - assert.Empty(t, errs) - if !assert.NotEmpty(t, events) { - t.FailNow() +} + +func TestData(t *testing.T) { + f := mbtest.NewReportingMetricSetV2Error(t, getConfig()) + err := mbtest.WriteEventsReporterV2Error(f, t, ".") + if err != nil { + t.Fatal("write", err) } - t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), - events[0].BeatEvent("system", "memory").Fields.StringToPrint()) } func getConfig() map[string]interface{} { From 27d36de46dcdf16c2e567fc94418622df9c27b47 Mon Sep 17 00:00:00 2001 From: Alex Kristiansen Date: Wed, 18 Dec 2019 14:38:01 -0800 Subject: [PATCH 03/21] update notice --- NOTICE.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 774e0d936a2..6e8cf796ade 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1104,13 +1104,19 @@ Apache License 2.0 -------------------------------------------------------------------- Dependency: github.com/elastic/go-sysinfo -Version: v1.1.0 -Revision: 51d9d1362d77a4792dfb39a7a19f056cdf1b9840 +Version: v1.2.0 +Revision: bd0a84193268134cbe6cdd21b0a5618aee1f5791 License type (autodetected): Apache-2.0 ./vendor/github.com/elastic/go-sysinfo/LICENSE.txt: -------------------------------------------------------------------- Apache License 2.0 +-------NOTICE.txt----- +Elastic go-sysinfo +Copyright 2017-2019 Elasticsearch B.V. + +This product includes software developed at +Elasticsearch, B.V. (https://www.elastic.co/). -------------------------------------------------------------------- Dependency: github.com/elastic/go-txfile From 61e394dbf61a45d32b19d02ca1542ea6dbd3c0e3 Mon Sep 17 00:00:00 2001 From: Alex Kristiansen Date: Thu, 19 Dec 2019 07:25:25 -0800 Subject: [PATCH 04/21] update golang.org/x/sys --- .../golang.org/x/net/internal/socket/empty.s | 10 +- vendor/golang.org/x/sys/AUTHORS | 3 + vendor/golang.org/x/sys/CONTRIBUTING.md | 26 + vendor/golang.org/x/sys/CONTRIBUTORS | 3 + vendor/golang.org/x/sys/README.md | 18 + vendor/golang.org/x/sys/codereview.cfg | 1 + vendor/golang.org/x/sys/cpu/byteorder.go | 48 + vendor/golang.org/x/sys/cpu/cpu.go | 39 + vendor/golang.org/x/sys/cpu/cpu_arm.go | 35 + vendor/golang.org/x/sys/cpu/cpu_arm64.s | 31 + vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go | 11 + .../golang.org/x/sys/cpu/cpu_gccgo_arm64.go | 11 + .../sys/cpu/{cpu_gccgo.c => cpu_gccgo_x86.c} | 0 .../cpu/{cpu_gccgo.go => cpu_gccgo_x86.go} | 0 vendor/golang.org/x/sys/cpu/cpu_linux.go | 24 + vendor/golang.org/x/sys/cpu/cpu_linux_arm.go | 39 + .../golang.org/x/sys/cpu/cpu_linux_arm64.go | 12 + .../golang.org/x/sys/cpu/cpu_linux_noinit.go | 9 + vendor/golang.org/x/sys/cpu/cpu_mips64x.go | 133 +- vendor/golang.org/x/sys/cpu/cpu_mipsx.go | 14 + .../golang.org/x/sys/cpu/cpu_other_arm64.go | 13 + vendor/golang.org/x/sys/cpu/cpu_riscv64.go | 9 + vendor/golang.org/x/sys/cpu/cpu_wasm.go | 3 + vendor/golang.org/x/sys/cpu/hwcap_linux.go | 56 + vendor/golang.org/x/sys/go.mod | 3 + .../x/sys/windows/asm_windows_386.s | 13 - .../x/sys/windows/asm_windows_amd64.s | 13 - .../golang.org/x/sys/windows/dll_windows.go | 22 +- vendor/golang.org/x/sys/windows/empty.s | 8 + vendor/golang.org/x/sys/windows/mksyscall.go | 2 +- .../x/sys/windows/registry/mksyscall.go | 2 +- .../x/sys/windows/registry/value.go | 11 +- .../x/sys/windows/security_windows.go | 630 +++++- .../x/sys/windows/syscall_windows.go | 175 +- .../golang.org/x/sys/windows/types_windows.go | 144 +- .../x/sys/windows/zsyscall_windows.go | 1937 +++++++++++++++-- vendor/vendor.json | 41 + 37 files changed, 3232 insertions(+), 317 deletions(-) create mode 100644 vendor/golang.org/x/sys/AUTHORS create mode 100644 vendor/golang.org/x/sys/CONTRIBUTING.md create mode 100644 vendor/golang.org/x/sys/CONTRIBUTORS create mode 100644 vendor/golang.org/x/sys/README.md create mode 100644 vendor/golang.org/x/sys/codereview.cfg create mode 100644 vendor/golang.org/x/sys/cpu/cpu_arm64.s create mode 100644 vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go create mode 100644 vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go rename vendor/golang.org/x/sys/cpu/{cpu_gccgo.c => cpu_gccgo_x86.c} (100%) rename vendor/golang.org/x/sys/cpu/{cpu_gccgo.go => cpu_gccgo_x86.go} (100%) create mode 100644 vendor/golang.org/x/sys/cpu/cpu_linux_arm.go create mode 100644 vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go create mode 100644 vendor/golang.org/x/sys/cpu/cpu_riscv64.go create mode 100644 vendor/golang.org/x/sys/cpu/hwcap_linux.go create mode 100644 vendor/golang.org/x/sys/go.mod delete mode 100644 vendor/golang.org/x/sys/windows/asm_windows_386.s delete mode 100644 vendor/golang.org/x/sys/windows/asm_windows_amd64.s create mode 100644 vendor/golang.org/x/sys/windows/empty.s diff --git a/vendor/golang.org/x/net/internal/socket/empty.s b/vendor/golang.org/x/net/internal/socket/empty.s index bff0231c7d5..966b66794ae 100644 --- a/vendor/golang.org/x/net/internal/socket/empty.s +++ b/vendor/golang.org/x/net/internal/socket/empty.s @@ -1,7 +1,15 @@ -// Copyright 2018 The Go Authors. All rights reserved. +// 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. +<<<<<<< HEAD:vendor/golang.org/x/net/internal/socket/empty.s // +build darwin,go1.12 // This exists solely so we can linkname in symbols from syscall. +======= +// +build !linux,arm64 + +package cpu + +func doinit() {} +>>>>>>> update golang.org/x/sys:vendor/golang.org/x/sys/cpu/cpu_other_arm64.go diff --git a/vendor/golang.org/x/sys/AUTHORS b/vendor/golang.org/x/sys/AUTHORS new file mode 100644 index 00000000000..15167cd746c --- /dev/null +++ b/vendor/golang.org/x/sys/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/sys/CONTRIBUTING.md b/vendor/golang.org/x/sys/CONTRIBUTING.md new file mode 100644 index 00000000000..d0485e887a2 --- /dev/null +++ b/vendor/golang.org/x/sys/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to Go + +Go is an open source project. + +It is the work of hundreds of contributors. We appreciate your help! + +## Filing issues + +When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: + +1. What version of Go are you using (`go version`)? +2. What operating system and processor architecture are you using? +3. What did you do? +4. What did you expect to see? +5. What did you see instead? + +General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. +The gophers there will answer or ask you to file an issue if you've tripped over a bug. + +## Contributing code + +Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) +before sending patches. + +Unless otherwise noted, the Go source files are distributed under +the BSD-style license found in the LICENSE file. diff --git a/vendor/golang.org/x/sys/CONTRIBUTORS b/vendor/golang.org/x/sys/CONTRIBUTORS new file mode 100644 index 00000000000..1c4577e9680 --- /dev/null +++ b/vendor/golang.org/x/sys/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/sys/README.md b/vendor/golang.org/x/sys/README.md new file mode 100644 index 00000000000..ef6c9e59c26 --- /dev/null +++ b/vendor/golang.org/x/sys/README.md @@ -0,0 +1,18 @@ +# sys + +This repository holds supplemental Go packages for low-level interactions with +the operating system. + +## Download/Install + +The easiest way to install is to run `go get -u golang.org/x/sys`. You can +also manually git clone the repository to `$GOPATH/src/golang.org/x/sys`. + +## Report Issues / Send Patches + +This repository uses Gerrit for code changes. To learn how to submit changes to +this repository, see https://golang.org/doc/contribute.html. + +The main issue tracker for the sys repository is located at +https://github.com/golang/go/issues. Prefix your issue with "x/sys:" in the +subject line, so it is easy to find. diff --git a/vendor/golang.org/x/sys/codereview.cfg b/vendor/golang.org/x/sys/codereview.cfg new file mode 100644 index 00000000000..3f8b14b64e8 --- /dev/null +++ b/vendor/golang.org/x/sys/codereview.cfg @@ -0,0 +1 @@ +issuerepo: golang/go diff --git a/vendor/golang.org/x/sys/cpu/byteorder.go b/vendor/golang.org/x/sys/cpu/byteorder.go index da6b9e4363d..3a7ea39c0cf 100644 --- a/vendor/golang.org/x/sys/cpu/byteorder.go +++ b/vendor/golang.org/x/sys/cpu/byteorder.go @@ -5,6 +5,7 @@ package cpu import ( +<<<<<<< HEAD "encoding/binary" "runtime" ) @@ -12,19 +13,66 @@ import ( // hostByteOrder returns binary.LittleEndian on little-endian machines and // binary.BigEndian on big-endian machines. func hostByteOrder() binary.ByteOrder { +======= + "runtime" +) + +// byteOrder is a subset of encoding/binary.ByteOrder. +type byteOrder interface { + Uint32([]byte) uint32 + Uint64([]byte) uint64 +} + +type littleEndian struct{} +type bigEndian struct{} + +func (littleEndian) Uint32(b []byte) uint32 { + _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 + return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 +} + +func (littleEndian) Uint64(b []byte) uint64 { + _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 + return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | + uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 +} + +func (bigEndian) Uint32(b []byte) uint32 { + _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 + return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 +} + +func (bigEndian) Uint64(b []byte) uint64 { + _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 + return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | + uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 +} + +// hostByteOrder returns binary.LittleEndian on little-endian machines and +// binary.BigEndian on big-endian machines. +func hostByteOrder() byteOrder { +>>>>>>> update golang.org/x/sys switch runtime.GOARCH { case "386", "amd64", "amd64p32", "arm", "arm64", "mipsle", "mips64le", "mips64p32le", "ppc64le", "riscv", "riscv64": +<<<<<<< HEAD return binary.LittleEndian +======= + return littleEndian{} +>>>>>>> update golang.org/x/sys case "armbe", "arm64be", "mips", "mips64", "mips64p32", "ppc", "ppc64", "s390", "s390x", "sparc", "sparc64": +<<<<<<< HEAD return binary.BigEndian +======= + return bigEndian{} +>>>>>>> update golang.org/x/sys } panic("unknown architecture") } diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go index 679e78c2cef..ba736df0f8d 100644 --- a/vendor/golang.org/x/sys/cpu/cpu.go +++ b/vendor/golang.org/x/sys/cpu/cpu.go @@ -78,6 +78,45 @@ var ARM64 struct { _ CacheLinePad } +<<<<<<< HEAD +======= +// ARM contains the supported CPU features of the current ARM (32-bit) platform. +// All feature flags are false if: +// 1. the current platform is not arm, or +// 2. the current operating system is not Linux. +var ARM struct { + _ CacheLinePad + HasSWP bool // SWP instruction support + HasHALF bool // Half-word load and store support + HasTHUMB bool // ARM Thumb instruction set + Has26BIT bool // Address space limited to 26-bits + HasFASTMUL bool // 32-bit operand, 64-bit result multiplication support + HasFPA bool // Floating point arithmetic support + HasVFP bool // Vector floating point support + HasEDSP bool // DSP Extensions support + HasJAVA bool // Java instruction set + HasIWMMXT bool // Intel Wireless MMX technology support + HasCRUNCH bool // MaverickCrunch context switching and handling + HasTHUMBEE bool // Thumb EE instruction set + HasNEON bool // NEON instruction set + HasVFPv3 bool // Vector floating point version 3 support + HasVFPv3D16 bool // Vector floating point version 3 D8-D15 + HasTLS bool // Thread local storage support + HasVFPv4 bool // Vector floating point version 4 support + HasIDIVA bool // Integer divide instruction support in ARM mode + HasIDIVT bool // Integer divide instruction support in Thumb mode + HasVFPD32 bool // Vector floating point version 3 D15-D31 + HasLPAE bool // Large Physical Address Extensions + HasEVTSTRM bool // Event stream support + HasAES bool // AES hardware implementation + HasPMULL bool // Polynomial multiplication instruction set + HasSHA1 bool // SHA1 hardware implementation + HasSHA2 bool // SHA2 hardware implementation + HasCRC32 bool // CRC32 hardware implementation + _ CacheLinePad +} + +>>>>>>> update golang.org/x/sys // PPC64 contains the supported CPU features of the current ppc64/ppc64le platforms. // If the current platform is not ppc64/ppc64le then all feature flags are false. // diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm.go b/vendor/golang.org/x/sys/cpu/cpu_arm.go index 7f2348b7d4b..be19943d425 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_arm.go +++ b/vendor/golang.org/x/sys/cpu/cpu_arm.go @@ -6,4 +6,39 @@ package cpu const cacheLineSize = 32 +<<<<<<< HEAD func doinit() {} +======= +// HWCAP/HWCAP2 bits. +// These are specific to Linux. +const ( + hwcap_SWP = 1 << 0 + hwcap_HALF = 1 << 1 + hwcap_THUMB = 1 << 2 + hwcap_26BIT = 1 << 3 + hwcap_FAST_MULT = 1 << 4 + hwcap_FPA = 1 << 5 + hwcap_VFP = 1 << 6 + hwcap_EDSP = 1 << 7 + hwcap_JAVA = 1 << 8 + hwcap_IWMMXT = 1 << 9 + hwcap_CRUNCH = 1 << 10 + hwcap_THUMBEE = 1 << 11 + hwcap_NEON = 1 << 12 + hwcap_VFPv3 = 1 << 13 + hwcap_VFPv3D16 = 1 << 14 + hwcap_TLS = 1 << 15 + hwcap_VFPv4 = 1 << 16 + hwcap_IDIVA = 1 << 17 + hwcap_IDIVT = 1 << 18 + hwcap_VFPD32 = 1 << 19 + hwcap_LPAE = 1 << 20 + hwcap_EVTSTRM = 1 << 21 + + hwcap2_AES = 1 << 0 + hwcap2_PMULL = 1 << 1 + hwcap2_SHA1 = 1 << 2 + hwcap2_SHA2 = 1 << 3 + hwcap2_CRC32 = 1 << 4 +) +>>>>>>> update golang.org/x/sys diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm64.s b/vendor/golang.org/x/sys/cpu/cpu_arm64.s new file mode 100644 index 00000000000..a54436e3909 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_arm64.s @@ -0,0 +1,31 @@ +// 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 !gccgo + +#include "textflag.h" + +// func getisar0() uint64 +TEXT ·getisar0(SB),NOSPLIT,$0-8 + // get Instruction Set Attributes 0 into x0 + // mrs x0, ID_AA64ISAR0_EL1 = d5380600 + WORD $0xd5380600 + MOVD R0, ret+0(FP) + RET + +// func getisar1() uint64 +TEXT ·getisar1(SB),NOSPLIT,$0-8 + // get Instruction Set Attributes 1 into x0 + // mrs x0, ID_AA64ISAR1_EL1 = d5380620 + WORD $0xd5380620 + MOVD R0, ret+0(FP) + RET + +// func getpfr0() uint64 +TEXT ·getpfr0(SB),NOSPLIT,$0-8 + // get Processor Feature Register 0 into x0 + // mrs x0, ID_AA64PFR0_EL1 = d5380400 + WORD $0xd5380400 + MOVD R0, ret+0(FP) + RET diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go new file mode 100644 index 00000000000..7b88e865a42 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go @@ -0,0 +1,11 @@ +// 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 !gccgo + +package cpu + +func getisar0() uint64 +func getisar1() uint64 +func getpfr0() uint64 diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go new file mode 100644 index 00000000000..53ca8d65c37 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go @@ -0,0 +1,11 @@ +// 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 gccgo + +package cpu + +func getisar0() uint64 { return 0 } +func getisar1() uint64 { return 0 } +func getpfr0() uint64 { return 0 } diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo.c b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c similarity index 100% rename from vendor/golang.org/x/sys/cpu/cpu_gccgo.c rename to vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go similarity index 100% rename from vendor/golang.org/x/sys/cpu/cpu_gccgo.go rename to vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux.go b/vendor/golang.org/x/sys/cpu/cpu_linux.go index 76b5f507faf..da06be2d876 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +<<<<<<< HEAD //+build !amd64,!amd64p32,!386 package cpu @@ -57,3 +58,26 @@ func init() { Initialized = true } +======= +<<<<<<< HEAD:vendor/golang.org/x/sys/cpu/cpu_mipsx.go +// +build mips mipsle + +package cpu + +const cacheLineSize = 32 + +func doinit() {} +======= +// +build !386,!amd64,!amd64p32,!arm64 + +package cpu + +func init() { + if err := readHWCAP(); err != nil { + return + } + doinit() + Initialized = true +} +>>>>>>> update golang.org/x/sys:vendor/golang.org/x/sys/cpu/cpu_linux.go +>>>>>>> update golang.org/x/sys diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_arm.go b/vendor/golang.org/x/sys/cpu/cpu_linux_arm.go new file mode 100644 index 00000000000..2057006dce4 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_arm.go @@ -0,0 +1,39 @@ +// 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. + +package cpu + +func doinit() { + ARM.HasSWP = isSet(hwCap, hwcap_SWP) + ARM.HasHALF = isSet(hwCap, hwcap_HALF) + ARM.HasTHUMB = isSet(hwCap, hwcap_THUMB) + ARM.Has26BIT = isSet(hwCap, hwcap_26BIT) + ARM.HasFASTMUL = isSet(hwCap, hwcap_FAST_MULT) + ARM.HasFPA = isSet(hwCap, hwcap_FPA) + ARM.HasVFP = isSet(hwCap, hwcap_VFP) + ARM.HasEDSP = isSet(hwCap, hwcap_EDSP) + ARM.HasJAVA = isSet(hwCap, hwcap_JAVA) + ARM.HasIWMMXT = isSet(hwCap, hwcap_IWMMXT) + ARM.HasCRUNCH = isSet(hwCap, hwcap_CRUNCH) + ARM.HasTHUMBEE = isSet(hwCap, hwcap_THUMBEE) + ARM.HasNEON = isSet(hwCap, hwcap_NEON) + ARM.HasVFPv3 = isSet(hwCap, hwcap_VFPv3) + ARM.HasVFPv3D16 = isSet(hwCap, hwcap_VFPv3D16) + ARM.HasTLS = isSet(hwCap, hwcap_TLS) + ARM.HasVFPv4 = isSet(hwCap, hwcap_VFPv4) + ARM.HasIDIVA = isSet(hwCap, hwcap_IDIVA) + ARM.HasIDIVT = isSet(hwCap, hwcap_IDIVT) + ARM.HasVFPD32 = isSet(hwCap, hwcap_VFPD32) + ARM.HasLPAE = isSet(hwCap, hwcap_LPAE) + ARM.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM) + ARM.HasAES = isSet(hwCap2, hwcap2_AES) + ARM.HasPMULL = isSet(hwCap2, hwcap2_PMULL) + ARM.HasSHA1 = isSet(hwCap2, hwcap2_SHA1) + ARM.HasSHA2 = isSet(hwCap2, hwcap2_SHA2) + ARM.HasCRC32 = isSet(hwCap2, hwcap2_CRC32) +} + +func isSet(hwc uint, value uint) bool { + return hwc&value != 0 +} diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go index fa7fb1bd7b2..cb74641e29e 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go @@ -4,8 +4,11 @@ package cpu +<<<<<<< HEAD const cacheLineSize = 64 +======= +>>>>>>> update golang.org/x/sys // HWCAP/HWCAP2 bits. These are exposed by Linux. const ( hwcap_FP = 1 << 0 @@ -35,6 +38,15 @@ const ( ) func doinit() { +<<<<<<< HEAD +======= + if err := readHWCAP(); err != nil { + // failed to read /proc/self/auxv, try reading registers directly + readARM64Registers() + return + } + +>>>>>>> update golang.org/x/sys // HWCAP feature bits ARM64.HasFP = isSet(hwCap, hwcap_FP) ARM64.HasASIMD = isSet(hwCap, hwcap_ASIMD) diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go new file mode 100644 index 00000000000..f65134f67ff --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go @@ -0,0 +1,9 @@ +// 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 linux,!arm,!arm64,!ppc64,!ppc64le,!s390x + +package cpu + +func doinit() {} diff --git a/vendor/golang.org/x/sys/cpu/cpu_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_mips64x.go index f55e0c82c73..da1cc1818de 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_mips64x.go +++ b/vendor/golang.org/x/sys/cpu/cpu_mips64x.go @@ -1,4 +1,4 @@ -// Copyright 2018 The Go Authors. All rights reserved. +// 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. @@ -6,6 +6,137 @@ package cpu +<<<<<<< HEAD:vendor/golang.org/x/sys/cpu/cpu_mips64x.go const cacheLineSize = 32 func doinit() {} +======= +import "runtime" + +const cacheLineSize = 64 + +func init() { + switch runtime.GOOS { + case "darwin": + // iOS does not seem to allow reading these registers + case "android", "linux": + doinit() + default: + readARM64Registers() + } +} + +func readARM64Registers() { + Initialized = true + + // ID_AA64ISAR0_EL1 + isar0 := getisar0() + + switch extractBits(isar0, 4, 7) { + case 1: + ARM64.HasAES = true + case 2: + ARM64.HasAES = true + ARM64.HasPMULL = true + } + + switch extractBits(isar0, 8, 11) { + case 1: + ARM64.HasSHA1 = true + } + + switch extractBits(isar0, 12, 15) { + case 1: + ARM64.HasSHA2 = true + case 2: + ARM64.HasSHA2 = true + ARM64.HasSHA512 = true + } + + switch extractBits(isar0, 16, 19) { + case 1: + ARM64.HasCRC32 = true + } + + switch extractBits(isar0, 20, 23) { + case 2: + ARM64.HasATOMICS = true + } + + switch extractBits(isar0, 28, 31) { + case 1: + ARM64.HasASIMDRDM = true + } + + switch extractBits(isar0, 32, 35) { + case 1: + ARM64.HasSHA3 = true + } + + switch extractBits(isar0, 36, 39) { + case 1: + ARM64.HasSM3 = true + } + + switch extractBits(isar0, 40, 43) { + case 1: + ARM64.HasSM4 = true + } + + switch extractBits(isar0, 44, 47) { + case 1: + ARM64.HasASIMDDP = true + } + + // ID_AA64ISAR1_EL1 + isar1 := getisar1() + + switch extractBits(isar1, 0, 3) { + case 1: + ARM64.HasDCPOP = true + } + + switch extractBits(isar1, 12, 15) { + case 1: + ARM64.HasJSCVT = true + } + + switch extractBits(isar1, 16, 19) { + case 1: + ARM64.HasFCMA = true + } + + switch extractBits(isar1, 20, 23) { + case 1: + ARM64.HasLRCPC = true + } + + // ID_AA64PFR0_EL1 + pfr0 := getpfr0() + + switch extractBits(pfr0, 16, 19) { + case 0: + ARM64.HasFP = true + case 1: + ARM64.HasFP = true + ARM64.HasFPHP = true + } + + switch extractBits(pfr0, 20, 23) { + case 0: + ARM64.HasASIMD = true + case 1: + ARM64.HasASIMD = true + ARM64.HasASIMDHP = true + } + + switch extractBits(pfr0, 32, 35) { + case 1: + ARM64.HasSVE = true + } +} + +func extractBits(data uint64, start, end uint) uint { + return (uint)(data>>start) & ((1 << (end - start + 1)) - 1) +} +>>>>>>> update golang.org/x/sys:vendor/golang.org/x/sys/cpu/cpu_arm64.go diff --git a/vendor/golang.org/x/sys/cpu/cpu_mipsx.go b/vendor/golang.org/x/sys/cpu/cpu_mipsx.go index cda87b1a1b1..872e6570987 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_mipsx.go +++ b/vendor/golang.org/x/sys/cpu/cpu_mipsx.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +<<<<<<< HEAD:vendor/golang.org/x/sys/cpu/cpu_mipsx.go // +build mips mipsle package cpu @@ -9,3 +10,16 @@ package cpu const cacheLineSize = 32 func doinit() {} +======= +// +build !386,!amd64,!amd64p32,!arm64 + +package cpu + +func init() { + if err := readHWCAP(); err != nil { + return + } + doinit() + Initialized = true +} +>>>>>>> update golang.org/x/sys:vendor/golang.org/x/sys/cpu/cpu_linux.go diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go index dd1e76dc921..7003a0a3ef8 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go @@ -2,10 +2,23 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +<<<<<<< HEAD +======= +<<<<<<< HEAD:vendor/golang.org/x/net/internal/socket/empty.s +// +build darwin,go1.12 + +// This exists solely so we can linkname in symbols from syscall. +======= +>>>>>>> update golang.org/x/sys // +build !linux,arm64 package cpu +<<<<<<< HEAD const cacheLineSize = 64 func doinit() {} +======= +func doinit() {} +>>>>>>> update golang.org/x/sys:vendor/golang.org/x/sys/cpu/cpu_other_arm64.go +>>>>>>> update golang.org/x/sys diff --git a/vendor/golang.org/x/sys/cpu/cpu_riscv64.go b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go new file mode 100644 index 00000000000..efe2b7a8477 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go @@ -0,0 +1,9 @@ +// 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 riscv64 + +package cpu + +const cacheLineSize = 32 diff --git a/vendor/golang.org/x/sys/cpu/cpu_wasm.go b/vendor/golang.org/x/sys/cpu/cpu_wasm.go index bd9bbda0c08..e14a9b62e02 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_wasm.go +++ b/vendor/golang.org/x/sys/cpu/cpu_wasm.go @@ -11,5 +11,8 @@ package cpu // rules are good enough. const cacheLineSize = 0 +<<<<<<< HEAD func doinit() {} +======= +>>>>>>> update golang.org/x/sys diff --git a/vendor/golang.org/x/sys/cpu/hwcap_linux.go b/vendor/golang.org/x/sys/cpu/hwcap_linux.go new file mode 100644 index 00000000000..f3baa379328 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/hwcap_linux.go @@ -0,0 +1,56 @@ +// 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. + +package cpu + +import ( + "io/ioutil" +) + +const ( + _AT_HWCAP = 16 + _AT_HWCAP2 = 26 + + procAuxv = "/proc/self/auxv" + + uintSize = int(32 << (^uint(0) >> 63)) +) + +// For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2 +// These are initialized in cpu_$GOARCH.go +// and should not be changed after they are initialized. +var hwCap uint +var hwCap2 uint + +func readHWCAP() error { + buf, err := ioutil.ReadFile(procAuxv) + if err != nil { + // e.g. on android /proc/self/auxv is not accessible, so silently + // ignore the error and leave Initialized = false. On some + // architectures (e.g. arm64) doinit() implements a fallback + // readout and will set Initialized = true again. + return err + } + bo := hostByteOrder() + for len(buf) >= 2*(uintSize/8) { + var tag, val uint + switch uintSize { + case 32: + tag = uint(bo.Uint32(buf[0:])) + val = uint(bo.Uint32(buf[4:])) + buf = buf[8:] + case 64: + tag = uint(bo.Uint64(buf[0:])) + val = uint(bo.Uint64(buf[8:])) + buf = buf[16:] + } + switch tag { + case _AT_HWCAP: + hwCap = val + case _AT_HWCAP2: + hwCap2 = val + } + } + return nil +} diff --git a/vendor/golang.org/x/sys/go.mod b/vendor/golang.org/x/sys/go.mod new file mode 100644 index 00000000000..b12171fdc29 --- /dev/null +++ b/vendor/golang.org/x/sys/go.mod @@ -0,0 +1,3 @@ +module golang.org/x/sys + +go 1.12 diff --git a/vendor/golang.org/x/sys/windows/asm_windows_386.s b/vendor/golang.org/x/sys/windows/asm_windows_386.s deleted file mode 100644 index 21d994d318a..00000000000 --- a/vendor/golang.org/x/sys/windows/asm_windows_386.s +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2009 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. - -// -// System calls for 386, Windows are implemented in runtime/syscall_windows.goc -// - -TEXT ·getprocaddress(SB), 7, $0-16 - JMP syscall·getprocaddress(SB) - -TEXT ·loadlibrary(SB), 7, $0-12 - JMP syscall·loadlibrary(SB) diff --git a/vendor/golang.org/x/sys/windows/asm_windows_amd64.s b/vendor/golang.org/x/sys/windows/asm_windows_amd64.s deleted file mode 100644 index 5bfdf797414..00000000000 --- a/vendor/golang.org/x/sys/windows/asm_windows_amd64.s +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2009 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. - -// -// System calls for amd64, Windows are implemented in runtime/syscall_windows.goc -// - -TEXT ·getprocaddress(SB), 7, $0-32 - JMP syscall·getprocaddress(SB) - -TEXT ·loadlibrary(SB), 7, $0-24 - JMP syscall·loadlibrary(SB) diff --git a/vendor/golang.org/x/sys/windows/dll_windows.go b/vendor/golang.org/x/sys/windows/dll_windows.go index ba67658db1d..d7771134158 100644 --- a/vendor/golang.org/x/sys/windows/dll_windows.go +++ b/vendor/golang.org/x/sys/windows/dll_windows.go @@ -11,6 +11,18 @@ import ( "unsafe" ) +// We need to use LoadLibrary and GetProcAddress from the Go runtime, because +// the these symbols are loaded by the system linker and are required to +// dynamically load additional symbols. Note that in the Go runtime, these +// return syscall.Handle and syscall.Errno, but these are the same, in fact, +// as windows.Handle and windows.Errno, and we intend to keep these the same. + +//go:linkname syscall_loadlibrary syscall.loadlibrary +func syscall_loadlibrary(filename *uint16) (handle Handle, err Errno) + +//go:linkname syscall_getprocaddress syscall.getprocaddress +func syscall_getprocaddress(handle Handle, procname *uint8) (proc uintptr, err Errno) + // DLLError describes reasons for DLL load failures. type DLLError struct { Err error @@ -20,10 +32,6 @@ type DLLError struct { func (e *DLLError) Error() string { return e.Msg } -// Implemented in runtime/syscall_windows.goc; we provide jumps to them in our assembly file. -func loadlibrary(filename *uint16) (handle uintptr, err syscall.Errno) -func getprocaddress(handle uintptr, procname *uint8) (proc uintptr, err syscall.Errno) - // A DLL implements access to a single DLL. type DLL struct { Name string @@ -40,7 +48,7 @@ func LoadDLL(name string) (dll *DLL, err error) { if err != nil { return nil, err } - h, e := loadlibrary(namep) + h, e := syscall_loadlibrary(namep) if e != 0 { return nil, &DLLError{ Err: e, @@ -50,7 +58,7 @@ func LoadDLL(name string) (dll *DLL, err error) { } d := &DLL{ Name: name, - Handle: Handle(h), + Handle: h, } return d, nil } @@ -71,7 +79,7 @@ func (d *DLL) FindProc(name string) (proc *Proc, err error) { if err != nil { return nil, err } - a, e := getprocaddress(uintptr(d.Handle), namep) + a, e := syscall_getprocaddress(d.Handle, namep) if e != 0 { return nil, &DLLError{ Err: e, diff --git a/vendor/golang.org/x/sys/windows/empty.s b/vendor/golang.org/x/sys/windows/empty.s new file mode 100644 index 00000000000..69309e4da55 --- /dev/null +++ b/vendor/golang.org/x/sys/windows/empty.s @@ -0,0 +1,8 @@ +// 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 !go1.12 + +// This file is here to allow bodyless functions with go:linkname for Go 1.11 +// and earlier (see https://golang.org/issue/23311). diff --git a/vendor/golang.org/x/sys/windows/mksyscall.go b/vendor/golang.org/x/sys/windows/mksyscall.go index 62770572747..328e3b2ace2 100644 --- a/vendor/golang.org/x/sys/windows/mksyscall.go +++ b/vendor/golang.org/x/sys/windows/mksyscall.go @@ -6,4 +6,4 @@ package windows -//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go +//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go diff --git a/vendor/golang.org/x/sys/windows/registry/mksyscall.go b/vendor/golang.org/x/sys/windows/registry/mksyscall.go index cf843ce2b22..50c32a3f4e1 100644 --- a/vendor/golang.org/x/sys/windows/registry/mksyscall.go +++ b/vendor/golang.org/x/sys/windows/registry/mksyscall.go @@ -6,4 +6,4 @@ package registry -//go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go +//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go syscall.go diff --git a/vendor/golang.org/x/sys/windows/registry/value.go b/vendor/golang.org/x/sys/windows/registry/value.go index 7487e05f8db..f25e7e97ae5 100644 --- a/vendor/golang.org/x/sys/windows/registry/value.go +++ b/vendor/golang.org/x/sys/windows/registry/value.go @@ -108,7 +108,7 @@ func (k Key) GetStringValue(name string) (val string, valtype uint32, err error) if len(data) == 0 { return "", typ, nil } - u := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:] + u := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[: len(data)/2 : len(data)/2] return syscall.UTF16ToString(u), typ, nil } @@ -185,8 +185,7 @@ func ExpandString(value string) (string, error) { return "", err } if n <= uint32(len(r)) { - u := (*[1 << 29]uint16)(unsafe.Pointer(&r[0]))[:] - return syscall.UTF16ToString(u), nil + return syscall.UTF16ToString(r[:n]), nil } r = make([]uint16, n) } @@ -208,7 +207,7 @@ func (k Key) GetStringsValue(name string) (val []string, valtype uint32, err err if len(data) == 0 { return nil, typ, nil } - p := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2] + p := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[: len(data)/2 : len(data)/2] if len(p) == 0 { return nil, typ, nil } @@ -299,7 +298,7 @@ func (k Key) setStringValue(name string, valtype uint32, value string) error { if err != nil { return err } - buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] + buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[: len(v)*2 : len(v)*2] return k.setValue(name, valtype, buf) } @@ -329,7 +328,7 @@ func (k Key) SetStringsValue(name string, value []string) error { ss += s + "\x00" } v := utf16.Encode([]rune(ss + "\x00")) - buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2] + buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[: len(v)*2 : len(v)*2] return k.setValue(name, MULTI_SZ, buf) } diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 61b49647b9a..35d9d56bb77 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -9,14 +9,6 @@ import ( "unsafe" ) -const ( - STANDARD_RIGHTS_REQUIRED = 0xf0000 - STANDARD_RIGHTS_READ = 0x20000 - STANDARD_RIGHTS_WRITE = 0x20000 - STANDARD_RIGHTS_EXECUTE = 0x20000 - STANDARD_RIGHTS_ALL = 0x1F0000 -) - const ( NameUnknown = 0 NameFullyQualifiedDN = 1 @@ -235,16 +227,21 @@ func LookupSID(system, account string) (sid *SID, domain string, accType uint32, } } +<<<<<<< HEAD // String converts SID to a string format // suitable for display, storage, or transmission. func (sid *SID) String() (string, error) { +======= +// String converts SID to a string format suitable for display, storage, or transmission. +func (sid *SID) String() string { +>>>>>>> update golang.org/x/sys var s *uint16 e := ConvertSidToStringSid(sid, &s) if e != nil { - return "", e + return "" } defer LocalFree((Handle)(unsafe.Pointer(s))) - return UTF16ToString((*[256]uint16)(unsafe.Pointer(s))[:]), nil + return UTF16ToString((*[256]uint16)(unsafe.Pointer(s))[:]) } // Len returns the length, in bytes, of a valid security identifier SID. @@ -644,6 +641,11 @@ func (tml *Tokenmandatorylabel) Size() uint32 { //sys DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) = advapi32.DuplicateTokenEx //sys GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) = userenv.GetUserProfileDirectoryW //sys getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) = kernel32.GetSystemDirectoryW +<<<<<<< HEAD +======= +//sys getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) = kernel32.GetWindowsDirectoryW +//sys getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) = kernel32.GetSystemWindowsDirectoryW +>>>>>>> update golang.org/x/sys // An access token contains the security information for a logon session. // The system creates an access token when a user logs on, and every @@ -654,21 +656,44 @@ func (tml *Tokenmandatorylabel) Size() uint32 { // system-related operations on the local computer. type Token Handle +<<<<<<< HEAD // OpenCurrentProcessToken opens the access token // associated with current process. It is a real // token that needs to be closed, unlike // GetCurrentProcessToken. +======= +// OpenCurrentProcessToken opens an access token associated with current +// process with TOKEN_QUERY access. It is a real token that needs to be closed. +// +// Deprecated: Explicitly call OpenProcessToken(CurrentProcess(), ...) +// with the desired access instead, or use GetCurrentProcessToken for a +// TOKEN_QUERY token. +>>>>>>> update golang.org/x/sys func OpenCurrentProcessToken() (Token, error) { - p, e := GetCurrentProcess() - if e != nil { - return 0, e - } - var t Token - e = OpenProcessToken(p, TOKEN_QUERY, &t) - if e != nil { - return 0, e - } - return t, nil + var token Token + err := OpenProcessToken(CurrentProcess(), TOKEN_QUERY, &token) + return token, err +} + +// GetCurrentProcessToken returns the access token associated with +// the current process. It is a pseudo token that does not need +// to be closed. +func GetCurrentProcessToken() Token { + return Token(^uintptr(4 - 1)) +} + +// GetCurrentThreadToken return the access token associated with +// the current thread. It is a pseudo token that does not need +// to be closed. +func GetCurrentThreadToken() Token { + return Token(^uintptr(5 - 1)) +} + +// GetCurrentThreadEffectiveToken returns the effective access token +// associated with the current thread. It is a pseudo token that does +// not need to be closed. +func GetCurrentThreadEffectiveToken() Token { + return Token(^uintptr(6 - 1)) } // GetCurrentProcessToken returns the access token associated with @@ -785,8 +810,13 @@ func (token Token) GetLinkedToken() (Token, error) { return linkedToken, nil } +<<<<<<< HEAD // GetSystemDirectory retrieves path to current location of the system // directory, which is typically, though not always, C:\Windows\System32. +======= +// GetSystemDirectory retrieves the path to current location of the system +// directory, which is typically, though not always, `C:\Windows\System32`. +>>>>>>> update golang.org/x/sys func GetSystemDirectory() (string, error) { n := uint32(MAX_PATH) for { @@ -802,6 +832,45 @@ func GetSystemDirectory() (string, error) { } } +<<<<<<< HEAD +======= +// GetWindowsDirectory retrieves the path to current location of the Windows +// directory, which is typically, though not always, `C:\Windows`. This may +// be a private user directory in the case that the application is running +// under a terminal server. +func GetWindowsDirectory() (string, error) { + n := uint32(MAX_PATH) + for { + b := make([]uint16, n) + l, e := getWindowsDirectory(&b[0], n) + if e != nil { + return "", e + } + if l <= n { + return UTF16ToString(b[:l]), nil + } + n = l + } +} + +// GetSystemWindowsDirectory retrieves the path to current location of the +// Windows directory, which is typically, though not always, `C:\Windows`. +func GetSystemWindowsDirectory() (string, error) { + n := uint32(MAX_PATH) + for { + b := make([]uint16, n) + l, e := getSystemWindowsDirectory(&b[0], n) + if e != nil { + return "", e + } + if l <= n { + return UTF16ToString(b[:l]), nil + } + n = l + } +} + +>>>>>>> update golang.org/x/sys // IsMember reports whether the access token t is a member of the provided SID. func (t Token) IsMember(sid *SID) (bool, error) { var b int32 @@ -852,3 +921,524 @@ type WTS_SESSION_INFO struct { //sys WTSQueryUserToken(session uint32, token *Token) (err error) = wtsapi32.WTSQueryUserToken //sys WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) = wtsapi32.WTSEnumerateSessionsW //sys WTSFreeMemory(ptr uintptr) = wtsapi32.WTSFreeMemory +<<<<<<< HEAD +======= + +type ACL struct { + aclRevision byte + sbz1 byte + aclSize uint16 + aceCount uint16 + sbz2 uint16 +} + +type SECURITY_DESCRIPTOR struct { + revision byte + sbz1 byte + control SECURITY_DESCRIPTOR_CONTROL + owner *SID + group *SID + sacl *ACL + dacl *ACL +} + +type SecurityAttributes struct { + Length uint32 + SecurityDescriptor *SECURITY_DESCRIPTOR + InheritHandle uint32 +} + +type SE_OBJECT_TYPE uint32 + +// Constants for type SE_OBJECT_TYPE +const ( + SE_UNKNOWN_OBJECT_TYPE = 0 + SE_FILE_OBJECT = 1 + SE_SERVICE = 2 + SE_PRINTER = 3 + SE_REGISTRY_KEY = 4 + SE_LMSHARE = 5 + SE_KERNEL_OBJECT = 6 + SE_WINDOW_OBJECT = 7 + SE_DS_OBJECT = 8 + SE_DS_OBJECT_ALL = 9 + SE_PROVIDER_DEFINED_OBJECT = 10 + SE_WMIGUID_OBJECT = 11 + SE_REGISTRY_WOW64_32KEY = 12 + SE_REGISTRY_WOW64_64KEY = 13 +) + +type SECURITY_INFORMATION uint32 + +// Constants for type SECURITY_INFORMATION +const ( + OWNER_SECURITY_INFORMATION = 0x00000001 + GROUP_SECURITY_INFORMATION = 0x00000002 + DACL_SECURITY_INFORMATION = 0x00000004 + SACL_SECURITY_INFORMATION = 0x00000008 + LABEL_SECURITY_INFORMATION = 0x00000010 + ATTRIBUTE_SECURITY_INFORMATION = 0x00000020 + SCOPE_SECURITY_INFORMATION = 0x00000040 + BACKUP_SECURITY_INFORMATION = 0x00010000 + PROTECTED_DACL_SECURITY_INFORMATION = 0x80000000 + PROTECTED_SACL_SECURITY_INFORMATION = 0x40000000 + UNPROTECTED_DACL_SECURITY_INFORMATION = 0x20000000 + UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000 +) + +type SECURITY_DESCRIPTOR_CONTROL uint16 + +// Constants for type SECURITY_DESCRIPTOR_CONTROL +const ( + SE_OWNER_DEFAULTED = 0x0001 + SE_GROUP_DEFAULTED = 0x0002 + SE_DACL_PRESENT = 0x0004 + SE_DACL_DEFAULTED = 0x0008 + SE_SACL_PRESENT = 0x0010 + SE_SACL_DEFAULTED = 0x0020 + SE_DACL_AUTO_INHERIT_REQ = 0x0100 + SE_SACL_AUTO_INHERIT_REQ = 0x0200 + SE_DACL_AUTO_INHERITED = 0x0400 + SE_SACL_AUTO_INHERITED = 0x0800 + SE_DACL_PROTECTED = 0x1000 + SE_SACL_PROTECTED = 0x2000 + SE_RM_CONTROL_VALID = 0x4000 + SE_SELF_RELATIVE = 0x8000 +) + +type ACCESS_MASK uint32 + +// Constants for type ACCESS_MASK +const ( + DELETE = 0x00010000 + READ_CONTROL = 0x00020000 + WRITE_DAC = 0x00040000 + WRITE_OWNER = 0x00080000 + SYNCHRONIZE = 0x00100000 + STANDARD_RIGHTS_REQUIRED = 0x000F0000 + STANDARD_RIGHTS_READ = READ_CONTROL + STANDARD_RIGHTS_WRITE = READ_CONTROL + STANDARD_RIGHTS_EXECUTE = READ_CONTROL + STANDARD_RIGHTS_ALL = 0x001F0000 + SPECIFIC_RIGHTS_ALL = 0x0000FFFF + ACCESS_SYSTEM_SECURITY = 0x01000000 + MAXIMUM_ALLOWED = 0x02000000 + GENERIC_READ = 0x80000000 + GENERIC_WRITE = 0x40000000 + GENERIC_EXECUTE = 0x20000000 + GENERIC_ALL = 0x10000000 +) + +type ACCESS_MODE uint32 + +// Constants for type ACCESS_MODE +const ( + NOT_USED_ACCESS = 0 + GRANT_ACCESS = 1 + SET_ACCESS = 2 + DENY_ACCESS = 3 + REVOKE_ACCESS = 4 + SET_AUDIT_SUCCESS = 5 + SET_AUDIT_FAILURE = 6 +) + +// Constants for AceFlags and Inheritance fields +const ( + NO_INHERITANCE = 0x0 + SUB_OBJECTS_ONLY_INHERIT = 0x1 + SUB_CONTAINERS_ONLY_INHERIT = 0x2 + SUB_CONTAINERS_AND_OBJECTS_INHERIT = 0x3 + INHERIT_NO_PROPAGATE = 0x4 + INHERIT_ONLY = 0x8 + INHERITED_ACCESS_ENTRY = 0x10 + INHERITED_PARENT = 0x10000000 + INHERITED_GRANDPARENT = 0x20000000 + OBJECT_INHERIT_ACE = 0x1 + CONTAINER_INHERIT_ACE = 0x2 + NO_PROPAGATE_INHERIT_ACE = 0x4 + INHERIT_ONLY_ACE = 0x8 + INHERITED_ACE = 0x10 + VALID_INHERIT_FLAGS = 0x1F +) + +type MULTIPLE_TRUSTEE_OPERATION uint32 + +// Constants for MULTIPLE_TRUSTEE_OPERATION +const ( + NO_MULTIPLE_TRUSTEE = 0 + TRUSTEE_IS_IMPERSONATE = 1 +) + +type TRUSTEE_FORM uint32 + +// Constants for TRUSTEE_FORM +const ( + TRUSTEE_IS_SID = 0 + TRUSTEE_IS_NAME = 1 + TRUSTEE_BAD_FORM = 2 + TRUSTEE_IS_OBJECTS_AND_SID = 3 + TRUSTEE_IS_OBJECTS_AND_NAME = 4 +) + +type TRUSTEE_TYPE uint32 + +// Constants for TRUSTEE_TYPE +const ( + TRUSTEE_IS_UNKNOWN = 0 + TRUSTEE_IS_USER = 1 + TRUSTEE_IS_GROUP = 2 + TRUSTEE_IS_DOMAIN = 3 + TRUSTEE_IS_ALIAS = 4 + TRUSTEE_IS_WELL_KNOWN_GROUP = 5 + TRUSTEE_IS_DELETED = 6 + TRUSTEE_IS_INVALID = 7 + TRUSTEE_IS_COMPUTER = 8 +) + +// Constants for ObjectsPresent field +const ( + ACE_OBJECT_TYPE_PRESENT = 0x1 + ACE_INHERITED_OBJECT_TYPE_PRESENT = 0x2 +) + +type EXPLICIT_ACCESS struct { + AccessPermissions ACCESS_MASK + AccessMode ACCESS_MODE + Inheritance uint32 + Trustee TRUSTEE +} + +// This type is the union inside of TRUSTEE and must be created using one of the TrusteeValueFrom* functions. +type TrusteeValue uintptr + +func TrusteeValueFromString(str string) TrusteeValue { + return TrusteeValue(unsafe.Pointer(StringToUTF16Ptr(str))) +} +func TrusteeValueFromSID(sid *SID) TrusteeValue { + return TrusteeValue(unsafe.Pointer(sid)) +} +func TrusteeValueFromObjectsAndSid(objectsAndSid *OBJECTS_AND_SID) TrusteeValue { + return TrusteeValue(unsafe.Pointer(objectsAndSid)) +} +func TrusteeValueFromObjectsAndName(objectsAndName *OBJECTS_AND_NAME) TrusteeValue { + return TrusteeValue(unsafe.Pointer(objectsAndName)) +} + +type TRUSTEE struct { + MultipleTrustee *TRUSTEE + MultipleTrusteeOperation MULTIPLE_TRUSTEE_OPERATION + TrusteeForm TRUSTEE_FORM + TrusteeType TRUSTEE_TYPE + TrusteeValue TrusteeValue +} + +type OBJECTS_AND_SID struct { + ObjectsPresent uint32 + ObjectTypeGuid GUID + InheritedObjectTypeGuid GUID + Sid *SID +} + +type OBJECTS_AND_NAME struct { + ObjectsPresent uint32 + ObjectType SE_OBJECT_TYPE + ObjectTypeName *uint16 + InheritedObjectTypeName *uint16 + Name *uint16 +} + +//sys getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) = advapi32.GetSecurityInfo +//sys SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) = advapi32.SetSecurityInfo +//sys getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) = advapi32.GetNamedSecurityInfoW +//sys SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) = advapi32.SetNamedSecurityInfoW + +//sys buildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, countAccessEntries uint32, accessEntries *EXPLICIT_ACCESS, countAuditEntries uint32, auditEntries *EXPLICIT_ACCESS, oldSecurityDescriptor *SECURITY_DESCRIPTOR, sizeNewSecurityDescriptor *uint32, newSecurityDescriptor **SECURITY_DESCRIPTOR) (ret error) = advapi32.BuildSecurityDescriptorW +//sys initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) = advapi32.InitializeSecurityDescriptor + +//sys getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) = advapi32.GetSecurityDescriptorControl +//sys getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) = advapi32.GetSecurityDescriptorDacl +//sys getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) = advapi32.GetSecurityDescriptorSacl +//sys getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) = advapi32.GetSecurityDescriptorOwner +//sys getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) = advapi32.GetSecurityDescriptorGroup +//sys getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) = advapi32.GetSecurityDescriptorLength +//sys getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) [failretval!=0] = advapi32.GetSecurityDescriptorRMControl +//sys isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) = advapi32.IsValidSecurityDescriptor + +//sys setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) = advapi32.SetSecurityDescriptorControl +//sys setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) = advapi32.SetSecurityDescriptorDacl +//sys setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) = advapi32.SetSecurityDescriptorSacl +//sys setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) = advapi32.SetSecurityDescriptorOwner +//sys setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) = advapi32.SetSecurityDescriptorGroup +//sys setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) = advapi32.SetSecurityDescriptorRMControl + +//sys convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) = advapi32.ConvertStringSecurityDescriptorToSecurityDescriptorW +//sys convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) = advapi32.ConvertSecurityDescriptorToStringSecurityDescriptorW + +//sys makeAbsoluteSD(selfRelativeSD *SECURITY_DESCRIPTOR, absoluteSD *SECURITY_DESCRIPTOR, absoluteSDSize *uint32, dacl *ACL, daclSize *uint32, sacl *ACL, saclSize *uint32, owner *SID, ownerSize *uint32, group *SID, groupSize *uint32) (err error) = advapi32.MakeAbsoluteSD +//sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD + +//sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW + +// Control returns the security descriptor control bits. +func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { + err = getSecurityDescriptorControl(sd, &control, &revision) + return +} + +// SetControl sets the security descriptor control bits. +func (sd *SECURITY_DESCRIPTOR) SetControl(controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) error { + return setSecurityDescriptorControl(sd, controlBitsOfInterest, controlBitsToSet) +} + +// RMControl returns the security descriptor resource manager control bits. +func (sd *SECURITY_DESCRIPTOR) RMControl() (control uint8, err error) { + err = getSecurityDescriptorRMControl(sd, &control) + return +} + +// SetRMControl sets the security descriptor resource manager control bits. +func (sd *SECURITY_DESCRIPTOR) SetRMControl(rmControl uint8) { + setSecurityDescriptorRMControl(sd, &rmControl) +} + +// DACL returns the security descriptor DACL and whether it was defaulted. The dacl return value may be nil +// if a DACL exists but is an "empty DACL", meaning fully permissive. If the DACL does not exist, err returns +// ERROR_OBJECT_NOT_FOUND. +func (sd *SECURITY_DESCRIPTOR) DACL() (dacl *ACL, defaulted bool, err error) { + var present bool + err = getSecurityDescriptorDacl(sd, &present, &dacl, &defaulted) + if !present { + err = ERROR_OBJECT_NOT_FOUND + } + return +} + +// SetDACL sets the absolute security descriptor DACL. +func (absoluteSD *SECURITY_DESCRIPTOR) SetDACL(dacl *ACL, present, defaulted bool) error { + return setSecurityDescriptorDacl(absoluteSD, present, dacl, defaulted) +} + +// SACL returns the security descriptor SACL and whether it was defaulted. The sacl return value may be nil +// if a SACL exists but is an "empty SACL", meaning fully permissive. If the SACL does not exist, err returns +// ERROR_OBJECT_NOT_FOUND. +func (sd *SECURITY_DESCRIPTOR) SACL() (sacl *ACL, defaulted bool, err error) { + var present bool + err = getSecurityDescriptorSacl(sd, &present, &sacl, &defaulted) + if !present { + err = ERROR_OBJECT_NOT_FOUND + } + return +} + +// SetSACL sets the absolute security descriptor SACL. +func (absoluteSD *SECURITY_DESCRIPTOR) SetSACL(sacl *ACL, present, defaulted bool) error { + return setSecurityDescriptorSacl(absoluteSD, present, sacl, defaulted) +} + +// Owner returns the security descriptor owner and whether it was defaulted. +func (sd *SECURITY_DESCRIPTOR) Owner() (owner *SID, defaulted bool, err error) { + err = getSecurityDescriptorOwner(sd, &owner, &defaulted) + return +} + +// SetOwner sets the absolute security descriptor owner. +func (absoluteSD *SECURITY_DESCRIPTOR) SetOwner(owner *SID, defaulted bool) error { + return setSecurityDescriptorOwner(absoluteSD, owner, defaulted) +} + +// Group returns the security descriptor group and whether it was defaulted. +func (sd *SECURITY_DESCRIPTOR) Group() (group *SID, defaulted bool, err error) { + err = getSecurityDescriptorGroup(sd, &group, &defaulted) + return +} + +// SetGroup sets the absolute security descriptor owner. +func (absoluteSD *SECURITY_DESCRIPTOR) SetGroup(group *SID, defaulted bool) error { + return setSecurityDescriptorGroup(absoluteSD, group, defaulted) +} + +// Length returns the length of the security descriptor. +func (sd *SECURITY_DESCRIPTOR) Length() uint32 { + return getSecurityDescriptorLength(sd) +} + +// IsValid returns whether the security descriptor is valid. +func (sd *SECURITY_DESCRIPTOR) IsValid() bool { + return isValidSecurityDescriptor(sd) +} + +// String returns the SDDL form of the security descriptor, with a function signature that can be +// used with %v formatting directives. +func (sd *SECURITY_DESCRIPTOR) String() string { + var sddl *uint16 + err := convertSecurityDescriptorToStringSecurityDescriptor(sd, 1, 0xff, &sddl, nil) + if err != nil { + return "" + } + defer LocalFree(Handle(unsafe.Pointer(sddl))) + return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(sddl))[:]) +} + +// ToAbsolute converts a self-relative security descriptor into an absolute one. +func (selfRelativeSD *SECURITY_DESCRIPTOR) ToAbsolute() (absoluteSD *SECURITY_DESCRIPTOR, err error) { + control, _, err := selfRelativeSD.Control() + if err != nil { + return + } + if control&SE_SELF_RELATIVE == 0 { + err = ERROR_INVALID_PARAMETER + return + } + var absoluteSDSize, daclSize, saclSize, ownerSize, groupSize uint32 + err = makeAbsoluteSD(selfRelativeSD, nil, &absoluteSDSize, + nil, &daclSize, nil, &saclSize, nil, &ownerSize, nil, &groupSize) + switch err { + case ERROR_INSUFFICIENT_BUFFER: + case nil: + // makeAbsoluteSD is expected to fail, but it succeeds. + return nil, ERROR_INTERNAL_ERROR + default: + return nil, err + } + if absoluteSDSize > 0 { + absoluteSD = (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&make([]byte, absoluteSDSize)[0])) + } + var ( + dacl *ACL + sacl *ACL + owner *SID + group *SID + ) + if daclSize > 0 { + dacl = (*ACL)(unsafe.Pointer(&make([]byte, daclSize)[0])) + } + if saclSize > 0 { + sacl = (*ACL)(unsafe.Pointer(&make([]byte, saclSize)[0])) + } + if ownerSize > 0 { + owner = (*SID)(unsafe.Pointer(&make([]byte, ownerSize)[0])) + } + if groupSize > 0 { + group = (*SID)(unsafe.Pointer(&make([]byte, groupSize)[0])) + } + err = makeAbsoluteSD(selfRelativeSD, absoluteSD, &absoluteSDSize, + dacl, &daclSize, sacl, &saclSize, owner, &ownerSize, group, &groupSize) + return +} + +// ToSelfRelative converts an absolute security descriptor into a self-relative one. +func (absoluteSD *SECURITY_DESCRIPTOR) ToSelfRelative() (selfRelativeSD *SECURITY_DESCRIPTOR, err error) { + control, _, err := absoluteSD.Control() + if err != nil { + return + } + if control&SE_SELF_RELATIVE != 0 { + err = ERROR_INVALID_PARAMETER + return + } + var selfRelativeSDSize uint32 + err = makeSelfRelativeSD(absoluteSD, nil, &selfRelativeSDSize) + switch err { + case ERROR_INSUFFICIENT_BUFFER: + case nil: + // makeSelfRelativeSD is expected to fail, but it succeeds. + return nil, ERROR_INTERNAL_ERROR + default: + return nil, err + } + if selfRelativeSDSize > 0 { + selfRelativeSD = (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&make([]byte, selfRelativeSDSize)[0])) + } + err = makeSelfRelativeSD(absoluteSD, selfRelativeSD, &selfRelativeSDSize) + return +} + +func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor() *SECURITY_DESCRIPTOR { + sdBytes := make([]byte, selfRelativeSD.Length()) + copy(sdBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(selfRelativeSD))[:len(sdBytes)]) + return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&sdBytes[0])) +} + +// SecurityDescriptorFromString converts an SDDL string describing a security descriptor into a +// self-relative security descriptor object allocated on the Go heap. +func SecurityDescriptorFromString(sddl string) (sd *SECURITY_DESCRIPTOR, err error) { + var winHeapSD *SECURITY_DESCRIPTOR + err = convertStringSecurityDescriptorToSecurityDescriptor(sddl, 1, &winHeapSD, nil) + if err != nil { + return + } + defer LocalFree(Handle(unsafe.Pointer(winHeapSD))) + return winHeapSD.copySelfRelativeSecurityDescriptor(), nil +} + +// GetSecurityInfo queries the security information for a given handle and returns the self-relative security +// descriptor result on the Go heap. +func GetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION) (sd *SECURITY_DESCRIPTOR, err error) { + var winHeapSD *SECURITY_DESCRIPTOR + err = getSecurityInfo(handle, objectType, securityInformation, nil, nil, nil, nil, &winHeapSD) + if err != nil { + return + } + defer LocalFree(Handle(unsafe.Pointer(winHeapSD))) + return winHeapSD.copySelfRelativeSecurityDescriptor(), nil +} + +// GetNamedSecurityInfo queries the security information for a given named object and returns the self-relative security +// descriptor result on the Go heap. +func GetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION) (sd *SECURITY_DESCRIPTOR, err error) { + var winHeapSD *SECURITY_DESCRIPTOR + err = getNamedSecurityInfo(objectName, objectType, securityInformation, nil, nil, nil, nil, &winHeapSD) + if err != nil { + return + } + defer LocalFree(Handle(unsafe.Pointer(winHeapSD))) + return winHeapSD.copySelfRelativeSecurityDescriptor(), nil +} + +// BuildSecurityDescriptor makes a new security descriptor using the input trustees, explicit access lists, and +// prior security descriptor to be merged, any of which can be nil, returning the self-relative security descriptor +// result on the Go heap. +func BuildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, accessEntries []EXPLICIT_ACCESS, auditEntries []EXPLICIT_ACCESS, mergedSecurityDescriptor *SECURITY_DESCRIPTOR) (sd *SECURITY_DESCRIPTOR, err error) { + var winHeapSD *SECURITY_DESCRIPTOR + var winHeapSDSize uint32 + var firstAccessEntry *EXPLICIT_ACCESS + if len(accessEntries) > 0 { + firstAccessEntry = &accessEntries[0] + } + var firstAuditEntry *EXPLICIT_ACCESS + if len(auditEntries) > 0 { + firstAuditEntry = &auditEntries[0] + } + err = buildSecurityDescriptor(owner, group, uint32(len(accessEntries)), firstAccessEntry, uint32(len(auditEntries)), firstAuditEntry, mergedSecurityDescriptor, &winHeapSDSize, &winHeapSD) + if err != nil { + return + } + defer LocalFree(Handle(unsafe.Pointer(winHeapSD))) + return winHeapSD.copySelfRelativeSecurityDescriptor(), nil +} + +// NewSecurityDescriptor creates and initializes a new absolute security descriptor. +func NewSecurityDescriptor() (absoluteSD *SECURITY_DESCRIPTOR, err error) { + absoluteSD = &SECURITY_DESCRIPTOR{} + err = initializeSecurityDescriptor(absoluteSD, 1) + return +} + +// ACLFromEntries returns a new ACL on the Go heap containing a list of explicit entries as well as those of another ACL. +// Both explicitEntries and mergedACL are optional and can be nil. +func ACLFromEntries(explicitEntries []EXPLICIT_ACCESS, mergedACL *ACL) (acl *ACL, err error) { + var firstExplicitEntry *EXPLICIT_ACCESS + if len(explicitEntries) > 0 { + firstExplicitEntry = &explicitEntries[0] + } + var winHeapACL *ACL + err = setEntriesInAcl(uint32(len(explicitEntries)), firstExplicitEntry, mergedACL, &winHeapACL) + if err != nil { + return + } + defer LocalFree(Handle(unsafe.Pointer(winHeapACL))) + aclBytes := make([]byte, winHeapACL.aclSize) + copy(aclBytes, (*[(1 << 31) - 1]byte)(unsafe.Pointer(winHeapACL))[:len(aclBytes)]) + return (*ACL)(unsafe.Pointer(&aclBytes[0])), nil +} +>>>>>>> update golang.org/x/sys diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index b23050924f5..d8d10a6d9e1 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -57,6 +57,13 @@ const ( FILE_VOLUME_IS_COMPRESSED = 0x00008000 FILE_VOLUME_QUOTAS = 0x00000020 +<<<<<<< HEAD +======= + // Flags for LockFileEx. + LOCKFILE_FAIL_IMMEDIATELY = 0x00000001 + LOCKFILE_EXCLUSIVE_LOCK = 0x00000002 + +>>>>>>> update golang.org/x/sys // Return values of SleepEx and other APC functions STATUS_USER_APC = 0x000000C0 WAIT_IO_COMPLETION = STATUS_USER_APC @@ -136,6 +143,8 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) = LoadLibraryExW //sys FreeLibrary(handle Handle) (err error) //sys GetProcAddress(module Handle, procname string) (proc uintptr, err error) +//sys GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) = kernel32.GetModuleFileNameW +//sys GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) = kernel32.GetModuleHandleExW //sys GetVersion() (ver uint32, err error) //sys FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) = FormatMessageW //sys ExitProcess(exitcode uint32) @@ -160,6 +169,8 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys DeleteFile(path *uint16) (err error) = DeleteFileW //sys MoveFile(from *uint16, to *uint16) (err error) = MoveFileW //sys MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) = MoveFileExW +//sys LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) +//sys UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) //sys GetComputerName(buf *uint16, n *uint32) (err error) = GetComputerNameW //sys GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) = GetComputerNameExW //sys SetEndOfFile(handle Handle) (err error) @@ -173,13 +184,20 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys CancelIoEx(s Handle, o *Overlapped) (err error) //sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) +<<<<<<< HEAD //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) = shell32.ShellExecuteW +======= +//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW +>>>>>>> update golang.org/x/sys //sys shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) = shell32.SHGetKnownFolderPath //sys TerminateProcess(handle Handle, exitcode uint32) (err error) //sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) //sys GetStartupInfo(startupInfo *StartupInfo) (err error) = GetStartupInfoW +<<<<<<< HEAD //sys GetCurrentProcess() (pseudoHandle Handle, err error) //sys GetCurrentThread() (pseudoHandle Handle, err error) +======= +>>>>>>> update golang.org/x/sys //sys GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) //sys DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) //sys WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) [failretval==0xffffffff] @@ -257,6 +275,13 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys SetEvent(event Handle) (err error) = kernel32.SetEvent //sys ResetEvent(event Handle) (err error) = kernel32.ResetEvent //sys PulseEvent(event Handle) (err error) = kernel32.PulseEvent +<<<<<<< HEAD +======= +//sys CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) = kernel32.CreateMutexW +//sys CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) = kernel32.CreateMutexExW +//sys OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) = kernel32.OpenMutexW +//sys ReleaseMutex(mutex Handle) (err error) = kernel32.ReleaseMutex +>>>>>>> update golang.org/x/sys //sys SleepEx(milliseconds uint32, alertable bool) (ret uint32) = kernel32.SleepEx //sys CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) = kernel32.CreateJobObjectW //sys AssignProcessToJobObject(job Handle, process Handle) (err error) = kernel32.AssignProcessToJobObject @@ -269,6 +294,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) //sys GetProcessId(process Handle) (id uint32, err error) //sys OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) +<<<<<<< HEAD +======= +//sys SetProcessPriorityBoost(process Handle, disable bool) (err error) = kernel32.SetProcessPriorityBoost +>>>>>>> update golang.org/x/sys // Volume Management Functions //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW @@ -279,6 +308,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) = FindNextVolumeMountPointW //sys FindVolumeClose(findVolume Handle) (err error) //sys FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) +//sys GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) = GetDiskFreeSpaceExW //sys GetDriveType(rootPathName *uint16) (driveType uint32) = GetDriveTypeW //sys GetLogicalDrives() (drivesBitMask uint32, err error) [failretval==0] //sys GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) [failretval==0] = GetLogicalDriveStringsW @@ -291,14 +321,60 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) = SetVolumeLabelW //sys SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) = SetVolumeMountPointW //sys MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW +<<<<<<< HEAD +======= +//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx +//sys InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) = advapi32.InitiateSystemShutdownExW +//sys SetProcessShutdownParameters(level uint32, flags uint32) (err error) = kernel32.SetProcessShutdownParameters +//sys GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) = kernel32.GetProcessShutdownParameters +>>>>>>> update golang.org/x/sys //sys clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) = ole32.CLSIDFromString //sys stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) = ole32.StringFromGUID2 //sys coCreateGuid(pguid *GUID) (ret error) = ole32.CoCreateGuid //sys CoTaskMemFree(address unsafe.Pointer) = ole32.CoTaskMemFree //sys rtlGetVersion(info *OsVersionInfoEx) (ret error) = ntdll.RtlGetVersion +<<<<<<< HEAD +======= +//sys rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) = ntdll.RtlGetNtVersionNumbers +//sys getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetProcessPreferredUILanguages +//sys getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetThreadPreferredUILanguages +//sys getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetUserPreferredUILanguages +//sys getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) = kernel32.GetSystemPreferredUILanguages + +// Process Status API (PSAPI) +//sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses +>>>>>>> update golang.org/x/sys // syscall interface implementation for other packages +// GetCurrentProcess returns the handle for the current process. +// It is a pseudo handle that does not need to be closed. +// The returned error is always nil. +// +// Deprecated: use CurrentProcess for the same Handle without the nil +// error. +func GetCurrentProcess() (Handle, error) { + return CurrentProcess(), nil +} + +// CurrentProcess returns the handle for the current process. +// It is a pseudo handle that does not need to be closed. +func CurrentProcess() Handle { return Handle(^uintptr(1 - 1)) } + +// GetCurrentThread returns the handle for the current thread. +// It is a pseudo handle that does not need to be closed. +// The returned error is always nil. +// +// Deprecated: use CurrentThread for the same Handle without the nil +// error. +func GetCurrentThread() (Handle, error) { + return CurrentThread(), nil +} + +// CurrentThread returns the handle for the current thread. +// It is a pseudo handle that does not need to be closed. +func CurrentThread() Handle { return Handle(^uintptr(2 - 1)) } + // GetProcAddressByOrdinal retrieves the address of the exported // function from module by ordinal. func GetProcAddressByOrdinal(module Handle, ordinal uintptr) (proc uintptr, err error) { @@ -365,7 +441,11 @@ func Open(path string, mode int, perm uint32) (fd Handle, err error) { default: createmode = OPEN_EXISTING } - h, e := CreateFile(pathp, access, sharemode, sa, createmode, FILE_ATTRIBUTE_NORMAL, 0) + var attrs uint32 = FILE_ATTRIBUTE_NORMAL + if perm&S_IWRITE == 0 { + attrs = FILE_ATTRIBUTE_READONLY + } + h, e := CreateFile(pathp, access, sharemode, sa, createmode, attrs, 0) return h, e } @@ -645,6 +725,8 @@ const socket_error = uintptr(^uint32(0)) //sys WSACleanup() (err error) [failretval==socket_error] = ws2_32.WSACleanup //sys WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) [failretval==socket_error] = ws2_32.WSAIoctl //sys socket(af int32, typ int32, protocol int32) (handle Handle, err error) [failretval==InvalidHandle] = ws2_32.socket +//sys sendto(s Handle, buf []byte, flags int, to unsafe.Pointer, tolen int32) (err error) [failretval==socket_error] = ws2_32.sendto +//sys recvfrom(s Handle, buf []byte, flags int, from *RawSockaddrAny, fromlen *int) (n int, err error) [failretval==-1] = ws2_32.recvfrom //sys Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) [failretval==socket_error] = ws2_32.setsockopt //sys Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) [failretval==socket_error] = ws2_32.getsockopt //sys bind(s Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socket_error] = ws2_32.bind @@ -812,7 +894,11 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { for n < len(pp.Path) && pp.Path[n] != 0 { n++ } +<<<<<<< HEAD bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] +======= + bytes := (*[len(pp.Path)]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] +>>>>>>> update golang.org/x/sys sa.Name = string(bytes) return sa, nil @@ -1073,10 +1159,26 @@ func NsecToTimespec(nsec int64) (ts Timespec) { // TODO(brainman): fix all needed for net func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, syscall.EWINDOWS } + func Recvfrom(fd Handle, p []byte, flags int) (n int, from Sockaddr, err error) { - return 0, nil, syscall.EWINDOWS + var rsa RawSockaddrAny + l := int(unsafe.Sizeof(rsa)) + n, err = recvfrom(fd, p, flags, &rsa, &l) + if err != nil { + return + } + from, err = rsa.Sockaddr() + return +} + +func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error) { + ptr, l, err := to.sockaddr() + if err != nil { + return err + } + return sendto(fd, p, flags, ptr, l) } -func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error) { return syscall.EWINDOWS } + func SetsockoptTimeval(fd Handle, level, opt int, tv *Timeval) (err error) { return syscall.EWINDOWS } // The Linger struct is wrong but we only noticed after Go 1. @@ -1306,8 +1408,13 @@ func (t Token) KnownFolderPath(folderID *KNOWNFOLDERID, flags uint32) (string, e return UTF16ToString((*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))[:]), nil } +<<<<<<< HEAD // RtlGetVersion returns the true version of the underlying operating system, ignoring // any manifesting or compatibility layers on top of the win32 layer. +======= +// RtlGetVersion returns the version of the underlying operating system, ignoring +// manifest semantics but is affected by the application compatibility layer. +>>>>>>> update golang.org/x/sys func RtlGetVersion() *OsVersionInfoEx { info := &OsVersionInfoEx{} info.osVersionInfoSize = uint32(unsafe.Sizeof(*info)) @@ -1318,3 +1425,65 @@ func RtlGetVersion() *OsVersionInfoEx { _ = rtlGetVersion(info) return info } +<<<<<<< HEAD +======= + +// RtlGetNtVersionNumbers returns the version of the underlying operating system, +// ignoring manifest semantics and the application compatibility layer. +func RtlGetNtVersionNumbers() (majorVersion, minorVersion, buildNumber uint32) { + rtlGetNtVersionNumbers(&majorVersion, &minorVersion, &buildNumber) + buildNumber &= 0xffff + return +} + +// GetProcessPreferredUILanguages retrieves the process preferred UI languages. +func GetProcessPreferredUILanguages(flags uint32) ([]string, error) { + return getUILanguages(flags, getProcessPreferredUILanguages) +} + +// GetThreadPreferredUILanguages retrieves the thread preferred UI languages for the current thread. +func GetThreadPreferredUILanguages(flags uint32) ([]string, error) { + return getUILanguages(flags, getThreadPreferredUILanguages) +} + +// GetUserPreferredUILanguages retrieves information about the user preferred UI languages. +func GetUserPreferredUILanguages(flags uint32) ([]string, error) { + return getUILanguages(flags, getUserPreferredUILanguages) +} + +// GetSystemPreferredUILanguages retrieves the system preferred UI languages. +func GetSystemPreferredUILanguages(flags uint32) ([]string, error) { + return getUILanguages(flags, getSystemPreferredUILanguages) +} + +func getUILanguages(flags uint32, f func(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) error) ([]string, error) { + size := uint32(128) + for { + var numLanguages uint32 + buf := make([]uint16, size) + err := f(flags, &numLanguages, &buf[0], &size) + if err == ERROR_INSUFFICIENT_BUFFER { + continue + } + if err != nil { + return nil, err + } + buf = buf[:size] + if numLanguages == 0 || len(buf) == 0 { // GetProcessPreferredUILanguages may return numLanguages==0 with "\0\0" + return []string{}, nil + } + if buf[len(buf)-1] == 0 { + buf = buf[:len(buf)-1] // remove terminating null + } + languages := make([]string, 0, numLanguages) + from := 0 + for i, c := range buf { + if c == 0 { + languages = append(languages, string(utf16.Decode(buf[from:i]))) + from = i + 1 + } + } + return languages, nil + } +} +>>>>>>> update golang.org/x/sys diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index 1e3947f0f60..8adc146cdc3 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -62,11 +62,6 @@ var signals = [...]string{ } const ( - GENERIC_READ = 0x80000000 - GENERIC_WRITE = 0x40000000 - GENERIC_EXECUTE = 0x20000000 - GENERIC_ALL = 0x10000000 - FILE_LIST_DIRECTORY = 0x00000001 FILE_APPEND_DATA = 0x00000004 FILE_WRITE_ATTRIBUTES = 0x00000100 @@ -158,6 +153,7 @@ const ( WAIT_OBJECT_0 = 0x00000000 WAIT_FAILED = 0xFFFFFFFF +<<<<<<< HEAD // Standard access rights. DELETE = 0x00010000 READ_CONTROL = 0x00020000 @@ -165,6 +161,8 @@ const ( WRITE_DAC = 0x00040000 WRITE_OWNER = 0x00080000 +======= +>>>>>>> update golang.org/x/sys // Access rights for process. PROCESS_CREATE_PROCESS = 0x0080 PROCESS_CREATE_THREAD = 0x0002 @@ -483,12 +481,6 @@ func NsecToTimeval(nsec int64) (tv Timeval) { return } -type SecurityAttributes struct { - Length uint32 - SecurityDescriptor uintptr - InheritHandle uint32 -} - type Overlapped struct { Internal uintptr InternalHigh uintptr @@ -1190,6 +1182,28 @@ const ( REG_QWORD = REG_QWORD_LITTLE_ENDIAN ) +const ( + EVENT_MODIFY_STATE = 0x0002 + EVENT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3 + + MUTANT_QUERY_STATE = 0x0001 + MUTANT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE + + SEMAPHORE_MODIFY_STATE = 0x0002 + SEMAPHORE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3 + + TIMER_QUERY_STATE = 0x0001 + TIMER_MODIFY_STATE = 0x0002 + TIMER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE + + MUTEX_MODIFY_STATE = MUTANT_QUERY_STATE + MUTEX_ALL_ACCESS = MUTANT_ALL_ACCESS + + CREATE_EVENT_MANUAL_RESET = 0x1 + CREATE_EVENT_INITIAL_SET = 0x2 + CREATE_MUTEX_INITIAL_OWNER = 0x1 +) + type AddrinfoW struct { Flags int32 Family int32 @@ -1666,3 +1680,111 @@ type OsVersionInfoEx struct { ProductType byte _ byte } +<<<<<<< HEAD +======= + +const ( + EWX_LOGOFF = 0x00000000 + EWX_SHUTDOWN = 0x00000001 + EWX_REBOOT = 0x00000002 + EWX_FORCE = 0x00000004 + EWX_POWEROFF = 0x00000008 + EWX_FORCEIFHUNG = 0x00000010 + EWX_QUICKRESOLVE = 0x00000020 + EWX_RESTARTAPPS = 0x00000040 + EWX_HYBRID_SHUTDOWN = 0x00400000 + EWX_BOOTOPTIONS = 0x01000000 + + SHTDN_REASON_FLAG_COMMENT_REQUIRED = 0x01000000 + SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED = 0x02000000 + SHTDN_REASON_FLAG_CLEAN_UI = 0x04000000 + SHTDN_REASON_FLAG_DIRTY_UI = 0x08000000 + SHTDN_REASON_FLAG_USER_DEFINED = 0x40000000 + SHTDN_REASON_FLAG_PLANNED = 0x80000000 + SHTDN_REASON_MAJOR_OTHER = 0x00000000 + SHTDN_REASON_MAJOR_NONE = 0x00000000 + SHTDN_REASON_MAJOR_HARDWARE = 0x00010000 + SHTDN_REASON_MAJOR_OPERATINGSYSTEM = 0x00020000 + SHTDN_REASON_MAJOR_SOFTWARE = 0x00030000 + SHTDN_REASON_MAJOR_APPLICATION = 0x00040000 + SHTDN_REASON_MAJOR_SYSTEM = 0x00050000 + SHTDN_REASON_MAJOR_POWER = 0x00060000 + SHTDN_REASON_MAJOR_LEGACY_API = 0x00070000 + SHTDN_REASON_MINOR_OTHER = 0x00000000 + SHTDN_REASON_MINOR_NONE = 0x000000ff + SHTDN_REASON_MINOR_MAINTENANCE = 0x00000001 + SHTDN_REASON_MINOR_INSTALLATION = 0x00000002 + SHTDN_REASON_MINOR_UPGRADE = 0x00000003 + SHTDN_REASON_MINOR_RECONFIG = 0x00000004 + SHTDN_REASON_MINOR_HUNG = 0x00000005 + SHTDN_REASON_MINOR_UNSTABLE = 0x00000006 + SHTDN_REASON_MINOR_DISK = 0x00000007 + SHTDN_REASON_MINOR_PROCESSOR = 0x00000008 + SHTDN_REASON_MINOR_NETWORKCARD = 0x00000009 + SHTDN_REASON_MINOR_POWER_SUPPLY = 0x0000000a + SHTDN_REASON_MINOR_CORDUNPLUGGED = 0x0000000b + SHTDN_REASON_MINOR_ENVIRONMENT = 0x0000000c + SHTDN_REASON_MINOR_HARDWARE_DRIVER = 0x0000000d + SHTDN_REASON_MINOR_OTHERDRIVER = 0x0000000e + SHTDN_REASON_MINOR_BLUESCREEN = 0x0000000F + SHTDN_REASON_MINOR_SERVICEPACK = 0x00000010 + SHTDN_REASON_MINOR_HOTFIX = 0x00000011 + SHTDN_REASON_MINOR_SECURITYFIX = 0x00000012 + SHTDN_REASON_MINOR_SECURITY = 0x00000013 + SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = 0x00000014 + SHTDN_REASON_MINOR_WMI = 0x00000015 + SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL = 0x00000016 + SHTDN_REASON_MINOR_HOTFIX_UNINSTALL = 0x00000017 + SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL = 0x00000018 + SHTDN_REASON_MINOR_MMC = 0x00000019 + SHTDN_REASON_MINOR_SYSTEMRESTORE = 0x0000001a + SHTDN_REASON_MINOR_TERMSRV = 0x00000020 + SHTDN_REASON_MINOR_DC_PROMOTION = 0x00000021 + SHTDN_REASON_MINOR_DC_DEMOTION = 0x00000022 + SHTDN_REASON_UNKNOWN = SHTDN_REASON_MINOR_NONE + SHTDN_REASON_LEGACY_API = SHTDN_REASON_MAJOR_LEGACY_API | SHTDN_REASON_FLAG_PLANNED + SHTDN_REASON_VALID_BIT_MASK = 0xc0ffffff + + SHUTDOWN_NORETRY = 0x1 +) + +// Flags used for GetModuleHandleEx +const ( + GET_MODULE_HANDLE_EX_FLAG_PIN = 1 + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2 + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 4 +) + +// MUI function flag values +const ( + MUI_LANGUAGE_ID = 0x4 + MUI_LANGUAGE_NAME = 0x8 + MUI_MERGE_SYSTEM_FALLBACK = 0x10 + MUI_MERGE_USER_FALLBACK = 0x20 + MUI_UI_FALLBACK = MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK + MUI_THREAD_LANGUAGES = 0x40 + MUI_CONSOLE_FILTER = 0x100 + MUI_COMPLEX_SCRIPT_FILTER = 0x200 + MUI_RESET_FILTERS = 0x001 + MUI_USER_PREFERRED_UI_LANGUAGES = 0x10 + MUI_USE_INSTALLED_LANGUAGES = 0x20 + MUI_USE_SEARCH_ALL_LANGUAGES = 0x40 + MUI_LANG_NEUTRAL_PE_FILE = 0x100 + MUI_NON_LANG_NEUTRAL_FILE = 0x200 + MUI_MACHINE_LANGUAGE_SETTINGS = 0x400 + MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL = 0x001 + MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = 0x002 + MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI = 0x004 + MUI_QUERY_TYPE = 0x001 + MUI_QUERY_CHECKSUM = 0x002 + MUI_QUERY_LANGUAGE_NAME = 0x004 + MUI_QUERY_RESOURCE_TYPES = 0x008 + MUI_FILEINFO_VERSION = 0x001 + + MUI_FULL_LANGUAGE = 0x01 + MUI_PARTIAL_LANGUAGE = 0x02 + MUI_LIP_LANGUAGE = 0x04 + MUI_LANGUAGE_INSTALLED = 0x20 + MUI_LANGUAGE_LICENSED = 0x40 +) +>>>>>>> update golang.org/x/sys diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index d461bed98ac..5f32435ae66 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -44,6 +44,10 @@ var ( moduser32 = NewLazySystemDLL("user32.dll") modole32 = NewLazySystemDLL("ole32.dll") modntdll = NewLazySystemDLL("ntdll.dll") +<<<<<<< HEAD +======= + modpsapi = NewLazySystemDLL("psapi.dll") +>>>>>>> update golang.org/x/sys modws2_32 = NewLazySystemDLL("ws2_32.dll") moddnsapi = NewLazySystemDLL("dnsapi.dll") modiphlpapi = NewLazySystemDLL("iphlpapi.dll") @@ -51,6 +55,7 @@ var ( modnetapi32 = NewLazySystemDLL("netapi32.dll") modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") +<<<<<<< HEAD procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW") procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource") procReportEventW = modadvapi32.NewProc("ReportEventW") @@ -306,6 +311,310 @@ var ( procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken") procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW") procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory") +======= + procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW") + procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource") + procReportEventW = modadvapi32.NewProc("ReportEventW") + procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW") + procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle") + procCreateServiceW = modadvapi32.NewProc("CreateServiceW") + procOpenServiceW = modadvapi32.NewProc("OpenServiceW") + procDeleteService = modadvapi32.NewProc("DeleteService") + procStartServiceW = modadvapi32.NewProc("StartServiceW") + procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus") + procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW") + procControlService = modadvapi32.NewProc("ControlService") + procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW") + procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus") + procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW") + procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW") + procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W") + procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W") + procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW") + procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx") + procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW") + procGetLastError = modkernel32.NewProc("GetLastError") + procLoadLibraryW = modkernel32.NewProc("LoadLibraryW") + procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW") + procFreeLibrary = modkernel32.NewProc("FreeLibrary") + procGetProcAddress = modkernel32.NewProc("GetProcAddress") + procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW") + procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW") + procGetVersion = modkernel32.NewProc("GetVersion") + procFormatMessageW = modkernel32.NewProc("FormatMessageW") + procExitProcess = modkernel32.NewProc("ExitProcess") + procIsWow64Process = modkernel32.NewProc("IsWow64Process") + procCreateFileW = modkernel32.NewProc("CreateFileW") + procReadFile = modkernel32.NewProc("ReadFile") + procWriteFile = modkernel32.NewProc("WriteFile") + procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult") + procSetFilePointer = modkernel32.NewProc("SetFilePointer") + procCloseHandle = modkernel32.NewProc("CloseHandle") + procGetStdHandle = modkernel32.NewProc("GetStdHandle") + procSetStdHandle = modkernel32.NewProc("SetStdHandle") + procFindFirstFileW = modkernel32.NewProc("FindFirstFileW") + procFindNextFileW = modkernel32.NewProc("FindNextFileW") + procFindClose = modkernel32.NewProc("FindClose") + procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle") + procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx") + procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") + procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") + procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW") + procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW") + procDeleteFileW = modkernel32.NewProc("DeleteFileW") + procMoveFileW = modkernel32.NewProc("MoveFileW") + procMoveFileExW = modkernel32.NewProc("MoveFileExW") + procLockFileEx = modkernel32.NewProc("LockFileEx") + procUnlockFileEx = modkernel32.NewProc("UnlockFileEx") + procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") + procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") + procSetEndOfFile = modkernel32.NewProc("SetEndOfFile") + procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime") + procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime") + procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation") + procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort") + procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus") + procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus") + procCancelIo = modkernel32.NewProc("CancelIo") + procCancelIoEx = modkernel32.NewProc("CancelIoEx") + procCreateProcessW = modkernel32.NewProc("CreateProcessW") + procOpenProcess = modkernel32.NewProc("OpenProcess") + procShellExecuteW = modshell32.NewProc("ShellExecuteW") + procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") + procTerminateProcess = modkernel32.NewProc("TerminateProcess") + procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess") + procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW") + procGetProcessTimes = modkernel32.NewProc("GetProcessTimes") + procDuplicateHandle = modkernel32.NewProc("DuplicateHandle") + procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject") + procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects") + procGetTempPathW = modkernel32.NewProc("GetTempPathW") + procCreatePipe = modkernel32.NewProc("CreatePipe") + procGetFileType = modkernel32.NewProc("GetFileType") + procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW") + procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext") + procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom") + procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW") + procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW") + procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW") + procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW") + procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") + procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") + procGetTickCount64 = modkernel32.NewProc("GetTickCount64") + procSetFileTime = modkernel32.NewProc("SetFileTime") + procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW") + procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW") + procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW") + procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") + procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") + procLocalFree = modkernel32.NewProc("LocalFree") + procSetHandleInformation = modkernel32.NewProc("SetHandleInformation") + procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers") + procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW") + procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW") + procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW") + procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW") + procMapViewOfFile = modkernel32.NewProc("MapViewOfFile") + procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile") + procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile") + procVirtualLock = modkernel32.NewProc("VirtualLock") + procVirtualUnlock = modkernel32.NewProc("VirtualUnlock") + procVirtualAlloc = modkernel32.NewProc("VirtualAlloc") + procVirtualFree = modkernel32.NewProc("VirtualFree") + procVirtualProtect = modkernel32.NewProc("VirtualProtect") + procTransmitFile = modmswsock.NewProc("TransmitFile") + procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW") + procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW") + procCertOpenStore = modcrypt32.NewProc("CertOpenStore") + procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore") + procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore") + procCertCloseStore = modcrypt32.NewProc("CertCloseStore") + procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain") + procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain") + procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext") + procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext") + procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy") + procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW") + procRegCloseKey = modadvapi32.NewProc("RegCloseKey") + procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW") + procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW") + procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW") + procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") + procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") + procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") + procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") + procWriteConsoleW = modkernel32.NewProc("WriteConsoleW") + procReadConsoleW = modkernel32.NewProc("ReadConsoleW") + procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot") + procProcess32FirstW = modkernel32.NewProc("Process32FirstW") + procProcess32NextW = modkernel32.NewProc("Process32NextW") + procThread32First = modkernel32.NewProc("Thread32First") + procThread32Next = modkernel32.NewProc("Thread32Next") + procDeviceIoControl = modkernel32.NewProc("DeviceIoControl") + procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW") + procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW") + procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId") + procCreateEventW = modkernel32.NewProc("CreateEventW") + procCreateEventExW = modkernel32.NewProc("CreateEventExW") + procOpenEventW = modkernel32.NewProc("OpenEventW") + procSetEvent = modkernel32.NewProc("SetEvent") + procResetEvent = modkernel32.NewProc("ResetEvent") + procPulseEvent = modkernel32.NewProc("PulseEvent") + procCreateMutexW = modkernel32.NewProc("CreateMutexW") + procCreateMutexExW = modkernel32.NewProc("CreateMutexExW") + procOpenMutexW = modkernel32.NewProc("OpenMutexW") + procReleaseMutex = modkernel32.NewProc("ReleaseMutex") + procSleepEx = modkernel32.NewProc("SleepEx") + procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW") + procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject") + procTerminateJobObject = modkernel32.NewProc("TerminateJobObject") + procSetErrorMode = modkernel32.NewProc("SetErrorMode") + procResumeThread = modkernel32.NewProc("ResumeThread") + procSetPriorityClass = modkernel32.NewProc("SetPriorityClass") + procGetPriorityClass = modkernel32.NewProc("GetPriorityClass") + procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject") + procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent") + procGetProcessId = modkernel32.NewProc("GetProcessId") + procOpenThread = modkernel32.NewProc("OpenThread") + procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost") + procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW") + procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW") + procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW") + procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW") + procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW") + procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW") + procFindVolumeClose = modkernel32.NewProc("FindVolumeClose") + procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose") + procGetDiskFreeSpaceExW = modkernel32.NewProc("GetDiskFreeSpaceExW") + procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW") + procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives") + procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW") + procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW") + procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW") + procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW") + procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW") + procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW") + procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW") + procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW") + procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW") + procMessageBoxW = moduser32.NewProc("MessageBoxW") + procExitWindowsEx = moduser32.NewProc("ExitWindowsEx") + procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW") + procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters") + procGetProcessShutdownParameters = modkernel32.NewProc("GetProcessShutdownParameters") + procCLSIDFromString = modole32.NewProc("CLSIDFromString") + procStringFromGUID2 = modole32.NewProc("StringFromGUID2") + procCoCreateGuid = modole32.NewProc("CoCreateGuid") + procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") + procRtlGetVersion = modntdll.NewProc("RtlGetVersion") + procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers") + procGetProcessPreferredUILanguages = modkernel32.NewProc("GetProcessPreferredUILanguages") + procGetThreadPreferredUILanguages = modkernel32.NewProc("GetThreadPreferredUILanguages") + procGetUserPreferredUILanguages = modkernel32.NewProc("GetUserPreferredUILanguages") + procGetSystemPreferredUILanguages = modkernel32.NewProc("GetSystemPreferredUILanguages") + procEnumProcesses = modpsapi.NewProc("EnumProcesses") + procWSAStartup = modws2_32.NewProc("WSAStartup") + procWSACleanup = modws2_32.NewProc("WSACleanup") + procWSAIoctl = modws2_32.NewProc("WSAIoctl") + procsocket = modws2_32.NewProc("socket") + procsendto = modws2_32.NewProc("sendto") + procrecvfrom = modws2_32.NewProc("recvfrom") + procsetsockopt = modws2_32.NewProc("setsockopt") + procgetsockopt = modws2_32.NewProc("getsockopt") + procbind = modws2_32.NewProc("bind") + procconnect = modws2_32.NewProc("connect") + procgetsockname = modws2_32.NewProc("getsockname") + procgetpeername = modws2_32.NewProc("getpeername") + proclisten = modws2_32.NewProc("listen") + procshutdown = modws2_32.NewProc("shutdown") + procclosesocket = modws2_32.NewProc("closesocket") + procAcceptEx = modmswsock.NewProc("AcceptEx") + procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs") + procWSARecv = modws2_32.NewProc("WSARecv") + procWSASend = modws2_32.NewProc("WSASend") + procWSARecvFrom = modws2_32.NewProc("WSARecvFrom") + procWSASendTo = modws2_32.NewProc("WSASendTo") + procgethostbyname = modws2_32.NewProc("gethostbyname") + procgetservbyname = modws2_32.NewProc("getservbyname") + procntohs = modws2_32.NewProc("ntohs") + procgetprotobyname = modws2_32.NewProc("getprotobyname") + procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") + procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") + procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") + procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") + procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") + procGetIfEntry = modiphlpapi.NewProc("GetIfEntry") + procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") + procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes") + procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW") + procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") + procGetACP = modkernel32.NewProc("GetACP") + procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar") + procTranslateNameW = modsecur32.NewProc("TranslateNameW") + procGetUserNameExW = modsecur32.NewProc("GetUserNameExW") + procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo") + procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation") + procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree") + procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW") + procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW") + procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW") + procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW") + procGetLengthSid = modadvapi32.NewProc("GetLengthSid") + procCopySid = modadvapi32.NewProc("CopySid") + procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid") + procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid") + procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid") + procFreeSid = modadvapi32.NewProc("FreeSid") + procEqualSid = modadvapi32.NewProc("EqualSid") + procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority") + procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount") + procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority") + procIsValidSid = modadvapi32.NewProc("IsValidSid") + procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership") + procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken") + procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken") + procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf") + procRevertToSelf = modadvapi32.NewProc("RevertToSelf") + procSetThreadToken = modadvapi32.NewProc("SetThreadToken") + procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW") + procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges") + procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups") + procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation") + procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation") + procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx") + procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") + procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW") + procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW") + procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW") + procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken") + procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW") + procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory") + procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo") + procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo") + procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW") + procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW") + procBuildSecurityDescriptorW = modadvapi32.NewProc("BuildSecurityDescriptorW") + procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor") + procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl") + procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl") + procGetSecurityDescriptorSacl = modadvapi32.NewProc("GetSecurityDescriptorSacl") + procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner") + procGetSecurityDescriptorGroup = modadvapi32.NewProc("GetSecurityDescriptorGroup") + procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength") + procGetSecurityDescriptorRMControl = modadvapi32.NewProc("GetSecurityDescriptorRMControl") + procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor") + procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl") + procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl") + procSetSecurityDescriptorSacl = modadvapi32.NewProc("SetSecurityDescriptorSacl") + procSetSecurityDescriptorOwner = modadvapi32.NewProc("SetSecurityDescriptorOwner") + procSetSecurityDescriptorGroup = modadvapi32.NewProc("SetSecurityDescriptorGroup") + procSetSecurityDescriptorRMControl = modadvapi32.NewProc("SetSecurityDescriptorRMControl") + procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW") + procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW") + procMakeAbsoluteSD = modadvapi32.NewProc("MakeAbsoluteSD") + procMakeSelfRelativeSD = modadvapi32.NewProc("MakeSelfRelativeSD") + procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW") +>>>>>>> update golang.org/x/sys ) func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) { @@ -646,6 +955,31 @@ func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) { return } +func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size)) + n = uint32(r0) + if n == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) { + r1, _, e1 := syscall.Syscall(procGetModuleHandleExW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(moduleName)), uintptr(unsafe.Pointer(module))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func GetVersion() (ver uint32, err error) { r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0) ver = uint32(r0) @@ -682,7 +1016,18 @@ func ExitProcess(exitcode uint32) { } func IsWow64Process(handle Handle, isWow64 *bool) (err error) { +<<<<<<< HEAD r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(isWow64)), 0) +======= + var _p0 uint32 + if *isWow64 { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0) + *isWow64 = _p0 != 0 +>>>>>>> update golang.org/x/sys if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -952,6 +1297,30 @@ func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) { return } +func LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) { + r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) { + r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + func GetComputerName(buf *uint16, n *uint32) (err error) { r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0) if r1 == 0 { @@ -1111,6 +1480,7 @@ func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (ha func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) { r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd)) +<<<<<<< HEAD if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -1132,6 +1502,9 @@ func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **u func TerminateProcess(handle Handle, exitcode uint32) (err error) { r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0) if r1 == 0 { +======= + if r1 <= 32 { +>>>>>>> update golang.org/x/sys if e1 != 0 { err = errnoErr(e1) } else { @@ -1141,8 +1514,16 @@ func TerminateProcess(handle Handle, exitcode uint32) (err error) { return } -func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0) +func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) { + r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func TerminateProcess(handle Handle, exitcode uint32) (err error) { + r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -1153,8 +1534,8 @@ func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { return } -func GetStartupInfo(startupInfo *StartupInfo) (err error) { - r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) +func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -1165,10 +1546,9 @@ func GetStartupInfo(startupInfo *StartupInfo) (err error) { return } -func GetCurrentProcess() (pseudoHandle Handle, err error) { - r0, _, e1 := syscall.Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0) - pseudoHandle = Handle(r0) - if pseudoHandle == 0 { +func GetStartupInfo(startupInfo *StartupInfo) (err error) { + r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2105,13 +2485,20 @@ func PulseEvent(event Handle) (err error) { return } +<<<<<<< HEAD func SleepEx(milliseconds uint32, alertable bool) (ret uint32) { var _p0 uint32 if alertable { +======= +func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) { + var _p0 uint32 + if initialOwner { +>>>>>>> update golang.org/x/sys _p0 = 1 } else { _p0 = 0 } +<<<<<<< HEAD r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0) ret = uint32(r0) return @@ -2258,6 +2645,11 @@ func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (hand func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) { r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath))) if r1 == 0 { +======= + r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name))) + handle = Handle(r0) + if handle == 0 { +>>>>>>> update golang.org/x/sys if e1 != 0 { err = errnoErr(e1) } else { @@ -2267,9 +2659,10 @@ func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err return } -func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0) - if r1 == 0 { +func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) { + r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0) + handle = Handle(r0) + if handle == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2279,10 +2672,16 @@ func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) { return } -func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0) +func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) { + var _p0 uint32 + if inheritHandle { + _p0 = 1 + } else { + _p0 = 0 + } + r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name))) handle = Handle(r0) - if handle == InvalidHandle { + if handle == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2292,10 +2691,9 @@ func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, er return } -func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) - handle = Handle(r0) - if handle == InvalidHandle { +func ReleaseMutex(mutex Handle) (err error) { + r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2305,21 +2703,22 @@ func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, b return } -func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) { - r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength)) - if r1 == 0 { - if e1 != 0 { - err = errnoErr(e1) - } else { - err = syscall.EINVAL - } +func SleepEx(milliseconds uint32, alertable bool) (ret uint32) { + var _p0 uint32 + if alertable { + _p0 = 1 + } else { + _p0 = 0 } + r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0) + ret = uint32(r0) return } -func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) { - r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) - if r1 == 0 { +func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) { + r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0) + handle = Handle(r0) + if handle == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2329,8 +2728,8 @@ func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uin return } -func FindVolumeClose(findVolume Handle) (err error) { - r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0) +func AssignProcessToJobObject(job Handle, process Handle) (err error) { + r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2341,8 +2740,8 @@ func FindVolumeClose(findVolume Handle) (err error) { return } -func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) { - r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0) +func TerminateJobObject(job Handle, exitCode uint32) (err error) { + r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2353,16 +2752,16 @@ func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) { return } -func GetDriveType(rootPathName *uint16) (driveType uint32) { - r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0) - driveType = uint32(r0) +func SetErrorMode(mode uint32) (ret uint32) { + r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0) + ret = uint32(r0) return } -func GetLogicalDrives() (drivesBitMask uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0) - drivesBitMask = uint32(r0) - if drivesBitMask == 0 { +func ResumeThread(thread Handle) (ret uint32, err error) { + r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0) + ret = uint32(r0) + if ret == 0xffffffff { if e1 != 0 { err = errnoErr(e1) } else { @@ -2372,10 +2771,9 @@ func GetLogicalDrives() (drivesBitMask uint32, err error) { return } -func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0) - n = uint32(r0) - if n == 0 { +func SetPriorityClass(process Handle, priorityClass uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2385,9 +2783,10 @@ func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err return } -func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0) - if r1 == 0 { +func GetPriorityClass(process Handle) (ret uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0) + ret = uint32(r0) + if ret == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2397,9 +2796,10 @@ func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volume return } -func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0) - if r1 == 0 { +func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) { + r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0) + ret = int(r0) + if ret == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2409,8 +2809,8 @@ func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeN return } -func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength)) +func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2421,9 +2821,10 @@ func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint return } -func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength)) - if r1 == 0 { +func GetProcessId(process Handle) (id uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0) + id = uint32(r0) + if id == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2433,9 +2834,16 @@ func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength ui return } -func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0) - if r1 == 0 { +func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) { + var _p0 uint32 + if inheritHandle { + _p0 = 1 + } else { + _p0 = 0 + } + r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId)) + handle = Handle(r0) + if handle == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2445,10 +2853,15 @@ func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16 return } -func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) { - r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max)) - n = uint32(r0) - if n == 0 { +func SetProcessPriorityBoost(process Handle, disable bool) (err error) { + var _p0 uint32 + if disable { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2458,8 +2871,8 @@ func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint3 return } -func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0) +func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) { + r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath))) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2470,8 +2883,8 @@ func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) { return } -func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) { - r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0) +func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) { + r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2482,15 +2895,23 @@ func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err erro return } +<<<<<<< HEAD func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) if ret == 0 { +======= +func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) { + r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0) + handle = Handle(r0) + if handle == InvalidHandle { +>>>>>>> update golang.org/x/sys if e1 != 0 { err = errnoErr(e1) } else { err = syscall.EINVAL } +<<<<<<< HEAD } return } @@ -2534,13 +2955,16 @@ func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) if r0 != 0 { sockerr = syscall.Errno(r0) +======= +>>>>>>> update golang.org/x/sys } return } -func WSACleanup() (err error) { - r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0) - if r1 == socket_error { +func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) { + r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) + handle = Handle(r0) + if handle == InvalidHandle { if e1 != 0 { err = errnoErr(e1) } else { @@ -2550,9 +2974,9 @@ func WSACleanup() (err error) { return } -func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { - r1, _, e1 := syscall.Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine)) - if r1 == socket_error { +func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) { + r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength)) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2562,10 +2986,9 @@ func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbo return } -func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { - r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol)) - handle = Handle(r0) - if handle == InvalidHandle { +func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) { + r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength)) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2575,9 +2998,9 @@ func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { return } -func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) { - r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0) - if r1 == socket_error { +func FindVolumeClose(findVolume Handle) (err error) { + r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2587,9 +3010,9 @@ func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32 return } -func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) { - r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0) - if r1 == socket_error { +func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) { + r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2599,9 +3022,9 @@ func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int3 return } -func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { - r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) - if r1 == socket_error { +func GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) { + r1, _, e1 := syscall.Syscall6(procGetDiskFreeSpaceExW.Addr(), 4, uintptr(unsafe.Pointer(directoryName)), uintptr(unsafe.Pointer(freeBytesAvailableToCaller)), uintptr(unsafe.Pointer(totalNumberOfBytes)), uintptr(unsafe.Pointer(totalNumberOfFreeBytes)), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2611,9 +3034,16 @@ func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { return } -func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { - r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) - if r1 == socket_error { +func GetDriveType(rootPathName *uint16) (driveType uint32) { + r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0) + driveType = uint32(r0) + return +} + +func GetLogicalDrives() (drivesBitMask uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0) + drivesBitMask = uint32(r0) + if drivesBitMask == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2623,11 +3053,12 @@ func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { return } -func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { - r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - if r1 == socket_error { - if e1 != 0 { - err = errnoErr(e1) +func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0) + n = uint32(r0) + if n == 0 { + if e1 != 0 { + err = errnoErr(e1) } else { err = syscall.EINVAL } @@ -2635,9 +3066,9 @@ func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { return } -func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { - r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) - if r1 == socket_error { +func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { + r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2647,9 +3078,9 @@ func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { return } -func listen(s Handle, backlog int32) (err error) { - r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0) - if r1 == socket_error { +func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) { + r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2659,9 +3090,9 @@ func listen(s Handle, backlog int32) (err error) { return } -func shutdown(s Handle, how int32) (err error) { - r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0) - if r1 == socket_error { +func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength)) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2671,9 +3102,9 @@ func shutdown(s Handle, how int32) (err error) { return } -func Closesocket(s Handle) (err error) { - r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0) - if r1 == socket_error { +func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength)) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2683,8 +3114,8 @@ func Closesocket(s Handle) (err error) { return } -func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) { - r1, _, e1 := syscall.Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0) +func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2695,14 +3126,22 @@ func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32 return } -func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) { - syscall.Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0) +func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) { + r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max)) + n = uint32(r0) + if n == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } return } -func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) - if r1 == socket_error { +func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) { + r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2712,9 +3151,9 @@ func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32 return } -func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) - if r1 == socket_error { +func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) { + r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2724,9 +3163,10 @@ func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, return } -func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) - if r1 == socket_error { +func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { + r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) + ret = int32(r0) + if ret == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2736,9 +3176,9 @@ func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *ui return } -func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) { - r1, _, e1 := syscall.Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) - if r1 == socket_error { +func ExitWindowsEx(flags uint32, reason uint32) (err error) { + r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2748,19 +3188,33 @@ func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32 return } -func GetHostByName(name string) (h *Hostent, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(name) - if err != nil { - return +func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) { + var _p0 uint32 + if forceAppsClosed { + _p0 = 1 + } else { + _p0 = 0 } - return _GetHostByName(_p0) + var _p1 uint32 + if rebootAfterShutdown { + _p1 = 1 + } else { + _p1 = 0 + } + r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason)) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return } -func _GetHostByName(name *byte) (h *Hostent, err error) { - r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) - h = (*Hostent)(unsafe.Pointer(r0)) - if h == nil { +func SetProcessShutdownParameters(level uint32, flags uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetProcessShutdownParameters.Addr(), 2, uintptr(level), uintptr(flags), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2770,24 +3224,61 @@ func _GetHostByName(name *byte) (h *Hostent, err error) { return } -func GetServByName(name string, proto string) (s *Servent, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(name) - if err != nil { - return +func GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetProcessShutdownParameters.Addr(), 2, uintptr(unsafe.Pointer(level)), uintptr(unsafe.Pointer(flags)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } } - var _p1 *byte - _p1, err = syscall.BytePtrFromString(proto) - if err != nil { - return + return +} + +func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) { + r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0) + if r0 != 0 { + ret = syscall.Errno(r0) } - return _GetServByName(_p0, _p1) + return } -func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { - r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0) - s = (*Servent)(unsafe.Pointer(r0)) - if s == nil { +func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) { + r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax)) + chars = int32(r0) + return +} + +func coCreateGuid(pguid *GUID) (ret error) { + r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func CoTaskMemFree(address unsafe.Pointer) { + syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0) + return +} + +func rtlGetVersion(info *OsVersionInfoEx) (ret error) { + r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) { + syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber))) + return +} + +func getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetProcessPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2797,25 +3288,33 @@ func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { return } -func Ntohs(netshort uint16) (u uint16) { - r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0) - u = uint16(r0) +func getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetThreadPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } return } -func GetProtoByName(name string) (p *Protoent, err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(name) - if err != nil { - return +func getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetUserPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } } - return _GetProtoByName(_p0) + return } -func _GetProtoByName(name *byte) (p *Protoent, err error) { - r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) - p = (*Protoent)(unsafe.Pointer(r0)) - if p == nil { +func getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetSystemPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2825,65 +3324,797 @@ func _GetProtoByName(name *byte) (p *Protoent, err error) { return } -func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { - var _p0 *uint16 - _p0, status = syscall.UTF16PtrFromString(name) - if status != nil { - return +func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) { + var _p0 *uint32 + if len(processIds) > 0 { + _p0 = &processIds[0] } - return _DnsQuery(_p0, qtype, options, extra, qrs, pr) + r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(processIds)), uintptr(unsafe.Pointer(bytesReturned))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return } -func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { - r0, _, _ := syscall.Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(name)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr))) +func WSAStartup(verreq uint32, data *WSAData) (sockerr error) { + r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0) if r0 != 0 { - status = syscall.Errno(r0) + sockerr = syscall.Errno(r0) } return } -func DnsRecordListFree(rl *DNSRecord, freetype uint32) { - syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0) +func WSACleanup() (err error) { + r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } return } -func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { - r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) - same = r0 != 0 +func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) { + r1, _, e1 := syscall.Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine)) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } return } -func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) { - r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0) - if r0 != 0 { - sockerr = syscall.Errno(r0) +func socket(af int32, typ int32, protocol int32) (handle Handle, err error) { + r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol)) + handle = Handle(r0) + if handle == InvalidHandle { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func sendto(s Handle, buf []byte, flags int, to unsafe.Pointer, tolen int32) (err error) { + var _p0 *byte + if len(buf) > 0 { + _p0 = &buf[0] + } + r1, _, e1 := syscall.Syscall6(procsendto.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(tolen)) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func recvfrom(s Handle, buf []byte, flags int, from *RawSockaddrAny, fromlen *int) (n int, err error) { + var _p0 *byte + if len(buf) > 0 { + _p0 = &buf[0] + } + r0, _, e1 := syscall.Syscall6(procrecvfrom.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if n == -1 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) { + r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) { + r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) { + r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) { + r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen)) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { + r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) { + r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func listen(s Handle, backlog int32) (err error) { + r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func shutdown(s Handle, how int32) (err error) { + r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func Closesocket(s Handle) (err error) { + r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) { + r1, _, e1 := syscall.Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) { + syscall.Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0) + return +} + +func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) { + r1, _, e1 := syscall.Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) { + r1, _, e1 := syscall.Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) { + r1, _, e1 := syscall.Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) { + r1, _, e1 := syscall.Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine))) + if r1 == socket_error { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetHostByName(name string) (h *Hostent, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(name) + if err != nil { + return + } + return _GetHostByName(_p0) +} + +func _GetHostByName(name *byte) (h *Hostent, err error) { + r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) + h = (*Hostent)(unsafe.Pointer(r0)) + if h == nil { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetServByName(name string, proto string) (s *Servent, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(name) + if err != nil { + return + } + var _p1 *byte + _p1, err = syscall.BytePtrFromString(proto) + if err != nil { + return + } + return _GetServByName(_p0, _p1) +} + +func _GetServByName(name *byte, proto *byte) (s *Servent, err error) { + r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0) + s = (*Servent)(unsafe.Pointer(r0)) + if s == nil { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func Ntohs(netshort uint16) (u uint16) { + r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0) + u = uint16(r0) + return +} + +func GetProtoByName(name string) (p *Protoent, err error) { + var _p0 *byte + _p0, err = syscall.BytePtrFromString(name) + if err != nil { + return + } + return _GetProtoByName(_p0) +} + +func _GetProtoByName(name *byte) (p *Protoent, err error) { + r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0) + p = (*Protoent)(unsafe.Pointer(r0)) + if p == nil { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { + var _p0 *uint16 + _p0, status = syscall.UTF16PtrFromString(name) + if status != nil { + return + } + return _DnsQuery(_p0, qtype, options, extra, qrs, pr) +} + +func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) { + r0, _, _ := syscall.Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(name)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr))) + if r0 != 0 { + status = syscall.Errno(r0) + } + return +} + +func DnsRecordListFree(rl *DNSRecord, freetype uint32) { + syscall.Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0) + return +} + +func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { + r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) + same = r0 != 0 + return +} + +func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) { + r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0) + if r0 != 0 { + sockerr = syscall.Errno(r0) + } + return +} + +func FreeAddrInfoW(addrinfo *AddrinfoW) { + syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0) + return +} + +func GetIfEntry(pIfRow *MibIfRow) (errcode error) { + r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + +func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) { + r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + +func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) { + r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) { + r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength))) + n = int32(r0) + if n == -1 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { + r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) + if r0 != 0 { + errcode = syscall.Errno(r0) + } + return +} + +func GetACP() (acp uint32) { + r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) + acp = uint32(r0) + return +} + +func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { + r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) + nwrite = int32(r0) + if nwrite == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0) + if r1&0xff == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) + if r1&0xff == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) { + r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0) + if r0 != 0 { + neterr = syscall.Errno(r0) + } + return +} + +func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) { + r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType))) + if r0 != 0 { + neterr = syscall.Errno(r0) + } + return +} + +func NetApiBufferFree(buf *byte) (neterr error) { + r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0) + if r0 != 0 { + neterr = syscall.Errno(r0) + } + return +} + +func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { + r1, _, e1 := syscall.Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { + r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { + r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { + r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func GetLengthSid(sid *SID) (len uint32) { + r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) + len = uint32(r0) + return +} + +func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { + r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) { + r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) { + r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0) + isWellKnown = r0 != 0 + return +} + +func FreeSid(sid *SID) (err error) { + r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) + if r1 != 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) { + r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0) + isEqual = r0 != 0 + return +} + +func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) { + r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) + authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0)) + return +} + +func getSidSubAuthorityCount(sid *SID) (count *uint8) { + r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) + count = (*uint8)(unsafe.Pointer(r0)) + return +} + +func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) { + r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0) + subAuthority = (*uint32)(unsafe.Pointer(r0)) + return +} + +func isValidSid(sid *SID) (isValid bool) { + r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) + isValid = r0 != 0 + return +} + +func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) { + r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func OpenProcessToken(process Handle, access uint32, token *Token) (err error) { + r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) { + var _p0 uint32 + if openAsSelf { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func ImpersonateSelf(impersonationlevel uint32) (err error) { + r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func RevertToSelf() (err error) { + r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func SetThreadToken(thread *Handle, token Token) (err error) { + r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) { + r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) { + var _p0 uint32 + if disableAllPrivileges { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) { + var _p0 uint32 + if resetToDefault { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen))) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } } return } -func FreeAddrInfoW(addrinfo *AddrinfoW) { - syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0) - return -} - -func GetIfEntry(pIfRow *MibIfRow) (errcode error) { - r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0) - if r0 != 0 { - errcode = syscall.Errno(r0) +func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } } return } -func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) { - r0, _, _ := syscall.Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0) - if r0 != 0 { - errcode = syscall.Errno(r0) +func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } } return } -func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) { - r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0) +func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) { + r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken))) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2894,10 +4125,9 @@ func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) return } -func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) { - r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength))) - n = int32(r0) - if n == -1 { +func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen))) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2907,24 +4137,36 @@ func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferL return } -func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { - r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) - if r0 != 0 { - errcode = syscall.Errno(r0) +func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) + len = uint32(r0) + if len == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } } return } -func GetACP() (acp uint32) { - r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0) - acp = uint32(r0) +func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) + len = uint32(r0) + if len == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } return } -func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) { - r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar)) - nwrite = int32(r0) - if nwrite == 0 { +func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) + len = uint32(r0) + if len == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2934,9 +4176,9 @@ func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, return } -func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) { - r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0) - if r1&0xff == 0 { +func WTSQueryUserToken(session uint32, token *Token) (err error) { + r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2946,9 +4188,9 @@ func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint return } -func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize))) - if r1&0xff == 0 { +func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0) + if r1 == 0 { if e1 != 0 { err = errnoErr(e1) } else { @@ -2958,32 +4200,68 @@ func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err er return } -func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) { - r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0) +func WTSFreeMemory(ptr uintptr) { + syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0) + return +} + +func getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) { + r0, _, _ := syscall.Syscall9(procGetSecurityInfo.Addr(), 8, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0) if r0 != 0 { - neterr = syscall.Errno(r0) + ret = syscall.Errno(r0) } return } -func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) { - r0, _, _ := syscall.Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType))) +func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) { + syscall.Syscall9(procSetSecurityInfo.Addr(), 7, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0) + return +} + +func getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) { + var _p0 *uint16 + _p0, ret = syscall.UTF16PtrFromString(objectName) + if ret != nil { + return + } + return _getNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl, sd) +} + +func _getNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) { + r0, _, _ := syscall.Syscall9(procGetNamedSecurityInfoW.Addr(), 8, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0) if r0 != 0 { - neterr = syscall.Errno(r0) + ret = syscall.Errno(r0) } return } -func NetApiBufferFree(buf *byte) (neterr error) { - r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0) +func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) { + var _p0 *uint16 + _p0, ret = syscall.UTF16PtrFromString(objectName) + if ret != nil { + return + } + return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl) +} + +func _SetNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) { + r0, _, _ := syscall.Syscall9(procSetNamedSecurityInfoW.Addr(), 7, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0) if r0 != 0 { - neterr = syscall.Errno(r0) + ret = syscall.Errno(r0) } return } -func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) +func buildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, countAccessEntries uint32, accessEntries *EXPLICIT_ACCESS, countAuditEntries uint32, auditEntries *EXPLICIT_ACCESS, oldSecurityDescriptor *SECURITY_DESCRIPTOR, sizeNewSecurityDescriptor *uint32, newSecurityDescriptor **SECURITY_DESCRIPTOR) (ret error) { + r0, _, _ := syscall.Syscall9(procBuildSecurityDescriptorW.Addr(), 9, uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(countAccessEntries), uintptr(unsafe.Pointer(accessEntries)), uintptr(countAuditEntries), uintptr(unsafe.Pointer(auditEntries)), uintptr(unsafe.Pointer(oldSecurityDescriptor)), uintptr(unsafe.Pointer(sizeNewSecurityDescriptor)), uintptr(unsafe.Pointer(newSecurityDescriptor))) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) { + r1, _, e1 := syscall.Syscall(procInitializeSecurityDescriptor.Addr(), 2, uintptr(unsafe.Pointer(absoluteSD)), uintptr(revision), 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -2994,8 +4272,8 @@ func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint3 return } -func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) { - r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0) +func getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(control)), uintptr(unsafe.Pointer(revision))) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3006,8 +4284,22 @@ func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen return } -func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { - r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0) +func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) { + var _p0 uint32 + if *daclPresent { + _p0 = 1 + } else { + _p0 = 0 + } + var _p1 uint32 + if *daclDefaulted { + _p1 = 1 + } else { + _p1 = 0 + } + r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0) + *daclPresent = _p0 != 0 + *daclDefaulted = _p1 != 0 if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3018,8 +4310,22 @@ func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) { return } -func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { - r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0) +func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) { + var _p0 uint32 + if *saclPresent { + _p0 = 1 + } else { + _p0 = 0 + } + var _p1 uint32 + if *saclDefaulted { + _p1 = 1 + } else { + _p1 = 0 + } + r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0) + *saclPresent = _p0 != 0 + *saclDefaulted = _p1 != 0 if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3030,14 +4336,66 @@ func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) { return } -func GetLengthSid(sid *SID) (len uint32) { - r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) +func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) { + var _p0 uint32 + if *ownerDefaulted { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0))) + *ownerDefaulted = _p0 != 0 + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) { + var _p0 uint32 + if *groupDefaulted { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0))) + *groupDefaulted = _p0 != 0 + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) { + r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0) len = uint32(r0) return } -func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { - r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid))) +func getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) { + r0, _, _ := syscall.Syscall(procGetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) { + r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0) + isValid = r0 != 0 + return +} + +func setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) { + r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(controlBitsOfInterest), uintptr(controlBitsToSet)) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3048,8 +4406,20 @@ func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) { return } -func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) { - r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0) +func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) { + var _p0 uint32 + if daclPresent { + _p0 = 1 + } else { + _p0 = 0 + } + var _p1 uint32 + if daclDefaulted { + _p1 = 1 + } else { + _p1 = 0 + } + r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3060,6 +4430,7 @@ func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, s return } +<<<<<<< HEAD func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) { r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0) if r1 == 0 { @@ -3081,6 +4452,23 @@ func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) { func FreeSid(sid *SID) (err error) { r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) if r1 != 0 { +======= +func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) { + var _p0 uint32 + if saclPresent { + _p0 = 1 + } else { + _p0 = 0 + } + var _p1 uint32 + if saclDefaulted { + _p1 = 1 + } else { + _p1 = 0 + } + r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0) + if r1 == 0 { +>>>>>>> update golang.org/x/sys if e1 != 0 { err = errnoErr(e1) } else { @@ -3090,12 +4478,25 @@ func FreeSid(sid *SID) (err error) { return } -func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) { - r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0) - isEqual = r0 != 0 +func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) { + var _p0 uint32 + if ownerDefaulted { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0)) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } return } +<<<<<<< HEAD func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) { r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0)) @@ -3122,6 +4523,16 @@ func isValidSid(sid *SID) (isValid bool) { func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) { r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember))) +======= +func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) { + var _p0 uint32 + if groupDefaulted { + _p0 = 1 + } else { + _p0 = 0 + } + r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0)) +>>>>>>> update golang.org/x/sys if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3132,6 +4543,7 @@ func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) ( return } +<<<<<<< HEAD func OpenProcessToken(process Handle, access uint32, token *Token) (err error) { r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token))) if r1 == 0 { @@ -3164,6 +4576,24 @@ func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token func ImpersonateSelf(impersonationlevel uint32) (err error) { r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0) +======= +func setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) { + syscall.Syscall(procSetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0) + return +} + +func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) { + var _p0 *uint16 + _p0, err = syscall.UTF16PtrFromString(str) + if err != nil { + return + } + return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size) +} + +func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0) +>>>>>>> update golang.org/x/sys if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3174,6 +4604,7 @@ func ImpersonateSelf(impersonationlevel uint32) (err error) { return } +<<<<<<< HEAD func RevertToSelf() (err error) { r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0) if r1 == 0 { @@ -3272,6 +4703,10 @@ func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) { r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken))) +======= +func convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) { + r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(securityInformation), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(strLen)), 0) +>>>>>>> update golang.org/x/sys if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3282,8 +4717,20 @@ func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes return } -func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { - r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen))) +func makeAbsoluteSD(selfRelativeSD *SECURITY_DESCRIPTOR, absoluteSD *SECURITY_DESCRIPTOR, absoluteSDSize *uint32, dacl *ACL, daclSize *uint32, sacl *ACL, saclSize *uint32, owner *SID, ownerSize *uint32, group *SID, groupSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall12(procMakeAbsoluteSD.Addr(), 11, uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(absoluteSDSize)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(daclSize)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(saclSize)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(ownerSize)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(groupSize)), 0) + if r1 == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} + +func makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procMakeSelfRelativeSD.Addr(), 3, uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(selfRelativeSDSize))) if r1 == 0 { if e1 != 0 { err = errnoErr(e1) @@ -3294,6 +4741,7 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) { return } +<<<<<<< HEAD func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) { r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0) len = uint32(r0) @@ -3335,3 +4783,12 @@ func WTSFreeMemory(ptr uintptr) { syscall.Syscall(procWTSFreeMemory.Addr(), 1, uintptr(ptr), 0, 0) return } +======= +func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) { + r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)), 0, 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} +>>>>>>> update golang.org/x/sys diff --git a/vendor/vendor.json b/vendor/vendor.json index 18d66923444..abf458260db 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -3927,12 +3927,25 @@ "revisionTime": "2019-04-22T22:11:18Z" }, { +<<<<<<< HEAD "checksumSHA1": "NaPKWo2/NhJLk/+GrsBiAL/V6J4=", "path": "golang.org/x/sys/cpu", "revision": "fde4db37ae7ad8191b03d30d27f258b5291ae4e3", "revisionTime": "2019-08-12T08:24:04Z", "version": "release-branch.go1.13", "versionExact": "release-branch.go1.13" +======= + "checksumSHA1": "2pnfgKuVmbRVa1McLMqfxpJ4H3s=", + "path": "golang.org/x/sys", + "revision": "4a24b406529242041050cb1dec3e0e4c46a5f1b6", + "revisionTime": "2019-12-18T06:34:59Z" + }, + { + "checksumSHA1": "2/z4EueF+LWm1l1PMr4LYvlI70w=", + "path": "golang.org/x/sys/cpu", + "revision": "4a24b406529242041050cb1dec3e0e4c46a5f1b6", + "revisionTime": "2019-12-18T06:34:59Z" +>>>>>>> update golang.org/x/sys }, { "checksumSHA1": "2DA7yQXGLTxH4M5zugia3YpJAV0=", @@ -3943,6 +3956,7 @@ "versionExact": "release-branch.go1.13" }, { +<<<<<<< HEAD "checksumSHA1": "3cAdqNoRgaMQU+qEXVgsqNC9QOQ=", "path": "golang.org/x/sys/windows", "revision": "fde4db37ae7ad8191b03d30d27f258b5291ae4e3", @@ -3957,30 +3971,57 @@ "revisionTime": "2019-08-12T08:24:04Z", "version": "release-branch.go1.13", "versionExact": "release-branch.go1.13" +======= + "checksumSHA1": "/2lxeYmsfx264LhkH1fjzJPHrbg=", + "path": "golang.org/x/sys/windows", + "revision": "4a24b406529242041050cb1dec3e0e4c46a5f1b6", + "revisionTime": "2019-12-18T06:34:59Z" + }, + { + "checksumSHA1": "QkGcmV/rr56ZUKi6E7mdevKUE0g=", + "path": "golang.org/x/sys/windows/registry", + "revision": "4a24b406529242041050cb1dec3e0e4c46a5f1b6", + "revisionTime": "2019-12-18T06:34:59Z" +>>>>>>> update golang.org/x/sys }, { "checksumSHA1": "aeOJe5xLqyC3gN07YRyEC4pI2oo=", "path": "golang.org/x/sys/windows/svc", +<<<<<<< HEAD "revision": "fde4db37ae7ad8191b03d30d27f258b5291ae4e3", "revisionTime": "2019-08-12T08:24:04Z", "version": "release-branch.go1.13", "versionExact": "release-branch.go1.13" +======= + "revision": "4a24b406529242041050cb1dec3e0e4c46a5f1b6", + "revisionTime": "2019-12-18T06:34:59Z" +>>>>>>> update golang.org/x/sys }, { "checksumSHA1": "e9KJPWrdqg5PMkbE2w60Io8rY4M=", "path": "golang.org/x/sys/windows/svc/debug", +<<<<<<< HEAD "revision": "fde4db37ae7ad8191b03d30d27f258b5291ae4e3", "revisionTime": "2019-08-12T08:24:04Z", "version": "release-branch.go1.13", "versionExact": "release-branch.go1.13" +======= + "revision": "4a24b406529242041050cb1dec3e0e4c46a5f1b6", + "revisionTime": "2019-12-18T06:34:59Z" +>>>>>>> update golang.org/x/sys }, { "checksumSHA1": "uVlUSSKplihZG7N+QJ6fzDZ4Kh8=", "path": "golang.org/x/sys/windows/svc/eventlog", +<<<<<<< HEAD "revision": "fde4db37ae7ad8191b03d30d27f258b5291ae4e3", "revisionTime": "2019-08-12T08:24:04Z", "version": "release-branch.go1.13", "versionExact": "release-branch.go1.13" +======= + "revision": "4a24b406529242041050cb1dec3e0e4c46a5f1b6", + "revisionTime": "2019-12-18T06:34:59Z" +>>>>>>> update golang.org/x/sys }, { "checksumSHA1": "aLtwllQwDoDuDKVToBaTlBnbS9Y=", From f7ac244487309191e8b0d02ee38f11f97d348e89 Mon Sep 17 00:00:00 2001 From: Alex Kristiansen Date: Thu, 19 Dec 2019 07:38:08 -0800 Subject: [PATCH 05/21] update notice --- NOTICE.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NOTICE.txt b/NOTICE.txt index 6e8cf796ade..45f450b0b6c 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -5626,8 +5626,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------- Dependency: golang.org/x/sys +<<<<<<< HEAD Version: release-branch.go1.13 Revision: fde4db37ae7ad8191b03d30d27f258b5291ae4e3 +======= +Revision: 4a24b406529242041050cb1dec3e0e4c46a5f1b6 +>>>>>>> update notice License type (autodetected): BSD-3-Clause ./vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------- From 0568dd51b9149dbfc0da8397c63cea28c70483e5 Mon Sep 17 00:00:00 2001 From: Alex Kristiansen Date: Thu, 19 Dec 2019 09:40:18 -0800 Subject: [PATCH 06/21] fix change in sid.String --- winlogbeat/sys/eventlogging/eventlogging_windows.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/winlogbeat/sys/eventlogging/eventlogging_windows.go b/winlogbeat/sys/eventlogging/eventlogging_windows.go index 29d2c47fdef..eb38f1f92db 100644 --- a/winlogbeat/sys/eventlogging/eventlogging_windows.go +++ b/winlogbeat/sys/eventlogging/eventlogging_windows.go @@ -413,10 +413,7 @@ func parseSID(record eventLogRecord, buffer []byte) (*sys.SID, error) { } sid := (*windows.SID)(unsafe.Pointer(&buffer[record.userSidOffset])) - identifier, err := sid.String() - if err != nil { - return nil, err - } + identifier := sid.String() return &sys.SID{Identifier: identifier}, nil } From 2f8cf0a04643ae0f42fb7c69d4ccfeb8ba98aed7 Mon Sep 17 00:00:00 2001 From: Alex Kristiansen Date: Mon, 30 Dec 2019 10:34:16 -0800 Subject: [PATCH 07/21] try and revert vendor to master --- vendor/4d63.com/tz/README.md | 4 +- .../Azure/azure-sdk-for-go/version/version.go | 2 +- vendor/github.com/Shopify/sarama/dev.yml | 10 + .../Shopify/sarama/examples/README.md | 12 + .../sarama/examples/consumergroup/README.md | 7 + .../sarama/examples/consumergroup/go.mod | 5 + .../sarama/examples/consumergroup/go.sum | 34 + .../sarama/examples/consumergroup/main.go | 161 + .../sarama/examples/http_server/README.md | 7 + .../examples/http_server/http_server.go | 247 + .../examples/sasl_scram_client/README.md | 4 + .../sarama/examples/sasl_scram_client/main.go | 170 + .../sasl_scram_client/scram_client.go | 36 + .../github.com/Shopify/sarama/mocks/README.md | 13 + .../Shopify/sarama/mocks/async_producer.go | 173 + .../Shopify/sarama/mocks/consumer.go | 315 + .../github.com/Shopify/sarama/mocks/mocks.go | 48 + .../Shopify/sarama/mocks/sync_producer.go | 157 + .../github.com/Shopify/sarama/tools/README.md | 11 + .../tools/kafka-console-consumer/README.md | 29 + .../kafka-console-consumer.go | 163 + .../kafka-console-partitionconsumer/README.md | 28 + .../kafka-console-partitionconsumer.go | 102 + .../tools/kafka-console-producer/README.md | 34 + .../kafka-console-producer.go | 140 + .../kafka-producer-performance/README.md | 20 + .../tools/kafka-producer-performance/main.go | 400 + .../Shopify/sarama/tools/tls/config.go | 17 + .../Shopify/sarama/vagrant/boot_cluster.sh | 22 + .../Shopify/sarama/vagrant/create_topics.sh | 9 + .../Shopify/sarama/vagrant/halt_cluster.sh | 15 + .../Shopify/sarama/vagrant/install_cluster.sh | 49 + .../Shopify/sarama/vagrant/kafka.conf | 9 + .../Shopify/sarama/vagrant/provision.sh | 17 + .../sarama/vagrant/run_java_producer.sh | 6 + .../Shopify/sarama/vagrant/run_toxiproxy.sh | 22 + .../Shopify/sarama/vagrant/server.properties | 127 + .../Shopify/sarama/vagrant/setup_services.sh | 29 + .../Shopify/sarama/vagrant/toxiproxy.conf | 6 + .../Shopify/sarama/vagrant/zookeeper.conf | 7 + .../sarama/vagrant/zookeeper.properties | 36 + .../awslabs/goformation/CONTRIBUTING.md | 209 +- .../github.com/awslabs/goformation/Makefile | 12 + .../github.com/awslabs/goformation/README.md | 40 +- vendor/github.com/awslabs/goformation/go.mod | 23 +- vendor/github.com/awslabs/goformation/go.sum | 54 +- .../awslabs/goformation/goformation.go | 12 +- .../coreos/go-systemd/sdjournal/journal.go | 56 +- .../distribution/reference/normalize.go | 29 - .../distribution/reference/reference.go | 2 +- vendor/github.com/docker/docker/NOTICE | 2 +- .../github.com/docker/docker/api/swagger.yaml | 7 +- .../docker/docker/api/types/filters/parse.go | 9 - .../docker/docker/client/request.go | 8 +- .../docker/docker/errdefs/http_helpers.go | 26 - .../docker/docker/pkg/mount/mount.go | 4 +- .../docker/pkg/mount/sharedsubtree_linux.go | 24 +- .../pkg/namesgenerator/names-generator.go | 6 + vendor/github.com/elastic/ecs/NOTICE.txt | 14 + .../elastic/go-sysinfo/CHANGELOG.md | 18 +- .../github.com/elastic/go-sysinfo/README.md | 1 - vendor/github.com/elastic/go-sysinfo/go.mod | 4 +- vendor/github.com/elastic/go-sysinfo/go.sum | 4 +- .../go-sysinfo/providers/linux/container.go | 2 +- .../go-sysinfo/providers/linux/host_linux.go | 23 - .../go-sysinfo/providers/linux/machineid.go | 8 +- .../elastic/go-sysinfo/providers/linux/os.go | 2 +- .../providers/windows/process_windows.go | 12 +- .../elastic/go-sysinfo/types/host.go | 27 - .../opencontainers/go-digest/LICENSE.code | 191 + .../opencontainers/go-digest/README.md | 18 +- .../opencontainers/go-digest/algorithm.go | 32 +- .../opencontainers/go-digest/digest.go | 20 +- .../image-spec/specs-go/v1/config.go | 2 +- .../image-spec/specs-go/v1/mediatype.go | 9 - .../image-spec/specs-go/version.go | 4 +- .../prometheus/procfs/CONTRIBUTING.md | 109 +- .../prometheus/procfs/MAINTAINERS.md | 3 +- vendor/github.com/prometheus/procfs/Makefile | 60 +- vendor/github.com/prometheus/procfs/README.md | 54 +- .../github.com/prometheus/procfs/buddyinfo.go | 16 +- .../prometheus/procfs/fixtures.ttar | 5101 +---- vendor/github.com/prometheus/procfs/fs.go | 71 +- .../prometheus/procfs/internal/util/parse.go | 44 +- vendor/github.com/prometheus/procfs/ipvs.go | 42 +- vendor/github.com/prometheus/procfs/mdstat.go | 145 +- .../prometheus/procfs/mountstats.go | 94 +- .../github.com/prometheus/procfs/net_dev.go | 41 +- .../github.com/prometheus/procfs/nfs/nfs.go | 76 +- .../github.com/prometheus/procfs/nfs/parse.go | 20 +- vendor/github.com/prometheus/procfs/proc.go | 106 +- .../github.com/prometheus/procfs/proc_io.go | 16 +- .../prometheus/procfs/proc_limits.go | 7 - .../github.com/prometheus/procfs/proc_ns.go | 4 +- .../github.com/prometheus/procfs/proc_stat.go | 28 +- vendor/github.com/prometheus/procfs/stat.go | 46 +- vendor/github.com/prometheus/procfs/ttar | 42 +- vendor/github.com/prometheus/procfs/xfrm.go | 4 +- .../github.com/prometheus/procfs/xfs/parse.go | 200 +- .../github.com/prometheus/procfs/xfs/xfs.go | 208 - .../shirou/gopsutil/.circleci/config.yml | 28 + .../shirou/gopsutil/cpu/cpu_freebsd_test.go | 40 + .../shirou/gopsutil/cpu/cpu_linux_test.go | 40 + .../shirou/gopsutil/cpu/cpu_solaris_test.go | 113 + .../shirou/gopsutil/cpu/cpu_test.go | 175 + .../cpu/testdata/freebsd/1cpu_2core.txt | 43 + .../cpu/testdata/freebsd/1cpu_4core.txt | 38 + .../cpu/testdata/freebsd/2cpu_4core.txt | 45 + .../testdata/solaris/1cpu_1core_isainfo.txt | 4 + .../testdata/solaris/1cpu_1core_psrinfo.txt | 3 + .../testdata/solaris/2cpu_1core_isainfo.txt | 4 + .../testdata/solaris/2cpu_1core_psrinfo.txt | 6 + .../testdata/solaris/2cpu_8core_isainfo.txt | 3 + .../testdata/solaris/2cpu_8core_psrinfo.txt | 22 + .../gopsutil/docker/docker_linux_test.go | 82 + .../shirou/gopsutil/host/host_linux_test.go | 61 + .../shirou/gopsutil/host/host_test.go | 162 + .../shirou/gopsutil/host/types_darwin.go | 17 + .../shirou/gopsutil/host/types_freebsd.go | 44 + .../shirou/gopsutil/host/types_linux.go | 42 + .../shirou/gopsutil/host/types_openbsd.go | 43 + .../shirou/gopsutil/load/load_test.go | 59 + .../shirou/gopsutil/mem/mem_darwin_test.go | 46 + .../shirou/gopsutil/mem/mem_test.go | 102 + .../shirou/gopsutil/mem/types_openbsd.go | 34 + .../gopsutil/process/process_posix_test.go | 20 + .../shirou/gopsutil/process/process_test.go | 568 + .../shirou/gopsutil/process/types_darwin.go | 160 + .../shirou/gopsutil/process/types_freebsd.go | 95 + .../shirou/gopsutil/process/types_openbsd.go | 103 + vendor/github.com/zmap/zcrypto/LICENSE | 257 + vendor/github.com/zmap/zcrypto/json/dhe.go | 130 + vendor/github.com/zmap/zcrypto/json/ecdhe.go | 107 + vendor/github.com/zmap/zcrypto/json/names.go | 113 + vendor/github.com/zmap/zcrypto/json/rsa.go | 67 + vendor/github.com/zmap/zcrypto/util/isURL.go | 77 + vendor/github.com/zmap/zcrypto/x509/README.md | 8 + .../github.com/zmap/zcrypto/x509/cert_pool.go | 171 + .../zmap/zcrypto/x509/certificate_type.go | 64 + vendor/github.com/zmap/zcrypto/x509/chain.go | 70 + .../zmap/zcrypto/x509/ct/serialization.go | 168 + .../github.com/zmap/zcrypto/x509/ct/types.go | 229 + .../github.com/zmap/zcrypto/x509/example.json | 65 + .../zmap/zcrypto/x509/extended_key_usage.go | 679 + .../zcrypto/x509/extended_key_usage_schema.sh | 21 + .../zmap/zcrypto/x509/extensions.go | 760 + .../zmap/zcrypto/x509/fingerprint.go | 61 + .../generated_certvalidationlevel_string.go | 16 + vendor/github.com/zmap/zcrypto/x509/json.go | 645 + vendor/github.com/zmap/zcrypto/x509/names.go | 30 + .../zmap/zcrypto/x509/pem_decrypt.go | 240 + vendor/github.com/zmap/zcrypto/x509/pkcs1.go | 121 + vendor/github.com/zmap/zcrypto/x509/pkcs8.go | 54 + .../github.com/zmap/zcrypto/x509/pkix/json.go | 274 + .../github.com/zmap/zcrypto/x509/pkix/oid.go | 74 + .../zmap/zcrypto/x509/pkix/oid_names.go | 1013 + .../github.com/zmap/zcrypto/x509/pkix/pkix.go | 289 + vendor/github.com/zmap/zcrypto/x509/sec1.go | 105 + .../zcrypto/x509/tor_service_descriptor.go | 158 + .../zmap/zcrypto/x509/validation.go | 60 + vendor/github.com/zmap/zcrypto/x509/verify.go | 635 + vendor/github.com/zmap/zcrypto/x509/x509.go | 2930 +++ vendor/golang.org/x/crypto/blake2b/blake2b.go | 8 +- .../x/crypto/blake2b/blake2b_generic.go | 69 +- vendor/golang.org/x/crypto/blake2b/blake2x.go | 2 +- vendor/golang.org/x/crypto/ed25519/ed25519.go | 5 - vendor/golang.org/x/crypto/md4/md4.go | 4 - vendor/golang.org/x/crypto/sha3/doc.go | 2 +- vendor/golang.org/x/crypto/sha3/hashes.go | 40 +- vendor/golang.org/x/crypto/sha3/shake.go | 125 +- .../x/crypto/ssh/terminal/terminal.go | 71 +- .../golang.org/x/crypto/ssh/terminal/util.go | 8 +- .../x/crypto/ssh/terminal/util_plan9.go | 2 +- .../x/crypto/ssh/terminal/util_solaris.go | 42 +- .../x/crypto/ssh/terminal/util_windows.go | 12 +- vendor/golang.org/x/net/bpf/constants.go | 24 +- vendor/golang.org/x/net/bpf/instructions.go | 224 +- vendor/golang.org/x/net/bpf/vm.go | 10 - .../golang.org/x/net/bpf/vm_instructions.go | 36 +- vendor/golang.org/x/net/context/context.go | 2 - .../x/net/context/ctxhttp/ctxhttp.go | 5 +- .../x/net/context/ctxhttp/ctxhttp_pre17.go | 147 + vendor/golang.org/x/net/http2/ciphers.go | 2 +- .../x/net/http2/client_conn_pool.go | 28 +- .../x/net/http2/configure_transport.go | 80 + vendor/golang.org/x/net/http2/flow.go | 10 +- vendor/golang.org/x/net/http2/frame.go | 71 +- vendor/golang.org/x/net/http2/go16.go | 16 + vendor/golang.org/x/net/http2/go17.go | 106 + vendor/golang.org/x/net/http2/go17_not18.go | 36 + vendor/golang.org/x/net/http2/go18.go | 56 + vendor/golang.org/x/net/http2/go19.go | 16 + vendor/golang.org/x/net/http2/headermap.go | 20 +- vendor/golang.org/x/net/http2/hpack/encode.go | 2 +- vendor/golang.org/x/net/http2/hpack/hpack.go | 14 - .../golang.org/x/net/http2/hpack/huffman.go | 20 +- vendor/golang.org/x/net/http2/http2.go | 25 +- vendor/golang.org/x/net/http2/not_go16.go | 21 + vendor/golang.org/x/net/http2/not_go17.go | 87 + vendor/golang.org/x/net/http2/not_go18.go | 29 + vendor/golang.org/x/net/http2/not_go19.go | 16 + vendor/golang.org/x/net/http2/server.go | 298 +- vendor/golang.org/x/net/http2/transport.go | 878 +- vendor/golang.org/x/net/http2/write.go | 15 +- vendor/golang.org/x/net/http2/writesched.go | 8 +- .../x/net/http2/writesched_random.go | 9 +- vendor/golang.org/x/net/icmp/dstunreach.go | 28 +- vendor/golang.org/x/net/icmp/echo.go | 132 +- vendor/golang.org/x/net/icmp/endpoint.go | 18 +- vendor/golang.org/x/net/icmp/extension.go | 109 +- vendor/golang.org/x/net/icmp/helper_posix.go | 2 +- vendor/golang.org/x/net/icmp/interface.go | 100 +- vendor/golang.org/x/net/icmp/ipv4.go | 12 +- vendor/golang.org/x/net/icmp/listen_posix.go | 2 +- vendor/golang.org/x/net/icmp/listen_stub.go | 4 +- vendor/golang.org/x/net/icmp/message.go | 52 +- vendor/golang.org/x/net/icmp/messagebody.go | 29 +- vendor/golang.org/x/net/icmp/mpls.go | 4 +- vendor/golang.org/x/net/icmp/multipart.go | 68 +- vendor/golang.org/x/net/icmp/packettoobig.go | 2 +- vendor/golang.org/x/net/icmp/paramprob.go | 31 +- vendor/golang.org/x/net/icmp/timeexceeded.go | 28 +- vendor/golang.org/x/net/idna/idna.go | 732 + vendor/golang.org/x/net/idna/tables.go | 4557 ++++ .../golang.org/x/net/internal/iana/const.go | 109 +- .../x/net/internal/socket/cmsghdr.go | 2 +- .../x/net/internal/socket/cmsghdr_bsd.go | 2 +- .../internal/socket/cmsghdr_linux_64bit.go | 2 +- .../x/net/internal/socket/cmsghdr_stub.go | 2 +- .../x/net/internal/socket/error_unix.go | 2 +- .../x/net/internal/socket/iovec_64bit.go | 4 +- .../x/net/internal/socket/iovec_stub.go | 2 +- .../x/net/internal/socket/mmsghdr_stub.go | 2 +- .../x/net/internal/socket/mmsghdr_unix.go | 2 +- .../x/net/internal/socket/msghdr_bsd.go | 2 +- .../x/net/internal/socket/msghdr_bsdvar.go | 2 +- .../net/internal/socket/msghdr_linux_64bit.go | 2 +- .../x/net/internal/socket/msghdr_stub.go | 2 +- .../x/net/internal/socket/rawconn.go | 2 + .../x/net/internal/socket/rawconn_mmsg.go | 1 + .../x/net/internal/socket/rawconn_msg.go | 3 +- .../x/net/internal/socket/rawconn_nommsg.go | 7 +- .../x/net/internal/socket/rawconn_nomsg.go | 9 +- .../x/net/internal/socket/rawconn_stub.go | 25 + .../x/net/internal/socket/reflect.go | 62 + .../x/net/internal/socket/socket.go | 3 - .../golang.org/x/net/internal/socket/sys.go | 2 +- .../x/net/internal/socket/sys_bsd.go | 8 +- .../x/net/internal/socket/sys_bsdvar.go | 13 +- .../x/net/internal/socket/sys_posix.go | 45 +- .../x/net/internal/socket/sys_solaris.go | 5 +- .../x/net/internal/socket/sys_stub.go | 17 +- .../x/net/internal/socket/sys_unix.go | 2 +- .../x/net/internal/socket/sys_windows.go | 19 +- .../x/net/internal/socket/zsys_darwin_386.go | 10 +- .../net/internal/socket/zsys_darwin_amd64.go | 10 +- .../x/net/internal/socket/zsys_darwin_arm.go | 10 +- .../net/internal/socket/zsys_darwin_arm64.go | 10 +- .../internal/socket/zsys_dragonfly_amd64.go | 10 +- .../x/net/internal/socket/zsys_freebsd_386.go | 10 +- .../net/internal/socket/zsys_freebsd_amd64.go | 10 +- .../x/net/internal/socket/zsys_freebsd_arm.go | 10 +- .../x/net/internal/socket/zsys_linux_386.go | 10 +- .../x/net/internal/socket/zsys_linux_amd64.go | 10 +- .../x/net/internal/socket/zsys_linux_arm.go | 10 +- .../x/net/internal/socket/zsys_linux_arm64.go | 10 +- .../x/net/internal/socket/zsys_linux_mips.go | 10 +- .../net/internal/socket/zsys_linux_mips64.go | 10 +- .../internal/socket/zsys_linux_mips64le.go | 10 +- .../net/internal/socket/zsys_linux_mipsle.go | 10 +- .../x/net/internal/socket/zsys_linux_ppc64.go | 10 +- .../net/internal/socket/zsys_linux_ppc64le.go | 10 +- .../x/net/internal/socket/zsys_linux_s390x.go | 10 +- .../x/net/internal/socket/zsys_netbsd_386.go | 10 +- .../net/internal/socket/zsys_netbsd_amd64.go | 10 +- .../x/net/internal/socket/zsys_netbsd_arm.go | 10 +- .../x/net/internal/socket/zsys_openbsd_386.go | 10 +- .../net/internal/socket/zsys_openbsd_amd64.go | 10 +- .../x/net/internal/socket/zsys_openbsd_arm.go | 10 +- .../net/internal/socket/zsys_solaris_amd64.go | 10 +- vendor/golang.org/x/net/ipv4/batch.go | 17 +- vendor/golang.org/x/net/ipv4/control_bsd.go | 2 +- vendor/golang.org/x/net/ipv4/control_stub.go | 4 +- vendor/golang.org/x/net/ipv4/control_unix.go | 2 +- .../golang.org/x/net/ipv4/control_windows.go | 8 +- vendor/golang.org/x/net/ipv4/dgramopt.go | 61 +- vendor/golang.org/x/net/ipv4/doc.go | 6 +- vendor/golang.org/x/net/ipv4/endpoint.go | 23 +- vendor/golang.org/x/net/ipv4/genericopt.go | 18 +- vendor/golang.org/x/net/ipv4/header.go | 26 +- vendor/golang.org/x/net/ipv4/helper.go | 25 +- vendor/golang.org/x/net/ipv4/iana.go | 10 +- vendor/golang.org/x/net/ipv4/packet.go | 58 +- vendor/golang.org/x/net/ipv4/packet_go1_8.go | 56 + vendor/golang.org/x/net/ipv4/packet_go1_9.go | 67 + vendor/golang.org/x/net/ipv4/payload_cmsg.go | 60 +- .../x/net/ipv4/payload_cmsg_go1_8.go | 59 + .../x/net/ipv4/payload_cmsg_go1_9.go | 67 + .../golang.org/x/net/ipv4/payload_nocmsg.go | 11 +- vendor/golang.org/x/net/ipv4/sockopt_posix.go | 6 +- vendor/golang.org/x/net/ipv4/sockopt_stub.go | 16 +- vendor/golang.org/x/net/ipv4/sys_asmreq.go | 2 +- .../golang.org/x/net/ipv4/sys_asmreq_stub.go | 8 +- .../golang.org/x/net/ipv4/sys_asmreqn_stub.go | 4 +- vendor/golang.org/x/net/ipv4/sys_bpf_stub.go | 2 +- vendor/golang.org/x/net/ipv4/sys_darwin.go | 52 +- vendor/golang.org/x/net/ipv4/sys_freebsd.go | 2 +- vendor/golang.org/x/net/ipv4/sys_ssmreq.go | 6 +- .../golang.org/x/net/ipv4/sys_ssmreq_stub.go | 4 +- vendor/golang.org/x/net/ipv4/sys_stub.go | 2 +- vendor/golang.org/x/net/ipv4/zsys_darwin.go | 2 +- .../golang.org/x/net/ipv4/zsys_dragonfly.go | 2 +- .../golang.org/x/net/ipv4/zsys_freebsd_386.go | 2 +- .../x/net/ipv4/zsys_freebsd_amd64.go | 2 +- .../golang.org/x/net/ipv4/zsys_freebsd_arm.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_386.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_amd64.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_arm.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_arm64.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_mips.go | 2 +- .../x/net/ipv4/zsys_linux_mips64.go | 2 +- .../x/net/ipv4/zsys_linux_mips64le.go | 2 +- .../x/net/ipv4/zsys_linux_mipsle.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_ppc.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_ppc64.go | 2 +- .../x/net/ipv4/zsys_linux_ppc64le.go | 2 +- .../golang.org/x/net/ipv4/zsys_linux_s390x.go | 2 +- vendor/golang.org/x/net/ipv4/zsys_netbsd.go | 2 +- vendor/golang.org/x/net/ipv4/zsys_openbsd.go | 2 +- vendor/golang.org/x/net/ipv4/zsys_solaris.go | 2 +- vendor/golang.org/x/net/ipv6/batch.go | 7 +- .../x/net/ipv6/control_rfc3542_unix.go | 2 +- vendor/golang.org/x/net/ipv6/control_stub.go | 4 +- vendor/golang.org/x/net/ipv6/control_unix.go | 2 +- .../golang.org/x/net/ipv6/control_windows.go | 8 +- vendor/golang.org/x/net/ipv6/dgramopt.go | 69 +- vendor/golang.org/x/net/ipv6/doc.go | 4 +- vendor/golang.org/x/net/ipv6/endpoint.go | 15 +- vendor/golang.org/x/net/ipv6/genericopt.go | 18 +- vendor/golang.org/x/net/ipv6/helper.go | 4 +- vendor/golang.org/x/net/ipv6/iana.go | 10 +- vendor/golang.org/x/net/ipv6/icmp_bsd.go | 2 +- vendor/golang.org/x/net/ipv6/icmp_stub.go | 2 +- vendor/golang.org/x/net/ipv6/payload_cmsg.go | 47 +- .../x/net/ipv6/payload_cmsg_go1_8.go | 55 + .../x/net/ipv6/payload_cmsg_go1_9.go | 57 + .../golang.org/x/net/ipv6/payload_nocmsg.go | 11 +- vendor/golang.org/x/net/ipv6/sockopt_posix.go | 12 +- vendor/golang.org/x/net/ipv6/sockopt_stub.go | 18 +- vendor/golang.org/x/net/ipv6/sys_asmreq.go | 2 +- .../golang.org/x/net/ipv6/sys_asmreq_stub.go | 4 +- vendor/golang.org/x/net/ipv6/sys_bpf_stub.go | 2 +- vendor/golang.org/x/net/ipv6/sys_darwin.go | 74 +- vendor/golang.org/x/net/ipv6/sys_freebsd.go | 2 +- vendor/golang.org/x/net/ipv6/sys_ssmreq.go | 8 +- .../golang.org/x/net/ipv6/sys_ssmreq_stub.go | 6 +- vendor/golang.org/x/net/ipv6/sys_stub.go | 2 +- vendor/golang.org/x/net/ipv6/zsys_darwin.go | 2 +- .../golang.org/x/net/ipv6/zsys_dragonfly.go | 2 +- .../golang.org/x/net/ipv6/zsys_freebsd_386.go | 2 +- .../x/net/ipv6/zsys_freebsd_amd64.go | 2 +- .../golang.org/x/net/ipv6/zsys_freebsd_arm.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_386.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_amd64.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_arm.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_arm64.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_mips.go | 2 +- .../x/net/ipv6/zsys_linux_mips64.go | 2 +- .../x/net/ipv6/zsys_linux_mips64le.go | 2 +- .../x/net/ipv6/zsys_linux_mipsle.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_ppc.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_ppc64.go | 2 +- .../x/net/ipv6/zsys_linux_ppc64le.go | 2 +- .../golang.org/x/net/ipv6/zsys_linux_s390x.go | 2 +- vendor/golang.org/x/net/ipv6/zsys_netbsd.go | 2 +- vendor/golang.org/x/net/ipv6/zsys_openbsd.go | 2 +- vendor/golang.org/x/net/ipv6/zsys_solaris.go | 2 +- .../golang.org/x/net/lex/httplex/httplex.go | 351 + vendor/golang.org/x/net/proxy/direct.go | 15 +- vendor/golang.org/x/net/proxy/per_host.go | 17 +- vendor/golang.org/x/net/proxy/proxy.go | 33 +- vendor/golang.org/x/net/proxy/socks5.go | 221 +- vendor/golang.org/x/net/publicsuffix/list.go | 64 +- vendor/golang.org/x/net/publicsuffix/table.go | 19021 ++++++++-------- vendor/golang.org/x/sys/cpu/cpu.go | 127 - vendor/golang.org/x/sys/cpu/cpu_arm.go | 37 - vendor/golang.org/x/sys/cpu/cpu_arm64.go | 7 + vendor/golang.org/x/sys/cpu/cpu_gccgo.c | 43 + vendor/golang.org/x/sys/cpu/cpu_gccgo.go | 26 + vendor/golang.org/x/sys/cpu/cpu_mips64x.go | 135 +- vendor/golang.org/x/sys/cpu/cpu_mipsx.go | 16 - vendor/golang.org/x/sys/cpu/cpu_ppc64x.go | 9 + vendor/golang.org/x/sys/cpu/cpu_s390x.go | 7 + vendor/golang.org/x/sys/cpu/cpu_x86.go | 4 - .../golang.org/x/sys/unix/affinity_linux.go | 8 +- vendor/golang.org/x/sys/unix/dirent.go | 2 +- vendor/golang.org/x/sys/unix/endian_little.go | 2 +- .../golang.org/x/sys/unix/syscall_darwin.go | 1 + .../x/sys/unix/syscall_darwin_386.go | 2 - .../x/sys/unix/syscall_darwin_amd64.go | 2 - .../x/sys/unix/syscall_darwin_arm.go | 4 - .../x/sys/unix/syscall_darwin_arm64.go | 4 - .../x/sys/unix/zerrors_linux_386.go | 2 - .../x/sys/unix/zerrors_linux_amd64.go | 2 - .../x/sys/unix/zerrors_linux_arm.go | 2 - .../x/sys/unix/zerrors_linux_arm64.go | 2 - .../x/sys/unix/zerrors_linux_mips.go | 2 - .../x/sys/unix/zerrors_linux_mips64.go | 2 - .../x/sys/unix/zerrors_linux_mips64le.go | 2 - .../x/sys/unix/zerrors_linux_mipsle.go | 2 - .../x/sys/unix/zerrors_linux_ppc64.go | 2 - .../x/sys/unix/zerrors_linux_ppc64le.go | 2 - .../x/sys/unix/zerrors_linux_riscv64.go | 2 - .../x/sys/unix/zerrors_linux_s390x.go | 2 - .../x/sys/unix/zerrors_linux_sparc64.go | 2 - .../x/sys/unix/zsyscall_darwin_386.1_11.go | 20 +- .../x/sys/unix/zsyscall_darwin_386.go | 30 +- .../x/sys/unix/zsyscall_darwin_386.s | 4 +- .../x/sys/unix/zsyscall_darwin_amd64.go | 30 +- .../x/sys/unix/zsyscall_darwin_amd64.s | 4 +- .../x/sys/unix/zsyscall_darwin_arm.go | 15 + .../x/sys/unix/zsyscall_darwin_arm.s | 2 + .../x/sys/unix/zsyscall_darwin_arm64.go | 15 + .../x/sys/unix/zsyscall_darwin_arm64.s | 2 + .../x/sys/unix/ztypes_linux_riscv64.go | 1 - .../x/sys/windows/asm_windows_386.s | 13 + .../x/sys/windows/asm_windows_amd64.s | 13 + .../golang.org/x/sys/windows/dll_windows.go | 30 +- .../golang.org/x/sys/windows/env_windows.go | 34 +- vendor/golang.org/x/sys/windows/mksyscall.go | 4 +- .../x/sys/windows/registry/mksyscall.go | 4 +- .../x/sys/windows/registry/value.go | 20 +- .../x/sys/windows/security_windows.go | 1032 +- vendor/golang.org/x/sys/windows/service.go | 74 +- .../golang.org/x/sys/windows/svc/service.go | 39 +- vendor/golang.org/x/sys/windows/svc/sys_386.s | 3 +- .../golang.org/x/sys/windows/svc/sys_amd64.s | 2 - .../x/sys/windows/syscall_windows.go | 362 +- .../golang.org/x/sys/windows/types_windows.go | 550 +- .../x/sys/windows/zsyscall_windows.go | 2626 +-- vendor/golang.org/x/text/CONTRIBUTING.md | 15 +- vendor/golang.org/x/text/README.md | 6 +- .../golang.org/x/text/cases/tables10.0.0.go | 220 +- vendor/golang.org/x/text/cases/tables9.0.0.go | 218 +- vendor/golang.org/x/text/cases/trieval.go | 7 +- vendor/golang.org/x/text/encoding/encoding.go | 2 +- .../x/text/encoding/htmlindex/tables.go | 1 - .../internal/identifier/identifier.go | 2 +- .../text/encoding/internal/identifier/mib.go | 96 +- .../x/text/encoding/unicode/unicode.go | 2 +- vendor/golang.org/x/text/language/Makefile | 16 + vendor/golang.org/x/text/language/common.go | 16 + vendor/golang.org/x/text/language/coverage.go | 34 +- vendor/golang.org/x/text/language/index.go | 783 + vendor/golang.org/x/text/language/language.go | 720 +- vendor/golang.org/x/text/language/lookup.go | 396 + vendor/golang.org/x/text/language/match.go | 422 +- vendor/golang.org/x/text/language/parse.go | 735 +- vendor/golang.org/x/text/language/tables.go | 3442 ++- vendor/golang.org/x/text/language/tags.go | 160 +- .../golang.org/x/text/transform/transform.go | 6 +- vendor/golang.org/x/text/unicode/bidi/bidi.go | 2 +- .../golang.org/x/text/unicode/bidi/bracket.go | 4 +- vendor/golang.org/x/text/unicode/bidi/core.go | 2 +- .../x/text/unicode/bidi/tables10.0.0.go | 2 +- .../x/text/unicode/norm/composition.go | 8 +- .../x/text/unicode/norm/forminfo.go | 19 - vendor/golang.org/x/text/unicode/norm/iter.go | 3 +- .../x/text/unicode/norm/normalize.go | 4 +- .../x/text/unicode/norm/readwriter.go | 4 +- .../x/text/unicode/norm/tables10.0.0.go | 1892 +- .../x/text/unicode/norm/tables9.0.0.go | 1890 +- .../x/text/unicode/norm/transform.go | 10 +- vendor/golang.org/x/time/rate/rate.go | 54 +- vendor/golang.org/x/time/rate/rate_go16.go | 21 + vendor/golang.org/x/time/rate/rate_go17.go | 21 + .../golang.org/x/tools/cmd/goimports/doc.go | 2 + .../x/tools/cmd/goimports/goimports.go | 22 +- .../x/tools/go/ast/astutil/imports.go | 61 +- .../x/tools/go/buildutil/fakecontext.go | 1 - vendor/golang.org/x/tools/go/loader/cgo.go | 207 + .../x/tools/go/loader/cgo_pkgconfig.go | 39 + vendor/golang.org/x/tools/go/loader/doc.go | 5 +- vendor/golang.org/x/tools/go/loader/loader.go | 15 +- vendor/golang.org/x/tools/imports/fastwalk.go | 187 + .../x/tools/imports/fastwalk_dirent_fileno.go | 13 + .../x/tools/imports/fastwalk_dirent_ino.go | 14 + .../x/tools/imports/fastwalk_portable.go | 29 + .../x/tools/imports/fastwalk_unix.go | 123 + vendor/golang.org/x/tools/imports/fix.go | 1082 + vendor/golang.org/x/tools/imports/imports.go | 297 + .../golang.org/x/tools/imports/sortimports.go | 212 + vendor/golang.org/x/tools/imports/zstdlib.go | 9448 ++++++++ .../googleapis/iam/v1/iam_policy.pb.go | 77 +- vendor/google.golang.org/grpc/CONTRIBUTING.md | 4 +- vendor/google.golang.org/grpc/backoff.go | 20 - vendor/google.golang.org/grpc/balancer.go | 8 +- .../grpc/balancer/balancer.go | 47 +- .../grpc/balancer/base/balancer.go | 27 +- .../grpclb/grpc_lb_v1/load_balancer.pb.go | 335 +- .../grpc/balancer/grpclb/grpclb.go | 78 +- .../grpc/balancer/grpclb/grpclb_config.go | 49 +- .../balancer/grpclb/grpclb_remote_balancer.go | 205 +- .../grpc/balancer/grpclb/grpclb_util.go | 2 +- .../grpc/balancer_conn_wrappers.go | 139 +- vendor/google.golang.org/grpc/clientconn.go | 436 +- .../internal/proto/grpc_gcp/altscontext.pb.go | 25 +- .../internal/proto/grpc_gcp/handshaker.pb.go | 419 +- .../grpc_gcp/transport_security_common.pb.go | 36 +- .../grpc/credentials/alts/utils.go | 3 - .../grpc/credentials/credentials.go | 46 +- vendor/google.golang.org/grpc/dialoptions.go | 99 +- .../grpc/encoding/encoding.go | 4 - vendor/google.golang.org/grpc/go.mod | 16 +- vendor/google.golang.org/grpc/go.sum | 36 +- .../google.golang.org/grpc/grpclog/grpclog.go | 2 +- .../grpc/internal/backoff/backoff.go | 27 +- .../grpc/internal/binarylog/binarylog.go | 2 +- .../grpc/internal/binarylog/env_config.go | 4 +- .../grpc/internal/binarylog/sink.go | 2 +- .../grpc/internal/envconfig/envconfig.go | 33 +- .../grpc/internal/internal.go | 26 +- .../grpc/internal/transport/controlbuf.go | 96 +- .../grpc/internal/transport/flowcontrol.go | 3 +- .../grpc/internal/transport/handler_server.go | 5 +- .../grpc/internal/transport/http2_client.go | 242 +- .../grpc/internal/transport/http2_server.go | 111 +- .../grpc/internal/transport/http_util.go | 1 - .../grpc/internal/transport/transport.go | 112 +- .../google.golang.org/grpc/naming/naming.go | 3 +- vendor/google.golang.org/grpc/pickfirst.go | 16 +- .../grpc/resolver/dns/dns_resolver.go | 435 +- .../grpc/resolver/passthrough/passthrough.go | 39 +- .../grpc/resolver/resolver.go | 55 +- .../grpc/resolver_conn_wrapper.go | 166 +- vendor/google.golang.org/grpc/rpc_util.go | 53 +- vendor/google.golang.org/grpc/server.go | 106 +- .../google.golang.org/grpc/service_config.go | 89 +- .../google.golang.org/grpc/status/status.go | 22 +- vendor/google.golang.org/grpc/stream.go | 94 +- vendor/google.golang.org/grpc/version.go | 2 +- vendor/google.golang.org/grpc/vet.sh | 29 +- vendor/vendor.json | 2027 +- 543 files changed, 56404 insertions(+), 30103 deletions(-) create mode 100644 vendor/github.com/Shopify/sarama/dev.yml create mode 100644 vendor/github.com/Shopify/sarama/examples/README.md create mode 100644 vendor/github.com/Shopify/sarama/examples/consumergroup/README.md create mode 100644 vendor/github.com/Shopify/sarama/examples/consumergroup/go.mod create mode 100644 vendor/github.com/Shopify/sarama/examples/consumergroup/go.sum create mode 100644 vendor/github.com/Shopify/sarama/examples/consumergroup/main.go create mode 100644 vendor/github.com/Shopify/sarama/examples/http_server/README.md create mode 100644 vendor/github.com/Shopify/sarama/examples/http_server/http_server.go create mode 100644 vendor/github.com/Shopify/sarama/examples/sasl_scram_client/README.md create mode 100644 vendor/github.com/Shopify/sarama/examples/sasl_scram_client/main.go create mode 100644 vendor/github.com/Shopify/sarama/examples/sasl_scram_client/scram_client.go create mode 100644 vendor/github.com/Shopify/sarama/mocks/README.md create mode 100644 vendor/github.com/Shopify/sarama/mocks/async_producer.go create mode 100644 vendor/github.com/Shopify/sarama/mocks/consumer.go create mode 100644 vendor/github.com/Shopify/sarama/mocks/mocks.go create mode 100644 vendor/github.com/Shopify/sarama/mocks/sync_producer.go create mode 100644 vendor/github.com/Shopify/sarama/tools/README.md create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/README.md create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/kafka-console-consumer.go create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/README.md create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/kafka-console-partitionconsumer.go create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-console-producer/README.md create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-console-producer/kafka-console-producer.go create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/README.md create mode 100644 vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/main.go create mode 100644 vendor/github.com/Shopify/sarama/tools/tls/config.go create mode 100755 vendor/github.com/Shopify/sarama/vagrant/boot_cluster.sh create mode 100755 vendor/github.com/Shopify/sarama/vagrant/create_topics.sh create mode 100755 vendor/github.com/Shopify/sarama/vagrant/halt_cluster.sh create mode 100755 vendor/github.com/Shopify/sarama/vagrant/install_cluster.sh create mode 100644 vendor/github.com/Shopify/sarama/vagrant/kafka.conf create mode 100755 vendor/github.com/Shopify/sarama/vagrant/provision.sh create mode 100755 vendor/github.com/Shopify/sarama/vagrant/run_java_producer.sh create mode 100755 vendor/github.com/Shopify/sarama/vagrant/run_toxiproxy.sh create mode 100644 vendor/github.com/Shopify/sarama/vagrant/server.properties create mode 100755 vendor/github.com/Shopify/sarama/vagrant/setup_services.sh create mode 100644 vendor/github.com/Shopify/sarama/vagrant/toxiproxy.conf create mode 100644 vendor/github.com/Shopify/sarama/vagrant/zookeeper.conf create mode 100644 vendor/github.com/Shopify/sarama/vagrant/zookeeper.properties create mode 100644 vendor/github.com/awslabs/goformation/Makefile create mode 100644 vendor/github.com/elastic/ecs/NOTICE.txt create mode 100644 vendor/github.com/opencontainers/go-digest/LICENSE.code create mode 100644 vendor/github.com/shirou/gopsutil/.circleci/config.yml create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_freebsd_test.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_linux_test.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_solaris_test.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/cpu_test.go create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/freebsd/1cpu_2core.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/freebsd/1cpu_4core.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/freebsd/2cpu_4core.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/solaris/1cpu_1core_isainfo.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/solaris/1cpu_1core_psrinfo.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/solaris/2cpu_1core_isainfo.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/solaris/2cpu_1core_psrinfo.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/solaris/2cpu_8core_isainfo.txt create mode 100644 vendor/github.com/shirou/gopsutil/cpu/testdata/solaris/2cpu_8core_psrinfo.txt create mode 100644 vendor/github.com/shirou/gopsutil/docker/docker_linux_test.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_linux_test.go create mode 100644 vendor/github.com/shirou/gopsutil/host/host_test.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_linux.go create mode 100644 vendor/github.com/shirou/gopsutil/host/types_openbsd.go create mode 100644 vendor/github.com/shirou/gopsutil/load/load_test.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_darwin_test.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/mem_test.go create mode 100644 vendor/github.com/shirou/gopsutil/mem/types_openbsd.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_posix_test.go create mode 100644 vendor/github.com/shirou/gopsutil/process/process_test.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_darwin.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_freebsd.go create mode 100644 vendor/github.com/shirou/gopsutil/process/types_openbsd.go create mode 100644 vendor/github.com/zmap/zcrypto/LICENSE create mode 100644 vendor/github.com/zmap/zcrypto/json/dhe.go create mode 100644 vendor/github.com/zmap/zcrypto/json/ecdhe.go create mode 100644 vendor/github.com/zmap/zcrypto/json/names.go create mode 100644 vendor/github.com/zmap/zcrypto/json/rsa.go create mode 100644 vendor/github.com/zmap/zcrypto/util/isURL.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/README.md create mode 100644 vendor/github.com/zmap/zcrypto/x509/cert_pool.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/certificate_type.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/chain.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/ct/serialization.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/ct/types.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/example.json create mode 100644 vendor/github.com/zmap/zcrypto/x509/extended_key_usage.go create mode 100755 vendor/github.com/zmap/zcrypto/x509/extended_key_usage_schema.sh create mode 100644 vendor/github.com/zmap/zcrypto/x509/extensions.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/fingerprint.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/generated_certvalidationlevel_string.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/json.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/names.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/pem_decrypt.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/pkcs1.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/pkcs8.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/pkix/json.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/pkix/oid.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/pkix/oid_names.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/pkix/pkix.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/sec1.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/tor_service_descriptor.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/validation.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/verify.go create mode 100644 vendor/github.com/zmap/zcrypto/x509/x509.go create mode 100644 vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go create mode 100644 vendor/golang.org/x/net/http2/configure_transport.go create mode 100644 vendor/golang.org/x/net/http2/go16.go create mode 100644 vendor/golang.org/x/net/http2/go17.go create mode 100644 vendor/golang.org/x/net/http2/go17_not18.go create mode 100644 vendor/golang.org/x/net/http2/go18.go create mode 100644 vendor/golang.org/x/net/http2/go19.go create mode 100644 vendor/golang.org/x/net/http2/not_go16.go create mode 100644 vendor/golang.org/x/net/http2/not_go17.go create mode 100644 vendor/golang.org/x/net/http2/not_go18.go create mode 100644 vendor/golang.org/x/net/http2/not_go19.go create mode 100644 vendor/golang.org/x/net/idna/idna.go create mode 100644 vendor/golang.org/x/net/idna/tables.go create mode 100644 vendor/golang.org/x/net/internal/socket/rawconn_stub.go create mode 100644 vendor/golang.org/x/net/internal/socket/reflect.go create mode 100644 vendor/golang.org/x/net/ipv4/packet_go1_8.go create mode 100644 vendor/golang.org/x/net/ipv4/packet_go1_9.go create mode 100644 vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go create mode 100644 vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go create mode 100644 vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go create mode 100644 vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go create mode 100644 vendor/golang.org/x/net/lex/httplex/httplex.go create mode 100644 vendor/golang.org/x/sys/cpu/cpu_arm64.go create mode 100644 vendor/golang.org/x/sys/cpu/cpu_gccgo.c create mode 100644 vendor/golang.org/x/sys/cpu/cpu_gccgo.go create mode 100644 vendor/golang.org/x/sys/cpu/cpu_ppc64x.go create mode 100644 vendor/golang.org/x/sys/cpu/cpu_s390x.go create mode 100644 vendor/golang.org/x/sys/windows/asm_windows_386.s create mode 100644 vendor/golang.org/x/sys/windows/asm_windows_amd64.s create mode 100644 vendor/golang.org/x/text/language/Makefile create mode 100644 vendor/golang.org/x/text/language/common.go create mode 100644 vendor/golang.org/x/text/language/index.go create mode 100644 vendor/golang.org/x/text/language/lookup.go create mode 100644 vendor/golang.org/x/time/rate/rate_go16.go create mode 100644 vendor/golang.org/x/time/rate/rate_go17.go create mode 100644 vendor/golang.org/x/tools/go/loader/cgo.go create mode 100644 vendor/golang.org/x/tools/go/loader/cgo_pkgconfig.go create mode 100644 vendor/golang.org/x/tools/imports/fastwalk.go create mode 100644 vendor/golang.org/x/tools/imports/fastwalk_dirent_fileno.go create mode 100644 vendor/golang.org/x/tools/imports/fastwalk_dirent_ino.go create mode 100644 vendor/golang.org/x/tools/imports/fastwalk_portable.go create mode 100644 vendor/golang.org/x/tools/imports/fastwalk_unix.go create mode 100644 vendor/golang.org/x/tools/imports/fix.go create mode 100644 vendor/golang.org/x/tools/imports/imports.go create mode 100644 vendor/golang.org/x/tools/imports/sortimports.go create mode 100644 vendor/golang.org/x/tools/imports/zstdlib.go diff --git a/vendor/4d63.com/tz/README.md b/vendor/4d63.com/tz/README.md index 7c06c772aaa..90c3c34a2aa 100644 --- a/vendor/4d63.com/tz/README.md +++ b/vendor/4d63.com/tz/README.md @@ -1,5 +1,7 @@ # tz -[![Tests](https://github.com/leighmcculloch/go-tz/workflows/tests/badge.svg)](https://github.com/leighmcculloch/go-tz/actions) +[![TravisCI](https://img.shields.io/travis/leighmcculloch/go-tz.svg)](https://travis-ci.org/leighmcculloch/go-tz) +[![CircleCI](https://circleci.com/gh/leighmcculloch/go-tz.svg?style=svg)](https://circleci.com/gh/leighmcculloch/go-tz) +[![Codecov](https://img.shields.io/codecov/c/github/leighmcculloch/go-tz.svg)](https://codecov.io/gh/leighmcculloch/go-tz) [![Go Report Card](https://goreportcard.com/badge/github.com/leighmcculloch/go-tz)](https://goreportcard.com/report/github.com/leighmcculloch/go-tz) [![Go docs](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/4d63.com/tz) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/version/version.go b/vendor/github.com/Azure/azure-sdk-for-go/version/version.go index 1fc8748fa47..60e618dac23 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/version/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/version/version.go @@ -18,4 +18,4 @@ package version // Changes may cause incorrect behavior and will be lost if the code is regenerated. // Number contains the semantic version of this SDK. -const Number = "v32.1.0" +const Number = "v32.0.0" diff --git a/vendor/github.com/Shopify/sarama/dev.yml b/vendor/github.com/Shopify/sarama/dev.yml new file mode 100644 index 00000000000..481f68144bb --- /dev/null +++ b/vendor/github.com/Shopify/sarama/dev.yml @@ -0,0 +1,10 @@ +name: sarama + +up: + - go: + version: '1.13.1' + +commands: + test: + run: make test + desc: 'run unit tests' diff --git a/vendor/github.com/Shopify/sarama/examples/README.md b/vendor/github.com/Shopify/sarama/examples/README.md new file mode 100644 index 00000000000..4c32436bc42 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/README.md @@ -0,0 +1,12 @@ +# Sarama examples + +This folder contains example applications to demonstrate the use of Sarama. For code snippet examples on how to use the different types in Sarama, see [Sarama's API documentation on godoc.org](https://godoc.org/github.com/Shopify/sarama) + +In these examples, we use `github.com/Shopify/sarama` as import path. We do this to ensure all the examples are up to date with the latest changes in Sarama. For your own applications, you may want to use `gopkg.in/Shopify/sarama.v1` to lock into a stable API version. + +#### HTTP server + +[http_server](./http_server) is a simple HTTP server uses both the sync producer to produce data as part of the request handling cycle, as well as the async producer to maintain an access log. It also uses the [mocks subpackage](https://godoc.org/github.com/Shopify/sarama/mocks) to test both. + +#### SASL SCRAM Authentication +[sasl_scram_authentication](./sasl_scram_authentication) is an example of how to authenticate to a Kafka cluster using SASL SCRAM-SHA-256 or SCRAM-SHA-512 mechanisms. diff --git a/vendor/github.com/Shopify/sarama/examples/consumergroup/README.md b/vendor/github.com/Shopify/sarama/examples/consumergroup/README.md new file mode 100644 index 00000000000..cfe8057695e --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/consumergroup/README.md @@ -0,0 +1,7 @@ +# Consumergroup example + +This example shows you how to use the Sarama consumer group consumer. The example simply starts consuming the given Kafka topics and logs the consumed messages. + +```bash +$ go run main.go -brokers="127.0.0.1:9092" -topics="sarama" -group="example" +``` \ No newline at end of file diff --git a/vendor/github.com/Shopify/sarama/examples/consumergroup/go.mod b/vendor/github.com/Shopify/sarama/examples/consumergroup/go.mod new file mode 100644 index 00000000000..018fabe963b --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/consumergroup/go.mod @@ -0,0 +1,5 @@ +module github.com/Shopify/sarama/examples/consumer + +replace github.com/Shopify/sarama => ../../ + +require github.com/Shopify/sarama v1.22.0 diff --git a/vendor/github.com/Shopify/sarama/examples/consumergroup/go.sum b/vendor/github.com/Shopify/sarama/examples/consumergroup/go.sum new file mode 100644 index 00000000000..b2189833554 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/consumergroup/go.sum @@ -0,0 +1,34 @@ +github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 h1:2T/jmrHeTezcCM58lvEQXs0UpQJCo5SoGAcg+mbSTIg= +github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41 h1:GeinFsrjWz97fAxVUEd748aV0cYL+I6k44gFJTCVvpU= +github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/vendor/github.com/Shopify/sarama/examples/consumergroup/main.go b/vendor/github.com/Shopify/sarama/examples/consumergroup/main.go new file mode 100644 index 00000000000..ebbceed027b --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/consumergroup/main.go @@ -0,0 +1,161 @@ +package main + +import ( + "context" + "flag" + "log" + "os" + "os/signal" + "strings" + "sync" + "syscall" + + "github.com/Shopify/sarama" +) + +// Sarama configuration options +var ( + brokers = "" + version = "" + group = "" + topics = "" + assignor = "" + oldest = true + verbose = false +) + +func init() { + flag.StringVar(&brokers, "brokers", "", "Kafka bootstrap brokers to connect to, as a comma separated list") + flag.StringVar(&group, "group", "", "Kafka consumer group definition") + flag.StringVar(&version, "version", "2.1.1", "Kafka cluster version") + flag.StringVar(&topics, "topics", "", "Kafka topics to be consumed, as a comma seperated list") + flag.StringVar(&assignor, "assignor", "range", "Consumer group partition assignment strategy (range, roundrobin, sticky)") + flag.BoolVar(&oldest, "oldest", true, "Kafka consumer consume initial offset from oldest") + flag.BoolVar(&verbose, "verbose", false, "Sarama logging") + flag.Parse() + + if len(brokers) == 0 { + panic("no Kafka bootstrap brokers defined, please set the -brokers flag") + } + + if len(topics) == 0 { + panic("no topics given to be consumed, please set the -topics flag") + } + + if len(group) == 0 { + panic("no Kafka consumer group defined, please set the -group flag") + } +} + +func main() { + log.Println("Starting a new Sarama consumer") + + if verbose { + sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags) + } + + version, err := sarama.ParseKafkaVersion(version) + if err != nil { + log.Panicf("Error parsing Kafka version: %v", err) + } + + /** + * Construct a new Sarama configuration. + * The Kafka cluster version has to be defined before the consumer/producer is initialized. + */ + config := sarama.NewConfig() + config.Version = version + + switch assignor { + case "sticky": + config.Consumer.Group.Rebalance.Strategy = sarama.BalanceStrategySticky + case "roundrobin": + config.Consumer.Group.Rebalance.Strategy = sarama.BalanceStrategyRoundRobin + case "range": + config.Consumer.Group.Rebalance.Strategy = sarama.BalanceStrategyRange + default: + log.Panicf("Unrecognized consumer group partition assignor: %s", assignor) + } + + if oldest { + config.Consumer.Offsets.Initial = sarama.OffsetOldest + } + + /** + * Setup a new Sarama consumer group + */ + consumer := Consumer{ + ready: make(chan bool), + } + + ctx, cancel := context.WithCancel(context.Background()) + client, err := sarama.NewConsumerGroup(strings.Split(brokers, ","), group, config) + if err != nil { + log.Panicf("Error creating consumer group client: %v", err) + } + + wg := &sync.WaitGroup{} + wg.Add(1) + go func() { + defer wg.Done() + for { + if err := client.Consume(ctx, strings.Split(topics, ","), &consumer); err != nil { + log.Panicf("Error from consumer: %v", err) + } + // check if context was cancelled, signaling that the consumer should stop + if ctx.Err() != nil { + return + } + consumer.ready = make(chan bool) + } + }() + + <-consumer.ready // Await till the consumer has been set up + log.Println("Sarama consumer up and running!...") + + sigterm := make(chan os.Signal, 1) + signal.Notify(sigterm, syscall.SIGINT, syscall.SIGTERM) + select { + case <-ctx.Done(): + log.Println("terminating: context cancelled") + case <-sigterm: + log.Println("terminating: via signal") + } + cancel() + wg.Wait() + if err = client.Close(); err != nil { + log.Panicf("Error closing client: %v", err) + } +} + +// Consumer represents a Sarama consumer group consumer +type Consumer struct { + ready chan bool +} + +// Setup is run at the beginning of a new session, before ConsumeClaim +func (consumer *Consumer) Setup(sarama.ConsumerGroupSession) error { + // Mark the consumer as ready + close(consumer.ready) + return nil +} + +// Cleanup is run at the end of a session, once all ConsumeClaim goroutines have exited +func (consumer *Consumer) Cleanup(sarama.ConsumerGroupSession) error { + return nil +} + +// ConsumeClaim must start a consumer loop of ConsumerGroupClaim's Messages(). +func (consumer *Consumer) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { + + // NOTE: + // Do not move the code below to a goroutine. + // The `ConsumeClaim` itself is called within a goroutine, see: + // https://github.com/Shopify/sarama/blob/master/consumer_group.go#L27-L29 + for message := range claim.Messages() { + log.Printf("Message claimed: value = %s, timestamp = %v, topic = %s", string(message.Value), message.Timestamp, message.Topic) + session.MarkMessage(message, "") + } + + return nil +} diff --git a/vendor/github.com/Shopify/sarama/examples/http_server/README.md b/vendor/github.com/Shopify/sarama/examples/http_server/README.md new file mode 100644 index 00000000000..5ff2bc2533b --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/http_server/README.md @@ -0,0 +1,7 @@ +# HTTP server example + +This HTTP server example shows you how to use the AsyncProducer and SyncProducer, and how to test them using mocks. The server simply sends the data of the HTTP request's query string to Kafka, and send a 200 result if that succeeds. For every request, it will send an access log entry to Kafka as well in the background. + +If you need to know whether a message was successfully sent to the Kafka cluster before you can send your HTTP response, using the `SyncProducer` is probably the simplest way to achieve this. If you don't care, e.g. for the access log, using the `AsyncProducer` will let you fire and forget. You can send the HTTP response, while the message is being produced in the background. + +One important thing to note is that both the `SyncProducer` and `AsyncProducer` are **thread-safe**. Go's `http.Server` handles requests concurrently in different goroutines, but you can use a single producer safely. This will actually achieve efficiency gains as the producer will be able to batch messages from concurrent requests together. diff --git a/vendor/github.com/Shopify/sarama/examples/http_server/http_server.go b/vendor/github.com/Shopify/sarama/examples/http_server/http_server.go new file mode 100644 index 00000000000..b6d83c5dc9d --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/http_server/http_server.go @@ -0,0 +1,247 @@ +package main + +import ( + "github.com/Shopify/sarama" + + "crypto/tls" + "crypto/x509" + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "log" + "net/http" + "os" + "strings" + "time" +) + +var ( + addr = flag.String("addr", ":8080", "The address to bind to") + brokers = flag.String("brokers", os.Getenv("KAFKA_PEERS"), "The Kafka brokers to connect to, as a comma separated list") + verbose = flag.Bool("verbose", false, "Turn on Sarama logging") + certFile = flag.String("certificate", "", "The optional certificate file for client authentication") + keyFile = flag.String("key", "", "The optional key file for client authentication") + caFile = flag.String("ca", "", "The optional certificate authority file for TLS client authentication") + verifySsl = flag.Bool("verify", false, "Optional verify ssl certificates chain") +) + +func main() { + flag.Parse() + + if *verbose { + sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags) + } + + if *brokers == "" { + flag.PrintDefaults() + os.Exit(1) + } + + brokerList := strings.Split(*brokers, ",") + log.Printf("Kafka brokers: %s", strings.Join(brokerList, ", ")) + + server := &Server{ + DataCollector: newDataCollector(brokerList), + AccessLogProducer: newAccessLogProducer(brokerList), + } + defer func() { + if err := server.Close(); err != nil { + log.Println("Failed to close server", err) + } + }() + + log.Fatal(server.Run(*addr)) +} + +func createTlsConfiguration() (t *tls.Config) { + if *certFile != "" && *keyFile != "" && *caFile != "" { + cert, err := tls.LoadX509KeyPair(*certFile, *keyFile) + if err != nil { + log.Fatal(err) + } + + caCert, err := ioutil.ReadFile(*caFile) + if err != nil { + log.Fatal(err) + } + + caCertPool := x509.NewCertPool() + caCertPool.AppendCertsFromPEM(caCert) + + t = &tls.Config{ + Certificates: []tls.Certificate{cert}, + RootCAs: caCertPool, + InsecureSkipVerify: *verifySsl, + } + } + // will be nil by default if nothing is provided + return t +} + +type Server struct { + DataCollector sarama.SyncProducer + AccessLogProducer sarama.AsyncProducer +} + +func (s *Server) Close() error { + if err := s.DataCollector.Close(); err != nil { + log.Println("Failed to shut down data collector cleanly", err) + } + + if err := s.AccessLogProducer.Close(); err != nil { + log.Println("Failed to shut down access log producer cleanly", err) + } + + return nil +} + +func (s *Server) Handler() http.Handler { + return s.withAccessLog(s.collectQueryStringData()) +} + +func (s *Server) Run(addr string) error { + httpServer := &http.Server{ + Addr: addr, + Handler: s.Handler(), + } + + log.Printf("Listening for requests on %s...\n", addr) + return httpServer.ListenAndServe() +} + +func (s *Server) collectQueryStringData() http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" { + http.NotFound(w, r) + return + } + + // We are not setting a message key, which means that all messages will + // be distributed randomly over the different partitions. + partition, offset, err := s.DataCollector.SendMessage(&sarama.ProducerMessage{ + Topic: "important", + Value: sarama.StringEncoder(r.URL.RawQuery), + }) + + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + fmt.Fprintf(w, "Failed to store your data:, %s", err) + } else { + // The tuple (topic, partition, offset) can be used as a unique identifier + // for a message in a Kafka cluster. + fmt.Fprintf(w, "Your data is stored with unique identifier important/%d/%d", partition, offset) + } + }) +} + +type accessLogEntry struct { + Method string `json:"method"` + Host string `json:"host"` + Path string `json:"path"` + IP string `json:"ip"` + ResponseTime float64 `json:"response_time"` + + encoded []byte + err error +} + +func (ale *accessLogEntry) ensureEncoded() { + if ale.encoded == nil && ale.err == nil { + ale.encoded, ale.err = json.Marshal(ale) + } +} + +func (ale *accessLogEntry) Length() int { + ale.ensureEncoded() + return len(ale.encoded) +} + +func (ale *accessLogEntry) Encode() ([]byte, error) { + ale.ensureEncoded() + return ale.encoded, ale.err +} + +func (s *Server) withAccessLog(next http.Handler) http.Handler { + + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + started := time.Now() + + next.ServeHTTP(w, r) + + entry := &accessLogEntry{ + Method: r.Method, + Host: r.Host, + Path: r.RequestURI, + IP: r.RemoteAddr, + ResponseTime: float64(time.Since(started)) / float64(time.Second), + } + + // We will use the client's IP address as key. This will cause + // all the access log entries of the same IP address to end up + // on the same partition. + s.AccessLogProducer.Input() <- &sarama.ProducerMessage{ + Topic: "access_log", + Key: sarama.StringEncoder(r.RemoteAddr), + Value: entry, + } + }) +} + +func newDataCollector(brokerList []string) sarama.SyncProducer { + + // For the data collector, we are looking for strong consistency semantics. + // Because we don't change the flush settings, sarama will try to produce messages + // as fast as possible to keep latency low. + config := sarama.NewConfig() + config.Producer.RequiredAcks = sarama.WaitForAll // Wait for all in-sync replicas to ack the message + config.Producer.Retry.Max = 10 // Retry up to 10 times to produce the message + config.Producer.Return.Successes = true + tlsConfig := createTlsConfiguration() + if tlsConfig != nil { + config.Net.TLS.Config = tlsConfig + config.Net.TLS.Enable = true + } + + // On the broker side, you may want to change the following settings to get + // stronger consistency guarantees: + // - For your broker, set `unclean.leader.election.enable` to false + // - For the topic, you could increase `min.insync.replicas`. + + producer, err := sarama.NewSyncProducer(brokerList, config) + if err != nil { + log.Fatalln("Failed to start Sarama producer:", err) + } + + return producer +} + +func newAccessLogProducer(brokerList []string) sarama.AsyncProducer { + + // For the access log, we are looking for AP semantics, with high throughput. + // By creating batches of compressed messages, we reduce network I/O at a cost of more latency. + config := sarama.NewConfig() + tlsConfig := createTlsConfiguration() + if tlsConfig != nil { + config.Net.TLS.Enable = true + config.Net.TLS.Config = tlsConfig + } + config.Producer.RequiredAcks = sarama.WaitForLocal // Only wait for the leader to ack + config.Producer.Compression = sarama.CompressionSnappy // Compress messages + config.Producer.Flush.Frequency = 500 * time.Millisecond // Flush batches every 500ms + + producer, err := sarama.NewAsyncProducer(brokerList, config) + if err != nil { + log.Fatalln("Failed to start Sarama producer:", err) + } + + // We will just log to STDOUT if we're not able to produce messages. + // Note: messages will only be returned here after all retry attempts are exhausted. + go func() { + for err := range producer.Errors() { + log.Println("Failed to write access log entry:", err) + } + }() + + return producer +} diff --git a/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/README.md b/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/README.md new file mode 100644 index 00000000000..b21dd7b23fa --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/README.md @@ -0,0 +1,4 @@ +Example commande line: + +```./sasl_scram_client -brokers localhost:9094 -username foo -passwd a_password -topic topic_name -tls -algorithm [sha256|sha512]``` + diff --git a/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/main.go b/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/main.go new file mode 100644 index 00000000000..b359b23d860 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/main.go @@ -0,0 +1,170 @@ +package main + +import ( + "crypto/tls" + "crypto/x509" + "flag" + "io/ioutil" + "log" + "os" + "os/signal" + "strings" + + "github.com/Shopify/sarama" +) + +func init() { + sarama.Logger = log.New(os.Stdout, "[Sarama] ", log.LstdFlags) +} + +var ( + brokers = flag.String("brokers", os.Getenv("KAFKA_PEERS"), "The Kafka brokers to connect to, as a comma separated list") + userName = flag.String("username", "", "The SASL username") + passwd = flag.String("passwd", "", "The SASL password") + algorithm = flag.String("algorithm", "", "The SASL SCRAM SHA algorithm sha256 or sha512 as mechanism") + topic = flag.String("topic", "default_topic", "The Kafka topic to use") + certFile = flag.String("certificate", "", "The optional certificate file for client authentication") + keyFile = flag.String("key", "", "The optional key file for client authentication") + caFile = flag.String("ca", "", "The optional certificate authority file for TLS client authentication") + verifySSL = flag.Bool("verify", false, "Optional verify ssl certificates chain") + useTLS = flag.Bool("tls", false, "Use TLS to communicate with the cluster") + mode = flag.String("mode", "produce", "Mode to run in: \"produce\" to produce, \"consume\" to consume") + logMsg = flag.Bool("logmsg", false, "True to log consumed messages to console") + + logger = log.New(os.Stdout, "[Producer] ", log.LstdFlags) +) + +func createTLSConfiguration() (t *tls.Config) { + t = &tls.Config{ + InsecureSkipVerify: *verifySSL, + } + if *certFile != "" && *keyFile != "" && *caFile != "" { + cert, err := tls.LoadX509KeyPair(*certFile, *keyFile) + if err != nil { + log.Fatal(err) + } + + caCert, err := ioutil.ReadFile(*caFile) + if err != nil { + log.Fatal(err) + } + + caCertPool := x509.NewCertPool() + caCertPool.AppendCertsFromPEM(caCert) + + t = &tls.Config{ + Certificates: []tls.Certificate{cert}, + RootCAs: caCertPool, + InsecureSkipVerify: *verifySSL, + } + } + return t +} + +func main() { + flag.Parse() + + if *brokers == "" { + log.Fatalln("at least one broker is required") + } + splitBrokers := strings.Split(*brokers, ",") + + if *userName == "" { + log.Fatalln("SASL username is required") + } + + if *passwd == "" { + log.Fatalln("SASL password is required") + } + + conf := sarama.NewConfig() + conf.Producer.Retry.Max = 1 + conf.Producer.RequiredAcks = sarama.WaitForAll + conf.Producer.Return.Successes = true + conf.Metadata.Full = true + conf.Version = sarama.V0_10_0_0 + conf.ClientID = "sasl_scram_client" + conf.Metadata.Full = true + conf.Net.SASL.Enable = true + conf.Net.SASL.User = *userName + conf.Net.SASL.Password = *passwd + conf.Net.SASL.Handshake = true + if *algorithm == "sha512" { + conf.Net.SASL.SCRAMClientGeneratorFunc = func() sarama.SCRAMClient { return &XDGSCRAMClient{HashGeneratorFcn: SHA512} } + conf.Net.SASL.Mechanism = sarama.SASLMechanism(sarama.SASLTypeSCRAMSHA512) + } else if *algorithm == "sha256" { + conf.Net.SASL.SCRAMClientGeneratorFunc = func() sarama.SCRAMClient { return &XDGSCRAMClient{HashGeneratorFcn: SHA256} } + conf.Net.SASL.Mechanism = sarama.SASLMechanism(sarama.SASLTypeSCRAMSHA256) + + } else { + log.Fatalf("invalid SHA algorithm \"%s\": can be either \"sha256\" or \"sha512\"", *algorithm) + } + + if *useTLS { + conf.Net.TLS.Enable = true + conf.Net.TLS.Config = createTLSConfiguration() + } + + if *mode == "consume" { + consumer, err := sarama.NewConsumer(splitBrokers, conf) + if err != nil { + panic(err) + } + log.Println("consumer created") + defer func() { + if err := consumer.Close(); err != nil { + log.Fatalln(err) + } + }() + log.Println("commence consuming") + partitionConsumer, err := consumer.ConsumePartition(*topic, 0, sarama.OffsetOldest) + if err != nil { + panic(err) + } + + defer func() { + if err := partitionConsumer.Close(); err != nil { + log.Fatalln(err) + } + }() + + // Trap SIGINT to trigger a shutdown. + signals := make(chan os.Signal, 1) + signal.Notify(signals, os.Interrupt) + + consumed := 0 + ConsumerLoop: + for { + log.Println("in the for") + select { + case msg := <-partitionConsumer.Messages(): + log.Printf("Consumed message offset %d\n", msg.Offset) + if *logMsg { + log.Printf("KEY: %s VALUE: %s", msg.Key, msg.Value) + } + consumed++ + case <-signals: + break ConsumerLoop + } + } + + log.Printf("Consumed: %d\n", consumed) + + } else { + syncProducer, err := sarama.NewSyncProducer(splitBrokers, conf) + if err != nil { + logger.Fatalln("failed to create producer: ", err) + } + partition, offset, err := syncProducer.SendMessage(&sarama.ProducerMessage{ + Topic: *topic, + Value: sarama.StringEncoder("test_message"), + }) + if err != nil { + logger.Fatalln("failed to send message to ", *topic, err) + } + logger.Printf("wrote message at partition: %d, offset: %d", partition, offset) + _ = syncProducer.Close() + } + logger.Println("Bye now !") + +} diff --git a/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/scram_client.go b/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/scram_client.go new file mode 100644 index 00000000000..6f62281764b --- /dev/null +++ b/vendor/github.com/Shopify/sarama/examples/sasl_scram_client/scram_client.go @@ -0,0 +1,36 @@ +package main + +import ( + "crypto/sha256" + "crypto/sha512" + "hash" + + "github.com/xdg/scram" +) + +var SHA256 scram.HashGeneratorFcn = func() hash.Hash { return sha256.New() } +var SHA512 scram.HashGeneratorFcn = func() hash.Hash { return sha512.New() } + +type XDGSCRAMClient struct { + *scram.Client + *scram.ClientConversation + scram.HashGeneratorFcn +} + +func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) { + x.Client, err = x.HashGeneratorFcn.NewClient(userName, password, authzID) + if err != nil { + return err + } + x.ClientConversation = x.Client.NewConversation() + return nil +} + +func (x *XDGSCRAMClient) Step(challenge string) (response string, err error) { + response, err = x.ClientConversation.Step(challenge) + return +} + +func (x *XDGSCRAMClient) Done() bool { + return x.ClientConversation.Done() +} diff --git a/vendor/github.com/Shopify/sarama/mocks/README.md b/vendor/github.com/Shopify/sarama/mocks/README.md new file mode 100644 index 00000000000..55a6c2e61cd --- /dev/null +++ b/vendor/github.com/Shopify/sarama/mocks/README.md @@ -0,0 +1,13 @@ +# sarama/mocks + +The `mocks` subpackage includes mock implementations that implement the interfaces of the major sarama types. +You can use them to test your sarama applications using dependency injection. + +The following mock objects are available: + +- [Consumer](https://godoc.org/github.com/Shopify/sarama/mocks#Consumer), which will create [PartitionConsumer](https://godoc.org/github.com/Shopify/sarama/mocks#PartitionConsumer) mocks. +- [AsyncProducer](https://godoc.org/github.com/Shopify/sarama/mocks#AsyncProducer) +- [SyncProducer](https://godoc.org/github.com/Shopify/sarama/mocks#SyncProducer) + +The mocks allow you to set expectations on them. When you close the mocks, the expectations will be verified, +and the results will be reported to the `*testing.T` object you provided when creating the mock. diff --git a/vendor/github.com/Shopify/sarama/mocks/async_producer.go b/vendor/github.com/Shopify/sarama/mocks/async_producer.go new file mode 100644 index 00000000000..488ef0754be --- /dev/null +++ b/vendor/github.com/Shopify/sarama/mocks/async_producer.go @@ -0,0 +1,173 @@ +package mocks + +import ( + "sync" + + "github.com/Shopify/sarama" +) + +// AsyncProducer implements sarama's Producer interface for testing purposes. +// Before you can send messages to it's Input channel, you have to set expectations +// so it knows how to handle the input; it returns an error if the number of messages +// received is bigger then the number of expectations set. You can also set a +// function in each expectation so that the message value is checked by this function +// and an error is returned if the match fails. +type AsyncProducer struct { + l sync.Mutex + t ErrorReporter + expectations []*producerExpectation + closed chan struct{} + input chan *sarama.ProducerMessage + successes chan *sarama.ProducerMessage + errors chan *sarama.ProducerError + lastOffset int64 +} + +// NewAsyncProducer instantiates a new Producer mock. The t argument should +// be the *testing.T instance of your test method. An error will be written to it if +// an expectation is violated. The config argument is used to determine whether it +// should ack successes on the Successes channel. +func NewAsyncProducer(t ErrorReporter, config *sarama.Config) *AsyncProducer { + if config == nil { + config = sarama.NewConfig() + } + mp := &AsyncProducer{ + t: t, + closed: make(chan struct{}, 0), + expectations: make([]*producerExpectation, 0), + input: make(chan *sarama.ProducerMessage, config.ChannelBufferSize), + successes: make(chan *sarama.ProducerMessage, config.ChannelBufferSize), + errors: make(chan *sarama.ProducerError, config.ChannelBufferSize), + } + + go func() { + defer func() { + close(mp.successes) + close(mp.errors) + close(mp.closed) + }() + + for msg := range mp.input { + mp.l.Lock() + if mp.expectations == nil || len(mp.expectations) == 0 { + mp.expectations = nil + mp.t.Errorf("No more expectation set on this mock producer to handle the input message.") + } else { + expectation := mp.expectations[0] + mp.expectations = mp.expectations[1:] + if expectation.CheckFunction != nil { + if val, err := msg.Value.Encode(); err != nil { + mp.t.Errorf("Input message encoding failed: %s", err.Error()) + mp.errors <- &sarama.ProducerError{Err: err, Msg: msg} + } else { + err = expectation.CheckFunction(val) + if err != nil { + mp.t.Errorf("Check function returned an error: %s", err.Error()) + mp.errors <- &sarama.ProducerError{Err: err, Msg: msg} + } + } + } + if expectation.Result == errProduceSuccess { + mp.lastOffset++ + if config.Producer.Return.Successes { + msg.Offset = mp.lastOffset + mp.successes <- msg + } + } else { + if config.Producer.Return.Errors { + mp.errors <- &sarama.ProducerError{Err: expectation.Result, Msg: msg} + } + } + } + mp.l.Unlock() + } + + mp.l.Lock() + if len(mp.expectations) > 0 { + mp.t.Errorf("Expected to exhaust all expectations, but %d are left.", len(mp.expectations)) + } + mp.l.Unlock() + }() + + return mp +} + +//////////////////////////////////////////////// +// Implement Producer interface +//////////////////////////////////////////////// + +// AsyncClose corresponds with the AsyncClose method of sarama's Producer implementation. +// By closing a mock producer, you also tell it that no more input will be provided, so it will +// write an error to the test state if there's any remaining expectations. +func (mp *AsyncProducer) AsyncClose() { + close(mp.input) +} + +// Close corresponds with the Close method of sarama's Producer implementation. +// By closing a mock producer, you also tell it that no more input will be provided, so it will +// write an error to the test state if there's any remaining expectations. +func (mp *AsyncProducer) Close() error { + mp.AsyncClose() + <-mp.closed + return nil +} + +// Input corresponds with the Input method of sarama's Producer implementation. +// You have to set expectations on the mock producer before writing messages to the Input +// channel, so it knows how to handle them. If there is no more remaining expectations and +// a messages is written to the Input channel, the mock producer will write an error to the test +// state object. +func (mp *AsyncProducer) Input() chan<- *sarama.ProducerMessage { + return mp.input +} + +// Successes corresponds with the Successes method of sarama's Producer implementation. +func (mp *AsyncProducer) Successes() <-chan *sarama.ProducerMessage { + return mp.successes +} + +// Errors corresponds with the Errors method of sarama's Producer implementation. +func (mp *AsyncProducer) Errors() <-chan *sarama.ProducerError { + return mp.errors +} + +//////////////////////////////////////////////// +// Setting expectations +//////////////////////////////////////////////// + +// ExpectInputWithCheckerFunctionAndSucceed sets an expectation on the mock producer that a message +// will be provided on the input channel. The mock producer will call the given function to check +// the message value. If an error is returned it will be made available on the Errors channel +// otherwise the mock will handle the message as if it produced successfully, i.e. it will make +// it available on the Successes channel if the Producer.Return.Successes setting is set to true. +func (mp *AsyncProducer) ExpectInputWithCheckerFunctionAndSucceed(cf ValueChecker) { + mp.l.Lock() + defer mp.l.Unlock() + mp.expectations = append(mp.expectations, &producerExpectation{Result: errProduceSuccess, CheckFunction: cf}) +} + +// ExpectInputWithCheckerFunctionAndFail sets an expectation on the mock producer that a message +// will be provided on the input channel. The mock producer will first call the given function to +// check the message value. If an error is returned it will be made available on the Errors channel +// otherwise the mock will handle the message as if it failed to produce successfully. This means +// it will make a ProducerError available on the Errors channel. +func (mp *AsyncProducer) ExpectInputWithCheckerFunctionAndFail(cf ValueChecker, err error) { + mp.l.Lock() + defer mp.l.Unlock() + mp.expectations = append(mp.expectations, &producerExpectation{Result: err, CheckFunction: cf}) +} + +// ExpectInputAndSucceed sets an expectation on the mock producer that a message will be provided +// on the input channel. The mock producer will handle the message as if it is produced successfully, +// i.e. it will make it available on the Successes channel if the Producer.Return.Successes setting +// is set to true. +func (mp *AsyncProducer) ExpectInputAndSucceed() { + mp.ExpectInputWithCheckerFunctionAndSucceed(nil) +} + +// ExpectInputAndFail sets an expectation on the mock producer that a message will be provided +// on the input channel. The mock producer will handle the message as if it failed to produce +// successfully. This means it will make a ProducerError available on the Errors channel. +func (mp *AsyncProducer) ExpectInputAndFail(err error) { + mp.ExpectInputWithCheckerFunctionAndFail(nil, err) +} diff --git a/vendor/github.com/Shopify/sarama/mocks/consumer.go b/vendor/github.com/Shopify/sarama/mocks/consumer.go new file mode 100644 index 00000000000..003d4d3e281 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/mocks/consumer.go @@ -0,0 +1,315 @@ +package mocks + +import ( + "sync" + "sync/atomic" + + "github.com/Shopify/sarama" +) + +// Consumer implements sarama's Consumer interface for testing purposes. +// Before you can start consuming from this consumer, you have to register +// topic/partitions using ExpectConsumePartition, and set expectations on them. +type Consumer struct { + l sync.Mutex + t ErrorReporter + config *sarama.Config + partitionConsumers map[string]map[int32]*PartitionConsumer + metadata map[string][]int32 +} + +// NewConsumer returns a new mock Consumer instance. The t argument should +// be the *testing.T instance of your test method. An error will be written to it if +// an expectation is violated. The config argument can be set to nil. +func NewConsumer(t ErrorReporter, config *sarama.Config) *Consumer { + if config == nil { + config = sarama.NewConfig() + } + + c := &Consumer{ + t: t, + config: config, + partitionConsumers: make(map[string]map[int32]*PartitionConsumer), + } + return c +} + +/////////////////////////////////////////////////// +// Consumer interface implementation +/////////////////////////////////////////////////// + +// ConsumePartition implements the ConsumePartition method from the sarama.Consumer interface. +// Before you can start consuming a partition, you have to set expectations on it using +// ExpectConsumePartition. You can only consume a partition once per consumer. +func (c *Consumer) ConsumePartition(topic string, partition int32, offset int64) (sarama.PartitionConsumer, error) { + c.l.Lock() + defer c.l.Unlock() + + if c.partitionConsumers[topic] == nil || c.partitionConsumers[topic][partition] == nil { + c.t.Errorf("No expectations set for %s/%d", topic, partition) + return nil, errOutOfExpectations + } + + pc := c.partitionConsumers[topic][partition] + if pc.consumed { + return nil, sarama.ConfigurationError("The topic/partition is already being consumed") + } + + if pc.offset != AnyOffset && pc.offset != offset { + c.t.Errorf("Unexpected offset when calling ConsumePartition for %s/%d. Expected %d, got %d.", topic, partition, pc.offset, offset) + } + + pc.consumed = true + return pc, nil +} + +// Topics returns a list of topics, as registered with SetMetadata +func (c *Consumer) Topics() ([]string, error) { + c.l.Lock() + defer c.l.Unlock() + + if c.metadata == nil { + c.t.Errorf("Unexpected call to Topics. Initialize the mock's topic metadata with SetMetadata.") + return nil, sarama.ErrOutOfBrokers + } + + var result []string + for topic := range c.metadata { + result = append(result, topic) + } + return result, nil +} + +// Partitions returns the list of parititons for the given topic, as registered with SetMetadata +func (c *Consumer) Partitions(topic string) ([]int32, error) { + c.l.Lock() + defer c.l.Unlock() + + if c.metadata == nil { + c.t.Errorf("Unexpected call to Partitions. Initialize the mock's topic metadata with SetMetadata.") + return nil, sarama.ErrOutOfBrokers + } + if c.metadata[topic] == nil { + return nil, sarama.ErrUnknownTopicOrPartition + } + + return c.metadata[topic], nil +} + +func (c *Consumer) HighWaterMarks() map[string]map[int32]int64 { + c.l.Lock() + defer c.l.Unlock() + + hwms := make(map[string]map[int32]int64, len(c.partitionConsumers)) + for topic, partitionConsumers := range c.partitionConsumers { + hwm := make(map[int32]int64, len(partitionConsumers)) + for partition, pc := range partitionConsumers { + hwm[partition] = pc.HighWaterMarkOffset() + } + hwms[topic] = hwm + } + + return hwms +} + +// Close implements the Close method from the sarama.Consumer interface. It will close +// all registered PartitionConsumer instances. +func (c *Consumer) Close() error { + c.l.Lock() + defer c.l.Unlock() + + for _, partitions := range c.partitionConsumers { + for _, partitionConsumer := range partitions { + _ = partitionConsumer.Close() + } + } + + return nil +} + +/////////////////////////////////////////////////// +// Expectation API +/////////////////////////////////////////////////// + +// SetTopicMetadata sets the clusters topic/partition metadata, +// which will be returned by Topics() and Partitions(). +func (c *Consumer) SetTopicMetadata(metadata map[string][]int32) { + c.l.Lock() + defer c.l.Unlock() + + c.metadata = metadata +} + +// ExpectConsumePartition will register a topic/partition, so you can set expectations on it. +// The registered PartitionConsumer will be returned, so you can set expectations +// on it using method chaining. Once a topic/partition is registered, you are +// expected to start consuming it using ConsumePartition. If that doesn't happen, +// an error will be written to the error reporter once the mock consumer is closed. It will +// also expect that the +func (c *Consumer) ExpectConsumePartition(topic string, partition int32, offset int64) *PartitionConsumer { + c.l.Lock() + defer c.l.Unlock() + + if c.partitionConsumers[topic] == nil { + c.partitionConsumers[topic] = make(map[int32]*PartitionConsumer) + } + + if c.partitionConsumers[topic][partition] == nil { + c.partitionConsumers[topic][partition] = &PartitionConsumer{ + t: c.t, + topic: topic, + partition: partition, + offset: offset, + messages: make(chan *sarama.ConsumerMessage, c.config.ChannelBufferSize), + errors: make(chan *sarama.ConsumerError, c.config.ChannelBufferSize), + } + } + + return c.partitionConsumers[topic][partition] +} + +/////////////////////////////////////////////////// +// PartitionConsumer mock type +/////////////////////////////////////////////////// + +// PartitionConsumer implements sarama's PartitionConsumer interface for testing purposes. +// It is returned by the mock Consumers ConsumePartitionMethod, but only if it is +// registered first using the Consumer's ExpectConsumePartition method. Before consuming the +// Errors and Messages channel, you should specify what values will be provided on these +// channels using YieldMessage and YieldError. +type PartitionConsumer struct { + highWaterMarkOffset int64 // must be at the top of the struct because https://golang.org/pkg/sync/atomic/#pkg-note-BUG + l sync.Mutex + t ErrorReporter + topic string + partition int32 + offset int64 + messages chan *sarama.ConsumerMessage + errors chan *sarama.ConsumerError + singleClose sync.Once + consumed bool + errorsShouldBeDrained bool + messagesShouldBeDrained bool +} + +/////////////////////////////////////////////////// +// PartitionConsumer interface implementation +/////////////////////////////////////////////////// + +// AsyncClose implements the AsyncClose method from the sarama.PartitionConsumer interface. +func (pc *PartitionConsumer) AsyncClose() { + pc.singleClose.Do(func() { + close(pc.messages) + close(pc.errors) + }) +} + +// Close implements the Close method from the sarama.PartitionConsumer interface. It will +// verify whether the partition consumer was actually started. +func (pc *PartitionConsumer) Close() error { + if !pc.consumed { + pc.t.Errorf("Expectations set on %s/%d, but no partition consumer was started.", pc.topic, pc.partition) + return errPartitionConsumerNotStarted + } + + if pc.errorsShouldBeDrained && len(pc.errors) > 0 { + pc.t.Errorf("Expected the errors channel for %s/%d to be drained on close, but found %d errors.", pc.topic, pc.partition, len(pc.errors)) + } + + if pc.messagesShouldBeDrained && len(pc.messages) > 0 { + pc.t.Errorf("Expected the messages channel for %s/%d to be drained on close, but found %d messages.", pc.topic, pc.partition, len(pc.messages)) + } + + pc.AsyncClose() + + var ( + closeErr error + wg sync.WaitGroup + ) + + wg.Add(1) + go func() { + defer wg.Done() + + var errs = make(sarama.ConsumerErrors, 0) + for err := range pc.errors { + errs = append(errs, err) + } + + if len(errs) > 0 { + closeErr = errs + } + }() + + wg.Add(1) + go func() { + defer wg.Done() + for range pc.messages { + // drain + } + }() + + wg.Wait() + return closeErr +} + +// Errors implements the Errors method from the sarama.PartitionConsumer interface. +func (pc *PartitionConsumer) Errors() <-chan *sarama.ConsumerError { + return pc.errors +} + +// Messages implements the Messages method from the sarama.PartitionConsumer interface. +func (pc *PartitionConsumer) Messages() <-chan *sarama.ConsumerMessage { + return pc.messages +} + +func (pc *PartitionConsumer) HighWaterMarkOffset() int64 { + return atomic.LoadInt64(&pc.highWaterMarkOffset) + 1 +} + +/////////////////////////////////////////////////// +// Expectation API +/////////////////////////////////////////////////// + +// YieldMessage will yield a messages Messages channel of this partition consumer +// when it is consumed. By default, the mock consumer will not verify whether this +// message was consumed from the Messages channel, because there are legitimate +// reasons forthis not to happen. ou can call ExpectMessagesDrainedOnClose so it will +// verify that the channel is empty on close. +func (pc *PartitionConsumer) YieldMessage(msg *sarama.ConsumerMessage) { + pc.l.Lock() + defer pc.l.Unlock() + + msg.Topic = pc.topic + msg.Partition = pc.partition + msg.Offset = atomic.AddInt64(&pc.highWaterMarkOffset, 1) + + pc.messages <- msg +} + +// YieldError will yield an error on the Errors channel of this partition consumer +// when it is consumed. By default, the mock consumer will not verify whether this error was +// consumed from the Errors channel, because there are legitimate reasons for this +// not to happen. You can call ExpectErrorsDrainedOnClose so it will verify that +// the channel is empty on close. +func (pc *PartitionConsumer) YieldError(err error) { + pc.errors <- &sarama.ConsumerError{ + Topic: pc.topic, + Partition: pc.partition, + Err: err, + } +} + +// ExpectMessagesDrainedOnClose sets an expectation on the partition consumer +// that the messages channel will be fully drained when Close is called. If this +// expectation is not met, an error is reported to the error reporter. +func (pc *PartitionConsumer) ExpectMessagesDrainedOnClose() { + pc.messagesShouldBeDrained = true +} + +// ExpectErrorsDrainedOnClose sets an expectation on the partition consumer +// that the errors channel will be fully drained when Close is called. If this +// expectation is not met, an error is reported to the error reporter. +func (pc *PartitionConsumer) ExpectErrorsDrainedOnClose() { + pc.errorsShouldBeDrained = true +} diff --git a/vendor/github.com/Shopify/sarama/mocks/mocks.go b/vendor/github.com/Shopify/sarama/mocks/mocks.go new file mode 100644 index 00000000000..4adb838d996 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/mocks/mocks.go @@ -0,0 +1,48 @@ +/* +Package mocks provides mocks that can be used for testing applications +that use Sarama. The mock types provided by this package implement the +interfaces Sarama exports, so you can use them for dependency injection +in your tests. + +All mock instances require you to set expectations on them before you +can use them. It will determine how the mock will behave. If an +expectation is not met, it will make your test fail. + +NOTE: this package currently does not fall under the API stability +guarantee of Sarama as it is still considered experimental. +*/ +package mocks + +import ( + "errors" + + "github.com/Shopify/sarama" +) + +// ErrorReporter is a simple interface that includes the testing.T methods we use to report +// expectation violations when using the mock objects. +type ErrorReporter interface { + Errorf(string, ...interface{}) +} + +// ValueChecker is a function type to be set in each expectation of the producer mocks +// to check the value passed. +type ValueChecker func(val []byte) error + +var ( + errProduceSuccess error = nil + errOutOfExpectations = errors.New("No more expectations set on mock") + errPartitionConsumerNotStarted = errors.New("The partition consumer was never started") +) + +const AnyOffset int64 = -1000 + +type producerExpectation struct { + Result error + CheckFunction ValueChecker +} + +type consumerExpectation struct { + Err error + Msg *sarama.ConsumerMessage +} diff --git a/vendor/github.com/Shopify/sarama/mocks/sync_producer.go b/vendor/github.com/Shopify/sarama/mocks/sync_producer.go new file mode 100644 index 00000000000..3f4986e2f8c --- /dev/null +++ b/vendor/github.com/Shopify/sarama/mocks/sync_producer.go @@ -0,0 +1,157 @@ +package mocks + +import ( + "sync" + + "github.com/Shopify/sarama" +) + +// SyncProducer implements sarama's SyncProducer interface for testing purposes. +// Before you can use it, you have to set expectations on the mock SyncProducer +// to tell it how to handle calls to SendMessage, so you can easily test success +// and failure scenarios. +type SyncProducer struct { + l sync.Mutex + t ErrorReporter + expectations []*producerExpectation + lastOffset int64 +} + +// NewSyncProducer instantiates a new SyncProducer mock. The t argument should +// be the *testing.T instance of your test method. An error will be written to it if +// an expectation is violated. The config argument is currently unused, but is +// maintained to be compatible with the async Producer. +func NewSyncProducer(t ErrorReporter, config *sarama.Config) *SyncProducer { + return &SyncProducer{ + t: t, + expectations: make([]*producerExpectation, 0), + } +} + +//////////////////////////////////////////////// +// Implement SyncProducer interface +//////////////////////////////////////////////// + +// SendMessage corresponds with the SendMessage method of sarama's SyncProducer implementation. +// You have to set expectations on the mock producer before calling SendMessage, so it knows +// how to handle them. You can set a function in each expectation so that the message value +// checked by this function and an error is returned if the match fails. +// If there is no more remaining expectation when SendMessage is called, +// the mock producer will write an error to the test state object. +func (sp *SyncProducer) SendMessage(msg *sarama.ProducerMessage) (partition int32, offset int64, err error) { + sp.l.Lock() + defer sp.l.Unlock() + + if len(sp.expectations) > 0 { + expectation := sp.expectations[0] + sp.expectations = sp.expectations[1:] + if expectation.CheckFunction != nil { + val, err := msg.Value.Encode() + if err != nil { + sp.t.Errorf("Input message encoding failed: %s", err.Error()) + return -1, -1, err + } + + errCheck := expectation.CheckFunction(val) + if errCheck != nil { + sp.t.Errorf("Check function returned an error: %s", errCheck.Error()) + return -1, -1, errCheck + } + } + if expectation.Result == errProduceSuccess { + sp.lastOffset++ + msg.Offset = sp.lastOffset + return 0, msg.Offset, nil + } + return -1, -1, expectation.Result + } + sp.t.Errorf("No more expectation set on this mock producer to handle the input message.") + return -1, -1, errOutOfExpectations +} + +// SendMessages corresponds with the SendMessages method of sarama's SyncProducer implementation. +// You have to set expectations on the mock producer before calling SendMessages, so it knows +// how to handle them. If there is no more remaining expectations when SendMessages is called, +// the mock producer will write an error to the test state object. +func (sp *SyncProducer) SendMessages(msgs []*sarama.ProducerMessage) error { + sp.l.Lock() + defer sp.l.Unlock() + + if len(sp.expectations) >= len(msgs) { + expectations := sp.expectations[0:len(msgs)] + sp.expectations = sp.expectations[len(msgs):] + + for i, expectation := range expectations { + if expectation.CheckFunction != nil { + val, err := msgs[i].Value.Encode() + if err != nil { + sp.t.Errorf("Input message encoding failed: %s", err.Error()) + return err + } + errCheck := expectation.CheckFunction(val) + if errCheck != nil { + sp.t.Errorf("Check function returned an error: %s", errCheck.Error()) + return errCheck + } + } + if expectation.Result != errProduceSuccess { + return expectation.Result + } + } + return nil + } + sp.t.Errorf("Insufficient expectations set on this mock producer to handle the input messages.") + return errOutOfExpectations +} + +// Close corresponds with the Close method of sarama's SyncProducer implementation. +// By closing a mock syncproducer, you also tell it that no more SendMessage calls will follow, +// so it will write an error to the test state if there's any remaining expectations. +func (sp *SyncProducer) Close() error { + sp.l.Lock() + defer sp.l.Unlock() + + if len(sp.expectations) > 0 { + sp.t.Errorf("Expected to exhaust all expectations, but %d are left.", len(sp.expectations)) + } + + return nil +} + +//////////////////////////////////////////////// +// Setting expectations +//////////////////////////////////////////////// + +// ExpectSendMessageWithCheckerFunctionAndSucceed sets an expectation on the mock producer that SendMessage +// will be called. The mock producer will first call the given function to check the message value. +// It will cascade the error of the function, if any, or handle the message as if it produced +// successfully, i.e. by returning a valid partition, and offset, and a nil error. +func (sp *SyncProducer) ExpectSendMessageWithCheckerFunctionAndSucceed(cf ValueChecker) { + sp.l.Lock() + defer sp.l.Unlock() + sp.expectations = append(sp.expectations, &producerExpectation{Result: errProduceSuccess, CheckFunction: cf}) +} + +// ExpectSendMessageWithCheckerFunctionAndFail sets an expectation on the mock producer that SendMessage will be +// called. The mock producer will first call the given function to check the message value. +// It will cascade the error of the function, if any, or handle the message as if it failed +// to produce successfully, i.e. by returning the provided error. +func (sp *SyncProducer) ExpectSendMessageWithCheckerFunctionAndFail(cf ValueChecker, err error) { + sp.l.Lock() + defer sp.l.Unlock() + sp.expectations = append(sp.expectations, &producerExpectation{Result: err, CheckFunction: cf}) +} + +// ExpectSendMessageAndSucceed sets an expectation on the mock producer that SendMessage will be +// called. The mock producer will handle the message as if it produced successfully, i.e. by +// returning a valid partition, and offset, and a nil error. +func (sp *SyncProducer) ExpectSendMessageAndSucceed() { + sp.ExpectSendMessageWithCheckerFunctionAndSucceed(nil) +} + +// ExpectSendMessageAndFail sets an expectation on the mock producer that SendMessage will be +// called. The mock producer will handle the message as if it failed to produce +// successfully, i.e. by returning the provided error. +func (sp *SyncProducer) ExpectSendMessageAndFail(err error) { + sp.ExpectSendMessageWithCheckerFunctionAndFail(nil, err) +} diff --git a/vendor/github.com/Shopify/sarama/tools/README.md b/vendor/github.com/Shopify/sarama/tools/README.md new file mode 100644 index 00000000000..e344b14504d --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/README.md @@ -0,0 +1,11 @@ +# Sarama tools + +This folder contains applications that are useful for exploration of your Kafka cluster, or instrumentation. +Some of these tools mirror tools that ship with Kafka, but these tools won't require installing the JVM to function. + +- [kafka-console-producer](./kafka-console-producer): a command line tool to produce a single message to your Kafka custer. +- [kafka-console-partitionconsumer](./kafka-console-partitionconsumer): (deprecated) a command line tool to consume a single partition of a topic on your Kafka cluster. +- [kafka-console-consumer](./kafka-console-consumer): a command line tool to consume arbitrary partitions of a topic on your Kafka cluster. +- [kafka-producer-performance](./kafka-producer-performance): a command line tool to performance test producers (sync and async) on your Kafka cluster. + +To install all tools, run `go get github.com/Shopify/sarama/tools/...` diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/README.md b/vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/README.md new file mode 100644 index 00000000000..4e77f0b7050 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/README.md @@ -0,0 +1,29 @@ +# kafka-console-consumer + +A simple command line tool to consume partitions of a topic and print the +messages on the standard output. + +### Installation + + go get github.com/Shopify/sarama/tools/kafka-console-consumer + +### Usage + + # Minimum invocation + kafka-console-consumer -topic=test -brokers=kafka1:9092 + + # It will pick up a KAFKA_PEERS environment variable + export KAFKA_PEERS=kafka1:9092,kafka2:9092,kafka3:9092 + kafka-console-consumer -topic=test + + # You can specify the offset you want to start at. It can be either + # `oldest`, `newest`. The default is `newest`. + kafka-console-consumer -topic=test -offset=oldest + kafka-console-consumer -topic=test -offset=newest + + # You can specify the partition(s) you want to consume as a comma-separated + # list. The default is `all`. + kafka-console-consumer -topic=test -partitions=1,2,3 + + # Display all command line options + kafka-console-consumer -help diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/kafka-console-consumer.go b/vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/kafka-console-consumer.go new file mode 100644 index 00000000000..824801c116c --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-console-consumer/kafka-console-consumer.go @@ -0,0 +1,163 @@ +package main + +import ( + "flag" + "fmt" + "log" + "os" + "os/signal" + "strconv" + "strings" + "sync" + + "github.com/Shopify/sarama" + "github.com/Shopify/sarama/tools/tls" +) + +var ( + brokerList = flag.String("brokers", os.Getenv("KAFKA_PEERS"), "The comma separated list of brokers in the Kafka cluster") + topic = flag.String("topic", "", "REQUIRED: the topic to consume") + partitions = flag.String("partitions", "all", "The partitions to consume, can be 'all' or comma-separated numbers") + offset = flag.String("offset", "newest", "The offset to start with. Can be `oldest`, `newest`") + verbose = flag.Bool("verbose", false, "Whether to turn on sarama logging") + tlsEnabled = flag.Bool("tls-enabled", false, "Whether to enable TLS") + tlsSkipVerify = flag.Bool("tls-skip-verify", false, "Whether skip TLS server cert verification") + tlsClientCert = flag.String("tls-client-cert", "", "Client cert for client authentication (use with -tls-enabled and -tls-client-key)") + tlsClientKey = flag.String("tls-client-key", "", "Client key for client authentication (use with tls-enabled and -tls-client-cert)") + + bufferSize = flag.Int("buffer-size", 256, "The buffer size of the message channel.") + + logger = log.New(os.Stderr, "", log.LstdFlags) +) + +func main() { + flag.Parse() + + if *brokerList == "" { + printUsageErrorAndExit("You have to provide -brokers as a comma-separated list, or set the KAFKA_PEERS environment variable.") + } + + if *topic == "" { + printUsageErrorAndExit("-topic is required") + } + + if *verbose { + sarama.Logger = logger + } + + var initialOffset int64 + switch *offset { + case "oldest": + initialOffset = sarama.OffsetOldest + case "newest": + initialOffset = sarama.OffsetNewest + default: + printUsageErrorAndExit("-offset should be `oldest` or `newest`") + } + + config := sarama.NewConfig() + if *tlsEnabled { + tlsConfig, err := tls.NewConfig(*tlsClientCert, *tlsClientKey) + if err != nil { + printErrorAndExit(69, "Failed to create TLS config: %s", err) + } + + config.Net.TLS.Enable = true + config.Net.TLS.Config = tlsConfig + config.Net.TLS.Config.InsecureSkipVerify = *tlsSkipVerify + } + + c, err := sarama.NewConsumer(strings.Split(*brokerList, ","), config) + if err != nil { + printErrorAndExit(69, "Failed to start consumer: %s", err) + } + + partitionList, err := getPartitions(c) + if err != nil { + printErrorAndExit(69, "Failed to get the list of partitions: %s", err) + } + + var ( + messages = make(chan *sarama.ConsumerMessage, *bufferSize) + closing = make(chan struct{}) + wg sync.WaitGroup + ) + + go func() { + signals := make(chan os.Signal, 1) + signal.Notify(signals, os.Kill, os.Interrupt) + <-signals + logger.Println("Initiating shutdown of consumer...") + close(closing) + }() + + for _, partition := range partitionList { + pc, err := c.ConsumePartition(*topic, partition, initialOffset) + if err != nil { + printErrorAndExit(69, "Failed to start consumer for partition %d: %s", partition, err) + } + + go func(pc sarama.PartitionConsumer) { + <-closing + pc.AsyncClose() + }(pc) + + wg.Add(1) + go func(pc sarama.PartitionConsumer) { + defer wg.Done() + for message := range pc.Messages() { + messages <- message + } + }(pc) + } + + go func() { + for msg := range messages { + fmt.Printf("Partition:\t%d\n", msg.Partition) + fmt.Printf("Offset:\t%d\n", msg.Offset) + fmt.Printf("Key:\t%s\n", string(msg.Key)) + fmt.Printf("Value:\t%s\n", string(msg.Value)) + fmt.Println() + } + }() + + wg.Wait() + logger.Println("Done consuming topic", *topic) + close(messages) + + if err := c.Close(); err != nil { + logger.Println("Failed to close consumer: ", err) + } +} + +func getPartitions(c sarama.Consumer) ([]int32, error) { + if *partitions == "all" { + return c.Partitions(*topic) + } + + tmp := strings.Split(*partitions, ",") + var pList []int32 + for i := range tmp { + val, err := strconv.ParseInt(tmp[i], 10, 32) + if err != nil { + return nil, err + } + pList = append(pList, int32(val)) + } + + return pList, nil +} + +func printErrorAndExit(code int, format string, values ...interface{}) { + fmt.Fprintf(os.Stderr, "ERROR: %s\n", fmt.Sprintf(format, values...)) + fmt.Fprintln(os.Stderr) + os.Exit(code) +} + +func printUsageErrorAndExit(format string, values ...interface{}) { + fmt.Fprintf(os.Stderr, "ERROR: %s\n", fmt.Sprintf(format, values...)) + fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, "Available command line options:") + flag.PrintDefaults() + os.Exit(64) +} diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/README.md b/vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/README.md new file mode 100644 index 00000000000..646dd5f5c29 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/README.md @@ -0,0 +1,28 @@ +# kafka-console-partitionconsumer + +NOTE: this tool is deprecated in favour of the more general and more powerful +`kafka-console-consumer`. + +A simple command line tool to consume a partition of a topic and print the messages +on the standard output. + +### Installation + + go get github.com/Shopify/sarama/tools/kafka-console-partitionconsumer + +### Usage + + # Minimum invocation + kafka-console-partitionconsumer -topic=test -partition=4 -brokers=kafka1:9092 + + # It will pick up a KAFKA_PEERS environment variable + export KAFKA_PEERS=kafka1:9092,kafka2:9092,kafka3:9092 + kafka-console-partitionconsumer -topic=test -partition=4 + + # You can specify the offset you want to start at. It can be either + # `oldest`, `newest`, or a specific offset number + kafka-console-partitionconsumer -topic=test -partition=3 -offset=oldest + kafka-console-partitionconsumer -topic=test -partition=2 -offset=1337 + + # Display all command line options + kafka-console-partitionconsumer -help diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/kafka-console-partitionconsumer.go b/vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/kafka-console-partitionconsumer.go new file mode 100644 index 00000000000..d5e4464de18 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-console-partitionconsumer/kafka-console-partitionconsumer.go @@ -0,0 +1,102 @@ +package main + +import ( + "flag" + "fmt" + "log" + "os" + "os/signal" + "strconv" + "strings" + + "github.com/Shopify/sarama" +) + +var ( + brokerList = flag.String("brokers", os.Getenv("KAFKA_PEERS"), "The comma separated list of brokers in the Kafka cluster") + topic = flag.String("topic", "", "REQUIRED: the topic to consume") + partition = flag.Int("partition", -1, "REQUIRED: the partition to consume") + offset = flag.String("offset", "newest", "The offset to start with. Can be `oldest`, `newest`, or an actual offset") + verbose = flag.Bool("verbose", false, "Whether to turn on sarama logging") + + logger = log.New(os.Stderr, "", log.LstdFlags) +) + +func main() { + flag.Parse() + + if *brokerList == "" { + printUsageErrorAndExit("You have to provide -brokers as a comma-separated list, or set the KAFKA_PEERS environment variable.") + } + + if *topic == "" { + printUsageErrorAndExit("-topic is required") + } + + if *partition == -1 { + printUsageErrorAndExit("-partition is required") + } + + if *verbose { + sarama.Logger = logger + } + + var ( + initialOffset int64 + offsetError error + ) + switch *offset { + case "oldest": + initialOffset = sarama.OffsetOldest + case "newest": + initialOffset = sarama.OffsetNewest + default: + initialOffset, offsetError = strconv.ParseInt(*offset, 10, 64) + } + + if offsetError != nil { + printUsageErrorAndExit("Invalid initial offset: %s", *offset) + } + + c, err := sarama.NewConsumer(strings.Split(*brokerList, ","), nil) + if err != nil { + printErrorAndExit(69, "Failed to start consumer: %s", err) + } + + pc, err := c.ConsumePartition(*topic, int32(*partition), initialOffset) + if err != nil { + printErrorAndExit(69, "Failed to start partition consumer: %s", err) + } + + go func() { + signals := make(chan os.Signal, 1) + signal.Notify(signals, os.Kill, os.Interrupt) + <-signals + pc.AsyncClose() + }() + + for msg := range pc.Messages() { + fmt.Printf("Offset:\t%d\n", msg.Offset) + fmt.Printf("Key:\t%s\n", string(msg.Key)) + fmt.Printf("Value:\t%s\n", string(msg.Value)) + fmt.Println() + } + + if err := c.Close(); err != nil { + logger.Println("Failed to close consumer: ", err) + } +} + +func printErrorAndExit(code int, format string, values ...interface{}) { + fmt.Fprintf(os.Stderr, "ERROR: %s\n", fmt.Sprintf(format, values...)) + fmt.Fprintln(os.Stderr) + os.Exit(code) +} + +func printUsageErrorAndExit(format string, values ...interface{}) { + fmt.Fprintf(os.Stderr, "ERROR: %s\n", fmt.Sprintf(format, values...)) + fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, "Available command line options:") + flag.PrintDefaults() + os.Exit(64) +} diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-console-producer/README.md b/vendor/github.com/Shopify/sarama/tools/kafka-console-producer/README.md new file mode 100644 index 00000000000..6b3a65f211a --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-console-producer/README.md @@ -0,0 +1,34 @@ +# kafka-console-producer + +A simple command line tool to produce a single message to Kafka. + +### Installation + + go get github.com/Shopify/sarama/tools/kafka-console-producer + + +### Usage + + # Minimum invocation + kafka-console-producer -topic=test -value=value -brokers=kafka1:9092 + + # It will pick up a KAFKA_PEERS environment variable + export KAFKA_PEERS=kafka1:9092,kafka2:9092,kafka3:9092 + kafka-console-producer -topic=test -value=value + + # It will read the value from stdin by using pipes + echo "hello world" | kafka-console-producer -topic=test + + # Specify a key: + echo "hello world" | kafka-console-producer -topic=test -key=key + + # Partitioning: by default, kafka-console-producer will partition as follows: + # - manual partitioning if a -partition is provided + # - hash partitioning by key if a -key is provided + # - random partioning otherwise. + # + # You can override this using the -partitioner argument: + echo "hello world" | kafka-console-producer -topic=test -key=key -partitioner=random + + # Display all command line options + kafka-console-producer -help diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-console-producer/kafka-console-producer.go b/vendor/github.com/Shopify/sarama/tools/kafka-console-producer/kafka-console-producer.go new file mode 100644 index 00000000000..f2b672dd54c --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-console-producer/kafka-console-producer.go @@ -0,0 +1,140 @@ +package main + +import ( + "flag" + "fmt" + "io/ioutil" + "log" + "os" + "strings" + + "github.com/Shopify/sarama" + "github.com/Shopify/sarama/tools/tls" + "github.com/rcrowley/go-metrics" +) + +var ( + brokerList = flag.String("brokers", os.Getenv("KAFKA_PEERS"), "The comma separated list of brokers in the Kafka cluster. You can also set the KAFKA_PEERS environment variable") + topic = flag.String("topic", "", "REQUIRED: the topic to produce to") + key = flag.String("key", "", "The key of the message to produce. Can be empty.") + value = flag.String("value", "", "REQUIRED: the value of the message to produce. You can also provide the value on stdin.") + partitioner = flag.String("partitioner", "", "The partitioning scheme to use. Can be `hash`, `manual`, or `random`") + partition = flag.Int("partition", -1, "The partition to produce to.") + verbose = flag.Bool("verbose", false, "Turn on sarama logging to stderr") + showMetrics = flag.Bool("metrics", false, "Output metrics on successful publish to stderr") + silent = flag.Bool("silent", false, "Turn off printing the message's topic, partition, and offset to stdout") + tlsEnabled = flag.Bool("tls-enabled", false, "Whether to enable TLS") + tlsSkipVerify = flag.Bool("tls-skip-verify", false, "Whether skip TLS server cert verification") + tlsClientCert = flag.String("tls-client-cert", "", "Client cert for client authentication (use with -tls-enabled and -tls-client-key)") + tlsClientKey = flag.String("tls-client-key", "", "Client key for client authentication (use with tls-enabled and -tls-client-cert)") + + logger = log.New(os.Stderr, "", log.LstdFlags) +) + +func main() { + flag.Parse() + + if *brokerList == "" { + printUsageErrorAndExit("no -brokers specified. Alternatively, set the KAFKA_PEERS environment variable") + } + + if *topic == "" { + printUsageErrorAndExit("no -topic specified") + } + + if *verbose { + sarama.Logger = logger + } + + config := sarama.NewConfig() + config.Producer.RequiredAcks = sarama.WaitForAll + config.Producer.Return.Successes = true + + if *tlsEnabled { + tlsConfig, err := tls.NewConfig(*tlsClientCert, *tlsClientKey) + if err != nil { + printErrorAndExit(69, "Failed to create TLS config: %s", err) + } + + config.Net.TLS.Enable = true + config.Net.TLS.Config = tlsConfig + config.Net.TLS.Config.InsecureSkipVerify = *tlsSkipVerify + } + + switch *partitioner { + case "": + if *partition >= 0 { + config.Producer.Partitioner = sarama.NewManualPartitioner + } else { + config.Producer.Partitioner = sarama.NewHashPartitioner + } + case "hash": + config.Producer.Partitioner = sarama.NewHashPartitioner + case "random": + config.Producer.Partitioner = sarama.NewRandomPartitioner + case "manual": + config.Producer.Partitioner = sarama.NewManualPartitioner + if *partition == -1 { + printUsageErrorAndExit("-partition is required when partitioning manually") + } + default: + printUsageErrorAndExit(fmt.Sprintf("Partitioner %s not supported.", *partitioner)) + } + + message := &sarama.ProducerMessage{Topic: *topic, Partition: int32(*partition)} + + if *key != "" { + message.Key = sarama.StringEncoder(*key) + } + + if *value != "" { + message.Value = sarama.StringEncoder(*value) + } else if stdinAvailable() { + bytes, err := ioutil.ReadAll(os.Stdin) + if err != nil { + printErrorAndExit(66, "Failed to read data from the standard input: %s", err) + } + message.Value = sarama.ByteEncoder(bytes) + } else { + printUsageErrorAndExit("-value is required, or you have to provide the value on stdin") + } + + producer, err := sarama.NewSyncProducer(strings.Split(*brokerList, ","), config) + if err != nil { + printErrorAndExit(69, "Failed to open Kafka producer: %s", err) + } + defer func() { + if err := producer.Close(); err != nil { + logger.Println("Failed to close Kafka producer cleanly:", err) + } + }() + + partition, offset, err := producer.SendMessage(message) + if err != nil { + printErrorAndExit(69, "Failed to produce message: %s", err) + } else if !*silent { + fmt.Printf("topic=%s\tpartition=%d\toffset=%d\n", *topic, partition, offset) + } + if *showMetrics { + metrics.WriteOnce(config.MetricRegistry, os.Stderr) + } +} + +func printErrorAndExit(code int, format string, values ...interface{}) { + fmt.Fprintf(os.Stderr, "ERROR: %s\n", fmt.Sprintf(format, values...)) + fmt.Fprintln(os.Stderr) + os.Exit(code) +} + +func printUsageErrorAndExit(message string) { + fmt.Fprintln(os.Stderr, "ERROR:", message) + fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, "Available command line options:") + flag.PrintDefaults() + os.Exit(64) +} + +func stdinAvailable() bool { + stat, _ := os.Stdin.Stat() + return (stat.Mode() & os.ModeCharDevice) == 0 +} diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/README.md b/vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/README.md new file mode 100644 index 00000000000..f135edf545b --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/README.md @@ -0,0 +1,20 @@ +# kafka-producer-performance + +A command line tool to test producer performance. + +### Installation + + go get github.com/Shopify/sarama/tools/kafka-producer-performance + + +### Usage + + # Display all command line options + kafka-producer-performance -help + + # Minimum invocation + kafka-producer-performance \ + -brokers=kafka:9092 \ + -message-load=50000 \ + -message-size=100 \ + -topic=producer_test diff --git a/vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/main.go b/vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/main.go new file mode 100644 index 00000000000..41a060a15ba --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/kafka-producer-performance/main.go @@ -0,0 +1,400 @@ +package main + +import ( + "context" + "crypto/rand" + "flag" + "fmt" + "io" + "os" + "strings" + gosync "sync" + "time" + + "github.com/Shopify/sarama" + metrics "github.com/rcrowley/go-metrics" +) + +var ( + sync = flag.Bool( + "sync", + false, + "Use a synchronous producer.", + ) + messageLoad = flag.Int( + "message-load", + 0, + "REQUIRED: The number of messages to produce to -topic.", + ) + messageSize = flag.Int( + "message-size", + 0, + "REQUIRED: The approximate size (in bytes) of each message to produce to -topic.", + ) + brokers = flag.String( + "brokers", + "", + "REQUIRED: A comma separated list of broker addresses.", + ) + topic = flag.String( + "topic", + "", + "REQUIRED: The topic to run the performance test on.", + ) + partition = flag.Int( + "partition", + -1, + "The partition of -topic to run the performance test on.", + ) + throughput = flag.Int( + "throughput", + 0, + "The maximum number of messages to send per second (0 for no limit).", + ) + maxMessageBytes = flag.Int( + "max-message-bytes", + 1000000, + "The max permitted size of a message.", + ) + requiredAcks = flag.Int( + "required-acks", + 1, + "The required number of acks needed from the broker (-1: all, 0: none, 1: local).", + ) + timeout = flag.Duration( + "timeout", + 10*time.Second, + "The duration the producer will wait to receive -required-acks.", + ) + partitioner = flag.String( + "partitioner", + "roundrobin", + "The partitioning scheme to use (hash, manual, random, roundrobin).", + ) + compression = flag.String( + "compression", + "none", + "The compression method to use (none, gzip, snappy, lz4).", + ) + flushFrequency = flag.Duration( + "flush-frequency", + 0, + "The best-effort frequency of flushes.", + ) + flushBytes = flag.Int( + "flush-bytes", + 0, + "The best-effort number of bytes needed to trigger a flush.", + ) + flushMessages = flag.Int( + "flush-messages", + 0, + "The best-effort number of messages needed to trigger a flush.", + ) + flushMaxMessages = flag.Int( + "flush-max-messages", + 0, + "The maximum number of messages the producer will send in a single request.", + ) + retryMax = flag.Int( + "retry-max", + 3, + "The total number of times to retry sending a message.", + ) + retryBackoff = flag.Duration( + "retry-backoff", + 100*time.Millisecond, + "The duration the producer will wait for the cluster to settle between retries.", + ) + clientID = flag.String( + "client-id", + "sarama", + "The client ID sent with every request to the brokers.", + ) + channelBufferSize = flag.Int( + "channel-buffer-size", + 256, + "The number of events to buffer in internal and external channels.", + ) + routines = flag.Int( + "routines", + 1, + "The number of routines to send the messages from (-sync only).", + ) + version = flag.String( + "version", + "0.8.2.0", + "The assumed version of Kafka.", + ) +) + +func parseCompression(scheme string) sarama.CompressionCodec { + switch scheme { + case "none": + return sarama.CompressionNone + case "gzip": + return sarama.CompressionGZIP + case "snappy": + return sarama.CompressionSnappy + case "lz4": + return sarama.CompressionLZ4 + default: + printUsageErrorAndExit(fmt.Sprintf("Unknown -compression: %s", scheme)) + } + panic("should not happen") +} + +func parsePartitioner(scheme string, partition int) sarama.PartitionerConstructor { + if partition < 0 && scheme == "manual" { + printUsageErrorAndExit("-partition must not be -1 for -partitioning=manual") + } + switch scheme { + case "manual": + return sarama.NewManualPartitioner + case "hash": + return sarama.NewHashPartitioner + case "random": + return sarama.NewRandomPartitioner + case "roundrobin": + return sarama.NewRoundRobinPartitioner + default: + printUsageErrorAndExit(fmt.Sprintf("Unknown -partitioning: %s", scheme)) + } + panic("should not happen") +} + +func parseVersion(version string) sarama.KafkaVersion { + result, err := sarama.ParseKafkaVersion(version) + if err != nil { + printUsageErrorAndExit(fmt.Sprintf("unknown -version: %s", version)) + } + return result +} + +func generateMessages(topic string, partition, messageLoad, messageSize int) []*sarama.ProducerMessage { + messages := make([]*sarama.ProducerMessage, messageLoad) + for i := 0; i < messageLoad; i++ { + payload := make([]byte, messageSize) + if _, err := rand.Read(payload); err != nil { + printErrorAndExit(69, "Failed to generate message payload: %s", err) + } + messages[i] = &sarama.ProducerMessage{ + Topic: topic, + Partition: int32(partition), + Value: sarama.ByteEncoder(payload), + } + } + return messages +} + +func main() { + flag.Parse() + + if *brokers == "" { + printUsageErrorAndExit("-brokers is required") + } + if *topic == "" { + printUsageErrorAndExit("-topic is required") + } + if *messageLoad <= 0 { + printUsageErrorAndExit("-message-load must be greater than 0") + } + if *messageSize <= 0 { + printUsageErrorAndExit("-message-size must be greater than 0") + } + if *routines < 1 || *routines > *messageLoad { + printUsageErrorAndExit("-routines must be greater than 0 and less than or equal to -message-load") + } + + config := sarama.NewConfig() + + config.Producer.MaxMessageBytes = *maxMessageBytes + config.Producer.RequiredAcks = sarama.RequiredAcks(*requiredAcks) + config.Producer.Timeout = *timeout + config.Producer.Partitioner = parsePartitioner(*partitioner, *partition) + config.Producer.Compression = parseCompression(*compression) + config.Producer.Flush.Frequency = *flushFrequency + config.Producer.Flush.Bytes = *flushBytes + config.Producer.Flush.Messages = *flushMessages + config.Producer.Flush.MaxMessages = *flushMaxMessages + config.Producer.Return.Successes = true + config.ClientID = *clientID + config.ChannelBufferSize = *channelBufferSize + config.Version = parseVersion(*version) + + if err := config.Validate(); err != nil { + printErrorAndExit(69, "Invalid configuration: %s", err) + } + + // Print out metrics periodically. + done := make(chan struct{}) + ctx, cancel := context.WithCancel(context.Background()) + go func(ctx context.Context) { + defer close(done) + t := time.Tick(5 * time.Second) + for { + select { + case <-t: + printMetrics(os.Stdout, config.MetricRegistry) + case <-ctx.Done(): + return + } + } + }(ctx) + + brokers := strings.Split(*brokers, ",") + if *sync { + runSyncProducer(*topic, *partition, *messageLoad, *messageSize, *routines, + config, brokers, *throughput) + } else { + runAsyncProducer(*topic, *partition, *messageLoad, *messageSize, + config, brokers, *throughput) + } + + cancel() + <-done + + // Print final metrics. + printMetrics(os.Stdout, config.MetricRegistry) +} + +func runAsyncProducer(topic string, partition, messageLoad, messageSize int, + config *sarama.Config, brokers []string, throughput int) { + producer, err := sarama.NewAsyncProducer(brokers, config) + if err != nil { + printErrorAndExit(69, "Failed to create producer: %s", err) + } + defer func() { + if err := producer.Close(); err != nil { + printErrorAndExit(69, "Failed to close producer: %s", err) + } + }() + + messages := generateMessages(topic, partition, messageLoad, messageSize) + + messagesDone := make(chan struct{}) + go func() { + for i := 0; i < messageLoad; i++ { + select { + case <-producer.Successes(): + case err = <-producer.Errors(): + printErrorAndExit(69, "%s", err) + } + } + messagesDone <- struct{}{} + }() + + if throughput > 0 { + ticker := time.NewTicker(time.Second) + for _, message := range messages { + for i := 0; i < throughput; i++ { + producer.Input() <- message + } + <-ticker.C + } + ticker.Stop() + } else { + for _, message := range messages { + producer.Input() <- message + } + } + + <-messagesDone + close(messagesDone) +} + +func runSyncProducer(topic string, partition, messageLoad, messageSize, routines int, + config *sarama.Config, brokers []string, throughput int) { + producer, err := sarama.NewSyncProducer(brokers, config) + if err != nil { + printErrorAndExit(69, "Failed to create producer: %s", err) + } + defer func() { + if err := producer.Close(); err != nil { + printErrorAndExit(69, "Failed to close producer: %s", err) + } + }() + + messages := make([][]*sarama.ProducerMessage, routines) + for i := 0; i < routines; i++ { + if i == routines-1 { + messages[i] = generateMessages(topic, partition, messageLoad/routines+messageLoad%routines, messageSize) + } else { + messages[i] = generateMessages(topic, partition, messageLoad/routines, messageSize) + } + } + + var wg gosync.WaitGroup + if throughput > 0 { + for _, messages := range messages { + messages := messages + wg.Add(1) + go func() { + ticker := time.NewTicker(time.Second) + for _, message := range messages { + for i := 0; i < throughput; i++ { + _, _, err = producer.SendMessage(message) + if err != nil { + printErrorAndExit(69, "Failed to send message: %s", err) + } + } + <-ticker.C + } + ticker.Stop() + wg.Done() + }() + } + } else { + for _, messages := range messages { + messages := messages + wg.Add(1) + go func() { + for _, message := range messages { + _, _, err = producer.SendMessage(message) + if err != nil { + printErrorAndExit(69, "Failed to send message: %s", err) + } + } + wg.Done() + }() + } + } + wg.Wait() +} + +func printMetrics(w io.Writer, r metrics.Registry) { + if r.Get("record-send-rate") == nil || r.Get("request-latency-in-ms") == nil { + return + } + recordSendRate := r.Get("record-send-rate").(metrics.Meter).Snapshot() + requestLatency := r.Get("request-latency-in-ms").(metrics.Histogram).Snapshot() + requestLatencyPercentiles := requestLatency.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999}) + fmt.Fprintf(w, "%d records sent, %.1f records/sec (%.2f MB/sec), "+ + "%.1f ms avg latency, %.1f ms stddev, %.1f ms 50th, %.1f ms 75th, "+ + "%.1f ms 95th, %.1f ms 99th, %.1f ms 99.9th\n", + recordSendRate.Count(), + recordSendRate.RateMean(), + recordSendRate.RateMean()*float64(*messageSize)/1024/1024, + requestLatency.Mean(), + requestLatency.StdDev(), + requestLatencyPercentiles[0], + requestLatencyPercentiles[1], + requestLatencyPercentiles[2], + requestLatencyPercentiles[3], + requestLatencyPercentiles[4], + ) +} + +func printUsageErrorAndExit(message string) { + fmt.Fprintln(os.Stderr, "ERROR:", message) + fmt.Fprintln(os.Stderr) + fmt.Fprintln(os.Stderr, "Available command line options:") + flag.PrintDefaults() + os.Exit(64) +} + +func printErrorAndExit(code int, format string, values ...interface{}) { + fmt.Fprintf(os.Stderr, "ERROR: %s\n", fmt.Sprintf(format, values...)) + fmt.Fprintln(os.Stderr) + os.Exit(code) +} diff --git a/vendor/github.com/Shopify/sarama/tools/tls/config.go b/vendor/github.com/Shopify/sarama/tools/tls/config.go new file mode 100644 index 00000000000..68db6e19902 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/tools/tls/config.go @@ -0,0 +1,17 @@ +package tls + +import "crypto/tls" + +func NewConfig(clientCert, clientKey string) (*tls.Config, error) { + tlsConfig := tls.Config{} + + if clientCert != "" && clientKey != "" { + cert, err := tls.LoadX509KeyPair(clientCert, clientKey) + if err != nil { + return &tlsConfig, err + } + tlsConfig.Certificates = []tls.Certificate{cert} + } + + return &tlsConfig, nil +} diff --git a/vendor/github.com/Shopify/sarama/vagrant/boot_cluster.sh b/vendor/github.com/Shopify/sarama/vagrant/boot_cluster.sh new file mode 100755 index 00000000000..95e47dde434 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/vagrant/boot_cluster.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -ex + +# Launch and wait for toxiproxy +${REPOSITORY_ROOT}/vagrant/run_toxiproxy.sh & +while ! nc -q 1 localhost 2181 ${KAFKA_INSTALL_ROOT}/zookeeper-${ZK_PORT}/myid +done diff --git a/vendor/github.com/Shopify/sarama/vagrant/kafka.conf b/vendor/github.com/Shopify/sarama/vagrant/kafka.conf new file mode 100644 index 00000000000..25101df5a32 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/vagrant/kafka.conf @@ -0,0 +1,9 @@ +start on started zookeeper-ZK_PORT +stop on stopping zookeeper-ZK_PORT + +# Use a script instead of exec (using env stanza leaks KAFKA_HEAP_OPTS from zookeeper) +script + sleep 2 + export KAFKA_HEAP_OPTS="-Xmx320m" + exec /opt/kafka-KAFKAID/bin/kafka-server-start.sh /opt/kafka-KAFKAID/config/server.properties +end script diff --git a/vendor/github.com/Shopify/sarama/vagrant/provision.sh b/vendor/github.com/Shopify/sarama/vagrant/provision.sh new file mode 100755 index 00000000000..7f10de74a64 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/vagrant/provision.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -ex + +apt-get update +yes | apt-get install default-jre + +export KAFKA_INSTALL_ROOT=/opt +export KAFKA_HOSTNAME=192.168.100.67 +export KAFKA_VERSION=1.0.2 +export KAFKA_SCALA_VERSION=2.11 +export REPOSITORY_ROOT=/vagrant + +sh /vagrant/vagrant/install_cluster.sh +sh /vagrant/vagrant/setup_services.sh +sh /vagrant/vagrant/create_topics.sh +sh /vagrant/vagrant/run_java_producer.sh diff --git a/vendor/github.com/Shopify/sarama/vagrant/run_java_producer.sh b/vendor/github.com/Shopify/sarama/vagrant/run_java_producer.sh new file mode 100755 index 00000000000..5851b7484a2 --- /dev/null +++ b/vendor/github.com/Shopify/sarama/vagrant/run_java_producer.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -ex + +wget https://github.com/FrancoisPoinsot/simplest-uncommitted-msg/releases/download/0.1/simplest-uncommitted-msg-0.1-jar-with-dependencies.jar +java -jar simplest-uncommitted-msg-0.1-jar-with-dependencies.jar -b ${KAFKA_HOSTNAME}:9092 -c 4 \ No newline at end of file diff --git a/vendor/github.com/Shopify/sarama/vagrant/run_toxiproxy.sh b/vendor/github.com/Shopify/sarama/vagrant/run_toxiproxy.sh new file mode 100755 index 00000000000..e52c00e7b5a --- /dev/null +++ b/vendor/github.com/Shopify/sarama/vagrant/run_toxiproxy.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -ex + +${KAFKA_INSTALL_ROOT}/toxiproxy -port 8474 -host 0.0.0.0 & +PID=$! + +while ! nc -q 1 localhost 8474 + +# The number of threads handling network requests +num.network.threads=2 + +# The number of threads doing disk I/O +num.io.threads=8 + +# The send buffer (SO_SNDBUF) used by the socket server +socket.send.buffer.bytes=1048576 + +# The receive buffer (SO_RCVBUF) used by the socket server +socket.receive.buffer.bytes=1048576 + +# The maximum size of a request that the socket server will accept (protection against OOM) +socket.request.max.bytes=104857600 + + +############################# Log Basics ############################# + +# A comma seperated list of directories under which to store log files +log.dirs=KAFKA_DATADIR + +# The default number of log partitions per topic. More partitions allow greater +# parallelism for consumption, but this will also result in more files across +# the brokers. +num.partitions=2 + +# Create new topics with a replication factor of 2 so failover can be tested +# more easily. +default.replication.factor=2 + +auto.create.topics.enable=false +delete.topic.enable=true + +############################# Log Flush Policy ############################# + +# Messages are immediately written to the filesystem but by default we only fsync() to sync +# the OS cache lazily. The following configurations control the flush of data to disk. +# There are a few important trade-offs here: +# 1. Durability: Unflushed data may be lost if you are not using replication. +# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush. +# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks. +# The settings below allow one to configure the flush policy to flush data after a period of time or +# every N messages (or both). This can be done globally and overridden on a per-topic basis. + +# The number of messages to accept before forcing a flush of data to disk +#log.flush.interval.messages=10000 + +# The maximum amount of time a message can sit in a log before we force a flush +#log.flush.interval.ms=1000 + +############################# Log Retention Policy ############################# + +# The following configurations control the disposal of log segments. The policy can +# be set to delete segments after a period of time, or after a given size has accumulated. +# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens +# from the end of the log. + +# The minimum age of a log file to be eligible for deletion +log.retention.hours=168 + +# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining +# segments don't drop below log.retention.bytes. +log.retention.bytes=268435456 + +# The maximum size of a log segment file. When this size is reached a new log segment will be created. +log.segment.bytes=268435456 + +# The interval at which log segments are checked to see if they can be deleted according +# to the retention policies +log.retention.check.interval.ms=60000 + +# By default the log cleaner is disabled and the log retention policy will default to just delete segments after their retention expires. +# If log.cleaner.enable=true is set the cleaner will be enabled and individual logs can then be marked for log compaction. +log.cleaner.enable=false + +############################# Zookeeper ############################# + +# Zookeeper connection string (see zookeeper docs for details). +# This is a comma separated host:port pairs, each corresponding to a zk +# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002". +# You can also append an optional chroot string to the urls to specify the +# root directory for all kafka znodes. +zookeeper.connect=localhost:ZK_PORT + +# Timeout in ms for connecting to zookeeper +zookeeper.session.timeout.ms=3000 +zookeeper.connection.timeout.ms=3000 diff --git a/vendor/github.com/Shopify/sarama/vagrant/setup_services.sh b/vendor/github.com/Shopify/sarama/vagrant/setup_services.sh new file mode 100755 index 00000000000..81d8ea05d3b --- /dev/null +++ b/vendor/github.com/Shopify/sarama/vagrant/setup_services.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +set -ex + +stop toxiproxy || true +cp ${REPOSITORY_ROOT}/vagrant/toxiproxy.conf /etc/init/toxiproxy.conf +cp ${REPOSITORY_ROOT}/vagrant/run_toxiproxy.sh ${KAFKA_INSTALL_ROOT}/ +start toxiproxy + +for i in 1 2 3 4 5; do + ZK_PORT=`expr $i + 2180` + KAFKA_PORT=`expr $i + 9090` + + stop zookeeper-${ZK_PORT} || true + + # set up zk service + cp ${REPOSITORY_ROOT}/vagrant/zookeeper.conf /etc/init/zookeeper-${ZK_PORT}.conf + sed -i s/KAFKAID/${KAFKA_PORT}/g /etc/init/zookeeper-${ZK_PORT}.conf + + # set up kafka service + cp ${REPOSITORY_ROOT}/vagrant/kafka.conf /etc/init/kafka-${KAFKA_PORT}.conf + sed -i s/KAFKAID/${KAFKA_PORT}/g /etc/init/kafka-${KAFKA_PORT}.conf + sed -i s/ZK_PORT/${ZK_PORT}/g /etc/init/kafka-${KAFKA_PORT}.conf + + start zookeeper-${ZK_PORT} +done + +# Wait for the last kafka node to finish booting +while ! nc -q 1 localhost 29095 -``` -4. Make your code changes, following the [Coding rules](#coding-rules) -5. Push your topic branch up to your fork: -```bash -$ git push origin -``` -6. [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request/#creating-the-pull-request) with a clear title and description. - -**Tips**: -- For ambitious tasks, open a Pull Request as soon as possible with the `[WIP]` prefix in the title, in order to get feedback and help from the community. -- [Allow GoFormation maintainers to make changes to your Pull Request branch](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork). This way, we can rebase it and make some minor changes if necessary. - -## Coding rules - -### Source code - -To ensure consistency and quality throughout the source code, all code modifications must have: -- A [test](#tests) for every possible case introduced by your code change -- [Valid commit message(s)](#commit-message-guidelines) -- Documentation for new features -- Updated documentation for modified features - -### Commit message guidelines - -#### Atomic commits - -If possible, make [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit), which means: -- a commit should contain exactly one self-contained functional change -- a functional change should be contained in exactly one commit -- a commit should not create an inconsistent state (such as test errors, linting errors, partial fix, feature with documentation etc...) - -A complex feature can be broken down into multiple commits as long as each one maintains a consistent state and consists of a self-contained change. - -#### Commit message format - -Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**: - -```commit -(): - - - -