-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added daemon basic API class and basic and incomplete 'service' classes.
- Loading branch information
Showing
9 changed files
with
312 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "APIService.h" | ||
|
||
namespace p2pnet { | ||
namespace api { | ||
|
||
APIService::APIService() { | ||
// TODO Auto-generated constructor stub | ||
|
||
} | ||
|
||
APIService::~APIService() { | ||
// TODO Auto-generated destructor stub | ||
} | ||
|
||
} /* namespace api */ | ||
} /* namespace p2pnet */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef APISERVICE_H_ | ||
#define APISERVICE_H_ | ||
|
||
namespace p2pnet { | ||
namespace api { | ||
|
||
class APIService { | ||
public: | ||
APIService(); | ||
virtual ~APIService(); | ||
}; | ||
|
||
} /* namespace api */ | ||
} /* namespace p2pnet */ | ||
|
||
#endif /* APISERVICE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "LocalService.h" | ||
|
||
namespace p2pnet { | ||
namespace service { | ||
|
||
LocalService::LocalService(service_type type) { | ||
this->type = type; | ||
this->api_service_ptr = nullptr; | ||
} | ||
|
||
LocalService::LocalService(service_type type, api::APIService* api_service_ptr) { | ||
this->type = type; | ||
this->api_service_ptr = api_service_ptr; | ||
} | ||
|
||
LocalService::~LocalService() {} | ||
|
||
SH LocalService::getSH() const { | ||
return SH(private_key.derivePublicKey()); | ||
} | ||
|
||
} /* namespace service */ | ||
} /* namespace p2pnet */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef LOCALSERVICE_H_ | ||
#define LOCALSERVICE_H_ | ||
|
||
#include "../../common/crypto/PrivateKeyDSA.h" | ||
#include "SH.h" | ||
|
||
namespace p2pnet { | ||
|
||
namespace api { | ||
class APIService; | ||
} | ||
|
||
namespace service { | ||
|
||
class LocalService { | ||
protected: | ||
api::APIService* api_service_ptr; | ||
|
||
enum service_type { | ||
STANDARD = 0, | ||
//BROADCAST = 1 | ||
} type; | ||
|
||
crypto::PrivateKeyDSA private_key; //TODO use system-wide cryptographic storage. | ||
std::set<std::string> namespaces; | ||
public: | ||
LocalService(service_type type); | ||
LocalService(service_type type, api::APIService* api_service_ptr); | ||
virtual ~LocalService(); | ||
|
||
SH getSH() const; | ||
|
||
virtual void send(SH dest, std::string data) = 0; | ||
virtual void process(SH from, std::string data) = 0; | ||
}; | ||
|
||
} /* namespace service */ | ||
} /* namespace p2pnet */ | ||
|
||
#endif /* LOCALSERVICE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef SH_H_ | ||
#define SH_H_ | ||
|
||
#include "../../common/crypto/Hash.h" | ||
|
||
namespace p2pnet { | ||
namespace service { | ||
|
||
typedef crypto::Hash SH; | ||
|
||
} /* namespace service */ | ||
} /* namespace p2pnet */ | ||
|
||
#endif /* SH_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "ServiceManager.h" | ||
|
||
namespace p2pnet { | ||
namespace service { | ||
|
||
ServiceManager::ServiceManager() { | ||
// TODO Auto-generated constructor stub | ||
|
||
} | ||
|
||
ServiceManager::~ServiceManager() { | ||
// TODO Auto-generated destructor stub | ||
} | ||
|
||
} /* namespace service */ | ||
} /* namespace p2pnet */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef SERVICEMANAGER_H_ | ||
#define SERVICEMANAGER_H_ | ||
|
||
#include <map> | ||
#include <list> | ||
#include <memory> | ||
|
||
namespace p2pnet { | ||
|
||
namespace api { | ||
class APIService; | ||
} | ||
|
||
namespace service { | ||
|
||
class LocalService; | ||
|
||
class ServiceManager { | ||
std::map<api::APIService*, std::shared_ptr<LocalService>> api_services; | ||
std::list<std::shared_ptr<LocalService>> system_services; | ||
|
||
std::map<SH, std::shared_ptr<LocalService>> services_sh; | ||
public: | ||
ServiceManager(); | ||
virtual ~ServiceManager(); | ||
|
||
void registerAPIService(api::APIService* api_service); | ||
void removeAPIService(api::APIService* api_service); | ||
}; | ||
|
||
} /* namespace service */ | ||
} /* namespace p2pnet */ | ||
|
||
#endif /* SERVICEMANAGER_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include "StandardService.h" | ||
|
||
namespace p2pnet { | ||
namespace service { | ||
|
||
StandardService::StandardService() : LocalService(STANDARD) { | ||
} | ||
|
||
StandardService::StandardService(api::APIService* api_service_ptr) : LocalService(STANDARD, api_service_ptr) { | ||
} | ||
|
||
StandardService::~StandardService() { | ||
} | ||
|
||
} /* namespace service */ | ||
} /* namespace p2pnet */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* You may redistribute this program and/or modify it under the terms of | ||
* the GNU General Public License as published by the Free Software Foundation, | ||
* either version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef STANDARDSERVICE_H_ | ||
#define STANDARDSERVICE_H_ | ||
|
||
#include "LocalService.h" | ||
|
||
namespace p2pnet { | ||
namespace service { | ||
|
||
class StandardService : public p2pnet::service::LocalService { | ||
public: | ||
StandardService(); | ||
StandardService(api::APIService* api_service_ptr); | ||
virtual ~StandardService(); | ||
}; | ||
|
||
} /* namespace service */ | ||
} /* namespace p2pnet */ | ||
|
||
#endif /* STANDARDSERVICE_H_ */ |