Giter Club home page Giter Club logo

simple-echo-server's Introduction

Simple Echo Server

A simple echo server written in Rust.

Its basic use-case is for testing network connectivity in various scenario's. To this end, the project supports two modes:

  • In normal mode, the simple-echo-server executable listens for TCP connections and echoes the byte stream
  • In HTTP mode, the simple-echo-server executable listens for incoming HTTP requests and echoes the bodies of the requests.

In addition, the project includes files to run the executable in Docker and Kubernetes.

Note that a precompiled version of the executable is available in the releases page and on Docker Hub.

Requirements

To run 'bare metal', make sure you install the following:

To run in Docker in Kubernetes, however, you only need those technologies.

Compilation

Compilation is only necessary if you don't want to use the prebuilt binary/image.

Bare metal

First, clone the repository:

git clone https://github.com/Lut99/simple-echo-server && cd simple-echo-server

Next, you can build the project in the (default) TCP mode by using cargo:

cargo build --release

which will generate the executable in ./target/release/simple-echo-server.

Alternatively, to build in HTTP mode, specify the http feature:

cargo build --release --features http

which will generate the same executable, ./target/release/simple-echo-server.

Docker/Kubernetes

To build the Docker image, run the following the root of the repository:

docker build -f ./docker/Dockerfile -t simple-echo-server:latest .

Possibly, if you have the Buildx plugin installed, you may need to specify the --load flag to load the image in your daemon:

docker build --load -f ./docker/Dockerfile -t simple-echo-server:latest .

Usage

Bare metal

To run the bare metal version, run the following command:

./target/release/simple-echo-server

Run with the --help flag to see other options.

Docker

To run with Docker, simply run:

docker run -d --rm --public 80:<PORT> simple-echo-server:latest <PORT>

Kubernetes

Or, on Kubernetes:

kubectl apply -f ./k8s/deployment.yaml ./k8s/service.yaml

(To change the port, change the value of nodePort in ./k8s/service.yaml).

Calling

Once running, you can connect to it by using telnet for the TCP case, or curl for the HTTP case. For example:

# TCP case
telnet localhost <PORT>

(You can type and see the echoes, when done, hit Ctrl+], then type 'q' and hit enter)

# HTTP case, echo
curl -X GET localhost:<PORT> -d "Hello there\n"
# HTTP case, health
curl -X GET localhost:<PORT>/health

Contributing

If you want to contribute anything to this project, welcome! Feel free to checkout the issues to find anything that needs doing, or create an issue yourself. You can also create pull requests if you're eager and already implemented something.

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

simple-echo-server's People

Contributors

lut99 avatar adityakode avatar

Watchers

 avatar

simple-echo-server's Issues

Add proper README

Don't have time right now, but clearly a proper README is necessary

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.