From acefa66dbd97617d86dee270b2b95ecdb763434b Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 9 Jul 2017 16:12:55 +0200 Subject: [PATCH] Store the invitation data after a succesful join. This can be used by the invitee to examine the file after a join, and process it in different ways than the tinc CLI does. --- doc/tinc.conf.5.in | 4 ++++ src/invitation.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/doc/tinc.conf.5.in b/doc/tinc.conf.5.in index 22b01d20..8b67527a 100644 --- a/doc/tinc.conf.5.in +++ b/doc/tinc.conf.5.in @@ -781,6 +781,10 @@ It can be used to set up the corresponding network interface. If an executable file with this name exists, it will be executed right before the tinc daemon is going to close its connection to the virtual network device. +.It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /invitations/ +This directory contains outstanding invitations. +.It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /invitation-data +After a succesful join, this file contains a copy of the invitation data received. .El .Sh SEE ALSO .Xr tincd 8 , diff --git a/src/invitation.c b/src/invitation.c index ac410b81..b10151f0 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -607,6 +607,15 @@ make_names: return false; } + snprintf(filename, sizeof filename, "%s" SLASH "invitation-data", confbase); + FILE *finv = fopen(filename, "w"); + if(!finv || fwrite(data, datalen, 1, finv) != 1) { + fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno)); + fclose(finv); + return false; + } + fclose(finv); + snprintf(filename, sizeof filename, "%s" SLASH "tinc-up.invitation", confbase); FILE *fup = fopen(filename, "w"); if(!fup) { -- 2.20.1