summaryrefslogtreecommitdiff
path: root/netconf-service
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-10-25 13:04:42 -0400
committerroot <root@cthulhu.zerotier.com>2013-10-25 13:04:58 -0400
commit1505e8dd504711f38e5d975022c3c5366e87791a (patch)
treef4b35079263f9cd113e70b34d2af3949400f2e1f /netconf-service
parent5901972958d6ef50671b7bbb89d2b365e4baf17c (diff)
downloadinfinitytier-1505e8dd504711f38e5d975022c3c5366e87791a.tar.gz
infinitytier-1505e8dd504711f38e5d975022c3c5366e87791a.zip
Fix netconf init and identity transfer.
Diffstat (limited to 'netconf-service')
-rw-r--r--netconf-service/netconf.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/netconf-service/netconf.cpp b/netconf-service/netconf.cpp
index 7a905863..c016410b 100644
--- a/netconf-service/netconf.cpp
+++ b/netconf-service/netconf.cpp
@@ -134,6 +134,19 @@ int main(int argc,char **argv)
return -1;
}
+ // Send ready message to tell parent that the service is up, and to
+ // solicit netconf-init.
+ {
+ Dictionary response;
+ response["type"] = "ready";
+ std::string respm = response.toString();
+ uint32_t respml = (uint32_t)htonl((uint32_t)respm.length());
+ stdoutWriteLock.lock();
+ write(STDOUT_FILENO,&respml,4);
+ write(STDOUT_FILENO,respm.data(),respm.length());
+ stdoutWriteLock.unlock();
+ }
+
for(;;) {
for(int l=0;l<4;) {
int n = (int)read(STDIN_FILENO,buf + l,4 - l);
@@ -200,13 +213,19 @@ int main(int argc,char **argv)
const std::string &reqType = request.get("type");
if (reqType == "netconf-init") { // initialization to set things like netconf's identity
Identity netconfId(request.get("netconfId"));
- if ((netconfId)&&(netconfId.hasPrivate()))
+ if ((netconfId)&&(netconfId.hasPrivate())) {
signingIdentity = netconfId;
- else {
+ fprintf(stderr,"got netconf signing identity: %s\n",signingIdentity.toString(false).c_str());
+ } else {
fprintf(stderr,"netconfId invalid or lacks private key\n");
return -1;
}
} else if (reqType == "netconf-request") { // NETWORK_CONFIG_REQUEST packet
+ if (!signingIdentity) {
+ fprintf(stderr,"no signing identity; missing netconf-init?\n");
+ return -1;
+ }
+
// Deserialize querying peer identity and network ID
Identity peerIdentity(request.get("peerId"));
uint64_t nwid = strtoull(request.get("nwid").c_str(),(char **)0,16);
@@ -459,7 +478,7 @@ int main(int argc,char **argv)
netconf[ZT_NETWORKCONFIG_DICT_KEY_IPV4_STATIC] = ipv4Static;
if (ipv6Static.length())
netconf[ZT_NETWORKCONFIG_DICT_KEY_IPV6_STATIC] = ipv6Static;
- if ((!isOpen)&&(authenticated)&&(signingIdentity)&&(signingIdentity.hasPrivate())) {
+ if ((!isOpen)&&(authenticated)) {
CertificateOfMembership com(Utils::now(),ZT_NETWORK_AUTOCONF_DELAY * 3,nwid,peerIdentity.address());
com.sign(signingIdentity);
netconf[ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATE_OF_MEMBERSHIP] = com.toString();