HTTP API traffic recording and replay middleware based on GoReplay, can be used for migration and refactoring testing

Overview

gorc

HTTP API traffic recording and replay middleware based on GoReplay, can be used for migration and refactoring testing.

English | 中文

Requirements

gorc is a middleware of GoReplay, so you should install GoReplay first.

Download the latest binary from https://github.com/buger/goreplay/releases or compile by yourself or brew install gor in macOS

Install gorc

go install github.com/shockerli/gorc@latest
  • go build
git clone https://github.com/shockerli/gorc

cd gorc

go build .

Usage

--input-raw=":8001": original service port, which be recorded

--output-http="http://127.0.0.1:8002": replay request to another service

--middleware="${path-of-gorc} ${command-or-script}": gor middleware command

  • PHP
gor \
    --input-raw-track-response \
    --output-http-track-response \
    --input-raw=":8001" \
    --output-http="http://127.0.0.1:8002" \
    --middleware="go run gorc.go php examples/script.php"

gor \
    --input-raw-track-response \
    --output-http-track-response \
    --input-raw=":8001" \
    --output-http="http://127.0.0.1:8002" \
    --middleware="go run gorc.go ./examples/script.php"

gor \
    --input-raw-track-response \
    --output-http-track-response \
    --input-raw=":8001" \
    --output-http="http://127.0.0.1:8002" \
    --middleware="/path/to/bin/gorc ./examples/script.php"
  • NodeJS
gor \
    --input-raw-track-response \
    --output-http-track-response \
    --input-raw=":8001" \
    --output-http="http://127.0.0.1:8002" \
    --middleware="go run gorc.go node examples/script.js"

gor \
    --input-raw-track-response \
    --output-http-track-response \
    --input-raw=":8001" \
    --output-http="http://127.0.0.1:8002" \
    --middleware="go run gorc.go ./examples/script.js"

gor \
    --input-raw-track-response \
    --output-http-track-response \
    --input-raw=":8001" \
    --output-http="http://127.0.0.1:8002" \
    --middleware="/path/to/bin/gorc ./examples/script.js"
  • Any other programming language your machine supports

Datatype

Your custom script, read line from STDIN per request:

{
  // uuid, GoReplay generate the request unique id
  "req_id": "f33e1bab7f0000013e9b304d",
  // whole time: ns
  "latency": 1137963000,
  "request": {
    // unit: ns
    "time": 1636958850332299000,
    // unit: ns
    "latency": 0,
    "header": {
      "Accept": [
        "*/*"
      ],
      "Accept-Encoding": [
        "gzip, deflate, br"
      ],
      "Cache-Control": [
        "no-cache"
      ],
      "Connection": [
        "keep-alive"
      ],
      "Content-Length": [
        "70"
      ],
      "Content-Type": [
        "application/json"
      ],
      "User-Agent": [
        "PostmanRuntime/7.28.4"
      ]
    },
    "method": "POST",
    "uri": "/es/getTaskList",
    "proto": "HTTP/1.1",
    "body": {
      "key": "kkk",
      "type": 1
    }
  },
  "original_response": {
    "time": 1636958850404046000,
    "latency": 76000,
    "header": {
      "Connection": [
        "keep-alive"
      ],
      "Content-Type": [
        "application/json; charset=UTF-8"
      ],
      "Date": [
        "Mon, 15 Nov 2021 06:47:30 GMT"
      ],
      "Server": [
        "nginx/1.21.4"
      ],
      "X-Powered-By": [
        "PHP/7.1.33"
      ]
    },
    "status": "200 OK",
    "status_code": 200,
    "proto": "HTTP/1.1",
    "body": {
      "code": 200,
      "data": [],
      "msg": "success"
    }
  },
  "replayed_response": {
    "time": 1636958851470262000,
    "latency": 21424000,
    "header": {
      "Content-Length": [
        "107"
      ],
      "Content-Type": [
        "application/json; charset=utf-8"
      ],
      "Date": [
        "Mon, 15 Nov 2021 06:46:55 GMT"
      ]
    },
    "status": "200 OK",
    "status_code": 200,
    "proto": "HTTP/1.1",
    "body": {
      "code": 200,
      "data": [],
      "msg": "success"
    }
  }
}

