Git Product home page Git Product logo

violet's Introduction

Violet - Lightweight STUN/TURN server

License: GPL v2 or later Build Docker Gitter Discord

Violet is a lightweight STUN/TURN server (RFC8489 and RFC8656) written in C without dependencies, based on libjuice.

Violet is licensed under GPLv2 or later, see LICENSE.

Oompa-Loompas rolling Violet, from Charlie and the Chocolate Factory

"Mercy! Save us!" yelled Mrs Beauregarde. "[...] Violet, you’re turning violet, Violet!" [...]

"Squeeze her," said Mr Wonka. "We've got to squeeze the juice out of her immediately."

-- Charlie and the Chocolate Factory, Roald Dahl

Dependencies

None!

Building

Clone repository and submodules

$ git clone https://github.com/paullouisageneau/violet.git
$ cd violet
$ git submodule update --init --recursive

Build with CMake

$ cmake -B build
$ cd build
$ make -j2

Running

Running the TURN server with default options is as simple as:

$ ./violet --credentials=USER:PASSWORD

Available options can be listed with the --help (or -h) flag:

$ ./violet --help

Links

Violet is available as a package on AUR.

violet's People

Contributors

gitter-badger avatar paullouisageneau avatar saroamirkhanyan avatar tinpotnick 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  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

violet's Issues

License

Any chance of you licensing violet as LGPL? (like libdatachannel)

Segmentation fault during TURN allocate request

Hello,

I wanted to report a segmentation fault during a TURN allocate request.
The bugs happens 4 times in a row. (out of 4 try, so every time).
It happens when the connection is closing or when I start a second one.

I'm creating the webrtc peer with libdatachannel and libjuice on one side:

IceServer turn("160.98.47.137", 8000, "user", "password", IceServer::RelayType::TurnUdp);
config.iceServers.emplace_back("stun:stun.1.google.com:19302");
config.iceServers.emplace_back(turn);

And on the web browser side:

if (document.getElementById('use-stun').checked) {
    config.iceServers = [
    {
        urls: ['stun:stun.l.google.com:19302']
    },
    {
        urls: ['turn:160.98.47.137:8000'],
        username: 'user',
        credential: 'password'
    }
    ];
}

let pc = new RTCPeerConnection(config);

Here is the log:

Starting program: /opt/violet --file=example.conf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
2021-07-28 17:41:03 DEBUG   udp.c:139: UDP socket bound to any:8000
2021-07-28 17:41:03 INFO    server.c:235: Created server on port 8000
[New Thread 0x7ffff7d39700 (LWP 5675)]
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:11 DEBUG   server.c:607: Answering STUN unauthorized error response
2021-07-28 17:41:11 DEBUG   server.c:717: Answering STUN error response with code 401
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:11 DEBUG   server.c:752: Processing TURN Allocate request
2021-07-28 17:41:11 DEBUG   udp.c:157: UDP socket bound to any:65275
2021-07-28 17:41:11 INFO    server.c:869: Allocated TURN relayed address 160.98.47.137:65275 for client 160.98.47.35:60510
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 INFO    server.c:737: Got STUN binding from client 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:690: Answering STUN Binding request
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:607: Answering STUN unauthorized error response
2021-07-28 17:41:11 DEBUG   server.c:717: Answering STUN error response with code 401
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:752: Processing TURN Allocate request
2021-07-28 17:41:11 DEBUG   udp.c:157: UDP socket bound to any:65276
2021-07-28 17:41:11 INFO    server.c:869: Allocated TURN relayed address 160.98.47.137:65276 for client 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:11 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:11 DEBUG   server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG   server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG   server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG   server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:12 DEBUG   server.c:899: Processing STUN CreatePermission request
2021-07-28 17:41:12 DEBUG   server.c:467: Received STUN datagram from 160.98.47.35:60510
2021-07-28 17:41:12 DEBUG   server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG   server.c:941: Processing STUN ChannelBind request
2021-07-28 17:41:12 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG   server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:12 DEBUG   server.c:994: Processing STUN Send indication
2021-07-28 17:41:12 DEBUG   server.c:481: Received ChannelData datagram from 194.230.158.225:59603
2021-07-28 17:41:15 DEBUG   server.c:467: Received STUN datagram from 194.230.158.225:59603
2021-07-28 17:41:15 DEBUG   server.c:752: Processing TURN Allocate request

Thread 2 "violet" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7d39700 (LWP 4822)]
0x000055555556537d in addr_get_len (sa=0x0) at /opt/violet_src/deps/libjuice/src/addr.c:26
26		switch (sa->sa_family) {
(gdb) list
21	
22	#include <stdio.h>
23	#include <string.h>
24	
25	socklen_t addr_get_len(const struct sockaddr *sa) {
26		switch (sa->sa_family) {
27		case AF_INET:
28			return sizeof(struct sockaddr_in);
29		case AF_INET6:
30			return sizeof(struct sockaddr_in6);
(gdb) bt
#0  0x000055555556537d in addr_get_len (sa=0x0) at /opt/violet_src/deps/libjuice/src/addr.c:26
#1  0x0000555555565b6a in addr_to_string (sa=0x0, buffer=0x7ffff7d36d00 " }\323\367\377\177", size=64) at /opt/violet_src/deps/libjuice/src/addr.c:203
#2  0x000055555556600e in addr_record_to_string (record=0x0, buffer=0x7ffff7d36d00 " }\323\367\377\177", size=64) at /opt/violet_src/deps/libjuice/src/addr.c:304
#3  0x000055555555d267 in server_process_turn_allocate (server=0x555555582500, msg=0x7ffff7d370f0, src=0x7ffff7d37d20, credentials=0x555555583570)
    at /opt/violet_src/deps/libjuice/src/server.c:868
#4  0x000055555555c5cc in server_dispatch_stun (server=0x555555582500, buf=0x7ffff7d37db0, size=124, msg=0x7ffff7d370f0, src=0x7ffff7d37d20)
    at /opt/violet_src/deps/libjuice/src/server.c:671
#5  0x000055555555b9d1 in server_input (server=0x555555582500, buf=0x7ffff7d37db0 "", len=124, src=0x7ffff7d37d20) at /opt/violet_src/deps/libjuice/src/server.c:474
#6  0x000055555555b44b in server_recv (server=0x555555582500) at /opt/violet_src/deps/libjuice/src/server.c:402
#7  0x000055555555b0ba in server_run (server=0x555555582500) at /opt/violet_src/deps/libjuice/src/server.c:348
#8  0x000055555555a2bb in server_thread_entry (arg=0x555555582500) at /opt/violet_src/deps/libjuice/src/server.c:111
#9  0x00007ffff7fa6609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#10 0x00007ffff7ecd293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

And here is the configuration file that I used:

log-level=debug

# Port for STUN/TURN server
port=8000

# Port range for TURN relay
range=49152:65535

# TURN credentials with optional quota (default none)
credentials=user:password

Thank you for your work by the way.

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.