Skip to content

Latest commit

 

History

History
123 lines (87 loc) · 3.32 KB

README.md

File metadata and controls

123 lines (87 loc) · 3.32 KB

RGaaS - Random Generator as a Service

rgaas-server is a service that generates random bytes (using rand() which is not a cryptographically secure generator). The length of the random byte sequence can be specified by the client. The server can handle multiple random number requests per connection, can handle multiple connections, serves the clients via TCP/IP and can be run as a daemon.

rgaas-client is a client to test rgaas-server (connect, request and display multiple random byte sequences of a user-specified length).

Installation from source

Prerequisites

The following tools are necessary for building:

  • cmake (3.23)
  • clang (14.0.5)

How to build

Invoke the following commands:

$ cmake .
$ cmake --build .

which will build rgaas-server and rgaas-client executables. You can find them in the build folder.

Quickstart

Invoke the following commands (daemon mode):

$ ./build/rgaas-server -p 8000 -v -d
$ ./build/rgaas-client -n <hostname> -p 8000 -v

Note: you will need to send SIGINT to the process of rgaas-server to kill it:

$ kill -INT $(pidof ./build/rgaas-server)

Invoke the following commands (foreground mode):

$ ./build/rgaas-server -p 8000 -v

Open an other terminal:

$ ./build/rgaas-client -n <hostname> -p 8000 -v

Example

$ ./build/rgaas-server -p 8000 -v
15 rgaas - program started
15 rgaas - tcp setup successful
$ ./build/rgaas-client -n fedora -p 8000 -v
15 rgaas - program started
13 rgaas - please enter the number of random bytes to be requested: 
100
13 rgaas - received from server:
�1X�Z%]X�^ԫ��ƛ�T�tA!=܇p�>�A��g>~���k��8\*;�2�<T��\��C
13 rgaas - please enter the number of random bytes to be requested: 

For developers

The following tools are necessary to format, check and test your code before git push:

  • clang-format (14.0.5)
  • clang-tidy (14.0.5)
  • valgrind (3.19.0)

How to format, check and test your code

Invoke the following commands to format your code and run static code analysis:

$ clang-format myfile.c
$ clang-tidy myfile.c

or you can recursively format and check all .c, .h files in your folder:

$ find ./myfolder/ -name *.h -o -name *.c | xargs clang-format
$ find ./myfolder/ -name *.h -o -name *.c | xargs clang-tidy

Note: clang-format uses the .clang-format and clang-tidy uses the .clang-tidy config file. .clang-format has been generated by CLion 2022.2.4 based on personal preferences, .clang-tidy has been generated with the following command:

$ clang-tidy --warnings-as-errors=* -checks=-*,cert-*,clang-analyzer-*,llvm-*,misc-*,modernize-*,performance-*,portability-*,readability-*,-llvmlibc-restrict-system-libc-headers,-readability-identifier-length,-llvm-header-guard --dump-config > .clang-tidy

and is being constantly tailored during the development.

Invoke the following command to run dynamic analysis:

$ chmod +x ./test/valgrind/valgrind.sh
$ ./test/valgrind/valgrind.sh

which will generate the following files in the build folder:

  • valgrind-server.log
  • valgrind-client.log
  • rgaas-server.log
  • rgaas-client.log

and also print analysis information to stdout.

Invoke ./build/unit-test to run the unit tests:

$ ./build/unit-test