linkd

Control plane daemon for unos
git clone git://git.finwo.net/app/linkd
Log | Files | Refs | README

daemon.h (1671B)


      1 #ifndef __LINKD_CONFIG_DAEMON_H__
      2 #define __LINKD_CONFIG_DAEMON_H__
      3 
      4 #include <stddef.h>
      5 
      6 // linkd's own configuration: /etc/linkd.cnf. Same grammar as the rest, so
      7 // `source` works here too.
      8 
      9 struct linkd_plugin_cfg {
     10   char                    *target;    // executable path, or tcp://[user:pass@]host[:port]
     11   int                      optional;  // failures do not fail the operation
     12   struct linkd_plugin_cfg *next;
     13 };
     14 
     15 struct linkd_daemon_cfg {
     16   char  **ports;    size_t ports_n;   // path/glob patterns
     17   char  **iface;    size_t iface_n;
     18   char  **listen;   size_t listen_n;
     19   char   *authfile;
     20 
     21   struct linkd_plugin_cfg *plugins;
     22 };
     23 
     24 void daemon_cfg_register(void);
     25 
     26 // A missing config file is not an error; the defaults are usable.
     27 int daemon_cfg_load(const char *path);
     28 
     29 // Never NULL; returns defaults before daemon_cfg_load() runs.
     30 const struct linkd_daemon_cfg *daemon_cfg(void);
     31 
     32 void daemon_cfg_free(void);
     33 
     34 // First unix:// listen address, minus the scheme. NULL if only tcp:// is
     35 // configured. Used by the daemon to bind and by the clients to connect.
     36 const char *daemon_cfg_unix_socket(void);
     37 
     38 // Same, for the CLI tools: loads the config first, honouring $LINKD_CONFIG.
     39 // Never NULL -- falls back to the built-in default.
     40 const char *linkd_client_socket(void);
     41 
     42 // Load "ports" / "interfaces" from config_ports / config_iface patterns.
     43 // Expanded via `source`, so a pattern matching nothing is not an error.
     44 // Shared by startup and ifreload so the two cannot drift apart.
     45 int load_namespace(const char *ns_name, char **patterns, size_t n);
     46 
     47 // Default search path.
     48 #define LINKD_CONFIG_PATH "/etc/linkd.cnf"
     49 
     50 #endif // __LINKD_CONFIG_DAEMON_H__