Use the TCP socket infrastructure for control sockets.

The control socket code was completely different from how meta connections are
handled, resulting in lots of extra code to handle requests.  Also, not every
operating system has UNIX sockets, so we have to resort to another type of
sockets or pipes for those anyway.  To reduce code duplication and make control
sockets work the same on all platforms, we now just connect to the TCP port
where tincd is already listening on.

To authenticate, the program that wants to control a running tinc daemon must
send the contents of a cookie file. The cookie is a random 256 bits number that
is regenerated every time tincd starts. The cookie file should only be readable
by the same user that can start a tincd.

Instead of the binary-ish protocol previously used, we now use an ASCII
protocol similar to that of the meta connections, but this can still change.
This commit is contained in:
Guus Sliepen 2009-11-07 23:43:25 +01:00
parent c388527e34
commit edebf579f2
18 changed files with 294 additions and 552 deletions

View file

@ -20,8 +20,11 @@
#ifndef __TINC_CONTROL_PROTOCOL_H__
#define __TINC_CONTROL_PROTOCOL_H__
#include "protocol.h"
enum request_type {
REQ_STOP,
REQ_INVALID = -1,
REQ_STOP = 0,
REQ_RELOAD,
REQ_RESTART,
REQ_DUMP_NODES,
@ -36,18 +39,4 @@ enum request_type {
#define TINC_CTL_VERSION_CURRENT 0
/* This greeting is sent by the server on socket open. */
typedef struct tinc_ctl_greeting_t {
int version;
pid_t pid;
} tinc_ctl_greeting_t;
/* A single request or response header. */
typedef struct tinc_ctl_request_t {
size_t length; /* total length, including the header */
enum request_type type;
int id;
int res_errno; /* used only for responses */
} tinc_ctl_request_t;
#endif