mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
New fixes
This commit is contained in:
+9
-2
@@ -1,9 +1,16 @@
|
||||
FROM golang:1.5
|
||||
FROM google/golang:1.4
|
||||
|
||||
RUN cd /go/src/ && GOOS=linux GOARCH=386 ./make.bash --no-clean
|
||||
RUN cd /goroot/src/ && GOOS=linux GOARCH=386 ./make.bash --no-clean
|
||||
|
||||
RUN apt-get update && apt-get install ruby vim-common -y
|
||||
|
||||
# Install Java
|
||||
# RUN apt-get install -y software-properties-common python-software-properties
|
||||
# RUN add-apt-repository -y ppa:webupd8team/java
|
||||
# RUN apt-get update -y
|
||||
# RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
|
||||
# RUN apt-get install -y oracle-java8-installer
|
||||
|
||||
WORKDIR /gopath/src/github.com/buger/gor/
|
||||
|
||||
ADD . /gopath/src/github.com/buger/gor/
|
||||
|
||||
@@ -37,10 +37,13 @@ dbench:
|
||||
|
||||
# Used mainly for debugging, because docker container do not have access to parent machine ports
|
||||
drun:
|
||||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go run $(SOURCE) --input-dummy=0 --output-http="http://localhost:9000" --input-raw :9000 --input-http :9000 --verbose --debug
|
||||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go run $(SOURCE) --input-dummy=0 --output-http="http://localhost:9000" --input-raw :9000 --input-http :9000 --verbose --debug --middleware "./examples/middleware/echo.sh"
|
||||
|
||||
drun-2:
|
||||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go run $(SOURCE) --input-file="./fixtures/requests.gor" --output-dummy --verbose --debug --middleware "./examples/middleware/echo.sh"
|
||||
|
||||
drecord:
|
||||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go run $(SOURCE) --input-dummy=0 --output-file=requests.gor --verbose
|
||||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go run $(SOURCE) --input-dummy=0 --output-file=requests.gor --verbose --debug
|
||||
|
||||
dreplay:
|
||||
docker run -v `pwd`:$(SOURCE_PATH) -t -i gor go run $(SOURCE) --input-file=requests.bin --output-tcp=:9000 --verbose -h
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
public class Echo {
|
||||
public static void main(String[] args) {
|
||||
if(args != null){
|
||||
for(String arg : args){
|
||||
System.out.println(arg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BufferedReader stdin = new BufferedReader(new InputStreamReader(
|
||||
System.in));
|
||||
String line = null;
|
||||
|
||||
try {
|
||||
while ((line = stdin.readLine()) != null) {
|
||||
|
||||
System.out.println(line);
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
IOUtils.closeQuietly(stdin);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -22,11 +22,9 @@ func NewDummyInput(options string) (di *DummyInput) {
|
||||
func (i *DummyInput) Read(data []byte) (int, error) {
|
||||
buf := <-i.data
|
||||
|
||||
header := payloadHeader(RequestPayload, uuid(), time.Now().UnixNano())
|
||||
copy(data[0:len(header)], header)
|
||||
copy(data[len(header):], buf)
|
||||
copy(data, buf)
|
||||
|
||||
return len(buf) + len(header), nil
|
||||
return len(buf), nil
|
||||
}
|
||||
|
||||
func (i *DummyInput) emit() {
|
||||
@@ -35,7 +33,12 @@ func (i *DummyInput) emit() {
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
i.data <- []byte("POST /pub/WWW/å HTTP/1.1\nHost: www.w3.org\r\n\r\na=1&b=2")
|
||||
uuid := uuid()
|
||||
reqh := payloadHeader(RequestPayload, uuid, time.Now().UnixNano())
|
||||
i.data <- append(reqh, []byte("POST /pub/WWW/å HTTP/1.1\nHost: www.w3.org\r\nContent-Length: 7\r\n\r\na=1&b=2")...)
|
||||
|
||||
resh := payloadHeader(ResponsePayload, uuid, 1)
|
||||
i.data <- append(resh, []byte("HTTP/1.1 200 OK\r\n\r\n")...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +80,6 @@ func (i *FileInput) emit() {
|
||||
|
||||
i.data <- newBuf
|
||||
}
|
||||
|
||||
log.Println("FileInput: end of file")
|
||||
}
|
||||
|
||||
+7
-2
@@ -5,6 +5,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"time"
|
||||
)
|
||||
|
||||
// HTTPInput used for sending requests to Gor via http
|
||||
@@ -27,9 +28,13 @@ func NewHTTPInput(address string) (i *HTTPInput) {
|
||||
|
||||
func (i *HTTPInput) Read(data []byte) (int, error) {
|
||||
buf := <-i.data
|
||||
copy(data, buf)
|
||||
|
||||
return len(buf), nil
|
||||
header := payloadHeader(RequestPayload, uuid(), time.Now().UnixNano())
|
||||
|
||||
copy(data[0:len(header)], header)
|
||||
copy(data[len(header):], buf)
|
||||
|
||||
return len(buf) + len(header), nil
|
||||
}
|
||||
|
||||
func (i *HTTPInput) handler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
+4
-4
@@ -10,10 +10,10 @@ import (
|
||||
|
||||
// RAWInput used for intercepting traffic for given address
|
||||
type RAWInput struct {
|
||||
data chan *raw.TCPMessage
|
||||
address string
|
||||
expire time.Duration
|
||||
quit chan bool
|
||||
data chan *raw.TCPMessage
|
||||
address string
|
||||
expire time.Duration
|
||||
quit chan bool
|
||||
listener *raw.Listener
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -26,9 +26,8 @@ func TestRAWInput(t *testing.T) {
|
||||
defer origin.Close()
|
||||
originAddr := strings.Replace(origin.Listener.Addr().String(), "[::]", "127.0.0.1", -1)
|
||||
|
||||
|
||||
var respCounter, reqCounter int64
|
||||
defer func(){
|
||||
defer func() {
|
||||
log.Println(reqCounter, respCounter)
|
||||
}()
|
||||
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ func TestEchoMiddleware(t *testing.T) {
|
||||
|
||||
quit := make(chan int)
|
||||
|
||||
Settings.middleware = "./examples/middleware/echo_modifier.sh"
|
||||
Settings.middleware = "./examples/middleware/echo.sh"
|
||||
|
||||
// Catch traffic from one service
|
||||
input := NewRAWInput(from.Listener.Addr().String(), testRawExpire)
|
||||
|
||||
+4
-4
@@ -41,9 +41,9 @@ type HTTPOutput struct {
|
||||
// aligned at 64bit. See https://github.com/golang/go/issues/599
|
||||
activeWorkers int64
|
||||
|
||||
address string
|
||||
limit int
|
||||
queue chan []byte
|
||||
address string
|
||||
limit int
|
||||
queue chan []byte
|
||||
|
||||
responses chan response
|
||||
|
||||
@@ -173,7 +173,7 @@ func (o *HTTPOutput) Write(data []byte) (n int, err error) {
|
||||
func (o *HTTPOutput) Read(data []byte) (int, error) {
|
||||
resp := <-o.responses
|
||||
|
||||
Debug("[OUTPUT-HTTP] Received response", string(resp.payload))
|
||||
Debug("[OUTPUT-HTTP] Received response:", string(resp.payload))
|
||||
|
||||
header := payloadHeader(ReplayedResponsePayload, resp.uuid, resp.roundTripTime)
|
||||
copy(data[0:len(header)], header)
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
"net"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"time"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Listener handle traffic capture
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/buger/gor/proto"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TCPMessage ensure that all TCP packets for given request is received, and processed in right sequence
|
||||
|
||||
Reference in New Issue
Block a user