Skip to content

aykhans/ech0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ech0

A raw TCP echo server that reflects HTTP requests exactly as received. Built on raw TCP sockets, so headers and body are echoed exactly as received.

Usage

docker run -p 8421:8421 aykhans/ech0
curl http://localhost:8421/hello
Remote-Addr: 172.17.0.1:54321

GET /hello HTTP/1.1

--- Headers ---
Host: localhost:8421
User-Agent: curl/8.5.0
Accept: */*

JSON output

curl "http://localhost:8421/hello?format=json"
{
  "method": "GET",
  "path": "/hello?format=json",
  "proto": "HTTP/1.1",
  "remote_addr": "172.17.0.1:54321",
  "headers": [
    "Host: localhost:8421",
    "User-Agent: curl/8.5.0",
    "Accept: */*"
  ],
  "query_params": {
    "format": [
      "json"
    ]
  }
}

Custom status code

curl -w "\n%{http_code}" "http://localhost:8421/?status=404"

POST with body

curl -X POST http://localhost:8421/ -d '{"key": "value"}' -H "Content-Type: application/json"
Remote-Addr: 172.17.0.1:54321

POST / HTTP/1.1

--- Headers ---
Host: localhost:8421
User-Agent: curl/8.5.0
Accept: */*
Content-Type: application/json
Content-Length: 16

--- Body (16 bytes) ---
{"key": "value"}

Query Parameters

Parameter Description
format Set to json for JSON output, otherwise plain text
status Set the response status code (any integer)

Environment Variables

Variable Default Description
PORT 8421 Port to listen on
REMOTE_ADDR_HEADER Header to read the client IP from (e.g. X-Forwarded-For, X-Real-IP). When set, the header is removed from the echoed response.

Install

Docker

docker run -p 8421:8421 aykhans/ech0

Behind a reverse proxy:

docker run -p 8421:8421 -e REMOTE_ADDR_HEADER=X-Forwarded-For aykhans/ech0

Binary

Download from releases.

./ech0

About

HTTP echo server built on raw TCP sockets.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors