Skip to content

demerphq/relay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socket<->socket relay that listens on UDP or TCP port and enqueues
packets into one or more workers which send them to their destination.

If the remote socket is TCP then the relay uses TCP_CORK (if available).

install:

    $ git clone https://github.com/demerphq/relay.git
    $ cd relay
    $ make
    $ ./bin/event-relay --help

packet \         / worker -> listener-1
packet  |- relay - worker -> listener-2
packet /         \ worker -> listener-3

main_thread
    -> foreach listener
        -> start one worker thread
    -> listen for udp sereal packet
        -> append sereal packet to queue for each worker

worker
    main_loop:
    -> if queue is non-empty
        -> lock queue
           hijack queue (move items from queue to local storage)
           unlock queue
        -> open connection to listener
        -> while items in hijacked queue
            -> try to send top item to listener
                -> if it fails: write remaining items to disk
                   goto main_loop
                -> if it is ok: pop item from hijacked queue.
        -> close connection