Most Powerful Open Source ERP

Re6st Control Flow

Summary of re6st control flow
  • Last Update:2022-07-13
  • Version:001
  • Language:en

This page summarizes re6st control flow in the most common cases. Different re6st configurations might lead to different control flows (such as client mode).

See P-VIFIB-Re6stnet.Re6st.Components to get a summary of the components involved during the execution of re6st

Re6st Node

Initial setup, Configuration

  • Get token (through mail or HTML interface)
  • Request certificate (through HTTP RPC with the registry client)

Re6stnet process startup

These are the steps that happens once re6st is started or restarted. (re6st can restart itself in some cases, when certificate expires for instance)

  • Load configuration
  • Load and verify CA, certificate, key
  • Create cache
    • Create registry client
    • Renew certificate if necessary
    • Get network configuration from registry if it changed
    • Check protocol is higher than the minimum protocol from network configuration
  • Create UPnP forwarder if no public IPv4 available
  • (line 280)
  • Create tunnel manager
    • Get country from registry if not in cache
    • Create socket for re6st inter-node communication
  • Create openVPN server
  • Start thread to periodically check there are no default routes if --default is enabled
  • Start babel

Select loop

(reader should be familiar with the posix select function for this section)

Re6st node calls in a loop a set of custom select functions with three lists (R, W, T) as argument:

  • R: A list of read file descriptors with associated handlers
  • W: A list of write file descriptors with associated handlers
  • T: A list of timeouts with associated handlers

The custom select functions use the posix select function to make sure all handlers are executed when needed:

  • Once a read file descriptor has data to read
  • Once a write file descriptor has data to write
  • Once the timeout expires

Tasks executed during select loop

  • Periodically, at hello interval
  • Poll openVPN processes to check if there are alive
  • Every 5 seconds:
    • Check if openVPN tunnels are alive by polling the openVPN processes
    • Kill the worst tunnel if the maximum amount of tunnels has been reached
    • Make new tunnels if the maximum amount of tunnels hasn't been reached
    • Get a dump of all the neighbours from babel if necessary
  • Every minute or more:
    • If needed, refresh UPnP port forwarding to find free port
  • Certificate management:
    • Restart to renew our certificate when it is close to expiring
    • Remove peers whose certificate has expired
  • Handle messages from peers
  • openVPN events:
    • Once a openVPN client tunnel is up, re6st gets notified and receives information from openVPN (this is useful to initially know our IP for instance) 
    • When a openVPN client connects or disconnects, re6st gets notified