Giter VIP home page Giter VIP logo

shoreline's Introduction

Shoreline

A very fast pixelflut server with full IPv6 support written in C

Compiling

Dependencies

  • SDL2
  • libpthread
  • libvncserver
  • libnuma (numactl)
  • libfreetype2

On *buntu/Debian distros use sudo apt install git build-essential libsdl2-dev libpthread-stubs0-dev libvncserver-dev libnuma-dev libfreetype6-dev to install the dependencies.

Use make to build shoreline

Optionally the following environment variables can be set to control how shoreline is built:

  • INCLUDE_DIR: Allows to select an include dir other than /usr/include
  • OPTFLAGS: Allows to set the optimization flags used for this build
  • FEATURES: Allows to select what features shoreline will be built with (see Makefile for available features)

Usage

By default Shoreline runs in headless mode. In headless mode all user frontends are disabled. Use shoreline -f sdl to get a sdl window for drawing

There are a few more commandline switches:

Options:
  -p <port>                        Port to listen on (default 1234)
  -b <address>                     Address to listen on (default ::)
  -w <width>                       Width of drawing surface (default 1024)
  -h <height>                      Height of drawing surface (default 768)
  -r <update rate>                 Screen update rate in HZ (default 60)
  -s <ring size>                   Size of network ring buffer in bytes (default 65536)
  -l <listen threads>              Number of threads used to listen for incoming connections (default 10)
  -f <frontend,[option=value,...]> Frontend to use as a display. May be specified multiple times. Use -f ? to list available frontends and options
  -t <fontfile>                    Enable fancy text rendering using TTF, OTF or CFF font from <fontfile>
  -d <description>                 Set description text to be displayed in upper left corner (default https://github.com/TobleMiner/shoreline)
  -?                               Show this help

Frontend options

When specifying a frontend frontend-specific options may be passed to the frontend. For example the VNC frontend can be configured to use a nonstandard port:

shoreline -f vnc,port=2342

All available frontends and their options can be listed using shoreline -f ?.

Supported Pixelflut commands

PX <x> <y> <rrggbb|rrggbbaa> # Set pixel @(x,y) to specified hex color
PX <x> <y>                   # Get pixel @(x,y) as hex
SIZE                         # Get size of drawing surface
OFFSET <x> <y>               # Apply offset (x,y) to all further pixel draws on this connection

Alpha blending

By default alpha blending is disabled. This might cause images that contain transparency to be displayed incorrectly. You can enable alpha blending at compile time by adding ALPHA_BLENDING to the FEATURES environment variable. However, be warned this will have a large impact on performance since each pixel drawn turns into a memory read, modify, write instead of just a memory write.

Statistics

To enable on-screen statistics display shoreline needs to be passed a TTF (other formats supported by libfreetype2 will work, too) font via the -t option.

When running a system with a graphical frontend chances are you do have some TTF fonts in /usr/share/fonts/TTF/.

Statistics API

There is a special frontend called statistics. When enabled it serves a simple TCP based statistics API (default port 1235). Upon connecting to the statistics API it dumps a JSON object and closes the connection.

This is an example JSON object returned by the API:

{
  "traffic": {
    "bytes": 7292518314,
    "pixels": 405139493
  },
  "throughput": {
    "bytes": 512289334,
    "pixels": 28460518
  },
  "connections": 10,
  "fps": 59
}

Container setup

The awesome Sebastian Bernauer built a Docker based environment that makes running shoreline with fancy monitoring and colorful statistics a breeze: pixelflut-infrastructure

For optimum performance shoreline should be run on a host separate from the Docker host. Trying to run shoreline inside a Docker container might impact performance severely depending on your hardware and Docker configuration.

Troubleshooting

When using shoreline with a lot of clients default resource limits applied to processes may not be sufficient.

sysctl

The default maximum number of allowed vm mappings may not be enough. Consider increasing it by setting

vm.max_map_count = 1000000

in /etc/sysctl.d/50-vm.conf and reloading it using sysctl --system.

security/limits

Shoreline can hit the maximum number of allowed file descriptors quite easily. Increase it by setting

*		soft 	nofile		262144
*		hard 	nofile		262144

in /etc/security/limits.conf.

systemd

When running shoreline through a systemd service you will need to increase the default cgroup limits for larger installations. Consider adding the following to the [Service] section of your shoreline unit file.

TasksMax=infinity
LimitSTACK=infinity
LimitNOFILE=infinity
LimitNPROC=infinity

Hardware vulnerability mitigations

Over the past years an ever-growing set of mitigations for hardware vulnerabilities have been added to Linux. If you are only running trusted code on your system you might want to add mitigations=off to your kernel cmdline. This can result in a considerable performance increase. On Debian this change can by persisted by adding mitigations=off to GRUB_CMDLINE_LINUX in /etc/default/grub and running update-grub.

Reliability

Misbehaving VNC clients can occasionally trigger assertions in the VNC server library. When running shoreline with the VNC frontend exposed to arbitrary clients, adding a VNC multiplexer like VNCmux can improve reliability of shoreline considerably.

IP-Based Rate-Limiting

In order to rate-limit every IP to 10 established connections, you can simply use iptables:

iptables -A INPUT -p tcp -m tcp --dport 1234 --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 10 --connlimit-mask 32 --connlimit-saddr -j REJECT --reject-with icmp-port-unreachable ip6tables -A INPUT -p tcp -m tcp --dport 1234 --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 10 --connlimit-mask 128 --connlimit-saddr -j REJECT --reject-with icmp6-port-unreachable

Performance

Shoreline can easily handle full 10G line speed traffic on half way decent hardware (i7-6700, 32 GB dual channel DDR4 memory @2400 MHz)

On more beefy hardware (2x AMD EPYC 7821, 10x 8GB DDR4 ECC memory @2666 MHz, 6 memory channels) we are at about 37 Gbit/s

These results were obtained using Sturmflut as a client

VNC

With many VNC clients performance can degrade. Running a VNC multiplexer like VNCmux, even on the same host, can improve performance drastically.

shoreline's People

Contributors

craig avatar leodj avatar sbernauer avatar tobleminer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shoreline's Issues

VNC Frontend stops unintentionally

Hi there, I'm trying to put shoreline into a docker container and I managed to get it build and setup inside docker.

On the execution of shoreline - f vnc I get the following log and the server exits.

root@caca98cfbb5e:/opt# shoreline -f vnc
30/01/2019 22:48:33 Listening for VNC connections on TCP port 5900
30/01/2019 22:48:33 Listening for VNC connections on TCP6 port 5900
Shutting down frontend 'VNC server frontend'

Do you have a hint where to look at?

I use following debian packages for compiling: make g++ libvncserver-dev libnuma-dev libsdl2-dev libpthread-workqueue-dev
And those as non-dev versions on the runtime environment.

FR: transparency support

The framebuffer does not apply transparency correctly. It seems alpha values other than 0 are ignored?

See this comparison between shoreline (top) and pixelnuke (bottom) with similar inputs:

Screenshot from 2021-01-01 05-11-23 Screenshot from 2021-01-01 05-08-55

Thanks for this amazingly fast toy <3

iptables persistant rules for max. connections per ip

Would be nice if you could add this information to the readme

Connection Limit per IP via iptables (Port 1234)

Add in /etc/iptables/iptables.rules
-A INPUT -p tcp -m tcp --dport 1234 --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 10 --connlimit-mask 32 --connlimit-saddr -j REJECT --reject-with icmp-port-unreachable

Add in /etc/iptables/iptables.rules
-A INPUT -p tcp -m tcp --dport 1234 --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 10 --connlimit-mask 128 --connlimit-saddr -j REJECT --reject-with icmp6-port-unreachable

Does not compile (error: initializer element is not constant)

Hey, I tried to compile the server, but got an error at compile time, which I could not figure out how to resolve.
Playing with the frontend_ops declaration did not change the error.

OS: *buntu 18.04
Installed Packages: libsdl2-dev libpthread-workqueue-dev libvncserver-dev

Output of make:

rm -f shoreline
gcc -Ofast -Wall -march=native ring.c llist.c framebuffer.c sdl.c vnc.c network.c main.c -lpthread `pkg-config --libs --cflags sdl2 libvncserver` -D_GNU_SOURCE -o shoreline
In file included from sdl.h:7:0,
                 from sdl.c:9:
sdl.c:22:52: error: initializer element is not constant
 DECLARE_FRONTEND_NOSIG(front_sdl, "SDL2 Frontend", fops);
                                                    ^
frontend.h:32:41: note: in definition of macro ‘DECLARE_FRONTEND’
  struct frontend_def name = {frontname, frontops, sig}
                                         ^~~~~~~~
sdl.c:22:1: note: in expansion of macro ‘DECLARE_FRONTEND_NOSIG’
 DECLARE_FRONTEND_NOSIG(front_sdl, "SDL2 Frontend", fops);
 ^~~~~~~~~~~~~~~~~~~~~~
sdl.c:22:52: note: (near initialization for ‘front_sdl.ops’)
 DECLARE_FRONTEND_NOSIG(front_sdl, "SDL2 Frontend", fops);
                                                    ^
frontend.h:32:41: note: in definition of macro ‘DECLARE_FRONTEND’
  struct frontend_def name = {frontname, frontops, sig}
                                         ^~~~~~~~
sdl.c:22:1: note: in expansion of macro ‘DECLARE_FRONTEND_NOSIG’
 DECLARE_FRONTEND_NOSIG(front_sdl, "SDL2 Frontend", fops);
 ^~~~~~~~~~~~~~~~~~~~~~
In file included from vnc.h:7:0,
                 from vnc.c:3:
vnc.c:12:56: error: initializer element is not constant
 DECLARE_FRONTEND_SIG(front_vnc, "VNC server frontend", fops);
                                                        ^
frontend.h:32:41: note: in definition of macro ‘DECLARE_FRONTEND’
  struct frontend_def name = {frontname, frontops, sig}
                                         ^~~~~~~~
vnc.c:12:1: note: in expansion of macro ‘DECLARE_FRONTEND_SIG’
 DECLARE_FRONTEND_SIG(front_vnc, "VNC server frontend", fops);
 ^~~~~~~~~~~~~~~~~~~~
vnc.c:12:56: note: (near initialization for ‘front_vnc.ops’)
 DECLARE_FRONTEND_SIG(front_vnc, "VNC server frontend", fops);
                                                        ^
frontend.h:32:41: note: in definition of macro ‘DECLARE_FRONTEND’
  struct frontend_def name = {frontname, frontops, sig}
                                         ^~~~~~~~
vnc.c:12:1: note: in expansion of macro ‘DECLARE_FRONTEND_SIG’
 DECLARE_FRONTEND_SIG(front_vnc, "VNC server frontend", fops);
 ^~~~~~~~~~~~~~~~~~~~
Makefile:10: recipe for target 'shoreline' failed
make: *** [shoreline] Error 1

FEATURE: OFFSET Command not supported

Many pixelflut servers (and clients) support the OFFSET command: 'OFFSET {x} {y}\n', but shoreline currently does not. It would be nice if it was implemented. :)