License

This project is under the terms of the MIT license.

You might also like...
dumpr! is a tool to capture text based tcp traffic from the receivers point of view.
dumpr! is a tool to capture text based tcp traffic from the receivers point of view.

dumpr! dumpr! is a tool to capture text based tcp traffic. The project came about for the need to capture a web request from the back end. It was also

Reverse proxy server to filter traffic based on JA3 fingerprint/hash

JA3RP (JA3 Reverse Proxy) Ja3RP is a basic reverse proxy server that filters traffic based on JA3 fingerprints. It can also operate as a regular HTTP

Capdns is a network capture utility designed specifically for DNS traffic. This utility is based on tcpdump.
Capdns is a network capture utility designed specifically for DNS traffic. This utility is based on tcpdump.

Capdns is a network capture utility designed specifically for DNS traffic. This utility is based on tcpdump. Some of its features include: Unde

Go-http-sleep: Delayed response http server, useful for testing various timeout issue for application running behind proxy

delayed response http server, useful for testing various timeout issue for application running behind proxy

Http-server - A HTTP server and can be accessed via TLS and non-TLS mode

Application server.go runs a HTTP/HTTPS server on the port 9090. It gives you 4

Tapestry is an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate objects. This distributed system provides an interface for storing and retrieving key-value pairs.

Tapestry This project implements Tapestry, an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate

A yaml data-driven testing format together with golang testing library

Specified Yaml data-driven testing Specified is a yaml data format for data-driven testing. This enforces separation between feature being tested the

A small tool used to correspond to the IP address according to the name, id, and network alias of the docker container, which can be run as a DNS server

A small tool used to correspond to the IP address according to the name, id, and network alias of the docker container, which can be run as a DNS server

Owner
Jioby
I hear and I forget, I see and I remember, I do and I understand.
Jioby
Swiss Army knife Proxy tool for HTTP/HTTPS traffic capture, manipulation, and replay on the go.

Features • Installation • Usage • Running Proxify • Installing SSL Certificate • Applications of Proxify • Join Discord Swiss Army Knife Proxy for rap

ProjectDiscovery 1.9k Jan 8, 2023
A CLI-based HTTP intercept and replay proxy

GLORP Glorp is an HTTP intercept proxy, allowing the inspection and replaying of HTTP requests. The layout and flow was designed to function similar t

DoI 219 Dec 14, 2022
Record and replay a go net.Conn, mosting for testing.

fakeconn Record and replay a go net.Conn, mostly for testing and debugging. This package isn't finished, so you probably shouldn't use it. Recording f

null 0 Dec 5, 2021
The Akita CLI for watching network traffic, automatically generating API specs, and diffing API specs.

Catch breaking changes faster Akita builds models of your APIs to help you: Catch breaking changes on every pull request, including added/removed endp

Akita Software 230 Jan 2, 2023
Log4Shell is a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values.

Log4Shell Mitigation Log4Shell is a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values. Related to the Log4J CVE: htt

Traefik Labs 35 Dec 20, 2022
Transfer 10Gbps http traffic over 1Gbps networks :)

httpteleport Teleports 10Gbps http traffic over 1Gbps networks. Built on top of fastrpc. Use cases httpteleport may significantly reduce inter-server

Aliaksandr Valialkin 447 Nov 30, 2022
Serve traffic (HTTP/gRPC) over SSH using Domain Sockets

Serve On SSH Introduction There is often a need to offer services for administrative purposes on servers or even for microservices that are running on

John Doak 8 Nov 10, 2022
A simple network analyzer that capture http network traffic

httpcap A simple network analyzer that captures http network traffic. support Windows/MacOS/Linux/OpenWrt(x64) https only capture clienthello colorful

null 2 Oct 25, 2022