Giter Club home page Giter Club logo

echo's Introduction

n0r1sk echo

"echo.py" is a python3 based script which starts a threaded TCP/UDP-server to display informations about itself (hostname, interfaces) and about the connecting client (IP, HTTP headers,...).

We built this Docker container for testing of docker swarm, overlay networks, load balancers and so on.

Why

In the Docker environment it is often useful to have a simple container which provides a UDP, TCP and HTTP interface that you can pull from a client and that provides some helpful information like the client ip the request originates from. Furthermore if you are dealing with Docker Swarm or internal/external loadbalancers for your service it is often helpful to test your idea with a simple Docker container to check if the correct ip address is reaching your backend service.

What

This Docker image is based on Ubuntu:16.04 because we need Python3 to power our echo.py script. We have included some additional but useful tools like netcat, telnet, curl, nslookup and netstat. These are utilities which are helpful if you need to get more information on why something is not working as expected.

Running the Docker container

Single Docker container

Starting a new container based on the n0r1skcom/echo image on a dynamic port

docker run -d -P n0r1skcom/echo

If you want to specify the exposed port you have to use the following command

docker run -d -p 22222:3333 -p 22222:3333/udp n0r1sk/echo

Example result

console output ย 

Docker Swarm service

At first you have to create a new overlay network if you have no existing overlay network you want to use. If you have one, just skip this step.

docker network create --driver overlay overlay1

Create a new docker swarm service where 22222 is the port you want to expose the echo service to your network

docker service create --name echo --network overlay1 --replicas 2 -p 22222:3333 -p 22222:3333/udp n0r1skcom/echo

To see if your service is running

docker service ps echo

If you want to deploy a newer image of your running docker swarm service

docker service update echo --image n0r1skcom/echo:latest

Build the docker container on your own

You can simply build the docker container on your own. You only have to clone this github repository on a docker host and build the docker container via the included "Dockerfile"

git clone https://github.com/n0r1sk/echo.git
cd echo
docker build .

Start to use the echo tcp/udp-server

TCP

You can simply connect to the server via telnet

telnet IP_OF_DOCKER_HOST PORT_OF_DOCKER_CONTAINER

Or, if you want to see some http headers, just use curl

curl --header "X-Forwarded-For: 192.168.0.2" http://IP_OF_DOCKER_HOST:PORT_OF_DOCKER_CONTAINER

UDP

For testing udp connections

netcat -u IP_OF_DOCKER_HOST PORT_OF_DOCKER_CONTAINER

Or just use echo (WARNING -> no further output on client -> one way communication)

echo -n "test" > /dev/udp/IP_OF_DOCKER_HOST/PORT_OF_DOCKER_CONTAINER

FAQ

No questions so far... :)

If you have any questions please don't hesitate to contact us via github-comment or by mail. If you find a problem please open an issue here on github.

echo's People

Contributors

m4r10k avatar wrichter avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.