mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 18:18:03 +00:00
31 lines
693 B
C++
31 lines
693 B
C++
//
|
|
// Created by stephane bourque on 2022-02-05.
|
|
//
|
|
|
|
#include "RESTAPI_iptocountry_handler.h"
|
|
#include "FindCountry.h"
|
|
|
|
namespace OpenWifi {
|
|
|
|
void RESTAPI_iptocountry_handler::DoGet() {
|
|
auto IPList = GetParameter("iplist", "");
|
|
|
|
if (IPList.empty()) {
|
|
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
|
}
|
|
|
|
auto IPAddresses = Poco::StringTokenizer(IPList, ",");
|
|
Poco::JSON::Object Answer;
|
|
|
|
Answer.set("enabled", FindCountryFromIP()->Enabled());
|
|
Poco::JSON::Array Countries;
|
|
|
|
for (const auto &i : IPAddresses) {
|
|
Countries.add(FindCountryFromIP()->Get(i));
|
|
}
|
|
Answer.set("countryCodes", Countries);
|
|
|
|
return ReturnObject(Answer);
|
|
}
|
|
|
|
} // namespace OpenWifi
|