From 76bc9968ff0ec7d044042f9214fa59efb3146685 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 17 Jul 2013 14:10:44 -0400 Subject: New simpler command interface via loopback UDP protected by a crypto token. --- node/NodeConfig.hpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'node/NodeConfig.hpp') diff --git a/node/NodeConfig.hpp b/node/NodeConfig.hpp index 5c412c9b..bb24d815 100644 --- a/node/NodeConfig.hpp +++ b/node/NodeConfig.hpp @@ -31,11 +31,14 @@ #include #include #include +#include +#include #include #include "SharedPtr.hpp" #include "Network.hpp" #include "Utils.hpp" #include "Http.hpp" +#include "UdpSocket.hpp" namespace ZeroTier { @@ -49,9 +52,11 @@ class NodeConfig public: /** * @param renv Runtime environment - * @param url Autoconfiguration URL (http:// or file://) + * @param authToken Configuration authentication token + * @throws std::runtime_error Unable to bind to local control port */ - NodeConfig(const RuntimeEnvironment *renv,const std::string &url); + NodeConfig(const RuntimeEnvironment *renv,const char *authToken) + throw(std::runtime_error); ~NodeConfig(); @@ -106,32 +111,22 @@ public: } /** - * @return Time of last successful autoconfigure or refresh + * Execute a command + * + * @param command Command and arguments separated by whitespace (must already be trimmed of CR+LF, etc.) + * @return One or more command results (lines of output) */ - inline uint64_t lastAutoconfigure() const { return _lastAutoconfigure; } - - /** - * @return Autoconfiguration URL - */ - inline const std::string &url() const { return _url; } - - /** - * Refresh configuration from autoconf URL - */ - void refreshConfiguration(); + std::vector execute(const char *command); private: - void __CBautoconfHandler(const std::string &lastModified,const std::string &body); - static bool _CBautoconfHandler(Http::Request *req,void *arg,const std::string &url,int code,const std::map &headers,const std::string &body); + static void _CBcontrolPacketHandler(UdpSocket *sock,void *arg,const InetAddress &remoteAddr,const void *data,unsigned int len); const RuntimeEnvironment *_r; - volatile uint64_t _lastAutoconfigure; - - std::string _lastAutoconfigureLastModified; - std::string _url; - Mutex _autoconfigureLock; + const std::string _authToken; + unsigned char _keys[64]; // Salsa20 key, HMAC key + UdpSocket _controlSocket; std::map< uint64_t,SharedPtr > _networks; Mutex _networks_m; }; -- cgit v1.2.3