goreplay-cli package (#1148)

change package from `main -> goreplay`
this will allow importing `goreplay` as a package
This commit is contained in:
Dima Golomozy
2023-01-12 18:24:45 +03:00
committed by GitHub
parent 99e6fdfd60
commit 40946831b9
78 changed files with 148 additions and 174 deletions
+4 -4
View File
@@ -31,19 +31,19 @@ vendor:
go mod vendor go mod vendor
release-bin-linux-amd64: vendor release-bin-linux-amd64: vendor
docker run --platform linux/amd64 --rm -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=amd64 -i $(CONTAINER_AMD) go build -mod=vendor -o $(BIN_NAME) -tags netgo $(LDFLAGS) docker run --platform linux/amd64 --rm -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=amd64 -i $(CONTAINER_AMD) go build -mod=vendor -o $(BIN_NAME) -tags netgo $(LDFLAGS) ./cmd/gor/
release-bin-linux-arm64: vendor release-bin-linux-arm64: vendor
docker run --platform linux/arm64 --rm -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=arm64 -i $(CONTAINER_ARM) go build -mod=vendor -o $(BIN_NAME) -tags netgo $(LDFLAGS) docker run --platform linux/arm64 --rm -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=arm64 -i $(CONTAINER_ARM) go build -mod=vendor -o $(BIN_NAME) -tags netgo $(LDFLAGS) ./cmd/gor/
release-bin-mac-amd64: vendor release-bin-mac-amd64: vendor
GOOS=darwin go build -mod=vendor -o $(BIN_NAME) $(MAC_LDFLAGS) GOOS=darwin go build -mod=vendor -o $(BIN_NAME) $(MAC_LDFLAGS) ./cmd/gor/
release-bin-mac-arm64: vendor release-bin-mac-arm64: vendor
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -mod=vendor -o $(BIN_NAME) $(MAC_LDFLAGS) GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -mod=vendor -o $(BIN_NAME) $(MAC_LDFLAGS)
release-bin-windows: vendor release-bin-windows: vendor
docker run -it --rm -v `pwd`:$(SOURCE_PATH) -w $(SOURCE_PATH) -e CGO_ENABLED=1 docker.elastic.co/beats-dev/golang-crossbuild:1.19.2-main --build-cmd "make VERSION=$(VERSION) build" -p "windows/amd64" docker run -it --rm -v `pwd`:$(SOURCE_PATH) -w $(SOURCE_PATH) -e CGO_ENABLED=1 docker.elastic.co/beats-dev/golang-crossbuild:1.19.2-main --build-cmd "make VERSION=$(VERSION) build" -p "windows/amd64" ./cmd/gor/
mv $(BIN_NAME) "$(BIN_NAME).exe" mv $(BIN_NAME) "$(BIN_NAME).exe"
release-linux-amd64: dist release-bin-linux-amd64 release-linux-amd64: dist release-bin-linux-amd64
+14 -13
View File
@@ -6,6 +6,7 @@ import (
"expvar" "expvar"
"flag" "flag"
"fmt" "fmt"
"github.com/buger/goreplay"
"log" "log"
"net/http" "net/http"
"net/http/httputil" "net/http/httputil"
@@ -71,23 +72,23 @@ func main() {
} }
args := os.Args[1:] args := os.Args[1:]
var plugins *InOutPlugins var plugins *goreplay.InOutPlugins
if len(args) > 0 && args[0] == "file-server" { if len(args) > 0 && args[0] == "file-server" {
if len(args) != 2 { if len(args) != 2 {
log.Fatal("You should specify port and IP (optional) for the file server. Example: `gor file-server :80`") log.Fatal("You should specify port and IP (optional) for the file server. Example: `gor file-server :80`")
} }
dir, _ := os.Getwd() dir, _ := os.Getwd()
Debug(0, "Started example file server for current directory on address ", args[1]) goreplay.Debug(0, "Started example file server for current directory on address ", args[1])
log.Fatal(http.ListenAndServe(args[1], loggingMiddleware(args[1], http.FileServer(http.Dir(dir))))) log.Fatal(http.ListenAndServe(args[1], loggingMiddleware(args[1], http.FileServer(http.Dir(dir)))))
} else { } else {
flag.Parse() flag.Parse()
checkSettings() goreplay.CheckSettings()
plugins = NewPlugins() plugins = goreplay.NewPlugins()
} }
log.Printf("[PPID %d and PID %d] Version:%s\n", os.Getppid(), os.Getpid(), VERSION) log.Printf("[PPID %d and PID %d] Version:%s\n", os.Getppid(), os.Getpid(), goreplay.VERSION)
if len(plugins.Inputs) == 0 || len(plugins.Outputs) == 0 { if len(plugins.Inputs) == 0 || len(plugins.Outputs) == 0 {
log.Fatal("Required at least 1 input and 1 output") log.Fatal("Required at least 1 input and 1 output")
@@ -101,20 +102,20 @@ func main() {
profileCPU(*cpuprofile) profileCPU(*cpuprofile)
} }
if Settings.Pprof != "" { if goreplay.Settings.Pprof != "" {
go func() { go func() {
log.Println(http.ListenAndServe(Settings.Pprof, nil)) log.Println(http.ListenAndServe(goreplay.Settings.Pprof, nil))
}() }()
} }
closeCh := make(chan int) closeCh := make(chan int)
emitter := NewEmitter() emitter := goreplay.NewEmitter()
go emitter.Start(plugins, Settings.Middleware) go emitter.Start(plugins, goreplay.Settings.Middleware)
if Settings.ExitAfter > 0 { if goreplay.Settings.ExitAfter > 0 {
log.Printf("Running gor for a duration of %s\n", Settings.ExitAfter) log.Printf("Running gor for a duration of %s\n", goreplay.Settings.ExitAfter)
time.AfterFunc(Settings.ExitAfter, func() { time.AfterFunc(goreplay.Settings.ExitAfter, func() {
log.Printf("gor run timeout %s\n", Settings.ExitAfter) log.Printf("gor run timeout %s\n", goreplay.Settings.ExitAfter)
close(closeCh) close(closeCh)
}) })
} }
+2 -3
View File
@@ -1,14 +1,13 @@
package main package goreplay
import ( import (
"encoding/json" "encoding/json"
"github.com/buger/goreplay/proto"
"log" "log"
"net/url" "net/url"
"strings" "strings"
"time" "time"
"github.com/buger/goreplay/proto"
elastigo "github.com/mattbaird/elastigo/lib" elastigo "github.com/mattbaird/elastigo/lib"
) )
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"testing" "testing"
+2 -2
View File
@@ -1,13 +1,13 @@
package main package goreplay
import ( import (
"fmt" "fmt"
"github.com/buger/goreplay/internal/byteutils"
"hash/fnv" "hash/fnv"
"io" "io"
"log" "log"
"sync" "sync"
"github.com/buger/goreplay/byteutils"
"github.com/coocood/freecache" "github.com/coocood/freecache"
) )
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"fmt" "fmt"
+1 -2
View File
@@ -24,9 +24,8 @@ import (
"bytes" "bytes"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"os"
"github.com/buger/goreplay/proto" "github.com/buger/goreplay/proto"
"os"
) )
// requestID -> originalToken // requestID -> originalToken
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"runtime" "runtime"
+2 -3
View File
@@ -1,12 +1,11 @@
package main package goreplay
import ( import (
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"github.com/buger/goreplay/proto"
"hash/fnv" "hash/fnv"
"strings" "strings"
"github.com/buger/goreplay/proto"
) )
type HTTPModifier struct { type HTTPModifier struct {
+1 -17
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"errors" "errors"
@@ -24,9 +24,7 @@ type HTTPModifierConfig struct {
Methods HTTPMethods `json:"http-allow-method"` Methods HTTPMethods `json:"http-allow-method"`
} }
//
// Handling of --http-allow-header, --http-disallow-header options // Handling of --http-allow-header, --http-disallow-header options
//
type headerFilter struct { type headerFilter struct {
name []byte name []byte
regexp *regexp.Regexp regexp *regexp.Regexp
@@ -56,9 +54,7 @@ func (h *HTTPHeaderFilters) Set(value string) error {
return nil return nil
} }
//
// Handling of --http-basic-auth-filter option // Handling of --http-basic-auth-filter option
//
type basicAuthFilter struct { type basicAuthFilter struct {
regexp *regexp.Regexp regexp *regexp.Regexp
} }
@@ -82,9 +78,7 @@ func (h *HTTPHeaderBasicAuthFilters) Set(value string) error {
return nil return nil
} }
//
// Handling of --http-allow-header-hash and --http-allow-param-hash options // Handling of --http-allow-header-hash and --http-allow-param-hash options
//
type hashFilter struct { type hashFilter struct {
name []byte name []byte
percent uint32 percent uint32
@@ -129,9 +123,7 @@ func (h *HTTPHashFilters) Set(value string) error {
return nil return nil
} }
//
// Handling of --http-set-header option // Handling of --http-set-header option
//
type httpHeader struct { type httpHeader struct {
Name string Name string
Value string Value string
@@ -160,9 +152,7 @@ func (h *HTTPHeaders) Set(value string) error {
return nil return nil
} }
//
// Handling of --http-set-param option // Handling of --http-set-param option
//
type httpParam struct { type httpParam struct {
Name []byte Name []byte
Value []byte Value []byte
@@ -208,9 +198,7 @@ func (h *HTTPMethods) Set(value string) error {
return nil return nil
} }
//
// Handling of --http-rewrite-url option // Handling of --http-rewrite-url option
//
type urlRewrite struct { type urlRewrite struct {
src *regexp.Regexp src *regexp.Regexp
target []byte target []byte
@@ -237,9 +225,7 @@ func (r *URLRewriteMap) Set(value string) error {
return nil return nil
} }
//
// Handling of --http-rewrite-header option // Handling of --http-rewrite-header option
//
type headerRewrite struct { type headerRewrite struct {
header []byte header []byte
src *regexp.Regexp src *regexp.Regexp
@@ -275,9 +261,7 @@ func (r *HeaderRewriteMap) Set(value string) error {
return nil return nil
} }
//
// Handling of --http-allow-url option // Handling of --http-allow-url option
//
type urlRegexp struct { type urlRegexp struct {
regexp *regexp.Regexp regexp *regexp.Regexp
} }
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"testing" "testing"
+2 -3
View File
@@ -1,10 +1,9 @@
package main package goreplay
import ( import (
"bytes" "bytes"
"testing"
"github.com/buger/goreplay/proto" "github.com/buger/goreplay/proto"
"testing"
) )
func TestHTTPModifierWithoutConfig(t *testing.T) { func TestHTTPModifierWithoutConfig(t *testing.T) {
+2 -3
View File
@@ -1,14 +1,13 @@
package main package goreplay
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"fmt" "fmt"
"github.com/buger/goreplay/proto"
"io/ioutil" "io/ioutil"
"net/http/httputil" "net/http/httputil"
"strconv" "strconv"
"github.com/buger/goreplay/proto"
) )
func prettifyHTTP(p []byte) []byte { func prettifyHTTP(p []byte) []byte {
+2 -3
View File
@@ -1,12 +1,11 @@
package main package goreplay
import ( import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"github.com/buger/goreplay/proto"
"strconv" "strconv"
"testing" "testing"
"github.com/buger/goreplay/proto"
) )
func TestHTTPPrettifierGzip(t *testing.T) { func TestHTTPPrettifierGzip(t *testing.T) {
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"time" "time"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bufio" "bufio"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bytes" "bytes"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"log" "log"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bytes" "bytes"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"encoding/json" "encoding/json"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"testing" "testing"
+4 -5
View File
@@ -1,17 +1,16 @@
package main package goreplay
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/buger/goreplay/internal/capture"
"github.com/buger/goreplay/internal/tcp"
"github.com/buger/goreplay/proto"
"log" "log"
"net" "net"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"github.com/buger/goreplay/capture"
"github.com/buger/goreplay/proto"
"github.com/buger/goreplay/tcp"
) )
// RAWInputConfig represents configuration that can be applied on raw input // RAWInputConfig represents configuration that can be applied on raw input
+4 -5
View File
@@ -1,7 +1,10 @@
package main package goreplay
import ( import (
"bytes" "bytes"
"github.com/buger/goreplay/internal/capture"
"github.com/buger/goreplay/internal/tcp"
"github.com/buger/goreplay/proto"
"io/ioutil" "io/ioutil"
"net" "net"
"net/http" "net/http"
@@ -13,10 +16,6 @@ import (
"sync/atomic" "sync/atomic"
"testing" "testing"
"time" "time"
"github.com/buger/goreplay/capture"
"github.com/buger/goreplay/proto"
"github.com/buger/goreplay/tcp"
) )
const testRawExpire = time.Millisecond * 200 const testRawExpire = time.Millisecond * 200
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bufio" "bufio"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bytes" "bytes"
@@ -5,6 +5,9 @@ import (
"errors" "errors"
"expvar" "expvar"
"fmt" "fmt"
"github.com/buger/goreplay/internal/size"
"github.com/buger/goreplay/internal/tcp"
"github.com/buger/goreplay/proto"
"io" "io"
"log" "log"
"net" "net"
@@ -15,10 +18,6 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/buger/goreplay/proto"
"github.com/buger/goreplay/size"
"github.com/buger/goreplay/tcp"
"github.com/google/gopacket" "github.com/google/gopacket"
"github.com/google/gopacket/layers" "github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap" "github.com/google/gopacket/pcap"
@@ -286,11 +285,12 @@ func (l *Listener) ListenBackground(ctx context.Context) chan error {
} }
// Allowed format: // Allowed format:
// [namespace/]pod/[pod_name] //
// [namespace/]deployment/[deployment_name] // [namespace/]pod/[pod_name]
// [namespace/]daemonset/[daemonset_name] // [namespace/]deployment/[deployment_name]
// [namespace/]labelSelector/[selector] // [namespace/]daemonset/[daemonset_name]
// [namespace/]fieldSelector/[selector] // [namespace/]labelSelector/[selector]
// [namespace/]fieldSelector/[selector]
func k8sIPs(addr string) []string { func k8sIPs(addr string) []string {
config, err := rest.InClusterConfig() config, err := rest.InClusterConfig()
if err != nil { if err != nil {
+17 -10
View File
@@ -9,27 +9,34 @@ example:
// for the transport should be "tcp" // for the transport should be "tcp"
listener, err := capture.NewListener(host, port, transport, engine, trackResponse) listener, err := capture.NewListener(host, port, transport, engine, trackResponse)
if err != nil {
// handle error if err != nil {
} // handle error
}
listener.SetPcapOptions(opts) listener.SetPcapOptions(opts)
err = listner.Activate() err = listner.Activate()
if err != nil {
// handle it
}
if err := listener.Listen(context.Background(), handler); err != nil { if err != nil {
// handle error // handle it
} }
if err := listener.Listen(context.Background(), handler); err != nil {
// handle error
}
// or // or
errCh := listener.ListenBackground(context.Background(), handler) // runs in the background errCh := listener.ListenBackground(context.Background(), handler) // runs in the background
select { select {
case err := <- errCh: case err := <- errCh:
// handle error // handle error
case <-quit: case <-quit:
// //
case <- l.Reading: // if we have started reading case <- l.Reading: // if we have started reading
} }
*/ */
package capture // import github.com/buger/goreplay/capture package capture // import github.com/buger/goreplay/capture
+24 -24
View File
@@ -35,18 +35,18 @@ const versionMinor = 4
// an append), you must call WriteFileHeader before WritePacket. Packet // an append), you must call WriteFileHeader before WritePacket. Packet
// timestamps are written with nanosecond precision. // timestamps are written with nanosecond precision.
// //
// // Write a new file: // // Write a new file:
// f, _ := os.Create("/tmp/file.pcap") // f, _ := os.Create("/tmp/file.pcap")
// w := pcapgo.NewWriterNanos(f) // w := pcapgo.NewWriterNanos(f)
// w.WriteFileHeader(65536, layers.LinkTypeEthernet) // new file, must do this. // w.WriteFileHeader(65536, layers.LinkTypeEthernet) // new file, must do this.
// w.WritePacket(gopacket.CaptureInfo{...}, data1) // w.WritePacket(gopacket.CaptureInfo{...}, data1)
// f.Close() // f.Close()
// // Append to existing file (must have same snaplen and linktype) // // Append to existing file (must have same snaplen and linktype)
// f2, _ := os.OpenFile("/tmp/fileNano.pcap", os.O_APPEND, 0700) // f2, _ := os.OpenFile("/tmp/fileNano.pcap", os.O_APPEND, 0700)
// w2 := pcapgo.NewWriter(f2) // w2 := pcapgo.NewWriter(f2)
// // no need for file header, it's already written. // // no need for file header, it's already written.
// w2.WritePacket(gopacket.CaptureInfo{...}, data2) // w2.WritePacket(gopacket.CaptureInfo{...}, data2)
// f2.Close() // f2.Close()
func NewWriterNanos(w io.Writer) *Writer { func NewWriterNanos(w io.Writer) *Writer {
return &Writer{w: w, tsScaler: nanosPerNano} return &Writer{w: w, tsScaler: nanosPerNano}
} }
@@ -56,18 +56,18 @@ func NewWriterNanos(w io.Writer) *Writer {
// an append), you must call WriteFileHeader before WritePacket. // an append), you must call WriteFileHeader before WritePacket.
// Packet timestamps are written with microsecond precision. // Packet timestamps are written with microsecond precision.
// //
// // Write a new file: // // Write a new file:
// f, _ := os.Create("/tmp/file.pcap") // f, _ := os.Create("/tmp/file.pcap")
// w := pcapgo.NewWriter(f) // w := pcapgo.NewWriter(f)
// w.WriteFileHeader(65536, layers.LinkTypeEthernet) // new file, must do this. // w.WriteFileHeader(65536, layers.LinkTypeEthernet) // new file, must do this.
// w.WritePacket(gopacket.CaptureInfo{...}, data1) // w.WritePacket(gopacket.CaptureInfo{...}, data1)
// f.Close() // f.Close()
// // Append to existing file (must have same snaplen and linktype) // // Append to existing file (must have same snaplen and linktype)
// f2, _ := os.OpenFile("/tmp/file.pcap", os.O_APPEND, 0700) // f2, _ := os.OpenFile("/tmp/file.pcap", os.O_APPEND, 0700)
// w2 := pcapgo.NewWriter(f2) // w2 := pcapgo.NewWriter(f2)
// // no need for file header, it's already written. // // no need for file header, it's already written.
// w2.WritePacket(gopacket.CaptureInfo{...}, data2) // w2.WritePacket(gopacket.CaptureInfo{...}, data2)
// f2.Close() // f2.Close()
func NewWriter(w io.Writer) *Writer { func NewWriter(w io.Writer) *Writer {
return &Writer{w: w, tsScaler: nanosPerMicro} return &Writer{w: w, tsScaler: nanosPerMicro}
} }
-2
View File
@@ -4,7 +4,6 @@ parsing, reassembling tcp packets, handling communication with engine listeners(
and reporting errors and statistics of packets. and reporting errors and statistics of packets.
the packets are parsed by following TCP way(https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure). the packets are parsed by following TCP way(https://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure).
example: example:
import "github.com/buger/goreplay/tcp" import "github.com/buger/goreplay/tcp"
@@ -22,6 +21,5 @@ you can use pool.End or/and pool.Start to set custom session behaviors
debugLevel in debugger function indicates the priority of the logs, the bigger the number the lower debugLevel in debugger function indicates the priority of the logs, the bigger the number the lower
the priority. errors are signified by debug level 4 for errors, 5 for discarded packets, and 6 for received packets. the priority. errors are signified by debug level 4 for errors, 5 for discarded packets, and 6 for received packets.
*/ */
package tcp // import github.com/buger/goreplay/tcp package tcp // import github.com/buger/goreplay/tcp
@@ -4,13 +4,12 @@ import (
"encoding/binary" "encoding/binary"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/buger/goreplay/proto"
"net" "net"
"reflect" "reflect"
"sort" "sort"
"time" "time"
"unsafe" "unsafe"
"github.com/buger/goreplay/proto"
) )
// TCPProtocol is a number to indicate type of protocol // TCPProtocol is a number to indicate type of protocol
@@ -350,7 +349,7 @@ func (parser *MessageParser) processPacket(pckt *Packet) {
m.DstAddr = pckt.DstIP.String() m.DstAddr = pckt.DstIP.String()
parser.m[pckt.MessageID()] = m parser.m[pckt.MessageID()] = m
m.Start = pckt.Timestamp m.Start = pckt.Timestamp
m.parser = parser m.parser = parser
parser.addPacket(m, pckt) parser.addPacket(m, pckt)
+1 -1
View File
@@ -3,6 +3,7 @@ package tcp
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"github.com/buger/goreplay/proto"
// "runtime" // "runtime"
"testing" "testing"
@@ -10,7 +11,6 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/buger/goreplay/proto"
"github.com/google/gopacket" "github.com/google/gopacket"
"github.com/google/gopacket/layers" "github.com/google/gopacket/layers"
) )
+2 -2
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bytes" "bytes"
@@ -8,11 +8,11 @@ import (
"crypto/x509" "crypto/x509"
"errors" "errors"
"fmt" "fmt"
"github.com/buger/goreplay/proto"
"io/ioutil" "io/ioutil"
"log" "log"
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"github.com/buger/goreplay/proto"
"github.com/xdg-go/scram" "github.com/xdg-go/scram"
) )
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"fmt" "fmt"
+1 -1
View File
@@ -1,6 +1,6 @@
//go:build !race //go:build !race
package main package goreplay
import ( import (
"sync" "sync"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bufio" "bufio"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bytes" "bytes"
+2 -3
View File
@@ -1,10 +1,9 @@
package main package goreplay
import ( import (
"github.com/buger/goreplay/internal/size"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/buger/goreplay/size"
) )
// BinaryOutputConfig struct for holding binary output configuration // BinaryOutputConfig struct for holding binary output configuration
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"os" "os"
+2 -3
View File
@@ -1,10 +1,11 @@
package main package goreplay
import ( import (
"bufio" "bufio"
"compress/gzip" "compress/gzip"
"errors" "errors"
"fmt" "fmt"
"github.com/buger/goreplay/internal/size"
"io" "io"
"log" "log"
"math/rand" "math/rand"
@@ -16,8 +17,6 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/buger/goreplay/size"
) )
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
+2 -3
View File
@@ -1,7 +1,8 @@
package main package goreplay
import ( import (
"fmt" "fmt"
"github.com/buger/goreplay/internal/size"
"math/rand" "math/rand"
"os" "os"
"reflect" "reflect"
@@ -10,8 +11,6 @@ import (
"sync/atomic" "sync/atomic"
"testing" "testing"
"time" "time"
"github.com/buger/goreplay/size"
) )
func TestFileOutput(t *testing.T) { func TestFileOutput(t *testing.T) {
+2 -3
View File
@@ -1,10 +1,11 @@
package main package goreplay
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"github.com/buger/goreplay/internal/size"
"log" "log"
"math" "math"
"net/http" "net/http"
@@ -12,8 +13,6 @@ import (
"net/url" "net/url"
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/buger/goreplay/size"
) )
const ( const (
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"io/ioutil" "io/ioutil"
+3 -4
View File
@@ -1,14 +1,13 @@
package main package goreplay
import ( import (
"encoding/json" "encoding/json"
"github.com/buger/goreplay/internal/byteutils"
"github.com/buger/goreplay/proto"
"log" "log"
"strings" "strings"
"time" "time"
"github.com/buger/goreplay/byteutils"
"github.com/buger/goreplay/proto"
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
"github.com/Shopify/sarama/mocks" "github.com/Shopify/sarama/mocks"
) )
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"testing" "testing"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
// NullOutput used for debugging, prints nothing // NullOutput used for debugging, prints nothing
type NullOutput struct { type NullOutput struct {
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
_ "bufio" _ "bufio"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"context" "context"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bufio" "bufio"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"context" "context"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"reflect" "reflect"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"testing" "testing"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
// PRO this value indicates if goreplay is running in PRO mode.. // PRO this value indicates if goreplay is running in PRO mode..
// it must not be modified explicitly in production // it must not be modified explicitly in production
+1 -1
View File
@@ -1,4 +1,4 @@
// +build gofuzz //go:build gofuzz
package proto package proto
+1 -2
View File
@@ -19,13 +19,12 @@ package proto
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"github.com/buger/goreplay/internal/byteutils"
_ "fmt" _ "fmt"
"net/http" "net/http"
"net/textproto" "net/textproto"
"strings" "strings"
"github.com/buger/goreplay/byteutils"
) )
// CRLF In HTTP newline defined by 2 bytes (for both windows and *nix support) // CRLF In HTTP newline defined by 2 bytes (for both windows and *nix support)
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bytes" "bytes"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"bytes" "bytes"
+1 -1
View File
@@ -1,6 +1,6 @@
//go:build pro //go:build pro
package main package goreplay
import ( import (
"fmt" "fmt"
+3 -4
View File
@@ -1,14 +1,13 @@
package main package goreplay
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/buger/goreplay/internal/size"
"os" "os"
"strconv" "strconv"
"sync" "sync"
"time" "time"
"github.com/buger/goreplay/size"
) )
// DEMO indicates that goreplay is running in demo mode // DEMO indicates that goreplay is running in demo mode
@@ -276,7 +275,7 @@ func init() {
} }
func checkSettings() { func CheckSettings() {
if Settings.OutputFileConfig.SizeLimit < 1 { if Settings.OutputFileConfig.SizeLimit < 1 {
Settings.OutputFileConfig.SizeLimit.Set("32mb") Settings.OutputFileConfig.SizeLimit.Set("32mb")
} }
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"encoding/json" "encoding/json"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"crypto/tls" "crypto/tls"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
import ( import (
"encoding/base64" "encoding/base64"
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
type writeCallback func(*Message) type writeCallback func(*Message)
+1 -1
View File
@@ -1,4 +1,4 @@
package main package goreplay
// VERSION the current version of goreplay // VERSION the current version of goreplay
var VERSION = "1.3.0" var VERSION = "1.3.0"