Merge pull request #758 from buger/mod-tidy

mod tidy and higher version of Go
This commit is contained in:
Romanenko Alexey
2020-05-29 17:11:28 +07:00
committed by GitHub
8 changed files with 70 additions and 483 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
language: go
go: 1.12
go: 1.14
script: sudo -E bash -c "source /etc/profile && eval '$(gimme 1.12)' && export GOPATH=$HOME/gopath:$GOPATH && go get && GORACE='halt_on_error=1' go test ./... -v -timeout 120s -race"
before_install:
+6 -3
View File
@@ -1,12 +1,13 @@
module github.com/buger/goreplay
go 1.12
go 1.14
require (
github.com/Shopify/sarama v1.11.0
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
github.com/araddon/gou v0.0.0-20190110011759-c797efecbb61 // indirect
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/eapache/go-resiliency v0.0.0-20160104191539-b86b1ec0dd42 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20160609142408-bb955e01b934 // indirect
github.com/eapache/queue v1.1.0 // indirect
@@ -16,8 +17,10 @@ require (
github.com/kr/pretty v0.0.0-20130510082846-bc9499caa0f4 // indirect
github.com/kr/text v0.0.0-20130911015532-6807e777504f // indirect
github.com/mattbaird/elastigo v0.0.0-20170123220020-2fe47fd29e4b
github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065 // indirect
github.com/pierrec/lz4 v0.0.0-20161206202305-5c9560bfa9ac // indirect
github.com/pierrec/xxHash v0.0.0-20160112165351-5a004441f897 // indirect
github.com/rcrowley/go-metrics v0.0.0-20161128210544-1f30fe9094a5 // indirect
golang.org/x/sys v0.0.0-20170201051245-7a6e5648d140 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/stretchr/testify v1.5.1 // indirect
)
+36 -1
View File
@@ -1,9 +1,13 @@
github.com/Shopify/sarama v1.11.0 h1:JD701r42hP1ms1uytUMa34jZgoddt0XhiElhJt+2ERE=
github.com/Shopify/sarama v1.11.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
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/araddon/gou v0.0.0-20190110011759-c797efecbb61 h1:Xz25cuW4REGC5W5UtpMU3QItMIImag615HiQcRbxqKQ=
github.com/araddon/gou v0.0.0-20190110011759-c797efecbb61/go.mod h1:ikc1XA58M+Rx7SEbf0bLJCfBkwayZ8T5jBo5FXK8Uz8=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eapache/go-resiliency v0.0.0-20160104191539-b86b1ec0dd42 h1:f8ERmXYuaC+kCSv2w+y3rBK/oVu6If4DEm3jywJJ0hc=
@@ -14,18 +18,49 @@ 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.0-20160529050041-d9eb7a3d35ec h1:ZaSUjYC8aWT/om43c8YVz0SqjT8ABtqw7REbZGsCroE=
github.com/golang/snappy v0.0.0-20160529050041-d9eb7a3d35ec/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/gopacket v0.0.0-20190211013929-f86faeb88894 h1:uLlIRilC25T6VC/ePgHc2Oo1+AWlsrbmbMYUeEHfZAs=
github.com/google/gopacket v0.0.0-20190211013929-f86faeb88894/go.mod h1:UCLx9mCmAwsVbn6qQl1WIEt2SO7Nd2fD0th1TBAsqBw=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6 h1:KAZ1BW2TCmT6PRihDPpocIy1QTtsAsrx6TneU/4+CMg=
github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg=
github.com/kr/pretty v0.0.0-20130510082846-bc9499caa0f4 h1:VOF8pfnliVudEzEOQLybN6eDhP5Q/LmwMnpDCBe9C4I=
github.com/kr/pretty v0.0.0-20130510082846-bc9499caa0f4/go.mod h1:Bvhd+E3laJ0AVkG0c9rmtZcnhV0HQ3+c3YxxqTvc/gA=
github.com/kr/text v0.0.0-20130911015532-6807e777504f h1:JaNmHIV9Eby6srQVWuiQ6n8ko2o/lG6udSRCbFZe1fs=
github.com/kr/text v0.0.0-20130911015532-6807e777504f/go.mod h1:sjUstKUATFIcff4qlB53Kml0wQPtJVc/3fWrmuUmcfA=
github.com/mattbaird/elastigo v0.0.0-20170123220020-2fe47fd29e4b h1:v29yPGHhOqw7VHEnTeQFAth3SsBrmwc8JfuhNY0G34k=
github.com/mattbaird/elastigo v0.0.0-20170123220020-2fe47fd29e4b/go.mod h1:5MWrJXKRQyhQdUCF+vu6U5c4nQpg70vW3eHaU0/AYbU=
github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065 h1:aFkJ6lx4FPip+S+Uw4aTegFMct9shDvP+79PsSxpm3w=
github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065/go.mod h1:7EpbotpCmVZcu+KCX4g9WaRNuu11uyhiW7+Le1dKawg=
github.com/pierrec/lz4 v0.0.0-20161206202305-5c9560bfa9ac h1:tKcxwAA5OHUQjL6sWsuCIcP9OnzN+RwKfvomtIOsfy8=
github.com/pierrec/lz4 v0.0.0-20161206202305-5c9560bfa9ac/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/xxHash v0.0.0-20160112165351-5a004441f897 h1:jp3jc/PyyTrTKjJJ6rWnhTbmo7tGgBFyG9AL5FIrO1I=
github.com/pierrec/xxHash v0.0.0-20160112165351-5a004441f897/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I=
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-20161128210544-1f30fe9094a5 h1:gwcdIpH6NU2iF8CmcqD+CP6+1CkRBOhHaPR+iu6raBY=
github.com/rcrowley/go-metrics v0.0.0-20161128210544-1f30fe9094a5/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
golang.org/x/sys v0.0.0-20170201051245-7a6e5648d140/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190419010253-1f3472d942ba h1:h0zCzEL5UW1mERvwTN6AXcc75PpLkY6OcReia6Dq1BM=
golang.org/x/net v0.0.0-20190419010253-1f3472d942ba/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-20190418153312-f0ce4c0180be h1:mI+jhqkn68ybP0ORJqunXn+fq+Eeb4hHKqLQcFICjAc=
golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-109
View File
@@ -1,109 +0,0 @@
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build ignore
// This binary pulls known ports from IANA, and uses them to populate
// iana_ports.go's TCPPortNames and UDPPortNames maps.
//
// go run gen.go | gofmt > iana_ports.go
package main
import (
"bytes"
"encoding/xml"
"flag"
"fmt"
"io/ioutil"
"net/http"
"os"
"strconv"
"time"
)
const fmtString = `// Copyright 2012 Google, Inc. All rights reserved.
package layers
// Created by gen.go, don't edit manually
// Generated at %s
// Fetched from %q
// TCPPortNames contains the port names for all TCP ports.
var TCPPortNames = tcpPortNames
// UDPPortNames contains the port names for all UDP ports.
var UDPPortNames = udpPortNames
// SCTPPortNames contains the port names for all SCTP ports.
var SCTPPortNames = sctpPortNames
var tcpPortNames = map[TCPPort]string{
%s}
var udpPortNames = map[UDPPort]string{
%s}
var sctpPortNames = map[SCTPPort]string{
%s}
`
var url = flag.String("url", "http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml", "URL to grab port numbers from")
func main() {
fmt.Fprintf(os.Stderr, "Fetching ports from %q\n", *url)
resp, err := http.Get(*url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Fprintln(os.Stderr, "Parsing XML")
var registry struct {
Records []struct {
Protocol string `xml:"protocol"`
Number string `xml:"number"`
Name string `xml:"name"`
} `xml:"record"`
}
xml.Unmarshal(body, &registry)
var tcpPorts bytes.Buffer
var udpPorts bytes.Buffer
var sctpPorts bytes.Buffer
done := map[string]map[int]bool{
"tcp": map[int]bool{},
"udp": map[int]bool{},
"sctp": map[int]bool{},
}
for _, r := range registry.Records {
port, err := strconv.Atoi(r.Number)
if err != nil {
continue
}
if r.Name == "" {
continue
}
var b *bytes.Buffer
switch r.Protocol {
case "tcp":
b = &tcpPorts
case "udp":
b = &udpPorts
case "sctp":
b = &sctpPorts
default:
continue
}
if done[r.Protocol][port] {
continue
}
done[r.Protocol][port] = true
fmt.Fprintf(b, "\t%d: %q,\n", port, r.Name)
}
fmt.Fprintln(os.Stderr, "Writing results to stdout")
fmt.Printf(fmtString, time.Now(), *url, tcpPorts.String(), udpPorts.String(), sctpPorts.String())
}
-104
View File
@@ -1,104 +0,0 @@
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build ignore
// This binary handles creating string constants and function templates for enums.
//
// go run gen.go | gofmt > enums_generated.go
package main
import (
"fmt"
"log"
"os"
"text/template"
"time"
)
const fmtString = `// Copyright 2012 Google, Inc. All rights reserved.
package layers
// Created by gen2.go, don't edit manually
// Generated at %s
import (
"fmt"
"github.com/google/gopacket"
)
`
var funcsTmpl = template.Must(template.New("foo").Parse(`
// Decoder calls {{.Name}}Metadata.DecodeWith's decoder.
func (a {{.Name}}) Decode(data []byte, p gopacket.PacketBuilder) error {
return {{.Name}}Metadata[a].DecodeWith.Decode(data, p)
}
// String returns {{.Name}}Metadata.Name.
func (a {{.Name}}) String() string {
return {{.Name}}Metadata[a].Name
}
// LayerType returns {{.Name}}Metadata.LayerType.
func (a {{.Name}}) LayerType() gopacket.LayerType {
return {{.Name}}Metadata[a].LayerType
}
type errorDecoderFor{{.Name}} int
func (a *errorDecoderFor{{.Name}}) Decode(data []byte, p gopacket.PacketBuilder) error {
return a
}
func (a *errorDecoderFor{{.Name}}) Error() string {
return fmt.Sprintf("Unable to decode {{.Name}} %d", int(*a))
}
var errorDecodersFor{{.Name}} [{{.Num}}]errorDecoderFor{{.Name}}
var {{.Name}}Metadata [{{.Num}}]EnumMetadata
func initUnknownTypesFor{{.Name}}() {
for i := 0; i < {{.Num}}; i++ {
errorDecodersFor{{.Name}}[i] = errorDecoderFor{{.Name}}(i)
{{.Name}}Metadata[i] = EnumMetadata{
DecodeWith: &errorDecodersFor{{.Name}}[i],
Name: "Unknown{{.Name}}",
}
}
}
`))
func main() {
fmt.Fprintf(os.Stderr, "Writing results to stdout\n")
fmt.Printf(fmtString, time.Now())
types := []struct {
Name string
Num int
}{
{"LinkType", 256},
{"EthernetType", 65536},
{"PPPType", 65536},
{"IPProtocol", 256},
{"SCTPChunkType", 256},
{"PPPoECode", 256},
{"FDDIFrameControl", 256},
{"EAPOLType", 256},
{"ProtocolFamily", 256},
{"Dot11Type", 256},
{"USBTransportType", 256},
}
fmt.Println("func init() {")
for _, t := range types {
fmt.Printf("initUnknownTypesFor%s()\n", t.Name)
}
fmt.Println("initActualTypeData()")
fmt.Println("}")
for _, t := range types {
if err := funcsTmpl.Execute(os.Stdout, t); err != nil {
log.Fatalf("Failed to execute template %s: %v", t.Name, err)
}
}
}
-157
View File
@@ -1,157 +0,0 @@
// Copyright 2019 The GoPacket Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build ignore
package main
// This file generates the godefs needed for the windows version.
// Rebuild is only necessary if additional libpcap functionality is implemented, or a new arch is implemented in golang.
// Call with go run generate_windows.go [-I includepath]
// Needs npcap sdk, go tool cgo, and gofmt to work. Location of npcap includes can be specified with -I
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
)
const header = `// Copyright 2019 The GoPacket Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// This file contains necessary structs/constants generated from libpcap headers with cgo -godefs
// generated with: %s
// DO NOT MODIFY
`
const source = `
package pcap
//#include <pcap.h>
import "C"
import "syscall" // needed for RawSockaddr
const errorBufferSize = C.PCAP_ERRBUF_SIZE
const (
pcapErrorNotActivated = C.PCAP_ERROR_NOT_ACTIVATED
pcapErrorActivated = C.PCAP_ERROR_ACTIVATED
pcapWarningPromisc = C.PCAP_WARNING_PROMISC_NOTSUP
pcapErrorNoSuchDevice = C.PCAP_ERROR_NO_SUCH_DEVICE
pcapErrorDenied = C.PCAP_ERROR_PERM_DENIED
pcapErrorNotUp = C.PCAP_ERROR_IFACE_NOT_UP
pcapError = C.PCAP_ERROR
pcapWarning = C.PCAP_WARNING
pcapDIN = C.PCAP_D_IN
pcapDOUT = C.PCAP_D_OUT
pcapDINOUT = C.PCAP_D_INOUT
pcapNetmaskUnknown = C.PCAP_NETMASK_UNKNOWN
pcapTstampPrecisionMicro = C.PCAP_TSTAMP_PRECISION_MICRO
pcapTstampPrecisionNano = C.PCAP_TSTAMP_PRECISION_NANO
)
type timeval C.struct_timeval
type pcapPkthdr C.struct_pcap_pkthdr
type pcapTPtr uintptr
type pcapBpfInstruction C.struct_bpf_insn
type pcapBpfProgram C.struct_bpf_program
type pcapStats C.struct_pcap_stat
type pcapCint C.int
type pcapIf C.struct_pcap_if
// +godefs map struct_sockaddr syscall.RawSockaddr
type pcapAddr C.struct_pcap_addr
`
var includes = flag.String("I", "C:\\npcap-sdk-1.01\\Include", "Include path containing libpcap headers")
func main() {
flag.Parse()
infile, err := ioutil.TempFile(".", "defs.*.go")
if err != nil {
log.Fatal("Couldn't create temporary source file: ", err)
}
defer infile.Close()
defer os.Remove(infile.Name())
_, err = infile.WriteString(source)
if err != nil {
log.Fatalf("Couldn't write definitions to temporary file %s: %s", infile.Name(), err)
}
err = infile.Close()
if err != nil {
log.Fatalf("Couldn't close temporary source file %s: %s", infile.Name(), err)
}
archs := []string{"386", "amd64"}
for _, arch := range archs {
env := append(os.Environ(), "GOARCH="+arch)
cmd := exec.Command("go", "tool", "cgo", "-godefs", "--", "-I", *includes, infile.Name())
cmd.Env = env
cmd.Stderr = os.Stderr
var generated bytes.Buffer
cmd.Stdout = &generated
err := cmd.Run()
if err != nil {
log.Fatalf("Couldn't generated defs for %s: %s\n", arch, err)
}
cmd = exec.Command("gofmt")
cmd.Env = env
cmd.Stderr = os.Stderr
outName := fmt.Sprintf("defs_windows_%s.go", arch)
out, err := os.Create(outName)
if err != nil {
log.Fatalf("Couldn't open file %s: %s", outName, err)
}
cmd.Stdout = out
in, err := cmd.StdinPipe()
if err != nil {
log.Fatal("Couldn't create input pipe for gofmt: ", err)
}
err = cmd.Start()
if err != nil {
log.Fatal("Couldn't start gofmt: ", err)
}
_, err = fmt.Fprintf(in, header, strings.Join(append([]string{filepath.Base(os.Args[0])}, os.Args[1:]...), " "))
if err != nil {
log.Fatal("Couldn't write header to gofmt: ", err)
}
for {
line, err := generated.ReadBytes('\n')
if err != nil {
break
}
// remove godefs comments
if bytes.HasPrefix(line, []byte("//")) {
continue
}
_, err = in.Write(line)
if err != nil {
log.Fatal("Couldn't write line to gofmt: ", err)
}
}
in.Close()
err = cmd.Wait()
if err != nil {
log.Fatal("gofmt failed: ", err)
}
out.Close()
}
}
-108
View File
@@ -1,108 +0,0 @@
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build ignore
// This binary tests that PCAP packet capture is working correctly by issuing
// HTTP requests, then making sure we actually capture data off the wire.
package main
import (
"errors"
"flag"
"fmt"
"log"
"net/http"
"os"
"time"
"github.com/google/gopacket/pcap"
)
var mode = flag.String("mode", "basic", "One of: basic,filtered,timestamp")
func generatePackets() {
if resp, err := http.Get("http://code.google.com"); err != nil {
log.Printf("Could not get HTTP: %v", err)
} else {
resp.Body.Close()
}
}
func main() {
flag.Parse()
ifaces, err := pcap.FindAllDevs()
if err != nil {
log.Fatal(err)
}
for _, iface := range ifaces {
log.Printf("Trying capture on %q", iface.Name)
if err := tryCapture(iface); err != nil {
log.Printf("Error capturing on %q: %v", iface.Name, err)
} else {
log.Printf("Successfully captured on %q", iface.Name)
return
}
}
os.Exit(1)
}
func tryCapture(iface pcap.Interface) error {
if iface.Name[:2] == "lo" {
return errors.New("skipping loopback")
}
var h *pcap.Handle
var err error
switch *mode {
case "basic":
h, err = pcap.OpenLive(iface.Name, 65536, false, time.Second*3)
if err != nil {
return fmt.Errorf("openlive: %v", err)
}
defer h.Close()
case "filtered":
h, err = pcap.OpenLive(iface.Name, 65536, false, time.Second*3)
if err != nil {
return fmt.Errorf("openlive: %v", err)
}
defer h.Close()
if err := h.SetBPFFilter("port 80 or port 443"); err != nil {
return fmt.Errorf("setbpf: %v", err)
}
case "timestamp":
u, err := pcap.NewInactiveHandle(iface.Name)
if err != nil {
return err
}
defer u.CleanUp()
if err = u.SetSnapLen(65536); err != nil {
return err
} else if err = u.SetPromisc(false); err != nil {
return err
} else if err = u.SetTimeout(time.Second * 3); err != nil {
return err
}
sources := u.SupportedTimestamps()
if len(sources) == 0 {
return errors.New("no supported timestamp sources")
} else if err := u.SetTimestampSource(sources[0]); err != nil {
return fmt.Errorf("settimestampsource(%v): %v", sources[0], err)
} else if h, err = u.Activate(); err != nil {
return fmt.Errorf("could not activate: %v", err)
}
defer h.Close()
default:
panic("Invalid --mode: " + *mode)
}
go generatePackets()
h.ReadPacketData() // Do one dummy read to clear any timeouts.
data, ci, err := h.ReadPacketData()
if err != nil {
return fmt.Errorf("readpacketdata: %v", err)
}
log.Printf("Read packet, %v bytes, CI: %+v", len(data), ci)
return nil
}
+27
View File
@@ -1,31 +1,58 @@
# github.com/Shopify/sarama v1.11.0
## explicit
github.com/Shopify/sarama
github.com/Shopify/sarama/mocks
# github.com/Shopify/toxiproxy v2.1.4+incompatible
## explicit
# github.com/araddon/gou v0.0.0-20190110011759-c797efecbb61
## explicit
github.com/araddon/gou
# github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932
## explicit
github.com/bitly/go-hostpool
# github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
## explicit
# github.com/davecgh/go-spew v1.1.0
github.com/davecgh/go-spew/spew
# github.com/eapache/go-resiliency v0.0.0-20160104191539-b86b1ec0dd42
## explicit
github.com/eapache/go-resiliency/breaker
# github.com/eapache/go-xerial-snappy v0.0.0-20160609142408-bb955e01b934
## explicit
github.com/eapache/go-xerial-snappy
# github.com/eapache/queue v1.1.0
## explicit
github.com/eapache/queue
# github.com/golang/snappy v0.0.0-20160529050041-d9eb7a3d35ec
## explicit
github.com/golang/snappy
# github.com/google/gopacket v0.0.0-20190211013929-f86faeb88894
## explicit
github.com/google/gopacket
github.com/google/gopacket/layers
github.com/google/gopacket/pcap
# github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6
## explicit
github.com/klauspost/crc32
# github.com/kr/pretty v0.0.0-20130510082846-bc9499caa0f4
## explicit
# github.com/kr/text v0.0.0-20130911015532-6807e777504f
## explicit
# github.com/mattbaird/elastigo v0.0.0-20170123220020-2fe47fd29e4b
## explicit
github.com/mattbaird/elastigo/lib
# github.com/mdlayher/raw v0.0.0-20191009151244-50f2db8cc065
## explicit
# github.com/pierrec/lz4 v0.0.0-20161206202305-5c9560bfa9ac
## explicit
github.com/pierrec/lz4
# github.com/pierrec/xxHash v0.0.0-20160112165351-5a004441f897
## explicit
github.com/pierrec/xxHash/xxHash32
# github.com/rcrowley/go-metrics v0.0.0-20161128210544-1f30fe9094a5
## explicit
github.com/rcrowley/go-metrics
# github.com/smartystreets/goconvey v1.6.4
## explicit
# github.com/stretchr/testify v1.5.1
## explicit