#ifndef ZEROCONFAUTHENTICATOR_H #define ZEROCONFAUTHENTICATOR_H #include #ifndef _WIN32 #include #endif #include #include #include #include "Utils.h" #include "LoginBlob.h" #include "Crypto.h" #include "BellTask.h" #include "ConstantParameters.h" #ifdef ESP_PLATFORM #include "mdns.h" #elif defined(_WIN32) #include "mdnssvc.h" #else #include "dns_sd.h" #include #endif #ifndef SOCK_NONBLOCK #define SOCK_NONBLOCK O_NONBLOCK #endif #define SERVER_PORT_MAX 65535 // Max usable tcp port #define SERVER_PORT_MIN 1024 // 0-1024 services ports typedef std::function)> authCallback; class ZeroconfAuthenticator { private: #ifdef _WIN32 struct mdnsd* service; #endif int serverPort; bool authorized = false; std::unique_ptr crypto; std::shared_ptr server; authCallback gotBlobCallback; void startServer(); std::string buildJsonInfo(); void handleAddUser(std::map& queryMap); void registerZeroconf(); std::string getParameterFromUrlEncoded(std::string data, std::string param); public: ZeroconfAuthenticator(authCallback callback, std::shared_ptr httpServer); void registerHandlers(); }; #endif