Missing PX <x> <y> command

During use I noticed that the PX <x> <y> from the official documentation is not handled correctly.

It should return the color at the position <x> <y>.

Is there an easy way to patch this? (I'm before beginner on C)

FYI @TobiasSchaffner

`PX x y` API difference

PX x y returns RRGGBBAA values.
Any other server i looked at so far returns RRGGBB.
This may confuse clients. I'm unsure if there's a benefit of returning transparent pixels

[ring] Inlining

A lot of simple operations like

  • ring_peek_one
  • ring_read_one
  • ring_any_available

should probably be inline functions

Compilation failure on debian 9

Shoreline doesn't compile on Debian 9 anymore since commit 930eca2

cc -c -Wall -D_GNU_SOURCE -Ofast -march=native -DFEATURE_SIZE -DFEATURE_OFFSET -DFEATURE_STATISTICS -DFEATURE_SDL -DFEATURE_NUMA -DFEATURE_VNC -DFEATURE_TTF -DFEATURE_FBDEV -DFEATURE_PIXEL_COUNT  `pkg-config --cflags sdl2 numa libvncserver freetype2` main.c -o main.o
Package numa was not found in the pkg-config search path.
Perhaps you should add the directory containing `numa.pc'
to the PKG_CONFIG_PATH environment variable
No package 'numa' found
In file included from main.c:18:0:
sdl.h:4:17: fatal error: SDL.h: No such file or directory
 #include <SDL.h>
                 ^
compilation terminated.
Makefile:56: recipe for target 'main.o' failed
make: *** [main.o] Error 1

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.