mirror of
				https://github.com/Telecominfraproject/wlan-cloud-owprov.git
				synced 2025-11-03 20:17:54 +00:00 
			
		
		
		
	Compare commits
	
		
			225 Commits
		
	
	
		
			release/v2
			...
			v4.0.0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					939ebbde0d | ||
| 
						 | 
					0ef1dad4dc | ||
| 
						 | 
					d001c44a81 | ||
| 
						 | 
					1bd1cf0af6 | ||
| 
						 | 
					6ce0f2fb51 | ||
| 
						 | 
					020ff8641a | ||
| 
						 | 
					342c6900ef | ||
| 
						 | 
					a549024a29 | ||
| 
						 | 
					6f84eeb901 | ||
| 
						 | 
					c44dabe2f3 | ||
| 
						 | 
					c78888372c | ||
| 
						 | 
					4ae0b99f55 | ||
| 
						 | 
					41e172be25 | ||
| 
						 | 
					d7e05eac60 | ||
| 
						 | 
					fd25e19095 | ||
| 
						 | 
					3b8a8bafff | ||
| 
						 | 
					20785d82ce | ||
| 
						 | 
					1327b29d7b | ||
| 
						 | 
					226cd3e9e9 | ||
| 
						 | 
					de512f0e2c | ||
| 
						 | 
					7a845e2f8c | ||
| 
						 | 
					b0f925a7c0 | ||
| 
						 | 
					984c8fafac | ||
| 
						 | 
					da23ff1192 | ||
| 
						 | 
					4b07db924d | ||
| 
						 | 
					10a39f2f50 | ||
| 
						 | 
					8fc7ce7ca8 | ||
| 
						 | 
					da015b2ea0 | ||
| 
						 | 
					cd9fdc7a91 | ||
| 
						 | 
					a619c0dbe1 | ||
| 
						 | 
					2575fa628a | ||
| 
						 | 
					3529f86788 | ||
| 
						 | 
					0a846e45c4 | ||
| 
						 | 
					01b1107bac | ||
| 
						 | 
					9412c0094b | ||
| 
						 | 
					d6e3701ca3 | ||
| 
						 | 
					5ac7b92f1f | ||
| 
						 | 
					74557c1600 | ||
| 
						 | 
					c6535500f2 | ||
| 
						 | 
					2e8a2fe1c8 | ||
| 
						 | 
					102e240c7e | ||
| 
						 | 
					fd85c70c2f | ||
| 
						 | 
					ec11708046 | ||
| 
						 | 
					eed9525845 | ||
| 
						 | 
					4ded8997cd | ||
| 
						 | 
					4ab9a1d6ac | ||
| 
						 | 
					bc116c1d82 | ||
| 
						 | 
					b7b58196e6 | ||
| 
						 | 
					f5b5b3eb13 | ||
| 
						 | 
					5a8d5a1fa1 | ||
| 
						 | 
					4e92a19b90 | ||
| 
						 | 
					713b995d01 | ||
| 
						 | 
					8eb60b00ad | ||
| 
						 | 
					eb241d9be4 | ||
| 
						 | 
					836fb44991 | ||
| 
						 | 
					3eb579038c | ||
| 
						 | 
					0121ed5073 | ||
| 
						 | 
					51d7e599fb | ||
| 
						 | 
					fc307dace5 | ||
| 
						 | 
					5a646ebd49 | ||
| 
						 | 
					a296c31127 | ||
| 
						 | 
					f506b6e2ab | ||
| 
						 | 
					f5676b0917 | ||
| 
						 | 
					5094157f98 | ||
| 
						 | 
					dee0f1fc01 | ||
| 
						 | 
					43e9d8a775 | ||
| 
						 | 
					951164128c | ||
| 
						 | 
					1caa757a77 | ||
| 
						 | 
					7972b7cd6a | ||
| 
						 | 
					6eb50d1318 | ||
| 
						 | 
					1bb9f492d2 | ||
| 
						 | 
					0ecf5fdef9 | ||
| 
						 | 
					a20dd5ad47 | ||
| 
						 | 
					09351c4bbb | ||
| 
						 | 
					e5999a3810 | ||
| 
						 | 
					52e698c5db | ||
| 
						 | 
					8735dafbb0 | ||
| 
						 | 
					60ff1e76d3 | ||
| 
						 | 
					c1fbac422b | ||
| 
						 | 
					089edd2864 | ||
| 
						 | 
					09306f8547 | ||
| 
						 | 
					885619e5ae | ||
| 
						 | 
					3d32768bd4 | ||
| 
						 | 
					5300b56ab7 | ||
| 
						 | 
					d9eb14c962 | ||
| 
						 | 
					c7043fa12c | ||
| 
						 | 
					541266f7cf | ||
| 
						 | 
					ecf660e568 | ||
| 
						 | 
					f82739688b | ||
| 
						 | 
					969bcb0c25 | ||
| 
						 | 
					d74e791fae | ||
| 
						 | 
					08976831f2 | ||
| 
						 | 
					eb4722d944 | ||
| 
						 | 
					bf17e99ccf | ||
| 
						 | 
					4af09f15cf | ||
| 
						 | 
					f74a3877ae | ||
| 
						 | 
					cf2f3f57e9 | ||
| 
						 | 
					c3938921ce | ||
| 
						 | 
					174f62992c | ||
| 
						 | 
					8ba53d416b | ||
| 
						 | 
					2c7b9cf1bd | ||
| 
						 | 
					91826d136a | ||
| 
						 | 
					a6ac483ec3 | ||
| 
						 | 
					ce3ae0650f | ||
| 
						 | 
					a0c0efff73 | ||
| 
						 | 
					ae9c464fb3 | ||
| 
						 | 
					6575e47c74 | ||
| 
						 | 
					507ece011f | ||
| 
						 | 
					7f5fb52157 | ||
| 
						 | 
					e6bc329e7b | ||
| 
						 | 
					acf3c060c2 | ||
| 
						 | 
					0437a8ed6a | ||
| 
						 | 
					3b2d94172d | ||
| 
						 | 
					c573601a91 | ||
| 
						 | 
					fcd9c48569 | ||
| 
						 | 
					ad31dedf22 | ||
| 
						 | 
					6ff4308f7e | ||
| 
						 | 
					5bb9c1f427 | ||
| 
						 | 
					e1af5adccb | ||
| 
						 | 
					aec31441d4 | ||
| 
						 | 
					14efffa612 | ||
| 
						 | 
					25ebd7f203 | ||
| 
						 | 
					8cb6d58573 | ||
| 
						 | 
					6d9b9747a0 | ||
| 
						 | 
					a951cb0549 | ||
| 
						 | 
					27f6d7c552 | ||
| 
						 | 
					9ed74e0149 | ||
| 
						 | 
					b8ca24183d | ||
| 
						 | 
					af6a30d248 | ||
| 
						 | 
					3469b20c28 | ||
| 
						 | 
					65e5669bd5 | ||
| 
						 | 
					a8581f8f95 | ||
| 
						 | 
					fcce87d160 | ||
| 
						 | 
					e5f9759667 | ||
| 
						 | 
					817aeb405c | ||
| 
						 | 
					3292649808 | ||
| 
						 | 
					a8da1a4223 | ||
| 
						 | 
					69e507a5bd | ||
| 
						 | 
					7dd33ca841 | ||
| 
						 | 
					3029fbd596 | ||
| 
						 | 
					b7cb91b022 | ||
| 
						 | 
					4658f046d9 | ||
| 
						 | 
					9afdf685a4 | ||
| 
						 | 
					b4f5f8bde1 | ||
| 
						 | 
					05ddc258ac | ||
| 
						 | 
					23120feb82 | ||
| 
						 | 
					16f8f788d5 | ||
| 
						 | 
					0e54497c57 | ||
| 
						 | 
					2c612ab136 | ||
| 
						 | 
					48d3831052 | ||
| 
						 | 
					8388d12c88 | ||
| 
						 | 
					bc8e7e8ac9 | ||
| 
						 | 
					74ba4d8d8c | ||
| 
						 | 
					87c4b714b1 | ||
| 
						 | 
					91d833b669 | ||
| 
						 | 
					30e38c21fc | ||
| 
						 | 
					723e20de44 | ||
| 
						 | 
					03bd284183 | ||
| 
						 | 
					9ea65ebe5d | ||
| 
						 | 
					26a1d5df44 | ||
| 
						 | 
					dfc97ee8f9 | ||
| 
						 | 
					8e07eeb000 | ||
| 
						 | 
					3ed97e6c18 | ||
| 
						 | 
					e71b83ced7 | ||
| 
						 | 
					1d077b945d | ||
| 
						 | 
					ba46c1558c | ||
| 
						 | 
					ca1cf64fa2 | ||
| 
						 | 
					1948c50ad4 | ||
| 
						 | 
					c5737de2fc | ||
| 
						 | 
					5a3ce59073 | ||
| 
						 | 
					26fc29ac12 | ||
| 
						 | 
					19314815cd | ||
| 
						 | 
					5b040d132f | ||
| 
						 | 
					5bdcbe8423 | ||
| 
						 | 
					1ce856f222 | ||
| 
						 | 
					9068eb32b7 | ||
| 
						 | 
					4c9dbd76e1 | ||
| 
						 | 
					4c2ba2ec28 | ||
| 
						 | 
					a1176e7f4d | ||
| 
						 | 
					f2b1169d8c | ||
| 
						 | 
					5650e0decc | ||
| 
						 | 
					98f37d4748 | ||
| 
						 | 
					2065bd872d | ||
| 
						 | 
					96cfaf5051 | ||
| 
						 | 
					63f49db54c | ||
| 
						 | 
					7b524aa974 | ||
| 
						 | 
					7d995e7cb1 | ||
| 
						 | 
					94ce329143 | ||
| 
						 | 
					f9af051ce9 | ||
| 
						 | 
					87653e1e4b | ||
| 
						 | 
					4b78e64eb5 | ||
| 
						 | 
					3dadc191d5 | ||
| 
						 | 
					8a12becd2b | ||
| 
						 | 
					74de9188d2 | ||
| 
						 | 
					cb7ad596e2 | ||
| 
						 | 
					19528133a3 | ||
| 
						 | 
					043c167d3d | ||
| 
						 | 
					1d14018470 | ||
| 
						 | 
					5660689d68 | ||
| 
						 | 
					4fecee46ac | ||
| 
						 | 
					797a7f20bc | ||
| 
						 | 
					5390d1fcec | ||
| 
						 | 
					bf20fc27eb | ||
| 
						 | 
					69dce68d1a | ||
| 
						 | 
					ca7c618c16 | ||
| 
						 | 
					8826031939 | ||
| 
						 | 
					21f8742bd8 | ||
| 
						 | 
					5cc00a2e72 | ||
| 
						 | 
					b950694753 | ||
| 
						 | 
					3ce14e5efe | ||
| 
						 | 
					7f860eb633 | ||
| 
						 | 
					2628fe1b6a | ||
| 
						 | 
					29a48f6753 | ||
| 
						 | 
					f8220e3a5e | ||
| 
						 | 
					8dde169148 | ||
| 
						 | 
					0437031d78 | ||
| 
						 | 
					2242b02f0f | ||
| 
						 | 
					8287628583 | ||
| 
						 | 
					7b3de5d5ef | ||
| 
						 | 
					6007c1f06f | ||
| 
						 | 
					74916abdbd | ||
| 
						 | 
					0899c6f2d9 | ||
| 
						 | 
					f51b2bd11e | ||
| 
						 | 
					8b21ef16a1 | ||
| 
						 | 
					7ad4de4960 | 
							
								
								
									
										2
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/ci.yml
									
									
									
									
										vendored
									
									
								
							@@ -21,7 +21,7 @@ defaults:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  docker:
 | 
					  docker:
 | 
				
			||||||
    runs-on: ubuntu-20.04
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
    env:
 | 
					    env:
 | 
				
			||||||
      DOCKER_REGISTRY_URL: tip-tip-wlan-cloud-ucentral.jfrog.io
 | 
					      DOCKER_REGISTRY_URL: tip-tip-wlan-cloud-ucentral.jfrog.io
 | 
				
			||||||
      DOCKER_REGISTRY_USERNAME: ucentral
 | 
					      DOCKER_REGISTRY_USERNAME: ucentral
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										32
									
								
								BUILDING.md
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								BUILDING.md
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
# Building from source
 | 
					# Building from source
 | 
				
			||||||
In order to build the OWPROV, you will need to install its dependencies, which includes the following:
 | 
					In order to build OWPROV, you will need to install its dependencies, which includes the following:
 | 
				
			||||||
- cmake
 | 
					- cmake
 | 
				
			||||||
- boost
 | 
					- boost
 | 
				
			||||||
- POCO 1.10.1 or later
 | 
					- POCO 1.10.1 or later
 | 
				
			||||||
@@ -12,19 +12,19 @@ In order to build the OWPROV, you will need to install its dependencies, which i
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
The build is done in 2 parts. The first part is to build a local copy of the framework tailored to your environment. This
 | 
					The build is done in 2 parts. The first part is to build a local copy of the framework tailored to your environment. This
 | 
				
			||||||
framework is called [Poco](https://github.com/pocoproject/poco). The version used in this project has a couple of fixes
 | 
					framework is called [Poco](https://github.com/pocoproject/poco). The version used in this project has a couple of fixes
 | 
				
			||||||
from the master copy needed for cmake. Please use the version of this [Poco fix](https://github.com/AriliaWireless/poco). Building
 | 
					from the master copy needed for cmake. Please use the version of this [Poco fix](https://github.com/Telecominfraproject/wlan-cloud-lib-poco). Building
 | 
				
			||||||
Poco may take several minutes depending on the platform you are building on.
 | 
					Poco may take several minutes depending on the platform you are building on.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Ubuntu
 | 
					## Ubuntu
 | 
				
			||||||
These instructions have proven to work on Ubuntu 20.4.
 | 
					These instructions have proven to work on Ubuntu 20.4.
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
sudo apt install git cmake g++ libssl-dev libmariadb-dev 
 | 
					sudo apt install git cmake g++ libssl-dev libmariadb-dev
 | 
				
			||||||
sudo apt install libpq-dev libaprutil1-dev apache2-dev libboost-all-dev
 | 
					sudo apt install libpq-dev libaprutil1-dev apache2-dev libboost-all-dev
 | 
				
			||||||
sudo apt install librdkafka-dev // default-libmysqlclient-dev
 | 
					sudo apt install librdkafka-dev // default-libmysqlclient-dev
 | 
				
			||||||
sudo apt install nlohmann-json-dev
 | 
					sudo apt install nlohmann-json-dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
 | 
				
			||||||
cd poco
 | 
					cd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -33,7 +33,7 @@ cmake --build . --config Release
 | 
				
			|||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
 | 
				
			||||||
cd cppkafka
 | 
					cd cppkafka
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -42,7 +42,7 @@ cmake --build . --config Release
 | 
				
			|||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/AriliaWireless/valijson --branch tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
 | 
				
			||||||
cd valijson
 | 
					cd valijson
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -50,7 +50,8 @@ cmake ..
 | 
				
			|||||||
cmake --build . --config Release
 | 
					cmake --build . --config Release
 | 
				
			||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/fmtlib/fmt --branch 9.0.0 /fmtlib
 | 
					cd ~
 | 
				
			||||||
 | 
					git clone https://github.com/fmtlib/fmt --branch 9.0.0 fmtlib
 | 
				
			||||||
cd fmtlib
 | 
					cd fmtlib
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -71,11 +72,11 @@ make -j 8
 | 
				
			|||||||
The following instructions have proven to work on Fedora 33
 | 
					The following instructions have proven to work on Fedora 33
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
sudo yum install cmake g++ openssl-devel mysql-devel mysql apr-util-devel boost boost-devel
 | 
					sudo yum install cmake g++ openssl-devel mysql-devel mysql apr-util-devel boost boost-devel
 | 
				
			||||||
sudo yum install yaml-cpp-devel lua-devel 
 | 
					sudo yum install yaml-cpp-devel lua-devel
 | 
				
			||||||
sudo dnf install postgresql.x86_64 librdkafka-devel
 | 
					sudo dnf install postgresql.x86_64 librdkafka-devel
 | 
				
			||||||
sudo dnf install postgresql-devel json-devel
 | 
					sudo dnf install postgresql-devel json-devel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
 | 
				
			||||||
cd poco
 | 
					cd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -83,7 +84,8 @@ cmake ..
 | 
				
			|||||||
cmake --build . --config Release
 | 
					cmake --build . --config Release
 | 
				
			||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
 | 
					cd ~
 | 
				
			||||||
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
 | 
				
			||||||
cd cppkafka
 | 
					cd cppkafka
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -92,7 +94,7 @@ cmake --build . --config Release
 | 
				
			|||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/AriliaWireless/valijson --branch tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
 | 
				
			||||||
cd valijson
 | 
					cd valijson
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -125,7 +127,7 @@ brew install openssl \
 | 
				
			|||||||
	nlohmann-json \
 | 
						nlohmann-json \
 | 
				
			||||||
	fmt
 | 
						fmt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
 | 
				
			||||||
pushd poco
 | 
					pushd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
push cmake-build
 | 
					push cmake-build
 | 
				
			||||||
@@ -135,7 +137,7 @@ sudo cmake --build . --target install
 | 
				
			|||||||
popd
 | 
					popd
 | 
				
			||||||
popd
 | 
					popd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
 | 
				
			||||||
pushd cppkafka
 | 
					pushd cppkafka
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
pushd cmake-build
 | 
					pushd cmake-build
 | 
				
			||||||
@@ -145,7 +147,7 @@ sudo cmake --build . --target install
 | 
				
			|||||||
popd
 | 
					popd
 | 
				
			||||||
popd
 | 
					popd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/AriliaWireless/valijson --branch tip-v1
 | 
					git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
 | 
				
			||||||
cd valijson
 | 
					cd valijson
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -172,6 +174,8 @@ adding -DSMALL_BUILD=1 on the cmake build line.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
sudo apt install git cmake g++ libssl-dev libaprutil1-dev apache2-dev libboost-all-dev libyaml-cpp-dev
 | 
					sudo apt install git cmake g++ libssl-dev libaprutil1-dev apache2-dev libboost-all-dev libyaml-cpp-dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/stephb9959/poco
 | 
					git clone https://github.com/stephb9959/poco
 | 
				
			||||||
cd poco
 | 
					cd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.13)
 | 
					cmake_minimum_required(VERSION 3.13)
 | 
				
			||||||
project(owprov VERSION 2.9.0)
 | 
					project(owprov VERSION 3.2.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(CMAKE_CXX_STANDARD 17)
 | 
					set(CMAKE_CXX_STANDARD 17)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -37,7 +37,7 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
 | 
				
			|||||||
    string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
 | 
					    string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
 | 
					add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT -DBOOST_NO_CXX98_FUNCTION_BASE=1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
find_package(OpenSSL    REQUIRED)
 | 
					find_package(OpenSSL    REQUIRED)
 | 
				
			||||||
find_package(ZLIB       REQUIRED)
 | 
					find_package(ZLIB       REQUIRED)
 | 
				
			||||||
@@ -117,6 +117,7 @@ add_executable(owprov
 | 
				
			|||||||
        src/framework/MicroServiceExtra.h
 | 
					        src/framework/MicroServiceExtra.h
 | 
				
			||||||
        src/framework/ConfigurationValidator.cpp
 | 
					        src/framework/ConfigurationValidator.cpp
 | 
				
			||||||
        src/framework/ConfigurationValidator.h
 | 
					        src/framework/ConfigurationValidator.h
 | 
				
			||||||
 | 
					        src/framework/default_device_types.h
 | 
				
			||||||
        src/UI_Prov_WebSocketNotifications.h
 | 
					        src/UI_Prov_WebSocketNotifications.h
 | 
				
			||||||
        src/UI_Prov_WebSocketNotifications.cpp
 | 
					        src/UI_Prov_WebSocketNotifications.cpp
 | 
				
			||||||
        src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
 | 
					        src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
 | 
				
			||||||
@@ -208,12 +209,37 @@ add_executable(owprov
 | 
				
			|||||||
        src/ProvWebSocketClient.cpp src/ProvWebSocketClient.h
 | 
					        src/ProvWebSocketClient.cpp src/ProvWebSocketClient.h
 | 
				
			||||||
        src/Tasks/VenueRebooter.h src/Tasks/VenueUpgrade.h
 | 
					        src/Tasks/VenueRebooter.h src/Tasks/VenueUpgrade.h
 | 
				
			||||||
        src/sdks/SDK_fms.cpp src/sdks/SDK_fms.h
 | 
					        src/sdks/SDK_fms.cpp src/sdks/SDK_fms.h
 | 
				
			||||||
        src/RESTAPI/RESTAPI_overrides_handler.cpp src/RESTAPI/RESTAPI_overrides_handler.h)
 | 
					        src/RESTAPI/RESTAPI_overrides_handler.cpp src/RESTAPI/RESTAPI_overrides_handler.h
 | 
				
			||||||
 | 
					        src/storage/storage_glblraccounts.cpp src/storage/storage_glblraccounts.h
 | 
				
			||||||
 | 
					        src/storage/storage_glblrcerts.cpp src/storage/storage_glblrcerts.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.cpp src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.cpp src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.cpp src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.h
 | 
				
			||||||
 | 
					        src/storage/storage_orion_accounts.cpp src/storage/storage_orion_accounts.h
 | 
				
			||||||
 | 
					        src/storage/storage_radius_endpoints.cpp
 | 
				
			||||||
 | 
					        src/storage/storage_radius_endpoints.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_radiusendpoint_list_handler.cpp
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_radiusendpoint_list_handler.h
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_radius_endpoint_handler.cpp
 | 
				
			||||||
 | 
					        src/RESTAPI/RESTAPI_radius_endpoint_handler.h
 | 
				
			||||||
 | 
					        src/RadiusEndpointTypes/GlobalReach.cpp src/RadiusEndpointTypes/GlobalReach.h
 | 
				
			||||||
 | 
					        src/RadiusEndpointTypes/OrionWifi.h
 | 
				
			||||||
 | 
					        src/RadiusEndpointUpdater.cpp
 | 
				
			||||||
 | 
					        src/RadiusEndpointUpdater.h
 | 
				
			||||||
 | 
					        src/RadiusEndpointTypes/Radsec.cpp
 | 
				
			||||||
 | 
					        src/RadiusEndpointTypes/Radsec.h
 | 
				
			||||||
 | 
					        src/RadiusEndpointTypes/GenericRadius.cpp
 | 
				
			||||||
 | 
					        src/RadiusEndpointTypes/GenericRadius.h
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
target_link_libraries(owprov PUBLIC
 | 
					target_link_libraries(owprov PUBLIC
 | 
				
			||||||
        ${Poco_LIBRARIES}
 | 
					        ${Poco_LIBRARIES}
 | 
				
			||||||
        ${MySQL_LIBRARIES}
 | 
					        ${MySQL_LIBRARIES}
 | 
				
			||||||
        ${ZLIB_LIBRARIES}
 | 
					        ${ZLIB_LIBRARIES}
 | 
				
			||||||
        CppKafka::cppkafka
 | 
					        CppKafka::cppkafka
 | 
				
			||||||
 | 
					        resolv
 | 
				
			||||||
        fmt::fmt)
 | 
					        fmt::fmt)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -15,8 +15,9 @@ FROM build-base AS poco-build
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ARG POCO_VERSION
 | 
					ARG POCO_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ADD https://api.github.com/repos/AriliaWireless/poco/git/refs/tags/${POCO_VERSION} version.json
 | 
					ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-poco/git/refs/tags/${POCO_VERSION} version.json
 | 
				
			||||||
RUN git clone https://github.com/AriliaWireless/poco --branch ${POCO_VERSION} /poco
 | 
					RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch ${POCO_VERSION} /poco
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WORKDIR /poco
 | 
					WORKDIR /poco
 | 
				
			||||||
RUN mkdir cmake-build
 | 
					RUN mkdir cmake-build
 | 
				
			||||||
@@ -29,8 +30,8 @@ FROM build-base AS cppkafka-build
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ARG CPPKAFKA_VERSION
 | 
					ARG CPPKAFKA_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ADD https://api.github.com/repos/AriliaWireless/cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json
 | 
					ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json
 | 
				
			||||||
RUN git clone https://github.com/AriliaWireless/cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka
 | 
					RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WORKDIR /cppkafka
 | 
					WORKDIR /cppkafka
 | 
				
			||||||
RUN mkdir cmake-build
 | 
					RUN mkdir cmake-build
 | 
				
			||||||
@@ -43,8 +44,8 @@ FROM build-base AS valijson-build
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ARG VALIJASON_VERSION
 | 
					ARG VALIJASON_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ADD https://api.github.com/repos/AriliaWireless/valijson/git/refs/tags/${VALIJASON_VERSION} version.json
 | 
					ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-valijson/git/refs/tags/${VALIJASON_VERSION} version.json
 | 
				
			||||||
RUN git clone https://github.com/AriliaWireless/valijson --branch ${VALIJASON_VERSION} /valijson
 | 
					RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch ${VALIJASON_VERSION} /valijson
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WORKDIR /valijson
 | 
					WORKDIR /valijson
 | 
				
			||||||
RUN mkdir cmake-build
 | 
					RUN mkdir cmake-build
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										84
									
								
								config-samples/OpenRo.am Test.mobileconfig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								config-samples/OpenRo.am Test.mobileconfig
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,84 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 | 
				
			||||||
 | 
					<plist version="1.0">
 | 
				
			||||||
 | 
					<dict>
 | 
				
			||||||
 | 
						<key>PayloadContent</key>
 | 
				
			||||||
 | 
						<array>
 | 
				
			||||||
 | 
							<dict>
 | 
				
			||||||
 | 
								<key>AutoJoin</key>
 | 
				
			||||||
 | 
								<true/>
 | 
				
			||||||
 | 
								<key>CaptiveBypass</key>
 | 
				
			||||||
 | 
								<false/>
 | 
				
			||||||
 | 
								<key>DisableAssociationMACRandomization</key>
 | 
				
			||||||
 | 
								<false/>
 | 
				
			||||||
 | 
								<key>DisplayedOperatorName</key>
 | 
				
			||||||
 | 
								<string>OpenRo.am</string>
 | 
				
			||||||
 | 
								<key>DomainName</key>
 | 
				
			||||||
 | 
								<string>openro.am</string>
 | 
				
			||||||
 | 
								<key>EAPClientConfiguration</key>
 | 
				
			||||||
 | 
								<dict>
 | 
				
			||||||
 | 
									<key>AcceptEAPTypes</key>
 | 
				
			||||||
 | 
									<array>
 | 
				
			||||||
 | 
										<integer>21</integer>
 | 
				
			||||||
 | 
									</array>
 | 
				
			||||||
 | 
									<key>OuterIdentity</key>
 | 
				
			||||||
 | 
									<string>anonymous@openro.am</string>
 | 
				
			||||||
 | 
									<key>TLSMaximumVersion</key>
 | 
				
			||||||
 | 
									<string>1.2</string>
 | 
				
			||||||
 | 
									<key>TLSMinimumVersion</key>
 | 
				
			||||||
 | 
									<string>1.2</string>
 | 
				
			||||||
 | 
									<key>TTLSInnerAuthentication</key>
 | 
				
			||||||
 | 
									<string>MSCHAPv2</string>
 | 
				
			||||||
 | 
									<key>UserName</key>
 | 
				
			||||||
 | 
									<string>420a5371-47d4-4d1d-b234-d17be4e54bb3@openro.am</string>
 | 
				
			||||||
 | 
									<key>UserPassword</key>
 | 
				
			||||||
 | 
									<string>XaHBCFhgGxi-mCK9XXdQ8</string>
 | 
				
			||||||
 | 
								</dict>
 | 
				
			||||||
 | 
								<key>EncryptionType</key>
 | 
				
			||||||
 | 
								<string>WPA2</string>
 | 
				
			||||||
 | 
								<key>HIDDEN_NETWORK</key>
 | 
				
			||||||
 | 
								<false/>
 | 
				
			||||||
 | 
								<key>IsHotspot</key>
 | 
				
			||||||
 | 
								<true/>
 | 
				
			||||||
 | 
								<key>NAIRealmNames</key>
 | 
				
			||||||
 | 
								<array>
 | 
				
			||||||
 | 
									<string>openro.am</string>
 | 
				
			||||||
 | 
								</array>
 | 
				
			||||||
 | 
								<key>PayloadDescription</key>
 | 
				
			||||||
 | 
								<string>Configures Wi-Fi settings</string>
 | 
				
			||||||
 | 
								<key>PayloadDisplayName</key>
 | 
				
			||||||
 | 
								<string>Wi-Fi</string>
 | 
				
			||||||
 | 
								<key>PayloadIdentifier</key>
 | 
				
			||||||
 | 
								<string>com.apple.wifi.managed.12788EED-2E0C-4370-9411-4EEFC8D9ABB0</string>
 | 
				
			||||||
 | 
								<key>PayloadType</key>
 | 
				
			||||||
 | 
								<string>com.apple.wifi.managed</string>
 | 
				
			||||||
 | 
								<key>PayloadUUID</key>
 | 
				
			||||||
 | 
								<string>12788EED-2E0C-4370-9411-4EEFC8D9ABB0</string>
 | 
				
			||||||
 | 
								<key>PayloadVersion</key>
 | 
				
			||||||
 | 
								<integer>1</integer>
 | 
				
			||||||
 | 
								<key>ProxyType</key>
 | 
				
			||||||
 | 
								<string>None</string>
 | 
				
			||||||
 | 
								<key>RoamingConsortiumOIs</key>
 | 
				
			||||||
 | 
								<array>
 | 
				
			||||||
 | 
									<string>5A03BA0000</string>
 | 
				
			||||||
 | 
								</array>
 | 
				
			||||||
 | 
								<key>ServiceProviderRoamingEnabled</key>
 | 
				
			||||||
 | 
								<true/>
 | 
				
			||||||
 | 
							</dict>
 | 
				
			||||||
 | 
						</array>
 | 
				
			||||||
 | 
						<key>PayloadDisplayName</key>
 | 
				
			||||||
 | 
						<string>OpenRo.am Test</string>
 | 
				
			||||||
 | 
						<key>PayloadIdentifier</key>
 | 
				
			||||||
 | 
						<string>openroam.44A21054-2F3F-437F-822A-C2F6766A2A23</string>
 | 
				
			||||||
 | 
						<key>PayloadOrganization</key>
 | 
				
			||||||
 | 
						<string>OpenRo.am</string>
 | 
				
			||||||
 | 
						<key>PayloadRemovalDisallowed</key>
 | 
				
			||||||
 | 
						<false/>
 | 
				
			||||||
 | 
						<key>PayloadType</key>
 | 
				
			||||||
 | 
						<string>Configuration</string>
 | 
				
			||||||
 | 
						<key>PayloadUUID</key>
 | 
				
			||||||
 | 
						<string>1D460B0F-9311-4FD2-A75D-BADA866BC31C</string>
 | 
				
			||||||
 | 
						<key>PayloadVersion</key>
 | 
				
			||||||
 | 
						<integer>1</integer>
 | 
				
			||||||
 | 
					</dict>
 | 
				
			||||||
 | 
					</plist>
 | 
				
			||||||
@@ -42,6 +42,7 @@ if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then
 | 
				
			|||||||
  STORAGE_TYPE_MYSQL_PASSWORD=${STORAGE_TYPE_MYSQL_PASSWORD:-"owprov"} \
 | 
					  STORAGE_TYPE_MYSQL_PASSWORD=${STORAGE_TYPE_MYSQL_PASSWORD:-"owprov"} \
 | 
				
			||||||
  STORAGE_TYPE_MYSQL_DATABASE=${STORAGE_TYPE_MYSQL_DATABASE:-"owprov"} \
 | 
					  STORAGE_TYPE_MYSQL_DATABASE=${STORAGE_TYPE_MYSQL_DATABASE:-"owprov"} \
 | 
				
			||||||
  STORAGE_TYPE_MYSQL_PORT=${STORAGE_TYPE_MYSQL_PORT:-"3306"} \
 | 
					  STORAGE_TYPE_MYSQL_PORT=${STORAGE_TYPE_MYSQL_PORT:-"3306"} \
 | 
				
			||||||
 | 
					  RRM_PROVIDERS=${RRM_PROVIDERS:-"owrrm"} \
 | 
				
			||||||
  envsubst < /owprov.properties.tmpl > $OWPROV_CONFIG/owprov.properties
 | 
					  envsubst < /owprov.properties.tmpl > $OWPROV_CONFIG/owprov.properties
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ fullnameOverride: ""
 | 
				
			|||||||
images:
 | 
					images:
 | 
				
			||||||
  owprov:
 | 
					  owprov:
 | 
				
			||||||
    repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
 | 
					    repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
 | 
				
			||||||
    tag: v2.9.0
 | 
					    tag: v4.0.0
 | 
				
			||||||
    pullPolicy: Always
 | 
					    pullPolicy: Always
 | 
				
			||||||
#    regcred:
 | 
					#    regcred:
 | 
				
			||||||
#      registry: tip-tip-wlan-cloud-ucentral.jfrog.io
 | 
					#      registry: tip-tip-wlan-cloud-ucentral.jfrog.io
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										407
									
								
								openapi/openroaming_globalreach.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										407
									
								
								openapi/openroaming_globalreach.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,407 @@
 | 
				
			|||||||
 | 
					openapi: 3.0.1
 | 
				
			||||||
 | 
					info:
 | 
				
			||||||
 | 
					  title: OpenWiFi RadiusEndpointTypes Provisioning Model for Global Reach
 | 
				
			||||||
 | 
					  description: Definitions and APIs to Open Roaming WiFi.
 | 
				
			||||||
 | 
					  version: 2.5.0
 | 
				
			||||||
 | 
					  license:
 | 
				
			||||||
 | 
					    name: BSD3
 | 
				
			||||||
 | 
					    url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					servers:
 | 
				
			||||||
 | 
					  - url: 'https://localhost:16005/api/v1'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					security:
 | 
				
			||||||
 | 
					  - bearerAuth: []
 | 
				
			||||||
 | 
					  - ApiKeyAuth: []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					components:
 | 
				
			||||||
 | 
					  securitySchemes:
 | 
				
			||||||
 | 
					    ApiKeyAuth:
 | 
				
			||||||
 | 
					      type: apiKey
 | 
				
			||||||
 | 
					      in: header
 | 
				
			||||||
 | 
					      name: X-API-KEY
 | 
				
			||||||
 | 
					    bearerAuth:
 | 
				
			||||||
 | 
					      type: http
 | 
				
			||||||
 | 
					      scheme: bearer
 | 
				
			||||||
 | 
					      bearerFormat: JWT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  responses:
 | 
				
			||||||
 | 
					    NotFound:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/NotFound'
 | 
				
			||||||
 | 
					    Unauthorized:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					    Success:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Success'
 | 
				
			||||||
 | 
					    BadRequest:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  schemas:
 | 
				
			||||||
 | 
					    GLBLRAccountInfo:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        allOf:
 | 
				
			||||||
 | 
					          $ref: 'https://github.com/Telecominfraproject/wlan-cloud-owprov/blob/main/openpapi/owprov.yaml#/components/schemas/ObjectInfo'
 | 
				
			||||||
 | 
					        privateKey:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        country:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        province:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        city:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        organization:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        commonName:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        CSR:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        CSRPrivateKey:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        CSRPublicKey:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        GlobalReachAcctId:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    GLBLRCertificateInfo:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        id:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          format: uuid
 | 
				
			||||||
 | 
					        name:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        accountId:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          format: uuid
 | 
				
			||||||
 | 
					        csr:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        certificate:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        certificateChain:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        certificateId:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        expiresAt:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        created:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					paths:
 | 
				
			||||||
 | 
					  /openroaming/globalreach/accounts:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach
 | 
				
			||||||
 | 
					      operationId: getOpenRoamingGlobalReachAccountList
 | 
				
			||||||
 | 
					      summary: Retrieve account list.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Pagination start (starts at 1. If not specified, 1 is assumed)
 | 
				
			||||||
 | 
					          name: offset
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Maximum number of entries to return (if absent, no limit is assumed)
 | 
				
			||||||
 | 
					          name: limit
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: return the number of accounts
 | 
				
			||||||
 | 
					          name: countOnly
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: boolean
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          description: The list of accounts
 | 
				
			||||||
 | 
					          content:
 | 
				
			||||||
 | 
					            application/json:
 | 
				
			||||||
 | 
					              schema:
 | 
				
			||||||
 | 
					                type: array
 | 
				
			||||||
 | 
					                items:
 | 
				
			||||||
 | 
					                  $ref: '#/components/schemas/GLBLRAccountInfo'
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Success'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /openroaming/globalreach/account/{name}:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach
 | 
				
			||||||
 | 
					      operationId: getOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Retrieve account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name
 | 
				
			||||||
 | 
					          name: name
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GLBLRAccountInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach
 | 
				
			||||||
 | 
					      operationId: deleteOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Delete account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name
 | 
				
			||||||
 | 
					          name: name
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Success'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    post:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach
 | 
				
			||||||
 | 
					      operationId: createOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Create account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name
 | 
				
			||||||
 | 
					          name: name
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      requestBody:
 | 
				
			||||||
 | 
					        content:
 | 
				
			||||||
 | 
					          application/json:
 | 
				
			||||||
 | 
					            schema:
 | 
				
			||||||
 | 
					              $ref: '#/components/schemas/GLBLRAccountInfo'
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GLBLRAccountInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    put:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach
 | 
				
			||||||
 | 
					      operationId: modifyOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Modify account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name
 | 
				
			||||||
 | 
					          name: name
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      requestBody:
 | 
				
			||||||
 | 
					        content:
 | 
				
			||||||
 | 
					          application/json:
 | 
				
			||||||
 | 
					            schema:
 | 
				
			||||||
 | 
					              $ref: '#/components/schemas/GLBLRAccountInfo'
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GLBLRAccountInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /openroaming/globalreach/certificates/{account}:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach Certificate
 | 
				
			||||||
 | 
					      operationId: getOpenRoamingGlobalReachCertificateList
 | 
				
			||||||
 | 
					      summary: Retrieve certificate list.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name
 | 
				
			||||||
 | 
					          name: account
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Pagination start (starts at 1. If not specified, 1 is assumed)
 | 
				
			||||||
 | 
					          name: offset
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Maximum number of entries to return (if absent, no limit is assumed)
 | 
				
			||||||
 | 
					          name: limit
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: return the number of certificates
 | 
				
			||||||
 | 
					          name: countOnly
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: boolean
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          description: The list of certificates
 | 
				
			||||||
 | 
					          content:
 | 
				
			||||||
 | 
					            application/json:
 | 
				
			||||||
 | 
					              schema:
 | 
				
			||||||
 | 
					                type: array
 | 
				
			||||||
 | 
					                items:
 | 
				
			||||||
 | 
					                  $ref: '#/components/schemas/GLBLRCertificateInfo'
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Success'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /openroaming/globalreach/certificate/{account}/{id}:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach Certificate
 | 
				
			||||||
 | 
					      operationId: getOpenRoamingGlobalReachCertificate
 | 
				
			||||||
 | 
					      summary: Retrieve certificate information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
 | 
				
			||||||
 | 
					          name: account
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The certificate id in provisioning - not the certificate_id from GlobalReach
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GLBLRCertificateInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach Certificate
 | 
				
			||||||
 | 
					      operationId: deleteOpenRoamingGlobalReachCertificate
 | 
				
			||||||
 | 
					      summary: Delete certificate information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
 | 
				
			||||||
 | 
					          name: account
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The certificate id in provisioning - not the certificate_id from GlobalReach
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Success'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    post:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach Certificate
 | 
				
			||||||
 | 
					      operationId: createOpenRoamingGlobalReachCertificate
 | 
				
			||||||
 | 
					      summary: Create certificate information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
 | 
				
			||||||
 | 
					          name: account
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: Must be set to "0"
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      requestBody:
 | 
				
			||||||
 | 
					        content:
 | 
				
			||||||
 | 
					          application/json:
 | 
				
			||||||
 | 
					            schema:
 | 
				
			||||||
 | 
					              $ref: '#/components/schemas/GLBLRCertificateInfo'
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GLBLRCertificateInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    put:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Global Reach Certificate
 | 
				
			||||||
 | 
					      operationId: updateOpenRoamingGlobalReachCertificate
 | 
				
			||||||
 | 
					      summary: Update certificate information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account name - this is the provisioning ID for the account. Not the GlobalReach ID.
 | 
				
			||||||
 | 
					          name: account
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: the UUID of the certificate
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Update an existing certificate
 | 
				
			||||||
 | 
					          name: updateCertificate
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: boolean
 | 
				
			||||||
 | 
					            default: false
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GLBLRCertificateInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										199
									
								
								openapi/openroaming_orion.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										199
									
								
								openapi/openroaming_orion.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,199 @@
 | 
				
			|||||||
 | 
					openapi: 3.0.1
 | 
				
			||||||
 | 
					info:
 | 
				
			||||||
 | 
					  title: OpenWiFi RadiusEndpointTypes Provisioning Model for Google Orion
 | 
				
			||||||
 | 
					  description: Definitions and APIs to Open Roaming WiFi.
 | 
				
			||||||
 | 
					  version: 2.5.0
 | 
				
			||||||
 | 
					  license:
 | 
				
			||||||
 | 
					    name: BSD3
 | 
				
			||||||
 | 
					    url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					servers:
 | 
				
			||||||
 | 
					  - url: 'https://localhost:16005/api/v1'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					security:
 | 
				
			||||||
 | 
					  - bearerAuth: []
 | 
				
			||||||
 | 
					  - ApiKeyAuth: []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					components:
 | 
				
			||||||
 | 
					  securitySchemes:
 | 
				
			||||||
 | 
					    ApiKeyAuth:
 | 
				
			||||||
 | 
					      type: apiKey
 | 
				
			||||||
 | 
					      in: header
 | 
				
			||||||
 | 
					      name: X-API-KEY
 | 
				
			||||||
 | 
					    bearerAuth:
 | 
				
			||||||
 | 
					      type: http
 | 
				
			||||||
 | 
					      scheme: bearer
 | 
				
			||||||
 | 
					      bearerFormat: JWT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  responses:
 | 
				
			||||||
 | 
					    NotFound:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/NotFound'
 | 
				
			||||||
 | 
					    Unauthorized:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					    Success:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Success'
 | 
				
			||||||
 | 
					    BadRequest:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  schemas:
 | 
				
			||||||
 | 
					    GooglOrionAccountInfo:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        allOf:
 | 
				
			||||||
 | 
					          $ref: 'https://github.com/Telecominfraproject/wlan-cloud-owprov/blob/main/openpapi/owprov.yaml#/components/schemas/ObjectInfo'
 | 
				
			||||||
 | 
					        privateKey:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        certificate:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        cacerts:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					paths:
 | 
				
			||||||
 | 
					  /openroaming/orion/accounts:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Google Orion
 | 
				
			||||||
 | 
					      operationId: getOpenRoamingGlobalReachAccountList
 | 
				
			||||||
 | 
					      summary: Retrieve account list.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Pagination start (starts at 1. If not specified, 1 is assumed)
 | 
				
			||||||
 | 
					          name: offset
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Maximum number of entries to return (if absent, no limit is assumed)
 | 
				
			||||||
 | 
					          name: limit
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: return the number of accounts
 | 
				
			||||||
 | 
					          name: countOnly
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: boolean
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          description: The list of accounts
 | 
				
			||||||
 | 
					          content:
 | 
				
			||||||
 | 
					            application/json:
 | 
				
			||||||
 | 
					              schema:
 | 
				
			||||||
 | 
					                type: array
 | 
				
			||||||
 | 
					                items:
 | 
				
			||||||
 | 
					                  $ref: '#/components/schemas/GooglOrionAccountInfo'
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Success'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /openroaming/orion/account/{id}:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Google Orion
 | 
				
			||||||
 | 
					      operationId: getOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Retrieve account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account ID
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GooglOrionAccountInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Google Orion
 | 
				
			||||||
 | 
					      operationId: deleteOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Delete account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account ID
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Success'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    post:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Google Orion
 | 
				
			||||||
 | 
					      operationId: createOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Create account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account ID
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      requestBody:
 | 
				
			||||||
 | 
					        content:
 | 
				
			||||||
 | 
					          application/json:
 | 
				
			||||||
 | 
					            schema:
 | 
				
			||||||
 | 
					              $ref: '#/components/schemas/GooglOrionAccountInfo'
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GooglOrionAccountInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    put:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RadiusEndpointTypes-Google Orion
 | 
				
			||||||
 | 
					      operationId: modifyOpenRoamingGlobalReachAccount
 | 
				
			||||||
 | 
					      summary: Modify account information.
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          description: The account ID
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      requestBody:
 | 
				
			||||||
 | 
					        content:
 | 
				
			||||||
 | 
					          application/json:
 | 
				
			||||||
 | 
					            schema:
 | 
				
			||||||
 | 
					              $ref: '#/components/schemas/GooglOrionAccountInfo'
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/GooglOrionAccountInfo'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1,268 +0,0 @@
 | 
				
			|||||||
openapi: 3.0.1
 | 
					 | 
				
			||||||
info:
 | 
					 | 
				
			||||||
  title: OpenWiFi Open roaming Ameriband Provisioning Model
 | 
					 | 
				
			||||||
  description: Registration of an OpenRoaming profile with Ameriband for TIP OpenWifi.
 | 
					 | 
				
			||||||
  version: 1.0.0
 | 
					 | 
				
			||||||
  license:
 | 
					 | 
				
			||||||
    name: BSD3
 | 
					 | 
				
			||||||
    url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
servers:
 | 
					 | 
				
			||||||
  - url: 'https://tip.regiatration.ameriband.com:8001/api/v1'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
security:
 | 
					 | 
				
			||||||
  - bearerAuth: []
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
components:
 | 
					 | 
				
			||||||
  securitySchemes:
 | 
					 | 
				
			||||||
    bearerAuth:
 | 
					 | 
				
			||||||
      type: http
 | 
					 | 
				
			||||||
      scheme: bearer
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  responses:
 | 
					 | 
				
			||||||
    NotFound:
 | 
					 | 
				
			||||||
      description: The specified resource was not found.
 | 
					 | 
				
			||||||
      content:
 | 
					 | 
				
			||||||
        application/json:
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            properties:
 | 
					 | 
				
			||||||
              ErrorCode:
 | 
					 | 
				
			||||||
                type: integer
 | 
					 | 
				
			||||||
              ErrorDetails:
 | 
					 | 
				
			||||||
                type: string
 | 
					 | 
				
			||||||
              ErrorDescription:
 | 
					 | 
				
			||||||
                type: string
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Unauthorized:
 | 
					 | 
				
			||||||
      description: The requested does not have sufficient rights to perform the operation.
 | 
					 | 
				
			||||||
      content:
 | 
					 | 
				
			||||||
        application/json:
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            properties:
 | 
					 | 
				
			||||||
              ErrorCode:
 | 
					 | 
				
			||||||
                type: integer
 | 
					 | 
				
			||||||
                enum:
 | 
					 | 
				
			||||||
                  - 0     # Success
 | 
					 | 
				
			||||||
                  - 8     # INVALID_TOKEN
 | 
					 | 
				
			||||||
                  - 9     # EXPIRED_TOKEN
 | 
					 | 
				
			||||||
              ErrorDetails:
 | 
					 | 
				
			||||||
                type: string
 | 
					 | 
				
			||||||
              ErrorDescription:
 | 
					 | 
				
			||||||
                type: string
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Success:
 | 
					 | 
				
			||||||
      description: The requested operation was performed.
 | 
					 | 
				
			||||||
      content:
 | 
					 | 
				
			||||||
        application/json:
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            properties:
 | 
					 | 
				
			||||||
              Operation:
 | 
					 | 
				
			||||||
                type: string
 | 
					 | 
				
			||||||
              Details:
 | 
					 | 
				
			||||||
                type: string
 | 
					 | 
				
			||||||
              Code:
 | 
					 | 
				
			||||||
                type: integer
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    BadRequest:
 | 
					 | 
				
			||||||
      description: The requested operation failed.
 | 
					 | 
				
			||||||
      content:
 | 
					 | 
				
			||||||
        application/json:
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            properties:
 | 
					 | 
				
			||||||
              ErrorCode:
 | 
					 | 
				
			||||||
                type: integer
 | 
					 | 
				
			||||||
              ErrorDetails:
 | 
					 | 
				
			||||||
                type: string
 | 
					 | 
				
			||||||
              ErrorDescription:
 | 
					 | 
				
			||||||
                type: integer
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  schemas:
 | 
					 | 
				
			||||||
    RegistrationRequest:
 | 
					 | 
				
			||||||
      type: object
 | 
					 | 
				
			||||||
      properties:
 | 
					 | 
				
			||||||
        orgRequestId:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          format: uuid
 | 
					 | 
				
			||||||
          minLength: 36
 | 
					 | 
				
			||||||
          maxLength: 36
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            Client will generate a UUID that must be returned in the response.
 | 
					 | 
				
			||||||
        orgAcceptedTermsAndConditions:
 | 
					 | 
				
			||||||
          type: boolean
 | 
					 | 
				
			||||||
          default: false
 | 
					 | 
				
			||||||
        orgLegalName:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          minLength: 1
 | 
					 | 
				
			||||||
        orgWebSite:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          format: url
 | 
					 | 
				
			||||||
          minLength: 1
 | 
					 | 
				
			||||||
        orgContact:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          minLength: 1
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            John Smith
 | 
					 | 
				
			||||||
        orgEmail:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          format: email
 | 
					 | 
				
			||||||
          minLength: 1
 | 
					 | 
				
			||||||
        orgPhone:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            (607)555-1234 or +1(223)555-1222
 | 
					 | 
				
			||||||
        orgLocation:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            Boston, NH - LA, CA
 | 
					 | 
				
			||||||
        orgCertificate:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          minLength: 1
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            This must be the entire PEM file content of the certificate, encoded using base64
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    RegistrationResponse:
 | 
					 | 
				
			||||||
      type: object
 | 
					 | 
				
			||||||
      properties:
 | 
					 | 
				
			||||||
        orgRequestId:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          format: uuid
 | 
					 | 
				
			||||||
          minLength: 36
 | 
					 | 
				
			||||||
          maxLength: 36
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            This should be the same orgRequestId passed during registration.
 | 
					 | 
				
			||||||
        orgNASID:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          minLength: 10
 | 
					 | 
				
			||||||
          description:
 | 
					 | 
				
			||||||
            This is the NASID generated by Ameriband. It will be used by the operator as NASID when contacting Ameriband.
 | 
					 | 
				
			||||||
        ameribandCertificate:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          minLength: 1
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            This must be the entire PEM file content of the certificate, encoded using base64
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    RegistrationInformationRequest:
 | 
					 | 
				
			||||||
      type: object
 | 
					 | 
				
			||||||
      properties:
 | 
					 | 
				
			||||||
        link:
 | 
					 | 
				
			||||||
          description: This should be the link where a potential registrant can read the terms and conditions of registering with Ameriband.
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          format: url
 | 
					 | 
				
			||||||
          minLength: 1
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            https://ameriband.com/romain-registration.html
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
paths:
 | 
					 | 
				
			||||||
  /termsAndConditions:
 | 
					 | 
				
			||||||
    get:
 | 
					 | 
				
			||||||
      summary: The registrant must be given a chance to view the terms and conditions of the relationship they are entering into
 | 
					 | 
				
			||||||
      operationId: getTermsAndConditions
 | 
					 | 
				
			||||||
      responses:
 | 
					 | 
				
			||||||
        200:
 | 
					 | 
				
			||||||
          description: Sucessfully retrieved Terms and Conditions
 | 
					 | 
				
			||||||
          content:
 | 
					 | 
				
			||||||
            application/json:
 | 
					 | 
				
			||||||
              schema:
 | 
					 | 
				
			||||||
                $ref: '#/components/schemas/RegistrationInformationRequest'
 | 
					 | 
				
			||||||
        404:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/Unauthorized'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /registration:
 | 
					 | 
				
			||||||
    get:
 | 
					 | 
				
			||||||
      tags:
 | 
					 | 
				
			||||||
        - Registration
 | 
					 | 
				
			||||||
      operationId: getRegistrationInformation
 | 
					 | 
				
			||||||
      summary: This should return the information from a registration based on the NASID
 | 
					 | 
				
			||||||
      parameters:
 | 
					 | 
				
			||||||
        - in: query
 | 
					 | 
				
			||||||
          name: orgNASID
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            type: string
 | 
					 | 
				
			||||||
          required: true
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            This is the orgNASID returned during registration.
 | 
					 | 
				
			||||||
      responses:
 | 
					 | 
				
			||||||
        200:
 | 
					 | 
				
			||||||
          $ref: '#/components/schemas/RegistrationResponse'
 | 
					 | 
				
			||||||
        403:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/Unauthorized'
 | 
					 | 
				
			||||||
        404:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/NotFound'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    post:
 | 
					 | 
				
			||||||
      summary: Called when the registrant ahs read the T&Cs and iw willing to submit their information to enter in a partnership
 | 
					 | 
				
			||||||
      tags:
 | 
					 | 
				
			||||||
        - Registration
 | 
					 | 
				
			||||||
      operationId: createRegistration
 | 
					 | 
				
			||||||
      requestBody:
 | 
					 | 
				
			||||||
        required: true
 | 
					 | 
				
			||||||
        content:
 | 
					 | 
				
			||||||
          application/json:
 | 
					 | 
				
			||||||
            schema:
 | 
					 | 
				
			||||||
              $ref: '#/components/schemas/RegistrationRequest'
 | 
					 | 
				
			||||||
      responses:
 | 
					 | 
				
			||||||
        200:
 | 
					 | 
				
			||||||
          description: Succesfully registered
 | 
					 | 
				
			||||||
          content:
 | 
					 | 
				
			||||||
            application/json:
 | 
					 | 
				
			||||||
              schema:
 | 
					 | 
				
			||||||
                $ref: '#/components/schemas/RegistrationResponse'
 | 
					 | 
				
			||||||
        400:
 | 
					 | 
				
			||||||
          description: Registration failed due to  missing or incomplete information
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/BadRequest'
 | 
					 | 
				
			||||||
        403:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/Unauthorized'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    put:
 | 
					 | 
				
			||||||
      summary: Called when the registrant needs to update its information with Ameriband. The does not generate a new NASID.
 | 
					 | 
				
			||||||
      tags:
 | 
					 | 
				
			||||||
        - Registration
 | 
					 | 
				
			||||||
      operationId: updateRegistration
 | 
					 | 
				
			||||||
      parameters:
 | 
					 | 
				
			||||||
        - in: query
 | 
					 | 
				
			||||||
          name: orgNASID
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            type: string
 | 
					 | 
				
			||||||
          required: true
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            This is the orgNASID returned during registration.
 | 
					 | 
				
			||||||
      requestBody:
 | 
					 | 
				
			||||||
        required: true
 | 
					 | 
				
			||||||
        content:
 | 
					 | 
				
			||||||
          application/json:
 | 
					 | 
				
			||||||
            schema:
 | 
					 | 
				
			||||||
              $ref: '#/components/schemas/RegistrationRequest'
 | 
					 | 
				
			||||||
      responses:
 | 
					 | 
				
			||||||
        200:
 | 
					 | 
				
			||||||
          description: Succesfully found the information based on the orgNASID
 | 
					 | 
				
			||||||
          content:
 | 
					 | 
				
			||||||
            application/json:
 | 
					 | 
				
			||||||
              schema:
 | 
					 | 
				
			||||||
                $ref: '#/components/schemas/RegistrationResponse'
 | 
					 | 
				
			||||||
        400:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/BadRequest'
 | 
					 | 
				
			||||||
        403:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/Unauthorized'
 | 
					 | 
				
			||||||
        404:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/NotFound'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    delete:
 | 
					 | 
				
			||||||
      tags:
 | 
					 | 
				
			||||||
        - Registration
 | 
					 | 
				
			||||||
      summary: When a registrant wants to terminate a relationship with Ameriband. Ameriband should also delete all information from the registrant
 | 
					 | 
				
			||||||
      operationId: deleteRegistration
 | 
					 | 
				
			||||||
      parameters:
 | 
					 | 
				
			||||||
        - in: query
 | 
					 | 
				
			||||||
          name: orgNASID
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            type: string
 | 
					 | 
				
			||||||
          required: true
 | 
					 | 
				
			||||||
          example:
 | 
					 | 
				
			||||||
            This is the orgNASID returned during registration.
 | 
					 | 
				
			||||||
      responses:
 | 
					 | 
				
			||||||
        204:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/Success'
 | 
					 | 
				
			||||||
        403:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/Unauthorized'
 | 
					 | 
				
			||||||
        404:
 | 
					 | 
				
			||||||
          $ref: '#/components/responses/NotFound'
 | 
					 | 
				
			||||||
@@ -815,6 +815,17 @@ components:
 | 
				
			|||||||
          type: string
 | 
					          type: string
 | 
				
			||||||
          minLength: 2
 | 
					          minLength: 2
 | 
				
			||||||
          maxLength: 2
 | 
					          maxLength: 2
 | 
				
			||||||
 | 
					        imported:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        connected:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        platform:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          enum:
 | 
				
			||||||
 | 
					            - AP
 | 
				
			||||||
 | 
					            - SWITCH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    VenueDeviceList:
 | 
					    VenueDeviceList:
 | 
				
			||||||
      type: object
 | 
					      type: object
 | 
				
			||||||
@@ -1331,12 +1342,6 @@ components:
 | 
				
			|||||||
            - $ref: '#/components/schemas/StringList'
 | 
					            - $ref: '#/components/schemas/StringList'
 | 
				
			||||||
            - $ref: '#/components/schemas/TagValuePairList'
 | 
					            - $ref: '#/components/schemas/TagValuePairList'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SystemCommandResults:
 | 
					 | 
				
			||||||
      type: object
 | 
					 | 
				
			||||||
      oneOf:
 | 
					 | 
				
			||||||
        - $ref: '#/components/schemas/StringList'
 | 
					 | 
				
			||||||
        - $ref: '#/components/schemas/TagValuePairList'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    NoteInfo:
 | 
					    NoteInfo:
 | 
				
			||||||
      type: object
 | 
					      type: object
 | 
				
			||||||
      properties:
 | 
					      properties:
 | 
				
			||||||
@@ -1376,6 +1381,33 @@ components:
 | 
				
			|||||||
                type: integer
 | 
					                type: integer
 | 
				
			||||||
                format: int64
 | 
					                format: int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SystemResources:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        numberOfFileDescriptors:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        currRealMem:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        peakRealMem:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        currVirtMem:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        peakVirtMem:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SystemCommandResults:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      oneOf:
 | 
				
			||||||
 | 
					        - $ref: '#/components/schemas/SystemResources'
 | 
				
			||||||
 | 
					        - $ref: '#/components/schemas/SystemInfoResults'
 | 
				
			||||||
 | 
					        - $ref: '#/components/schemas/StringList'
 | 
				
			||||||
 | 
					        - $ref: '#/components/schemas/TagValuePairList'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Dashboard:
 | 
					    Dashboard:
 | 
				
			||||||
      type: object
 | 
					      type: object
 | 
				
			||||||
      properties:
 | 
					      properties:
 | 
				
			||||||
@@ -2258,7 +2290,7 @@ paths:
 | 
				
			|||||||
    get:
 | 
					    get:
 | 
				
			||||||
      tags:
 | 
					      tags:
 | 
				
			||||||
        - Configuration Overrides
 | 
					        - Configuration Overrides
 | 
				
			||||||
      operationId: getCponfigurationOverrides
 | 
					      operationId: getConfigurationOverrides
 | 
				
			||||||
      summary: retrieve a list of configuration overrides for a given device
 | 
					      summary: retrieve a list of configuration overrides for a given device
 | 
				
			||||||
      parameters:
 | 
					      parameters:
 | 
				
			||||||
        - in: path
 | 
					        - in: path
 | 
				
			||||||
@@ -2282,7 +2314,7 @@ paths:
 | 
				
			|||||||
    delete:
 | 
					    delete:
 | 
				
			||||||
      tags:
 | 
					      tags:
 | 
				
			||||||
        - Configuration Overrides
 | 
					        - Configuration Overrides
 | 
				
			||||||
      operationId: deleteCponfigurationOverrides
 | 
					      operationId: deleteConfigurationOverrides
 | 
				
			||||||
      summary: delete all configuration overrides for a given device from a given source
 | 
					      summary: delete all configuration overrides for a given device from a given source
 | 
				
			||||||
      parameters:
 | 
					      parameters:
 | 
				
			||||||
        - in: path
 | 
					        - in: path
 | 
				
			||||||
@@ -3219,6 +3251,15 @@ paths:
 | 
				
			|||||||
          schema:
 | 
					          schema:
 | 
				
			||||||
            type: boolean
 | 
					            type: boolean
 | 
				
			||||||
          required: false
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          name: deviceType
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            enum:
 | 
				
			||||||
 | 
					              - AP
 | 
				
			||||||
 | 
					              - SWITCH
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					          default: AP
 | 
				
			||||||
      requestBody:
 | 
					      requestBody:
 | 
				
			||||||
        description: Information used to create the new entity
 | 
					        description: Information used to create the new entity
 | 
				
			||||||
        content:
 | 
					        content:
 | 
				
			||||||
@@ -3247,6 +3288,15 @@ paths:
 | 
				
			|||||||
            format: uuid
 | 
					            format: uuid
 | 
				
			||||||
            example: When modifying the root entity, the uuid 0000-0000-0000 must be entered.
 | 
					            example: When modifying the root entity, the uuid 0000-0000-0000 must be entered.
 | 
				
			||||||
          required: true
 | 
					          required: true
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          name: deviceType
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            enum:
 | 
				
			||||||
 | 
					              - AP
 | 
				
			||||||
 | 
					              - SWITCH
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					          default: AP
 | 
				
			||||||
      requestBody:
 | 
					      requestBody:
 | 
				
			||||||
        description: Information used to modify the new entity
 | 
					        description: Information used to modify the new entity
 | 
				
			||||||
        content:
 | 
					        content:
 | 
				
			||||||
@@ -4423,15 +4473,12 @@ paths:
 | 
				
			|||||||
            type: string
 | 
					            type: string
 | 
				
			||||||
            enum:
 | 
					            enum:
 | 
				
			||||||
              - info
 | 
					              - info
 | 
				
			||||||
 | 
					              - extraConfiguration
 | 
				
			||||||
 | 
					              - resources
 | 
				
			||||||
          required: true
 | 
					          required: true
 | 
				
			||||||
      responses:
 | 
					      responses:
 | 
				
			||||||
        200:
 | 
					        200:
 | 
				
			||||||
          description: Successful command execution
 | 
					          $ref: '#/components/schemas/SystemCommandResults'
 | 
				
			||||||
          content:
 | 
					 | 
				
			||||||
            application/json:
 | 
					 | 
				
			||||||
              schema:
 | 
					 | 
				
			||||||
                oneOf:
 | 
					 | 
				
			||||||
                  - $ref: '#/components/schemas/SystemInfoResults'
 | 
					 | 
				
			||||||
        403:
 | 
					        403:
 | 
				
			||||||
          $ref: '#/components/responses/Unauthorized'
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
        404:
 | 
					        404:
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										342
									
								
								openapi/radius_endpoints.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										342
									
								
								openapi/radius_endpoints.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,342 @@
 | 
				
			|||||||
 | 
					openapi: 3.0.1
 | 
				
			||||||
 | 
					info:
 | 
				
			||||||
 | 
					  title: OpenWiFi RADIUS Resource Model
 | 
				
			||||||
 | 
					  description: Definitions and APIs to manage RADIUS Resources.
 | 
				
			||||||
 | 
					  version: 1.0.0
 | 
				
			||||||
 | 
					  license:
 | 
				
			||||||
 | 
					    name: BSD3
 | 
				
			||||||
 | 
					    url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					servers:
 | 
				
			||||||
 | 
					  - url: 'https://localhost:16005/api/v1'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					security:
 | 
				
			||||||
 | 
					  - bearerAuth: []
 | 
				
			||||||
 | 
					  - ApiKeyAuth: []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					components:
 | 
				
			||||||
 | 
					  securitySchemes:
 | 
				
			||||||
 | 
					    ApiKeyAuth:
 | 
				
			||||||
 | 
					      type: apiKey
 | 
				
			||||||
 | 
					      in: header
 | 
				
			||||||
 | 
					      name: X-API-KEY
 | 
				
			||||||
 | 
					    bearerAuth:
 | 
				
			||||||
 | 
					      type: http
 | 
				
			||||||
 | 
					      scheme: bearer
 | 
				
			||||||
 | 
					      bearerFormat: JWT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  responses:
 | 
				
			||||||
 | 
					    NotFound:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/NotFound'
 | 
				
			||||||
 | 
					    Unauthorized:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					    Success:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Success'
 | 
				
			||||||
 | 
					    BadRequest:
 | 
				
			||||||
 | 
					      $ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  schemas:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RADIUSServer:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        Hostname:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        IP:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        Port:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int32
 | 
				
			||||||
 | 
					        Secret:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RADIUSEndPointRadiusType:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        Authentication:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            $ref: '#/components/schemas/RADIUSServer'
 | 
				
			||||||
 | 
					        Accounting:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            $ref: '#/components/schemas/RADIUSServer'
 | 
				
			||||||
 | 
					        CoA:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            $ref: '#/components/schemas/RADIUSServer'
 | 
				
			||||||
 | 
					        AccountingInterval:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RADIUSEndPointRadsecType:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        Hostname:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        IP:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        Port:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					        Secret:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          default: radsec
 | 
				
			||||||
 | 
					        UseOpenRoamingAccount:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          format: uuid
 | 
				
			||||||
 | 
					        Weight:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int32
 | 
				
			||||||
 | 
					        Certificate:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        PrivateKey:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        CaCerts:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					        AllowSelfSigned:
 | 
				
			||||||
 | 
					          type: boolean
 | 
				
			||||||
 | 
					          default: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RADIUSEndPoint:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        allOf:
 | 
				
			||||||
 | 
					          $ref: 'https://github.com/Telecominfraproject/wlan-cloud-owprov/blob/main/openpapi/owprov.yaml#/components/schemas/ObjectInfo'
 | 
				
			||||||
 | 
					        Type:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          enum:
 | 
				
			||||||
 | 
					            - generic
 | 
				
			||||||
 | 
					            - radsec
 | 
				
			||||||
 | 
					            - globalreach
 | 
				
			||||||
 | 
					            - orion
 | 
				
			||||||
 | 
					          default: radius
 | 
				
			||||||
 | 
					        RadsecServers:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            $ref: '#/components/schemas/RADIUSEndPointRadsecType'
 | 
				
			||||||
 | 
					        RadiusServers:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            $ref: '#/components/schemas/RADIUSEndPointRadiusType'
 | 
				
			||||||
 | 
					        PoolStrategy:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          enum:
 | 
				
			||||||
 | 
					            - round_robin
 | 
				
			||||||
 | 
					            - weighted
 | 
				
			||||||
 | 
					            - random
 | 
				
			||||||
 | 
					          default: random
 | 
				
			||||||
 | 
					        UseGWProxy:
 | 
				
			||||||
 | 
					          type: boolean
 | 
				
			||||||
 | 
					          default: true
 | 
				
			||||||
 | 
					        Index:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					          example:
 | 
				
			||||||
 | 
					            - 0.0.1.1: a ficticious IP address that should be between 0.0.1.1 and 0.0.2.254
 | 
				
			||||||
 | 
					        UsedBy:
 | 
				
			||||||
 | 
					          type: array
 | 
				
			||||||
 | 
					          description: list of configuration using this endpoint
 | 
				
			||||||
 | 
					          items:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					        NasIdentifier:
 | 
				
			||||||
 | 
					          type: string
 | 
				
			||||||
 | 
					        AccountingInterval:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RADIUSEndpointUpdateStatus:
 | 
				
			||||||
 | 
					      type: object
 | 
				
			||||||
 | 
					      properties:
 | 
				
			||||||
 | 
					        lastUpdate:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					        lastConfigurationChange:
 | 
				
			||||||
 | 
					          type: integer
 | 
				
			||||||
 | 
					          format: int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					paths:
 | 
				
			||||||
 | 
					  /RADIUSEndPoints:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RADIUS Endpoints
 | 
				
			||||||
 | 
					      operationId: getRADIUSEndPoints
 | 
				
			||||||
 | 
					      summary: Retrieve the lists of RADIUSendPoints
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Pagination start (starts at 1. If not specified, 1 is assumed)
 | 
				
			||||||
 | 
					          name: offset
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: Maximum number of entries to return (if absent, no limit is assumed)
 | 
				
			||||||
 | 
					          name: limit
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: return the number of certificates
 | 
				
			||||||
 | 
					          name: countOnly
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: boolean
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          description: return the last update time
 | 
				
			||||||
 | 
					          name: currentStatus
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: boolean
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          description: The list of endpoints
 | 
				
			||||||
 | 
					          content:
 | 
				
			||||||
 | 
					            application/json:
 | 
				
			||||||
 | 
					              schema:
 | 
				
			||||||
 | 
					                oneOf:
 | 
				
			||||||
 | 
					                  - type: array
 | 
				
			||||||
 | 
					                    items:
 | 
				
			||||||
 | 
					                      $ref: '#/components/schemas/RADIUSEndPoint'
 | 
				
			||||||
 | 
					                  - $ref: '#/components/schemas/RADIUSEndpointUpdateStatus'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    put:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RADIUS Endpoints
 | 
				
			||||||
 | 
					      operationId: updateRADIUSEndpoints
 | 
				
			||||||
 | 
					      summary: Force an Update to teh RADIUSendPoints in the controller
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: query
 | 
				
			||||||
 | 
					          name: updateEndpoints
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: boolean
 | 
				
			||||||
 | 
					          required: false
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          description: The list of endpoints
 | 
				
			||||||
 | 
					          content:
 | 
				
			||||||
 | 
					            application/json:
 | 
				
			||||||
 | 
					              schema:
 | 
				
			||||||
 | 
					                type: object
 | 
				
			||||||
 | 
					                properties:
 | 
				
			||||||
 | 
					                  Error:
 | 
				
			||||||
 | 
					                    type: string
 | 
				
			||||||
 | 
					                  ErrorNum:
 | 
				
			||||||
 | 
					                    type: integer
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /RADIUSEndPoint/{id}:
 | 
				
			||||||
 | 
					    get:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RADIUS Endpoints
 | 
				
			||||||
 | 
					      operationId: getRADIUSEndPoint
 | 
				
			||||||
 | 
					      summary: Retrieve a RADIUSendPoint
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          description: The endpoint
 | 
				
			||||||
 | 
					          content:
 | 
				
			||||||
 | 
					            application/json:
 | 
				
			||||||
 | 
					              schema:
 | 
				
			||||||
 | 
					                $ref: '#/components/schemas/RADIUSEndPoint'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RADIUS Endpoints
 | 
				
			||||||
 | 
					      operationId: deleteRADIUSEndPoint
 | 
				
			||||||
 | 
					      summary: Delete a RADIUSendPoint
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Success'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    post:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RADIUS Endpoints
 | 
				
			||||||
 | 
					      operationId: createRADIUSEndPoint
 | 
				
			||||||
 | 
					      summary: Create a RADIUSendPoint
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      requestBody:
 | 
				
			||||||
 | 
					        content:
 | 
				
			||||||
 | 
					          application/json:
 | 
				
			||||||
 | 
					            schema:
 | 
				
			||||||
 | 
					              $ref: '#/components/schemas/RADIUSEndPoint'
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/RADIUSEndPoint'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    put:
 | 
				
			||||||
 | 
					      tags:
 | 
				
			||||||
 | 
					        - RADIUS Endpoints
 | 
				
			||||||
 | 
					      operationId: modifyRADIUSEndPoint
 | 
				
			||||||
 | 
					      summary: Modify a RADIUSendPoint
 | 
				
			||||||
 | 
					      parameters:
 | 
				
			||||||
 | 
					        - in: path
 | 
				
			||||||
 | 
					          name: id
 | 
				
			||||||
 | 
					          schema:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            format: uuid
 | 
				
			||||||
 | 
					          required: true
 | 
				
			||||||
 | 
					      requestBody:
 | 
				
			||||||
 | 
					        content:
 | 
				
			||||||
 | 
					          application/json:
 | 
				
			||||||
 | 
					            schema:
 | 
				
			||||||
 | 
					              $ref: '#/components/schemas/RADIUSEndPoint'
 | 
				
			||||||
 | 
					      responses:
 | 
				
			||||||
 | 
					        200:
 | 
				
			||||||
 | 
					          $ref: '#/components/schemas/RADIUSEndPoint'
 | 
				
			||||||
 | 
					        400:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/BadRequest'
 | 
				
			||||||
 | 
					        403:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/Unauthorized'
 | 
				
			||||||
 | 
					        404:
 | 
				
			||||||
 | 
					          $ref: '#/components/responses/NotFound'
 | 
				
			||||||
@@ -133,29 +133,32 @@ paths:
 | 
				
			|||||||
      summary: Run a specific or default RRM algorithm. The UI user or CLI user will have the ability to run an algorithm on demand.
 | 
					      summary: Run a specific or default RRM algorithm. The UI user or CLI user will have the ability to run an algorithm on demand.
 | 
				
			||||||
      parameters:
 | 
					      parameters:
 | 
				
			||||||
        - in: query
 | 
					        - in: query
 | 
				
			||||||
          description:
 | 
					          description: The venue this algorithm should be run on.
 | 
				
			||||||
          name: venue
 | 
					          name: venue
 | 
				
			||||||
          schema:
 | 
					          schema:
 | 
				
			||||||
            type: string
 | 
					            type: string
 | 
				
			||||||
            format: uuid
 | 
					            format: uuid
 | 
				
			||||||
          required: true
 | 
					          required: true
 | 
				
			||||||
        - in: query
 | 
					        - in: query
 | 
				
			||||||
          description: Perform RRM without updating anything. This may be used by an admin to see what RRM would do.
 | 
					          description: Perform RRM asynchronously, synchronously or in mockRun mode (without updating anything, this may be used by an admin to see what RRM would do).
 | 
				
			||||||
          name: mock
 | 
					          name: mode
 | 
				
			||||||
          schema:
 | 
					          schema:
 | 
				
			||||||
            type: boolean
 | 
					            type: string
 | 
				
			||||||
            default: false
 | 
					            enum: [ async, sync, mockRun ]
 | 
				
			||||||
          required: false
 | 
					          required: false
 | 
				
			||||||
        - in: query
 | 
					        - in: query
 | 
				
			||||||
          description: Specify the RRM algorithm to use. If omitted, select the default algorithm.
 | 
					          description: Specify the RRM algorithm to use. If omitted, select the default algorithm.
 | 
				
			||||||
 | 
					          name: algorithm
 | 
				
			||||||
          schema:
 | 
					          schema:
 | 
				
			||||||
            type: string
 | 
					            type: string
 | 
				
			||||||
          required: false
 | 
					          required: false
 | 
				
			||||||
        - in: query
 | 
					        - in: query
 | 
				
			||||||
          description: Specify the parameters to use with the RRM algorithm to use. If omitted, select the default parameters.
 | 
					          description: Specify the comma separated name=value parameters to use with the RRM algorithm to use. If omitted, select the default parameters.
 | 
				
			||||||
 | 
					          name: parameters
 | 
				
			||||||
          schema:
 | 
					          schema:
 | 
				
			||||||
            type: string
 | 
					            type: string
 | 
				
			||||||
          required: false
 | 
					          required: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      responses:
 | 
					      responses:
 | 
				
			||||||
        200:
 | 
					        200:
 | 
				
			||||||
          description: Return the list of actions that were or would be performed.
 | 
					          description: Return the list of actions that were or would be performed.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,10 +37,12 @@ openwifi.system.data = ${SYSTEM_DATA}
 | 
				
			|||||||
openwifi.system.debug = false
 | 
					openwifi.system.debug = false
 | 
				
			||||||
openwifi.system.uri.private = ${SYSTEM_URI_PRIVATE}
 | 
					openwifi.system.uri.private = ${SYSTEM_URI_PRIVATE}
 | 
				
			||||||
openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC}
 | 
					openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC}
 | 
				
			||||||
openwifi.system.commandchannel = /tmp/app.ucentralfms
 | 
					openwifi.system.commandchannel = /tmp/app.owprov
 | 
				
			||||||
openwifi.system.uri.ui = ${SYSTEM_URI_UI}
 | 
					openwifi.system.uri.ui = ${SYSTEM_URI_UI}
 | 
				
			||||||
openwifi.security.restapi.disable = ${SECURITY_RESTAPI_DISABLE}
 | 
					openwifi.security.restapi.disable = ${SECURITY_RESTAPI_DISABLE}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rrm.providers = ${RRM_PROVIDERS}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#############################
 | 
					#############################
 | 
				
			||||||
# Generic information for all micro services
 | 
					# Generic information for all micro services
 | 
				
			||||||
#############################
 | 
					#############################
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										189
									
								
								src/APConfig.cpp
									
									
									
									
									
								
							
							
						
						
									
										189
									
								
								src/APConfig.cpp
									
									
									
									
									
								
							@@ -9,6 +9,11 @@
 | 
				
			|||||||
#include "Poco/StringTokenizer.h"
 | 
					#include "Poco/StringTokenizer.h"
 | 
				
			||||||
#include "fmt/format.h"
 | 
					#include "fmt/format.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/OrionWifi.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/GlobalReach.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/Radsec.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/GenericRadius.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	APConfig::APConfig(const std::string &SerialNumber, const std::string &DeviceType,
 | 
						APConfig::APConfig(const std::string &SerialNumber, const std::string &DeviceType,
 | 
				
			||||||
@@ -55,75 +60,154 @@ namespace OpenWifi {
 | 
				
			|||||||
		 */
 | 
							 */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool APConfig::ReplaceVariablesInObject(const Poco::JSON::Object::Ptr &Original,
 | 
					    bool APConfig::InsertRadiusEndPoint(const ProvObjects::RADIUSEndPoint &RE, Poco::JSON::Object &Result) {
 | 
				
			||||||
											Poco::JSON::Object::Ptr &Result) {
 | 
					        if(RE.UseGWProxy) {
 | 
				
			||||||
		// get all the names and expand
 | 
					            Poco::JSON::Object  ServerSettings;
 | 
				
			||||||
		auto Names = Original->getNames();
 | 
					            if (RE.Type == "orion") {
 | 
				
			||||||
		for (const auto &i : Names) {
 | 
					                return OpenRoaming_Orion()->Render(RE, SerialNumber_, Result);
 | 
				
			||||||
			if (i == "__variableBlock") {
 | 
					            } else if (RE.Type == "globalreach") {
 | 
				
			||||||
				if (Original->isArray(i)) {
 | 
					                return OpenRoaming_GlobalReach()->Render(RE, SerialNumber_, Result);
 | 
				
			||||||
					auto UUIDs = Original->getArray(i);
 | 
					            } else if (RE.Type == "radsec") {
 | 
				
			||||||
					for (const auto &uuid : *UUIDs) {
 | 
					                return OpenRoaming_Radsec()->Render(RE, SerialNumber_, Result);
 | 
				
			||||||
						ProvObjects::VariableBlock VB;
 | 
					            } else if (RE.Type == "generic") {
 | 
				
			||||||
						if (StorageService()->VariablesDB().GetRecord("id", uuid, VB)) {
 | 
					                return OpenRoaming_GenericRadius()->Render(RE, SerialNumber_, Result);
 | 
				
			||||||
							for (const auto &var : VB.variables) {
 | 
					            }
 | 
				
			||||||
								Poco::JSON::Parser P;
 | 
					            Result.set( "radius" , ServerSettings);
 | 
				
			||||||
								auto VariableBlockInfo =
 | 
					        } else {
 | 
				
			||||||
									P.parse(var.value).extract<Poco::JSON::Object::Ptr>();
 | 
					            std::cout << "Radius proxy off" << RE.info.name << std::endl;
 | 
				
			||||||
								auto VarNames = VariableBlockInfo->getNames();
 | 
					        }
 | 
				
			||||||
								for (const auto &j : VarNames) {
 | 
					        return false;
 | 
				
			||||||
									Result->set(j, VariableBlockInfo->get(j));
 | 
					    }
 | 
				
			||||||
								}
 | 
					
 | 
				
			||||||
							}
 | 
						void APConfig::ReplaceNestedVariables(const std::string uuid, Poco::JSON::Object &Result) {
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
							Helper method contains code previously in ReplaceVariablesinObject.
 | 
				
			||||||
 | 
							Once the top-level variable is resolved, this will be called to resolve any
 | 
				
			||||||
 | 
							variables nested within the top-level variable.
 | 
				
			||||||
 | 
							*/
 | 
				
			||||||
 | 
							ProvObjects::VariableBlock VB;
 | 
				
			||||||
 | 
							if (StorageService()->VariablesDB().GetRecord("id", uuid, VB)) {
 | 
				
			||||||
 | 
								for (const auto &var: VB.variables) {
 | 
				
			||||||
 | 
									Poco::JSON::Parser P;
 | 
				
			||||||
 | 
									auto VariableBlockInfo =
 | 
				
			||||||
 | 
										P.parse(var.value).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
									auto VarNames = VariableBlockInfo->getNames();
 | 
				
			||||||
 | 
									for (const auto &j: VarNames) {
 | 
				
			||||||
 | 
										if(VariableBlockInfo->isArray(j)) {
 | 
				
			||||||
 | 
											auto Elements = VariableBlockInfo->getArray(j);
 | 
				
			||||||
 | 
											if(Elements->size()>0) {
 | 
				
			||||||
 | 
												Poco::JSON::Array InnerArray;
 | 
				
			||||||
 | 
												ReplaceVariablesInArray(*Elements, InnerArray);
 | 
				
			||||||
 | 
												Result.set(j, InnerArray);
 | 
				
			||||||
 | 
											} else {
 | 
				
			||||||
 | 
					//                      	std::cout << "Empty Array!!!" << std::endl;
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
 | 
										} else if(VariableBlockInfo->isObject(j)) {
 | 
				
			||||||
 | 
											Poco::JSON::Object  InnerEval;
 | 
				
			||||||
 | 
											auto O = VariableBlockInfo->getObject(j);
 | 
				
			||||||
 | 
											ReplaceVariablesInObject(*O,InnerEval);
 | 
				
			||||||
 | 
											Result.set(j, InnerEval);
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											Result.set(j, VariableBlockInfo->get(j));
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} else if (Original->isArray(i)) {
 | 
								}
 | 
				
			||||||
				auto Arr = Poco::makeShared<Poco::JSON::Array>();
 | 
							}
 | 
				
			||||||
				auto Obj = Original->getArray(i);
 | 
						}
 | 
				
			||||||
				ReplaceVariablesInArray(Obj, Arr);
 | 
					
 | 
				
			||||||
				Result->set(i, Arr);
 | 
					    bool APConfig::ReplaceVariablesInObject(const Poco::JSON::Object &Original,
 | 
				
			||||||
			} else if (Original->isObject(i)) {
 | 
																Poco::JSON::Object &Result) {
 | 
				
			||||||
				auto Expanded = Poco::makeShared<Poco::JSON::Object>();
 | 
							// get all the names and expand
 | 
				
			||||||
				auto Obj = Original->getObject(i);
 | 
							auto Names = Original.getNames();
 | 
				
			||||||
				ReplaceVariablesInObject(Obj, Expanded);
 | 
							for (const auto &i : Names) {
 | 
				
			||||||
				Result->set(i, Expanded);
 | 
					            if (i == "__variableBlock") {
 | 
				
			||||||
 | 
					                if (Original.isArray(i)) {
 | 
				
			||||||
 | 
										/*
 | 
				
			||||||
 | 
										E.g. of what the variable block would look like in an array:
 | 
				
			||||||
 | 
										"ssids": [
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												"__variableBlock": [
 | 
				
			||||||
 | 
													"79c083d2-d496-4de0-8600-76a63556851b"
 | 
				
			||||||
 | 
												]
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										]
 | 
				
			||||||
 | 
										*/
 | 
				
			||||||
 | 
					                    auto UUIDs = Original.getArray(i);
 | 
				
			||||||
 | 
					                    for (const std::string &uuid: *UUIDs) {
 | 
				
			||||||
 | 
					                        ReplaceNestedVariables(uuid, Result);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
									else {
 | 
				
			||||||
 | 
										/*
 | 
				
			||||||
 | 
										E.g. of what the variable block would look like replacing an entire json blob:
 | 
				
			||||||
 | 
										"services" : {
 | 
				
			||||||
 | 
											"__variableBlock": "ef8db4c0-f0ef-40d2-b676-c9c02ef39430"
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										*/
 | 
				
			||||||
 | 
										const std::string uuid = Original.get(i);
 | 
				
			||||||
 | 
										ReplaceNestedVariables(uuid, Result);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					            } else if (i == "__radiusEndpoint") {
 | 
				
			||||||
 | 
					                auto EndPointId = Original.get(i).toString();
 | 
				
			||||||
 | 
					                ProvObjects::RADIUSEndPoint RE;
 | 
				
			||||||
 | 
					//                std::cout << "ID->" << EndPointId << std::endl;
 | 
				
			||||||
 | 
					                if(StorageService()->RadiusEndpointDB().GetRecord("id",EndPointId,RE)) {
 | 
				
			||||||
 | 
					                    InsertRadiusEndPoint(RE, Result);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    poco_error(Logger_, fmt::format("RADIUS Endpoint {} could not be found. Please delete this configuration and recreate it."));
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
								} else if (Original.isArray(i)) {
 | 
				
			||||||
 | 
					                Poco::JSON::Array Arr;
 | 
				
			||||||
 | 
									auto Obj = Original.getArray(i);
 | 
				
			||||||
 | 
					                if(Obj->size()>0) {
 | 
				
			||||||
 | 
					                    ReplaceVariablesInArray(*Obj, Arr);
 | 
				
			||||||
 | 
					                    Result.set(i, Arr);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
								} else if (Original.isObject(i)) {
 | 
				
			||||||
 | 
					                Poco::JSON::Object Expanded;
 | 
				
			||||||
 | 
									auto Obj = Original.getObject(i);
 | 
				
			||||||
 | 
									ReplaceVariablesInObject(*Obj, Expanded);
 | 
				
			||||||
 | 
									Result.set(i, Expanded);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				Result->set(i, Original->get(i));
 | 
									Result.set(i, Original.get(i));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool APConfig::ReplaceVariablesInArray(const Poco::JSON::Array::Ptr &Original,
 | 
						bool APConfig::ReplaceVariablesInArray(const Poco::JSON::Array &Original,
 | 
				
			||||||
										   Poco::JSON::Array::Ptr &ResultArray) {
 | 
															   Poco::JSON::Array &ResultArray) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
		for (const auto &element : *Original) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (const auto &element : Original) {
 | 
				
			||||||
 | 
					//            std::cout << element.toString() << std::endl;
 | 
				
			||||||
			if (element.isArray()) {
 | 
								if (element.isArray()) {
 | 
				
			||||||
				auto Expanded = Poco::makeShared<Poco::JSON::Array>();
 | 
					                Poco::JSON::Array  Expanded;
 | 
				
			||||||
				const auto &Object = element.extract<Poco::JSON::Array::Ptr>();
 | 
									const auto Object = element.extract<Poco::JSON::Array::Ptr>();
 | 
				
			||||||
				ReplaceVariablesInArray(Object, Expanded);
 | 
					                if(Object->size()>0) {
 | 
				
			||||||
				ResultArray->add(Expanded);
 | 
					                    ReplaceVariablesInArray(*Object, Expanded);
 | 
				
			||||||
 | 
					                    ResultArray.add(Expanded);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
			} else if (element.isStruct()) {
 | 
								} else if (element.isStruct()) {
 | 
				
			||||||
				auto Expanded = Poco::makeShared<Poco::JSON::Object>();
 | 
					                Poco::JSON::Object  Expanded;
 | 
				
			||||||
				const auto &Object = element.extract<Poco::JSON::Object::Ptr>();
 | 
									const auto &Object = element.extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
				ReplaceVariablesInObject(Object, Expanded);
 | 
									ReplaceVariablesInObject(*Object, Expanded);
 | 
				
			||||||
				ResultArray->add(Expanded);
 | 
									ResultArray.add(Expanded);
 | 
				
			||||||
			} else if (element.isString() || element.isNumeric() || element.isBoolean() ||
 | 
								} else if (element.isString() || element.isNumeric() || element.isBoolean() ||
 | 
				
			||||||
					   element.isInteger() || element.isSigned()) {
 | 
										   element.isInteger() || element.isSigned()) {
 | 
				
			||||||
				ResultArray->add(element);
 | 
									ResultArray.add(element);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				auto Expanded = Poco::makeShared<Poco::JSON::Object>();
 | 
					                Poco::JSON::Object  Expanded;
 | 
				
			||||||
				const auto &Object = element.extract<Poco::JSON::Object::Ptr>();
 | 
									const auto &Object = element.extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
				ReplaceVariablesInObject(Object, Expanded);
 | 
									ReplaceVariablesInObject(*Object, Expanded);
 | 
				
			||||||
				ResultArray->add(Expanded);
 | 
									ResultArray.add(Expanded);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool APConfig::Get(Poco::JSON::Object::Ptr &Configuration) {
 | 
						bool APConfig::Get(Poco::JSON::Object::Ptr &Configuration) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (Config_.empty()) {
 | 
							if (Config_.empty()) {
 | 
				
			||||||
			Explanation_.clear();
 | 
								Explanation_.clear();
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
@@ -177,8 +261,8 @@ namespace OpenWifi {
 | 
				
			|||||||
								ExObj.set("element", OriginalArray);
 | 
													ExObj.set("element", OriginalArray);
 | 
				
			||||||
								Explanation_.add(ExObj);
 | 
													Explanation_.add(ExObj);
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
							auto ExpandedArray = Poco::makeShared<Poco::JSON::Array>();
 | 
					                            Poco::JSON::Array ExpandedArray;
 | 
				
			||||||
							ReplaceVariablesInArray(OriginalArray, ExpandedArray);
 | 
												ReplaceVariablesInArray(*OriginalArray, ExpandedArray);
 | 
				
			||||||
							Configuration->set(SectionName, ExpandedArray);
 | 
												Configuration->set(SectionName, ExpandedArray);
 | 
				
			||||||
						} else if (O->isObject(SectionName)) {
 | 
											} else if (O->isObject(SectionName)) {
 | 
				
			||||||
							auto OriginalSection =
 | 
												auto OriginalSection =
 | 
				
			||||||
@@ -191,8 +275,8 @@ namespace OpenWifi {
 | 
				
			|||||||
								ExObj.set("element", OriginalSection);
 | 
													ExObj.set("element", OriginalSection);
 | 
				
			||||||
								Explanation_.add(ExObj);
 | 
													Explanation_.add(ExObj);
 | 
				
			||||||
							}
 | 
												}
 | 
				
			||||||
							auto ExpandedSection = Poco::makeShared<Poco::JSON::Object>();
 | 
					                            Poco::JSON::Object ExpandedSection;
 | 
				
			||||||
							ReplaceVariablesInObject(OriginalSection, ExpandedSection);
 | 
												ReplaceVariablesInObject(*OriginalSection, ExpandedSection);
 | 
				
			||||||
							Configuration->set(SectionName, ExpandedSection);
 | 
												Configuration->set(SectionName, ExpandedSection);
 | 
				
			||||||
						} else {
 | 
											} else {
 | 
				
			||||||
                            poco_warning(Logger(), fmt::format("Unknown config element type: {}",O->get(SectionName).toString()));
 | 
					                            poco_warning(Logger(), fmt::format("Unknown config element type: {}",O->get(SectionName).toString()));
 | 
				
			||||||
@@ -225,7 +309,7 @@ namespace OpenWifi {
 | 
				
			|||||||
									RadioArray->get(RadioIndex).extract<Poco::JSON::Object::Ptr>();
 | 
														RadioArray->get(RadioIndex).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
								if (Tokens[2] == "tx-power") {
 | 
													if (Tokens[2] == "tx-power") {
 | 
				
			||||||
									IndexedRadio->set(
 | 
														IndexedRadio->set(
 | 
				
			||||||
										"rx-power",
 | 
															"tx-power",
 | 
				
			||||||
										std::strtoull(col.parameterValue.c_str(), nullptr, 10));
 | 
															std::strtoull(col.parameterValue.c_str(), nullptr, 10));
 | 
				
			||||||
									if (Explain_) {
 | 
														if (Explain_) {
 | 
				
			||||||
										Poco::JSON::Object ExObj;
 | 
															Poco::JSON::Object ExObj;
 | 
				
			||||||
@@ -317,6 +401,7 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		ProvObjects::DeviceConfiguration Config;
 | 
							ProvObjects::DeviceConfiguration Config;
 | 
				
			||||||
		if (StorageService()->ConfigurationDB().GetRecord("id", UUID, Config)) {
 | 
							if (StorageService()->ConfigurationDB().GetRecord("id", UUID, Config)) {
 | 
				
			||||||
 | 
					//            std::cout << Config.info.name << ":" << Config.configuration.size() << std::endl;
 | 
				
			||||||
			if (!Config.configuration.empty()) {
 | 
								if (!Config.configuration.empty()) {
 | 
				
			||||||
				if (DeviceTypeMatch(DeviceType_, Config.deviceTypes)) {
 | 
									if (DeviceTypeMatch(DeviceType_, Config.deviceTypes)) {
 | 
				
			||||||
					for (const auto &i : Config.configuration) {
 | 
										for (const auto &i : Config.configuration) {
 | 
				
			||||||
@@ -375,4 +460,4 @@ namespace OpenWifi {
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,10 +45,11 @@ namespace OpenWifi {
 | 
				
			|||||||
		bool Sub_ = false;
 | 
							bool Sub_ = false;
 | 
				
			||||||
		Poco::Logger &Logger() { return Logger_; }
 | 
							Poco::Logger &Logger() { return Logger_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool ReplaceVariablesInArray(const Poco::JSON::Array::Ptr &O,
 | 
							bool ReplaceVariablesInArray(const Poco::JSON::Array &O,
 | 
				
			||||||
									 Poco::JSON::Array::Ptr &Result);
 | 
														 Poco::JSON::Array &Result);
 | 
				
			||||||
		bool ReplaceVariablesInObject(const Poco::JSON::Object::Ptr &Original,
 | 
							void ReplaceNestedVariables(const std::string uuid, Poco::JSON::Object &Result);
 | 
				
			||||||
									  Poco::JSON::Object::Ptr &Result);
 | 
							bool ReplaceVariablesInObject(const Poco::JSON::Object &Original,
 | 
				
			||||||
 | 
														  Poco::JSON::Object &Result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool FindRadio(const std::string &Band, const Poco::JSON::Array::Ptr &Arr,
 | 
							bool FindRadio(const std::string &Band, const Poco::JSON::Array::Ptr &Arr,
 | 
				
			||||||
					   Poco::JSON::Object::Ptr &Radio);
 | 
										   Poco::JSON::Object::Ptr &Radio);
 | 
				
			||||||
@@ -58,5 +59,6 @@ namespace OpenWifi {
 | 
				
			|||||||
				   Poco::JSON::Object::Ptr &C);
 | 
									   Poco::JSON::Object::Ptr &C);
 | 
				
			||||||
		bool RemoveBand(const std::string &Band, const Poco::JSON::Array::Ptr &A_in,
 | 
							bool RemoveBand(const std::string &Band, const Poco::JSON::Array::Ptr &A_in,
 | 
				
			||||||
						Poco::JSON::Array::Ptr &A_Out);
 | 
											Poco::JSON::Array::Ptr &A_Out);
 | 
				
			||||||
 | 
					        bool InsertRadiusEndPoint(const ProvObjects::RADIUSEndPoint &EP, Poco::JSON::Object &Result);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@
 | 
				
			|||||||
#include "AutoDiscovery.h"
 | 
					#include "AutoDiscovery.h"
 | 
				
			||||||
#include "Poco/JSON/Parser.h"
 | 
					#include "Poco/JSON/Parser.h"
 | 
				
			||||||
#include "StorageService.h"
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "Tasks/VenueConfigUpdater.h"
 | 
				
			||||||
#include "framework/KafkaManager.h"
 | 
					#include "framework/KafkaManager.h"
 | 
				
			||||||
#include "framework/KafkaTopics.h"
 | 
					#include "framework/KafkaTopics.h"
 | 
				
			||||||
#include "framework/ow_constants.h"
 | 
					#include "framework/ow_constants.h"
 | 
				
			||||||
@@ -31,7 +32,51 @@ namespace OpenWifi {
 | 
				
			|||||||
		poco_information(Logger(), "Stopped...");
 | 
							poco_information(Logger(), "Stopped...");
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void AutoDiscovery::run() {
 | 
					    void AutoDiscovery::ProcessPing(const Poco::JSON::Object::Ptr & P, std::string &FW, std::string &SN,
 | 
				
			||||||
 | 
					                                    std::string &Compat, std::string &Conn, std::string &locale) {
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::CONNECTIONIP))
 | 
				
			||||||
 | 
					            Conn = P->get(uCentralProtocol::CONNECTIONIP).toString();
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::FIRMWARE))
 | 
				
			||||||
 | 
					            FW = P->get(uCentralProtocol::FIRMWARE).toString();
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::SERIALNUMBER))
 | 
				
			||||||
 | 
					            SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::COMPATIBLE))
 | 
				
			||||||
 | 
					            Compat = P->get(uCentralProtocol::COMPATIBLE).toString();
 | 
				
			||||||
 | 
					        if (P->has("locale")) {
 | 
				
			||||||
 | 
					            locale = P->get("locale").toString();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void AutoDiscovery::ProcessConnect(const Poco::JSON::Object::Ptr &P, std::string &FW, std::string &SN,
 | 
				
			||||||
 | 
					                                       std::string &Compat, std::string &Conn, std::string &locale) {
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::CONNECTIONIP))
 | 
				
			||||||
 | 
					            Conn = P->get(uCentralProtocol::CONNECTIONIP).toString();
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::FIRMWARE))
 | 
				
			||||||
 | 
					            FW = P->get(uCentralProtocol::FIRMWARE).toString();
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::SERIALNUMBER))
 | 
				
			||||||
 | 
					            SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
 | 
				
			||||||
 | 
					        else if (P->has(uCentralProtocol::SERIAL))
 | 
				
			||||||
 | 
					            SN = P->get(uCentralProtocol::SERIAL).toString();
 | 
				
			||||||
 | 
					        if (P->has("locale")) {
 | 
				
			||||||
 | 
					            locale = P->get("locale").toString();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if(P->has(uCentralProtocol::CAPABILITIES)) {
 | 
				
			||||||
 | 
					            auto CapObj = P->getObject(uCentralProtocol::CAPABILITIES);
 | 
				
			||||||
 | 
					            if (CapObj->has(uCentralProtocol::COMPATIBLE))
 | 
				
			||||||
 | 
					                Compat = CapObj->get(uCentralProtocol::COMPATIBLE).toString();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void AutoDiscovery::ProcessDisconnect(const Poco::JSON::Object::Ptr &P, [[maybe_unused]] std::string &FW,
 | 
				
			||||||
 | 
					                                            std::string &SN,
 | 
				
			||||||
 | 
					                                          [[maybe_unused]] std::string &Compat,
 | 
				
			||||||
 | 
					                                          [[maybe_unused]] std::string &Conn,
 | 
				
			||||||
 | 
					                                          [[maybe_unused]] std::string &locale) {
 | 
				
			||||||
 | 
					        if (P->has(uCentralProtocol::SERIALNUMBER))
 | 
				
			||||||
 | 
					            SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void AutoDiscovery::run() {
 | 
				
			||||||
		Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
 | 
							Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
 | 
				
			||||||
		Utils::SetThreadName("auto-discovery");
 | 
							Utils::SetThreadName("auto-discovery");
 | 
				
			||||||
		while (Note && Running_) {
 | 
							while (Note && Running_) {
 | 
				
			||||||
@@ -40,43 +85,38 @@ namespace OpenWifi {
 | 
				
			|||||||
				try {
 | 
									try {
 | 
				
			||||||
					Poco::JSON::Parser Parser;
 | 
										Poco::JSON::Parser Parser;
 | 
				
			||||||
					auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
 | 
										auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
					                    bool    Connected=true;
 | 
				
			||||||
 | 
					                    bool isConnection=false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					if (Object->has(uCentralProtocol::PAYLOAD)) {
 | 
										if (Object->has(uCentralProtocol::PAYLOAD)) {
 | 
				
			||||||
						auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
 | 
					                        auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
 | 
				
			||||||
						std::string ConnectedIP, SerialNumber, DeviceType;
 | 
					                        std::string ConnectedIP, SerialNumber, Compatible, Firmware, Locale ;
 | 
				
			||||||
						if (PayloadObj->has(uCentralProtocol::CONNECTIONIP))
 | 
					                        if (PayloadObj->has(uCentralProtocol::PING)) {
 | 
				
			||||||
							ConnectedIP =
 | 
					                            auto PingObj = PayloadObj->getObject("ping");
 | 
				
			||||||
								PayloadObj->get(uCentralProtocol::CONNECTIONIP).toString();
 | 
					                            ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
 | 
				
			||||||
						if (PayloadObj->has(uCentralProtocol::CAPABILITIES)) {
 | 
					                        } else if(PayloadObj->has("capabilities")) {
 | 
				
			||||||
							auto CapObj = PayloadObj->getObject(uCentralProtocol::CAPABILITIES);
 | 
					                            isConnection=true;
 | 
				
			||||||
							if (CapObj->has(uCentralProtocol::COMPATIBLE)) {
 | 
					                            ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
 | 
				
			||||||
								DeviceType = CapObj->get(uCentralProtocol::COMPATIBLE).toString();
 | 
					                        } else if(PayloadObj->has("disconnection")) {
 | 
				
			||||||
								SerialNumber = PayloadObj->get(uCentralProtocol::SERIAL).toString();
 | 
					                            //  we ignore disconnection in provisioning
 | 
				
			||||||
							}
 | 
					                            Connected=false;
 | 
				
			||||||
						} else if (PayloadObj->has(uCentralProtocol::PING)) {
 | 
					                            ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
 | 
				
			||||||
							auto PingMessage = PayloadObj->getObject(uCentralProtocol::PING);
 | 
					                        } else {
 | 
				
			||||||
							if (PingMessage->has(uCentralProtocol::FIRMWARE) &&
 | 
					                            poco_debug(Logger(),fmt::format("Unknown message on 'connection' topic: {}",Msg->Payload()));
 | 
				
			||||||
								PingMessage->has(uCentralProtocol::SERIALNUMBER) &&
 | 
					                        }
 | 
				
			||||||
								PingMessage->has(uCentralProtocol::COMPATIBLE)) {
 | 
					 | 
				
			||||||
								if (PingMessage->has(uCentralProtocol::CONNECTIONIP))
 | 
					 | 
				
			||||||
									ConnectedIP =
 | 
					 | 
				
			||||||
										PingMessage->get(uCentralProtocol::CONNECTIONIP).toString();
 | 
					 | 
				
			||||||
								SerialNumber =
 | 
					 | 
				
			||||||
									PingMessage->get(uCentralProtocol::SERIALNUMBER).toString();
 | 
					 | 
				
			||||||
								DeviceType =
 | 
					 | 
				
			||||||
									PingMessage->get(uCentralProtocol::COMPATIBLE).toString();
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						std::string Locale;
 | 
					 | 
				
			||||||
						if (PayloadObj->has("locale"))
 | 
					 | 
				
			||||||
							Locale = PayloadObj->get("locale").toString();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
						if (!SerialNumber.empty()) {
 | 
					                        if (!SerialNumber.empty() && Connected) {
 | 
				
			||||||
							StorageService()->InventoryDB().CreateFromConnection(
 | 
					                            StorageService()->InventoryDB().CreateFromConnection(
 | 
				
			||||||
								SerialNumber, ConnectedIP, DeviceType, Locale);
 | 
					                                    SerialNumber, ConnectedIP, Compatible, Locale, isConnection);
 | 
				
			||||||
						}
 | 
					                            // Now that the entry has been created, we can try to push a config if
 | 
				
			||||||
					}
 | 
					                            // the connection was a capabilities message.
 | 
				
			||||||
 | 
					                            if (isConnection){
 | 
				
			||||||
 | 
					                                ComputeAndPushConfig(SerialNumber, Compatible, Logger());
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
				} catch (const Poco::Exception &E) {
 | 
									} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					                    std::cout << "EX:" << Msg->Payload() << std::endl;
 | 
				
			||||||
					Logger().log(E);
 | 
										Logger().log(E);
 | 
				
			||||||
				} catch (...) {
 | 
									} catch (...) {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "Poco/Notification.h"
 | 
					#include "Poco/Notification.h"
 | 
				
			||||||
#include "Poco/NotificationQueue.h"
 | 
					#include "Poco/NotificationQueue.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/Object.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -46,7 +47,14 @@ namespace OpenWifi {
 | 
				
			|||||||
		Poco::Thread Worker_;
 | 
							Poco::Thread Worker_;
 | 
				
			||||||
		std::atomic_bool Running_ = false;
 | 
							std::atomic_bool Running_ = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		AutoDiscovery() noexcept
 | 
					        void ProcessPing(const Poco::JSON::Object::Ptr & P, std::string &FW, std::string &SN,
 | 
				
			||||||
 | 
					                                        std::string &Compat, std::string &Conn, std::string &locale) ;
 | 
				
			||||||
 | 
					        void ProcessConnect(const Poco::JSON::Object::Ptr & P, std::string &FW, std::string &SN,
 | 
				
			||||||
 | 
					                         std::string &Compat, std::string &Conn, std::string &locale) ;
 | 
				
			||||||
 | 
					        void ProcessDisconnect(const Poco::JSON::Object::Ptr & P, std::string &FW, std::string &SN,
 | 
				
			||||||
 | 
					                            std::string &Compat, std::string &Conn, std::string &locale) ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        AutoDiscovery() noexcept
 | 
				
			||||||
			: SubSystemServer("AutoDiscovery", "AUTO-DISCOVERY", "discovery") {}
 | 
								: SubSystemServer("AutoDiscovery", "AUTO-DISCOVERY", "discovery") {}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,10 @@
 | 
				
			|||||||
#include "UI_Prov_WebSocketNotifications.h"
 | 
					#include "UI_Prov_WebSocketNotifications.h"
 | 
				
			||||||
#include "framework/ConfigurationValidator.h"
 | 
					#include "framework/ConfigurationValidator.h"
 | 
				
			||||||
#include "framework/UI_WebSocketClientServer.h"
 | 
					#include "framework/UI_WebSocketClientServer.h"
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/GlobalReach.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/OrionWifi.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/Radsec.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/GenericRadius.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
	class Daemon *Daemon::instance_ = nullptr;
 | 
						class Daemon *Daemon::instance_ = nullptr;
 | 
				
			||||||
@@ -35,7 +39,11 @@ namespace OpenWifi {
 | 
				
			|||||||
												ConfigurationValidator(), SerialNumberCache(),
 | 
																	ConfigurationValidator(), SerialNumberCache(),
 | 
				
			||||||
												AutoDiscovery(), JobController(),
 | 
																	AutoDiscovery(), JobController(),
 | 
				
			||||||
												UI_WebSocketClientServer(), FindCountryFromIP(),
 | 
																	UI_WebSocketClientServer(), FindCountryFromIP(),
 | 
				
			||||||
												Signup(), FileDownloader()});
 | 
																	Signup(), FileDownloader(),
 | 
				
			||||||
 | 
					                                                OpenRoaming_GlobalReach(),
 | 
				
			||||||
 | 
					                                                OpenRoaming_Orion(), OpenRoaming_Radsec(),
 | 
				
			||||||
 | 
					                                                OpenRoaming_GenericRadius()
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return instance_;
 | 
							return instance_;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,17 +63,9 @@ namespace OpenWifi {
 | 
				
			|||||||
			std::lock_guard G(Mutex_);
 | 
								std::lock_guard G(Mutex_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Initialized_ = true;
 | 
								Initialized_ = true;
 | 
				
			||||||
			std::string DeviceTypes;
 | 
								std::vector<std::string> DeviceTypes;
 | 
				
			||||||
			if (AppServiceRegistry().Get("deviceTypes", DeviceTypes)) {
 | 
								AppServiceRegistry().Get("deviceTypes", DeviceTypes);
 | 
				
			||||||
				Poco::JSON::Parser P;
 | 
					            std::for_each(DeviceTypes.begin(),DeviceTypes.end(),[&](const std::string &s){ DeviceTypes_.insert(s);});
 | 
				
			||||||
				try {
 | 
					 | 
				
			||||||
					auto O = P.parse(DeviceTypes).extract<Poco::JSON::Array::Ptr>();
 | 
					 | 
				
			||||||
					for (const auto &i : *O) {
 | 
					 | 
				
			||||||
						DeviceTypes_.insert(i.toString());
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				} catch (...) {
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline bool UpdateDeviceTypes() {
 | 
							inline bool UpdateDeviceTypes() {
 | 
				
			||||||
@@ -107,15 +99,9 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		inline void SaveCache() {
 | 
							inline void SaveCache() {
 | 
				
			||||||
			std::lock_guard G(Mutex_);
 | 
								std::lock_guard G(Mutex_);
 | 
				
			||||||
 | 
					            std::vector<std::string>    DeviceTypes;
 | 
				
			||||||
			Poco::JSON::Array Arr;
 | 
					            std::for_each(DeviceTypes_.begin(),DeviceTypes_.end(),[&](const std::string &s){DeviceTypes.emplace_back(s);});
 | 
				
			||||||
			for (auto const &i : DeviceTypes_)
 | 
								AppServiceRegistry().Set("deviceTypes", DeviceTypes);
 | 
				
			||||||
				Arr.add(i);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			std::stringstream OS;
 | 
					 | 
				
			||||||
			Arr.stringify(OS);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			AppServiceRegistry().Set("deviceTypes", OS.str());
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,9 +24,15 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	void FileDownloader::onTimer([[maybe_unused]] Poco::Timer &timer) {
 | 
						void FileDownloader::onTimer([[maybe_unused]] Poco::Timer &timer) {
 | 
				
			||||||
		const static std::vector<std::pair<std::string, std::string>> Files{
 | 
							const static std::vector<std::pair<std::string, std::string>> Files{
 | 
				
			||||||
			{"https://raw.githubusercontent.com/blogic/ucentral-schema/main/ucentral.schema.json",
 | 
					            {
 | 
				
			||||||
			 "ucentral.schema.json"},
 | 
					                "https://raw.githubusercontent.com/Telecominfraproject/wlan-ucentral-schema/main/ucentral.schema.pretty.json",
 | 
				
			||||||
			{"https://ucentral.io/ucentral.schema.pretty.json", "ucentral.schema.pretty.json"}};
 | 
					                "ucentral.schema.pretty.json"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                "https://raw.githubusercontent.com/Telecominfraproject/wlan-ucentral-schema/main/ucentral.schema.json",
 | 
				
			||||||
 | 
					                "ucentral.schema.json"
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Utils::SetThreadName("file-dmnldr");
 | 
							Utils::SetThreadName("file-dmnldr");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,9 +39,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		Poco::JSON::Object Payload;
 | 
							Poco::JSON::Object Payload;
 | 
				
			||||||
		obj.to_json(Payload);
 | 
							obj.to_json(Payload);
 | 
				
			||||||
		Payload.set("ObjectType", OT);
 | 
							Payload.set("ObjectType", OT);
 | 
				
			||||||
		std::ostringstream OS;
 | 
							KafkaManager()->PostMessage(KafkaTopics::PROVISIONING_CHANGE, Ops[op], Payload);
 | 
				
			||||||
		Payload.stringify(OS);
 | 
					 | 
				
			||||||
		KafkaManager()->PostMessage(KafkaTopics::PROVISIONING_CHANGE, Ops[op], OS.str());
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,9 +91,10 @@ namespace OpenWifi {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			auto Config = RawObject->get("configuration").toString();
 | 
								auto Config = RawObject->get("configuration").toString();
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
			std::vector<std::string> Error;
 | 
					            auto deviceType = GetParameter("deviceType", "AP");
 | 
				
			||||||
 | 
					            std::string Error;
 | 
				
			||||||
			auto Res =
 | 
								auto Res =
 | 
				
			||||||
				ValidateUCentralConfiguration(Config, Error, GetBoolParameter("strict", true));
 | 
									ValidateUCentralConfiguration(ConfigurationValidator::GetType(deviceType),Config, Error, GetBoolParameter("strict", true));
 | 
				
			||||||
			Answer.set("valid", Res);
 | 
								Answer.set("valid", Res);
 | 
				
			||||||
			Answer.set("error", Error);
 | 
								Answer.set("error", Error);
 | 
				
			||||||
			return ReturnObject(Answer);
 | 
								return ReturnObject(Answer);
 | 
				
			||||||
@@ -134,11 +135,27 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::vector<std::string> Errors;
 | 
							std::vector<std::string> Errors;
 | 
				
			||||||
		if (!ValidateConfigBlock(NewObject, Errors)) {
 | 
					        auto deviceType = GetParameter("deviceType", "AP");
 | 
				
			||||||
			return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
					        if (!ValidateConfigBlock(ConfigurationValidator::GetType(deviceType), NewObject, Errors)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Types::UUIDvec_t ToVariables;
 | 
				
			||||||
 | 
							if (RawObject->has("variables")) {
 | 
				
			||||||
 | 
								for (const auto &i : NewObject.variables) {
 | 
				
			||||||
 | 
									if (!i.empty() && !StorageService()->VariablesDB().Exists("id", i)) {
 | 
				
			||||||
 | 
										return BadRequest(RESTAPI::Errors::VariableMustExist);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								for (const auto &i : NewObject.variables)
 | 
				
			||||||
 | 
									ToVariables.emplace_back(i);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								ToVariables = NewObject.variables;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (DB_.CreateRecord(NewObject)) {
 | 
							if (DB_.CreateRecord(NewObject)) {
 | 
				
			||||||
 | 
								AddMembership(StorageService()->VariablesDB(),
 | 
				
			||||||
 | 
												 &ProvObjects::VariableBlock::configurations, ToVariables, NewObject.info.id);
 | 
				
			||||||
			MoveUsage(StorageService()->PolicyDB(), DB_, "", NewObject.managementPolicy,
 | 
								MoveUsage(StorageService()->PolicyDB(), DB_, "", NewObject.managementPolicy,
 | 
				
			||||||
					  NewObject.info.id);
 | 
										  NewObject.info.id);
 | 
				
			||||||
			AddMembership(StorageService()->VenueDB(), &ProvObjects::Venue::configurations,
 | 
								AddMembership(StorageService()->VenueDB(), &ProvObjects::Venue::configurations,
 | 
				
			||||||
@@ -185,9 +202,10 @@ namespace OpenWifi {
 | 
				
			|||||||
			Existing.deviceTypes = NewObject.deviceTypes;
 | 
								Existing.deviceTypes = NewObject.deviceTypes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::vector<std::string> Errors;
 | 
							std::vector<std::string> Errors;
 | 
				
			||||||
		if (!ValidateConfigBlock(NewObject, Errors)) {
 | 
					        auto deviceType = GetParameter("deviceType", "AP");
 | 
				
			||||||
			return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
					        if (!ValidateConfigBlock(ConfigurationValidator::GetType(deviceType), NewObject, Errors)) {
 | 
				
			||||||
		}
 | 
					            return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (RawObject->has("configuration")) {
 | 
							if (RawObject->has("configuration")) {
 | 
				
			||||||
			Existing.configuration = NewObject.configuration;
 | 
								Existing.configuration = NewObject.configuration;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -389,6 +389,13 @@ namespace OpenWifi {
 | 
				
			|||||||
			DB.ManipulateVectorMember(T, "id", Obj, Id, true);
 | 
								DB.ManipulateVectorMember(T, "id", Obj, Id, true);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						template <typename db_type, typename Member>
 | 
				
			||||||
 | 
						void AddMembership(db_type &DB, Member T, const Types::UUIDvec_t &Obj, const std::string &Id) {
 | 
				
			||||||
 | 
							for (const auto &i : Obj) {
 | 
				
			||||||
 | 
								AddMembership(DB, T, i, Id);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <typename db_type, typename Member>
 | 
						template <typename db_type, typename Member>
 | 
				
			||||||
	void ManageMembership(db_type &DB, Member T, const std::string &From, const std::string &To,
 | 
						void ManageMembership(db_type &DB, Member T, const std::string &From, const std::string &To,
 | 
				
			||||||
						  const std::string &Id) {
 | 
											  const std::string &Id) {
 | 
				
			||||||
@@ -431,47 +438,49 @@ namespace OpenWifi {
 | 
				
			|||||||
		return EntityDB::RootUUID();
 | 
							return EntityDB::RootUUID();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline bool ValidateConfigBlock(const ProvObjects::DeviceConfiguration &Config,
 | 
					    inline bool ValidateConfigBlock(ConfigurationValidator::ConfigurationType Type, const ProvObjects::DeviceConfiguration &Config,
 | 
				
			||||||
									std::vector<std::string> &Errors) {
 | 
					                                    std::vector<std::string> &Errors) {
 | 
				
			||||||
		static const std::vector<std::string> SectionNames{
 | 
					        static const std::vector<std::string> SectionNames{
 | 
				
			||||||
			"globals",	   "interfaces", "metrics", "radios",	  "services",	"unit",
 | 
					                "globals",	   "interfaces", "metrics", "radios",	  "services",	"unit",
 | 
				
			||||||
			"definitions", "ethernet",	 "switch",	"config-raw", "third-party"};
 | 
					                "definitions", "ethernet",	 "switch",	"config-raw", "third-party"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (const auto &i : Config.configuration) {
 | 
					        for (const auto &i : Config.configuration) {
 | 
				
			||||||
			Poco::JSON::Parser P;
 | 
					            Poco::JSON::Parser P;
 | 
				
			||||||
			if (i.name.empty()) {
 | 
					            if (i.name.empty()) {
 | 
				
			||||||
				Errors.push_back("Name is empty");
 | 
					                Errors.push_back("Name is empty");
 | 
				
			||||||
				return false;
 | 
					                return false;
 | 
				
			||||||
			}
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			try {
 | 
					            try {
 | 
				
			||||||
				auto Blocks = P.parse(i.configuration).extract<Poco::JSON::Object::Ptr>();
 | 
					                auto Blocks = P.parse(i.configuration).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
				auto N = Blocks->getNames();
 | 
					                auto N = Blocks->getNames();
 | 
				
			||||||
				for (const auto &j : N) {
 | 
					                for (const auto &j : N) {
 | 
				
			||||||
					if (std::find(SectionNames.cbegin(), SectionNames.cend(), j) ==
 | 
					                    if (std::find(SectionNames.cbegin(), SectionNames.cend(), j) ==
 | 
				
			||||||
						SectionNames.cend()) {
 | 
					                        SectionNames.cend()) {
 | 
				
			||||||
						Errors.push_back("Unknown block name");
 | 
					                        Errors.push_back("Unknown block name");
 | 
				
			||||||
						return false;
 | 
					                        return false;
 | 
				
			||||||
					}
 | 
					                    }
 | 
				
			||||||
				}
 | 
					                }
 | 
				
			||||||
			} catch (const Poco::JSON::JSONException &E) {
 | 
					            } catch (const Poco::JSON::JSONException &E) {
 | 
				
			||||||
				Errors.push_back("Invalid JSON document");
 | 
					                Errors.push_back("Invalid JSON document");
 | 
				
			||||||
				return false;
 | 
					                return false;
 | 
				
			||||||
			}
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			try {
 | 
					            try {
 | 
				
			||||||
				if (ValidateUCentralConfiguration(i.configuration, Errors, true)) {
 | 
					                std::string Error;
 | 
				
			||||||
					// std::cout << "Block: " << i.name << " is valid" << std::endl;
 | 
					                if (ValidateUCentralConfiguration(Type,i.configuration, Error, true)) {
 | 
				
			||||||
				} else {
 | 
					                    // std::cout << "Block: " << i.name << " is valid" << std::endl;
 | 
				
			||||||
					return false;
 | 
					                } else {
 | 
				
			||||||
				}
 | 
					                    Errors.push_back(Error);
 | 
				
			||||||
			} catch (...) {
 | 
					                    return false;
 | 
				
			||||||
				Errors.push_back("Invalid configuration caused an exception");
 | 
					                }
 | 
				
			||||||
				return false;
 | 
					            } catch (...) {
 | 
				
			||||||
			}
 | 
					                Errors.push_back("Invalid configuration caused an exception");
 | 
				
			||||||
		}
 | 
					                return false;
 | 
				
			||||||
		return true;
 | 
					            }
 | 
				
			||||||
	}
 | 
					        }
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <typename Type>
 | 
						template <typename Type>
 | 
				
			||||||
	std::map<std::string, std::string> CreateObjects(Type &NewObject, RESTAPIHandler &R,
 | 
						std::map<std::string, std::string> CreateObjects(Type &NewObject, RESTAPIHandler &R,
 | 
				
			||||||
@@ -535,7 +544,7 @@ namespace OpenWifi {
 | 
				
			|||||||
						ProvObjects::DeviceConfiguration DC;
 | 
											ProvObjects::DeviceConfiguration DC;
 | 
				
			||||||
						if (DC.from_json(ConfigurationDetails)) {
 | 
											if (DC.from_json(ConfigurationDetails)) {
 | 
				
			||||||
							if constexpr (std::is_same_v<Type, ProvObjects::InventoryTag>) {
 | 
												if constexpr (std::is_same_v<Type, ProvObjects::InventoryTag>) {
 | 
				
			||||||
								if (!ValidateConfigBlock(DC, Errors)) {
 | 
													if (!ValidateConfigBlock(ConfigurationValidator::ConfigurationType::AP,DC, Errors)) {
 | 
				
			||||||
									break;
 | 
														break;
 | 
				
			||||||
								}
 | 
													}
 | 
				
			||||||
								ProvObjects::CreateObjectInfo(R.UserInfo_.userinfo, DC.info);
 | 
													ProvObjects::CreateObjectInfo(R.UserInfo_.userinfo, DC.info);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,28 +14,13 @@
 | 
				
			|||||||
#include "RESTAPI/RESTAPI_db_helpers.h"
 | 
					#include "RESTAPI/RESTAPI_db_helpers.h"
 | 
				
			||||||
#include "SerialNumberCache.h"
 | 
					#include "SerialNumberCache.h"
 | 
				
			||||||
#include "StorageService.h"
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "Tasks/VenueConfigUpdater.h"
 | 
				
			||||||
#include "framework/utils.h"
 | 
					#include "framework/utils.h"
 | 
				
			||||||
#include "sdks/SDK_gw.h"
 | 
					#include "sdks/SDK_gw.h"
 | 
				
			||||||
#include "sdks/SDK_sec.h"
 | 
					#include "sdks/SDK_sec.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void GetRejectedLines(const Poco::JSON::Object::Ptr &Response, Types::StringVec &Warnings) {
 | 
					 | 
				
			||||||
		try {
 | 
					 | 
				
			||||||
			if (Response->has("results")) {
 | 
					 | 
				
			||||||
				auto Results = Response->get("results").extract<Poco::JSON::Object::Ptr>();
 | 
					 | 
				
			||||||
				auto Status = Results->get("status").extract<Poco::JSON::Object::Ptr>();
 | 
					 | 
				
			||||||
				auto Rejected = Status->getArray("rejected");
 | 
					 | 
				
			||||||
				std::transform(
 | 
					 | 
				
			||||||
					Rejected->begin(), Rejected->end(), std::back_inserter(Warnings),
 | 
					 | 
				
			||||||
					[](auto i) -> auto { return i.toString(); });
 | 
					 | 
				
			||||||
				//                for(const auto &i:*Rejected)
 | 
					 | 
				
			||||||
				//                  Warnings.push_back(i.toString());
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} catch (...) {
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void RESTAPI_inventory_handler::DoGet() {
 | 
						void RESTAPI_inventory_handler::DoGet() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ProvObjects::InventoryTag Existing;
 | 
							ProvObjects::InventoryTag Existing;
 | 
				
			||||||
@@ -314,6 +299,8 @@ namespace OpenWifi {
 | 
				
			|||||||
			return NotFound();
 | 
								return NotFound();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							std::string previous_venue = Existing.venue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		auto RemoveSubscriber = GetParameter("removeSubscriber");
 | 
							auto RemoveSubscriber = GetParameter("removeSubscriber");
 | 
				
			||||||
		if (!RemoveSubscriber.empty()) {
 | 
							if (!RemoveSubscriber.empty()) {
 | 
				
			||||||
			if (Existing.subscriber == RemoveSubscriber) {
 | 
								if (Existing.subscriber == RemoveSubscriber) {
 | 
				
			||||||
@@ -471,6 +458,13 @@ namespace OpenWifi {
 | 
				
			|||||||
			SDK::GW::Device::SetOwnerShip(this, SerialNumber, Existing.entity, Existing.venue,
 | 
								SDK::GW::Device::SetOwnerShip(this, SerialNumber, Existing.entity, Existing.venue,
 | 
				
			||||||
										  Existing.subscriber);
 | 
															  Existing.subscriber);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Attempt an automatic config push when the venue is set and different than what is
 | 
				
			||||||
 | 
								// in DB.
 | 
				
			||||||
 | 
								poco_information(Logger(), fmt::format("New Venue {} Old Venue {}", NewObject.venue, previous_venue));
 | 
				
			||||||
 | 
								if (!NewObject.venue.empty() && NewObject.venue != previous_venue) {
 | 
				
			||||||
 | 
									ComputeAndPushConfig(SerialNumber, NewObject.deviceType, Logger());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ProvObjects::InventoryTag NewObjectCreated;
 | 
								ProvObjects::InventoryTag NewObjectCreated;
 | 
				
			||||||
			DB_.GetRecord("id", Existing.info.id, NewObjectCreated);
 | 
								DB_.GetRecord("id", Existing.info.id, NewObjectCreated);
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,7 +131,9 @@ namespace OpenWifi {
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			ProvObjects::InventoryTagVec Tags;
 | 
								ProvObjects::InventoryTagVec Tags;
 | 
				
			||||||
			DB_.GetRecords(QB_.Offset, QB_.Limit, Tags, "", OrderBy);
 | 
								DB_.GetRecords(QB_.Offset, QB_.Limit, Tags, "", OrderBy);
 | 
				
			||||||
			return MakeJSONObjectArray("taglist", Tags, *this);
 | 
					            return SendList(Tags, SerialOnly);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//			return MakeJSONObjectArray("taglist", Tags, *this);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
							
								
								
									
										125
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,125 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_openroaming_gr_acct_handler.h"
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/GlobalReach.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_acct_handler::DoGet() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType   Record;
 | 
				
			||||||
 | 
					        if(DB_.GetRecord("id",Account,Record)) {
 | 
				
			||||||
 | 
					            return ReturnObject(Record);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return NotFound();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_acct_handler::DoDelete() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType   Record;
 | 
				
			||||||
 | 
					        if(!DB_.GetRecord("id",Account,Record)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        StorageService()->GLBLRCertsDB().DeleteRecords(fmt::format(" accountId='{}' ", Account));
 | 
				
			||||||
 | 
					        DB_.DeleteRecord("id", Account);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return OK();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_acct_handler::DoPost() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto &RawObject = ParsedBody_;
 | 
				
			||||||
 | 
					        RecordType    NewObject;
 | 
				
			||||||
 | 
					        if( !NewObject.from_json(RawObject)) {
 | 
				
			||||||
 | 
					            return BadRequest(OpenWifi::RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(NewObject.privateKey.empty() || NewObject.GlobalReachAcctId.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!NewObject.privateKey.empty() && !Utils::VerifyECKey(NewObject.privateKey)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::NotAValidECKey);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::string GlobalReachName;
 | 
				
			||||||
 | 
					        if(!OpenRoaming_GlobalReach()->VerifyAccount(NewObject.GlobalReachAcctId,NewObject.privateKey,GlobalReachName)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::InvalidGlobalReachAccount);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if( NewObject.commonName.empty() || NewObject.organization.empty() ||
 | 
				
			||||||
 | 
					            NewObject.city.empty() || NewObject.province.empty() || NewObject.country.empty() ) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Utils::CSRCreationParameters    P;
 | 
				
			||||||
 | 
					        P.Country = NewObject.country;
 | 
				
			||||||
 | 
					        P.CommonName = NewObject.commonName;
 | 
				
			||||||
 | 
					        P.Province = NewObject.province;
 | 
				
			||||||
 | 
					        P.City = NewObject.city;
 | 
				
			||||||
 | 
					        P.Organization = NewObject.organization;
 | 
				
			||||||
 | 
					        Utils::CSRCreationResults       R;
 | 
				
			||||||
 | 
					        if(!Utils::CreateX509CSR(P,R)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::CannotCreateCSR);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        NewObject.CSR = R.CSR;
 | 
				
			||||||
 | 
					        NewObject.CSRPublicKey = R.PublicKey;
 | 
				
			||||||
 | 
					        NewObject.CSRPrivateKey = R.PrivateKey;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ProvObjects::CreateObjectInfo(RawObject,UserInfo_.userinfo,NewObject.info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(DB_.CreateRecord(NewObject)) {
 | 
				
			||||||
 | 
					            RecordType StoredObject;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id",NewObject.info.id,StoredObject);
 | 
				
			||||||
 | 
					            return ReturnObject(StoredObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::RecordNotCreated);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_acct_handler::DoPut() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("account","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto &RawObject = ParsedBody_;
 | 
				
			||||||
 | 
					        RecordType    Modify;
 | 
				
			||||||
 | 
					        if(!Modify.from_json(RawObject)) {
 | 
				
			||||||
 | 
					            return BadRequest(OpenWifi::RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType    Existing;
 | 
				
			||||||
 | 
					        if(!DB_.GetRecord("id",Account,Existing)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!ProvObjects::UpdateObjectInfo(RawObject,UserInfo_.userinfo,Existing.info)) {
 | 
				
			||||||
 | 
					            return BadRequest(OpenWifi::RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(DB_.UpdateRecord("id",Existing.info.id,Existing)) {
 | 
				
			||||||
 | 
					            RecordType StoredObject;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id",Existing.info.id,StoredObject);
 | 
				
			||||||
 | 
					            return ReturnObject(StoredObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::RecordNotUpdated);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										32
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_openroaming_gr_acct_handler : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_openroaming_gr_acct_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                                 RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                                 bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_DELETE,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_PUT,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_POST,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/openroaming/globalreach/account/{id}"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::GLBLRAccountInfo;
 | 
				
			||||||
 | 
					        GLBLRAccountInfoDB &DB_ = StorageService()->GLBLRAccountInfoDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final;
 | 
				
			||||||
 | 
					        void DoPut() final;
 | 
				
			||||||
 | 
					        void DoDelete() final;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
							
								
								
									
										113
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_openroaming_gr_cert_handler.h"
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/GlobalReach.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_cert_handler::DoGet() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("account","");
 | 
				
			||||||
 | 
					        auto Id = GetBinding("id","");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Account.empty() || Id.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!StorageService()->GLBLRAccountInfoDB().Exists("id",Account)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::vector<RecordType>  Certificates;
 | 
				
			||||||
 | 
					        DB_.GetRecords(0,1,Certificates,fmt::format(" accountId='{}' and id='{}' ", Account, Id));
 | 
				
			||||||
 | 
					        if(Certificates.empty()) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return ReturnObject(Certificates[0]);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_cert_handler::DoDelete() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("account","");
 | 
				
			||||||
 | 
					        auto Id = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty() || Id.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!StorageService()->GLBLRAccountInfoDB().Exists("id",Account)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        DB_.DeleteRecords(fmt::format(" accountId='{}' and id='{}' ", Account, Id));
 | 
				
			||||||
 | 
					        return OK();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_cert_handler::DoPost() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("account","");
 | 
				
			||||||
 | 
					        auto Id = GetBinding("id","");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Account.empty() || Id.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto &RawObject = ParsedBody_;
 | 
				
			||||||
 | 
					        RecordType   NewObject;
 | 
				
			||||||
 | 
					        if( !NewObject.from_json(RawObject)) {
 | 
				
			||||||
 | 
					            return BadRequest(OpenWifi::RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(NewObject.name.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ProvObjects::GLBLRAccountInfo   AccountInfo;
 | 
				
			||||||
 | 
					        if(!StorageService()->GLBLRAccountInfoDB().GetRecord("id",Account, AccountInfo)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::InvalidGlobalReachAccount);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(OpenRoaming_GlobalReach()->CreateRADSECCertificate(AccountInfo.GlobalReachAcctId,NewObject.name,AccountInfo.CSR, NewObject)) {
 | 
				
			||||||
 | 
					            NewObject.id = MicroServiceCreateUUID();
 | 
				
			||||||
 | 
					            NewObject.accountId = Account;
 | 
				
			||||||
 | 
					            NewObject.created = Utils::Now();
 | 
				
			||||||
 | 
					            NewObject.csr = AccountInfo.CSR;
 | 
				
			||||||
 | 
					            DB_.CreateRecord(NewObject);
 | 
				
			||||||
 | 
					            RecordType   CreatedObject;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id",NewObject.id,CreatedObject);
 | 
				
			||||||
 | 
					            return ReturnObject(CreatedObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::RecordNotCreated);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_cert_handler::DoPut() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("account","");
 | 
				
			||||||
 | 
					        auto Id = GetBinding("id","");
 | 
				
			||||||
 | 
					        auto UpdateCertificate = GetBoolParameter("updateCertificate",false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Account.empty() || Id.empty() || !UpdateCertificate){
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ProvObjects::GLBLRAccountInfo   AccountInfo;
 | 
				
			||||||
 | 
					        if(!StorageService()->GLBLRAccountInfoDB().GetRecord("id",Account, AccountInfo)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::InvalidGlobalReachAccount);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ProvObjects::GLBLRCertificateInfo   Existing;
 | 
				
			||||||
 | 
					        if(!DB_.GetRecord("id",Id,Existing)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(OpenRoaming_GlobalReach()->CreateRADSECCertificate(AccountInfo.GlobalReachAcctId,Existing.name,AccountInfo.CSR, Existing)) {
 | 
				
			||||||
 | 
					            Existing.created = Utils::Now();
 | 
				
			||||||
 | 
					            DB_.UpdateRecord("id",Existing.id,Existing);
 | 
				
			||||||
 | 
					            RecordType   CreatedObject;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id",Existing.id,CreatedObject);
 | 
				
			||||||
 | 
					            ProvObjects::RADIUSEndpointUpdateStatus Status;
 | 
				
			||||||
 | 
					            Status.ChangeConfiguration();
 | 
				
			||||||
 | 
					            return ReturnObject(CreatedObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::RecordNotUpdated);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										32
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_cert_handler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_openroaming_gr_cert_handler : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_openroaming_gr_cert_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                            RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                            bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_DELETE,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_POST,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_PUT,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/openroaming/globalreach/certificate/{account}/{id}"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::GLBLRCertificateInfo;
 | 
				
			||||||
 | 
					        GLBLRCertsDB &DB_ = StorageService()->GLBLRCertsDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final;
 | 
				
			||||||
 | 
					        void DoPut() final ;
 | 
				
			||||||
 | 
					        void DoDelete() final;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
							
								
								
									
										20
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_openroaming_gr_list_acct_handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_list_acct_handler::DoGet() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(GetBoolParameter("countOnly")) {
 | 
				
			||||||
 | 
					            return ReturnCountOnly(DB_.Count());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::vector<RecordType>  Accounts;
 | 
				
			||||||
 | 
					        DB_.GetRecords(QB_.Offset,QB_.Limit,Accounts);
 | 
				
			||||||
 | 
					        return ReturnObject(Accounts);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										30
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_openroaming_gr_list_acct_handler : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_openroaming_gr_list_acct_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                                 RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                                 bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/openroaming/globalreach/accounts"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::GLBLRAccountInfo;
 | 
				
			||||||
 | 
					        GLBLRAccountInfoDB &DB_ = StorageService()->GLBLRAccountInfoDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final{};
 | 
				
			||||||
 | 
					        void DoPut() final{};
 | 
				
			||||||
 | 
					        void DoDelete() final{};
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
							
								
								
									
										36
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_openroaming_gr_list_certificates.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_gr_list_certificates::DoGet() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("account");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Account=="*") {
 | 
				
			||||||
 | 
					            std::vector< ProvObjects::GLBLRCertificateInfo> Arr;
 | 
				
			||||||
 | 
					            for(const auto &cert:QB_.Select) {
 | 
				
			||||||
 | 
					                ProvObjects::GLBLRCertificateInfo CInfo;
 | 
				
			||||||
 | 
					                if(StorageService()->GLBLRCertsDB().GetRecord("id",cert,CInfo)) {
 | 
				
			||||||
 | 
					                    Arr.emplace_back(CInfo);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return ReturnObject(Arr);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        auto Where = fmt::format(" accountId='{}'", Account);
 | 
				
			||||||
 | 
					        if(GetBoolParameter("countOnly")) {
 | 
				
			||||||
 | 
					            return ReturnCountOnly(DB_.Count(Where));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::vector<RecordType>  Certificates;
 | 
				
			||||||
 | 
					        DB_.GetRecords(QB_.Offset,QB_.Limit,Certificates, Where);
 | 
				
			||||||
 | 
					        return ReturnObject(Certificates);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										30
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/RESTAPI/RESTAPI_openroaming_gr_list_certificates.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_openroaming_gr_list_certificates : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_openroaming_gr_list_certificates(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                                 RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                                 bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/openroaming/globalreach/certificates/{account}"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::GLBLRCertificateInfo;
 | 
				
			||||||
 | 
					        GLBLRCertsDB &DB_ = StorageService()->GLBLRCertsDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final{};
 | 
				
			||||||
 | 
					        void DoPut() final{};
 | 
				
			||||||
 | 
					        void DoDelete() final{};
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										99
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,99 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-15.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_openroaming_orion_acct_handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_orion_acct_handler::DoGet() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType   Record;
 | 
				
			||||||
 | 
					        if(DB_.GetRecord("id",Account,Record)) {
 | 
				
			||||||
 | 
					            return ReturnObject(Record);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return NotFound();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_orion_acct_handler::DoDelete() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType   Record;
 | 
				
			||||||
 | 
					        if(!DB_.GetRecord("id",Account,Record)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        DB_.DeleteRecord("id", Account);
 | 
				
			||||||
 | 
					        return OK();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_orion_acct_handler::DoPost() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto &RawObject = ParsedBody_;
 | 
				
			||||||
 | 
					        RecordType    NewObject;
 | 
				
			||||||
 | 
					        if( !NewObject.from_json(RawObject)) {
 | 
				
			||||||
 | 
					            return BadRequest(OpenWifi::RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if( NewObject.privateKey.empty()    ||
 | 
				
			||||||
 | 
					            NewObject.certificate.empty()   ||
 | 
				
			||||||
 | 
					            NewObject.cacerts.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if( !Utils::VerifyECKey(NewObject.privateKey)           ||
 | 
				
			||||||
 | 
					            !Utils::ValidX509Certificate(NewObject.certificate) ||
 | 
				
			||||||
 | 
					            !Utils::ValidX509Certificate(NewObject.cacerts)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::NotAValidECKey);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ProvObjects::CreateObjectInfo(RawObject,UserInfo_.userinfo,NewObject.info);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(DB_.CreateRecord(NewObject)) {
 | 
				
			||||||
 | 
					            RecordType StoredObject;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id",NewObject.info.id,StoredObject);
 | 
				
			||||||
 | 
					            return ReturnObject(StoredObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::RecordNotCreated);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_orion_acct_handler::DoPut() {
 | 
				
			||||||
 | 
					        auto Account = GetBinding("id","");
 | 
				
			||||||
 | 
					        if(Account.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto &RawObject = ParsedBody_;
 | 
				
			||||||
 | 
					        RecordType    Modify;
 | 
				
			||||||
 | 
					        if(!Modify.from_json(RawObject)) {
 | 
				
			||||||
 | 
					            return BadRequest(OpenWifi::RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType    Existing;
 | 
				
			||||||
 | 
					        if(!DB_.GetRecord("id",Account,Existing)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!ProvObjects::UpdateObjectInfo(RawObject,UserInfo_.userinfo,Existing.info)) {
 | 
				
			||||||
 | 
					            return BadRequest(OpenWifi::RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(DB_.UpdateRecord("id",Existing.info.id,Existing)) {
 | 
				
			||||||
 | 
					            RecordType StoredObject;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id",Existing.info.id,StoredObject);
 | 
				
			||||||
 | 
					            return ReturnObject(StoredObject);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::RecordNotUpdated);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										32
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-15.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_openroaming_orion_acct_handler : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_openroaming_orion_acct_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                                    RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                                    bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_DELETE,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_POST,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_PUT,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/openroaming/orion/account/{id}"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::GooglOrionAccountInfo;
 | 
				
			||||||
 | 
					        OrionAccountsDB &DB_ = StorageService()->OrionAccountsDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final;
 | 
				
			||||||
 | 
					        void DoPut() final;
 | 
				
			||||||
 | 
					        void DoDelete() final;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
							
								
								
									
										19
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-15.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_openroaming_orion_list_acct_handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_openroaming_orion_list_acct_handler::DoGet() {
 | 
				
			||||||
 | 
					        if(GetBoolParameter("countOnly")) {
 | 
				
			||||||
 | 
					            return ReturnCountOnly(DB_.Count());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        std::vector<RecordType >  Accounts;
 | 
				
			||||||
 | 
					        DB_.GetRecords(QB_.Offset,QB_.Limit,Accounts);
 | 
				
			||||||
 | 
					        return ReturnObject(Accounts);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										30
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-15.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_openroaming_orion_list_acct_handler : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_openroaming_orion_list_acct_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                                 RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                                 bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/openroaming/orion/accounts"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::GooglOrionAccountInfo;
 | 
				
			||||||
 | 
					        OrionAccountsDB &DB_ = StorageService()->OrionAccountsDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final{};
 | 
				
			||||||
 | 
					        void DoPut() final{};
 | 
				
			||||||
 | 
					        void DoDelete() final{};
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										202
									
								
								src/RESTAPI/RESTAPI_radius_endpoint_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								src/RESTAPI/RESTAPI_radius_endpoint_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,202 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-27.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_radius_endpoint_handler.h"
 | 
				
			||||||
 | 
					#include <storage/storage_orion_accounts.h>
 | 
				
			||||||
 | 
					#include <RESTObjects/RESTAPI_GWobjects.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_radius_endpoint_handler::DoGet() {
 | 
				
			||||||
 | 
					        auto id = GetBinding("id");
 | 
				
			||||||
 | 
					        if(id.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType Record;
 | 
				
			||||||
 | 
					        if(DB_.GetRecord("id",id,Record)) {
 | 
				
			||||||
 | 
					            return ReturnObject(Record);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return NotFound();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_radius_endpoint_handler::DoDelete() {
 | 
				
			||||||
 | 
					        auto id = GetBinding("id");
 | 
				
			||||||
 | 
					        if(id.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        RecordType Record;
 | 
				
			||||||
 | 
					        if(DB_.GetRecord("id",id,Record)) {
 | 
				
			||||||
 | 
					            DB_.DeleteRecord("id",id);
 | 
				
			||||||
 | 
					            ProvObjects::RADIUSEndpointUpdateStatus Status;
 | 
				
			||||||
 | 
					            Status.ChangeConfiguration();
 | 
				
			||||||
 | 
					            return OK();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return NotFound();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static bool ValidPort(std::uint32_t P) {
 | 
				
			||||||
 | 
					        return P>0 && P<65535;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static bool ValidRadiusServer(const ProvObjects::RADIUSServer &S) {
 | 
				
			||||||
 | 
					        if(S.Hostname.empty() || !ValidPort(S.Port) || !Utils::ValidIP(S.IP) || S.Secret.empty()) {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static bool ValidRadiusServer(const std::vector<ProvObjects::RADIUSServer> &ServerList) {
 | 
				
			||||||
 | 
					        return std::all_of(ServerList.begin(),ServerList.end(),[](const ProvObjects::RADIUSServer &Server)->bool { return ValidRadiusServer(Server); });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_radius_endpoint_handler::DoPost() {
 | 
				
			||||||
 | 
					        auto id = GetBinding("id");
 | 
				
			||||||
 | 
					        if(id.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto &RawObject = ParsedBody_;
 | 
				
			||||||
 | 
					        RecordType     NewRecord;
 | 
				
			||||||
 | 
					        if(!NewRecord.from_json(RawObject)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(GWObjects::RadiusEndpointType(NewRecord.Type)==GWObjects::RadiusEndpointType::unknown) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::InvalidRadiusTypeEndpoint);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if(GWObjects::RadiusPoolStrategy(NewRecord.PoolStrategy)==GWObjects::RadiusPoolStrategy::unknown) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::InvalidRadiusEndpointPoolStrategy);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if(!NewRecord.RadiusServers.empty() && !NewRecord.RadsecServers.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::EndpointMustHaveOneTypeOfServers);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        auto EndPointType = GWObjects::RadiusEndpointType(NewRecord.Type);
 | 
				
			||||||
 | 
					        switch(EndPointType) {
 | 
				
			||||||
 | 
					            case GWObjects::RadiusEndpointType::radsec:
 | 
				
			||||||
 | 
					            case GWObjects::RadiusEndpointType::orion:
 | 
				
			||||||
 | 
					            case GWObjects::RadiusEndpointType::globalreach:
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if(NewRecord.RadsecServers.empty()) {
 | 
				
			||||||
 | 
					                    return BadRequest(RESTAPI::Errors::EndpointMustHaveOneTypeOfServers);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } break;
 | 
				
			||||||
 | 
					            case GWObjects::RadiusEndpointType::generic: {
 | 
				
			||||||
 | 
					                if(NewRecord.RadiusServers.empty()) {
 | 
				
			||||||
 | 
					                    return BadRequest(RESTAPI::Errors::EndpointMustHaveOneTypeOfServers);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } break;
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                return BadRequest(RESTAPI::Errors::EndpointMustHaveOneTypeOfServers);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(NewRecord.Index.empty() || !RadiusEndpointDB::ValidIndex(NewRecord.Index)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::RadiusEndpointIndexInvalid);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //  Make sure that nobody is using that index
 | 
				
			||||||
 | 
					        auto where = fmt::format(" index='{}' ", NewRecord.Index);
 | 
				
			||||||
 | 
					        if(DB_.Count(where)!=0) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::RadiusEndpointIndexInvalid);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(EndPointType==GWObjects::RadiusEndpointType::generic) {
 | 
				
			||||||
 | 
					            for(const auto &Server:NewRecord.RadiusServers) {
 | 
				
			||||||
 | 
					                if(!ValidRadiusServer(Server.Authentication) ||
 | 
				
			||||||
 | 
					                !ValidRadiusServer(Server.Accounting) ||
 | 
				
			||||||
 | 
					                !ValidRadiusServer(Server.CoA)) {
 | 
				
			||||||
 | 
					                    return BadRequest(RESTAPI::Errors::InvalidRadiusServer);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            switch(EndPointType) {
 | 
				
			||||||
 | 
					                case GWObjects::RadiusEndpointType::orion: {
 | 
				
			||||||
 | 
					                    for(const auto &Server:NewRecord.RadsecServers) {
 | 
				
			||||||
 | 
					                        if(!StorageService()->OrionAccountsDB().Exists("id",Server.UseOpenRoamingAccount)) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::OrionAccountMustExist);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } break;
 | 
				
			||||||
 | 
					                case GWObjects::RadiusEndpointType::globalreach: {
 | 
				
			||||||
 | 
					                    for(const auto &Server:NewRecord.RadsecServers) {
 | 
				
			||||||
 | 
					                        if(!StorageService()->GLBLRCertsDB().Exists("id",Server.UseOpenRoamingAccount)) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::GlobalReachCertMustExist);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } break;
 | 
				
			||||||
 | 
					                case GWObjects::RadiusEndpointType::radsec: {
 | 
				
			||||||
 | 
					                    for(const auto &Server:NewRecord.RadsecServers) {
 | 
				
			||||||
 | 
					                        if(Server.Certificate.empty() || !Utils::ValidX509Certificate(Server.Certificate)) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::InvalidRadsecMainCertificate);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if(Server.CaCerts.empty() || !Utils::ValidX509Certificate(Server.CaCerts)) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::InvalidRadsecCaCertificate);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if(Server.PrivateKey.empty() || !Utils::VerifyPrivateKey(Server.PrivateKey)) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::InvalidRadsecPrivteKey);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if(!Utils::ValidIP(Server.IP)) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::InvalidRadsecIPAddress);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if(!(Server.Port>0 && Server.Port<65535)) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::InvalidRadsecPort);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        if(Server.Secret.empty()) {
 | 
				
			||||||
 | 
					                            return BadRequest(RESTAPI::Errors::InvalidRadsecSecret);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } break;
 | 
				
			||||||
 | 
					                default: {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ProvObjects::CreateObjectInfo(RawObject,UserInfo_.userinfo,NewRecord.info);
 | 
				
			||||||
 | 
					        if(DB_.CreateRecord(NewRecord)) {
 | 
				
			||||||
 | 
					            RecordType  AddedRecord;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id", NewRecord.info.id, AddedRecord);
 | 
				
			||||||
 | 
					            ProvObjects::RADIUSEndpointUpdateStatus Status;
 | 
				
			||||||
 | 
					            Status.ChangeConfiguration();
 | 
				
			||||||
 | 
					            return ReturnObject(AddedRecord);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::RecordNotCreated);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_radius_endpoint_handler::DoPut() {
 | 
				
			||||||
 | 
					        auto id = GetBinding("id");
 | 
				
			||||||
 | 
					        if(id.empty()) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const auto &RawObject = ParsedBody_;
 | 
				
			||||||
 | 
					        RecordType     ModifiedRecord;
 | 
				
			||||||
 | 
					        if(!ModifiedRecord.from_json(RawObject)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RecordType     Existing;
 | 
				
			||||||
 | 
					        if(!DB_.GetRecord("id",id,Existing)) {
 | 
				
			||||||
 | 
					            return NotFound();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        AssignIfPresent(RawObject,"NasIdentifier", Existing.NasIdentifier);
 | 
				
			||||||
 | 
					        AssignIfPresent(RawObject,"AccountingInterval", Existing.AccountingInterval);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ProvObjects::UpdateObjectInfo(RawObject, UserInfo_.userinfo, Existing.info);
 | 
				
			||||||
 | 
					        if(DB_.UpdateRecord("id", Existing.info.id, Existing)) {
 | 
				
			||||||
 | 
					            RecordType  AddedRecord;
 | 
				
			||||||
 | 
					            DB_.GetRecord("id", Existing.info.id, AddedRecord);
 | 
				
			||||||
 | 
					            ProvObjects::RADIUSEndpointUpdateStatus Status;
 | 
				
			||||||
 | 
					            Status.ChangeConfiguration();
 | 
				
			||||||
 | 
					            return ReturnObject(AddedRecord);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::NotImplemented);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										33
									
								
								src/RESTAPI/RESTAPI_radius_endpoint_handler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/RESTAPI/RESTAPI_radius_endpoint_handler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-27.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_radius_endpoint_handler : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_radius_endpoint_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                            RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                            bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_PUT,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_POST,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_DELETE,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/RADIUSEndPoint/{id}"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::RADIUSEndPoint;
 | 
				
			||||||
 | 
					        RadiusEndpointDB &DB_ = StorageService()->RadiusEndpointDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final;
 | 
				
			||||||
 | 
					        void DoPut() final;
 | 
				
			||||||
 | 
					        void DoDelete() final;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										49
									
								
								src/RESTAPI/RESTAPI_radiusendpoint_list_handler.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								src/RESTAPI/RESTAPI_radiusendpoint_list_handler.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-27.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RESTAPI_radiusendpoint_list_handler.h"
 | 
				
			||||||
 | 
					#include "framework/AppServiceRegistry.h"
 | 
				
			||||||
 | 
					#include "RadiusEndpointUpdater.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_radiusendpoint_list_handler::DoGet() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(GetBoolParameter("currentStatus")) {
 | 
				
			||||||
 | 
					            ProvObjects::RADIUSEndpointUpdateStatus Status;
 | 
				
			||||||
 | 
					            Status.Read();
 | 
				
			||||||
 | 
					            return ReturnObject(Status);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(QB_.CountOnly) {
 | 
				
			||||||
 | 
					            return ReturnCountOnly(DB_.Count());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::vector<RecordType>    Records;
 | 
				
			||||||
 | 
					        DB_.GetRecords(QB_.Offset,QB_.Limit,Records);
 | 
				
			||||||
 | 
					        return ReturnObject(Records);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RESTAPI_radiusendpoint_list_handler::DoPut() {
 | 
				
			||||||
 | 
					        if( UserInfo_.userinfo.userRole!=SecurityObjects::ROOT &&
 | 
				
			||||||
 | 
					            UserInfo_.userinfo.userRole!=SecurityObjects::ADMIN) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::ACCESS_DENIED);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(GetBoolParameter("updateEndpoints")) {
 | 
				
			||||||
 | 
					            RadiusEndpointUpdater R;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            std::uint64_t ErrorCode;
 | 
				
			||||||
 | 
					            std::string ErrorDetails;
 | 
				
			||||||
 | 
					            std::string ErrorDescription;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(!R.UpdateEndpoints(this, ErrorCode, ErrorDetails,ErrorDescription)) {
 | 
				
			||||||
 | 
					                return InternalError(RESTAPI::Errors::msg{.err_num = ErrorCode, .err_txt = ErrorDetails + ":" + ErrorDescription});
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return OK();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return BadRequest(RESTAPI::Errors::MissingAuthenticationInformation);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										31
									
								
								src/RESTAPI/RESTAPI_radiusendpoint_list_handler.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/RESTAPI/RESTAPI_radiusendpoint_list_handler.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-27.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "StorageService.h"
 | 
				
			||||||
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RESTAPI_radiusendpoint_list_handler : public RESTAPIHandler {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        RESTAPI_radiusendpoint_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L,
 | 
				
			||||||
 | 
					                                                 RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId,
 | 
				
			||||||
 | 
					                                                 bool Internal)
 | 
				
			||||||
 | 
					                : RESTAPIHandler(bindings, L,
 | 
				
			||||||
 | 
					                                 std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_PUT,
 | 
				
			||||||
 | 
					                                                          Poco::Net::HTTPRequest::HTTP_OPTIONS},
 | 
				
			||||||
 | 
					                                 Server, TransactionId, Internal) {}
 | 
				
			||||||
 | 
					        static auto PathName() { return std::list<std::string>{"/api/v1/RADIUSEndPoints"}; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        using RecordType = ProvObjects::RADIUSEndPoint;
 | 
				
			||||||
 | 
					        RadiusEndpointDB &DB_ = StorageService()->RadiusEndpointDB();
 | 
				
			||||||
 | 
					        void DoGet() final;
 | 
				
			||||||
 | 
					        void DoPost() final{};
 | 
				
			||||||
 | 
					        void DoPut() final;
 | 
				
			||||||
 | 
					        void DoDelete() final{};
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -35,6 +35,14 @@
 | 
				
			|||||||
#include "RESTAPI/RESTAPI_variables_list_handler.h"
 | 
					#include "RESTAPI/RESTAPI_variables_list_handler.h"
 | 
				
			||||||
#include "RESTAPI/RESTAPI_venue_handler.h"
 | 
					#include "RESTAPI/RESTAPI_venue_handler.h"
 | 
				
			||||||
#include "RESTAPI/RESTAPI_venue_list_handler.h"
 | 
					#include "RESTAPI/RESTAPI_venue_list_handler.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_openroaming_gr_acct_handler.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_openroaming_gr_list_acct_handler.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_openroaming_gr_cert_handler.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_openroaming_gr_list_certificates.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_openroaming_orion_acct_handler.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_openroaming_orion_list_acct_handler.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_radiusendpoint_list_handler.h"
 | 
				
			||||||
 | 
					#include "RESTAPI/RESTAPI_radius_endpoint_handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/RESTAPI_SystemCommand.h"
 | 
					#include "framework/RESTAPI_SystemCommand.h"
 | 
				
			||||||
#include "framework/RESTAPI_WebSocketServer.h"
 | 
					#include "framework/RESTAPI_WebSocketServer.h"
 | 
				
			||||||
@@ -60,7 +68,11 @@ namespace OpenWifi {
 | 
				
			|||||||
			RESTAPI_operators_list_handler, RESTAPI_service_class_handler,
 | 
								RESTAPI_operators_list_handler, RESTAPI_service_class_handler,
 | 
				
			||||||
			RESTAPI_service_class_list_handler, RESTAPI_op_contact_handler,
 | 
								RESTAPI_service_class_list_handler, RESTAPI_op_contact_handler,
 | 
				
			||||||
			RESTAPI_op_contact_list_handler, RESTAPI_op_location_handler,
 | 
								RESTAPI_op_contact_list_handler, RESTAPI_op_location_handler,
 | 
				
			||||||
			RESTAPI_op_location_list_handler, RESTAPI_asset_server, RESTAPI_overrides_handler>(
 | 
								RESTAPI_op_location_list_handler, RESTAPI_asset_server, RESTAPI_overrides_handler,
 | 
				
			||||||
 | 
					            RESTAPI_openroaming_gr_acct_handler, RESTAPI_openroaming_gr_list_acct_handler,
 | 
				
			||||||
 | 
					            RESTAPI_openroaming_gr_cert_handler, RESTAPI_openroaming_gr_list_certificates,
 | 
				
			||||||
 | 
					            RESTAPI_openroaming_orion_acct_handler, RESTAPI_openroaming_orion_list_acct_handler,
 | 
				
			||||||
 | 
					            RESTAPI_radiusendpoint_list_handler, RESTAPI_radius_endpoint_handler>(
 | 
				
			||||||
			Path, Bindings, L, S, TransactionId);
 | 
								Path, Bindings, L, S, TransactionId);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -82,7 +94,11 @@ namespace OpenWifi {
 | 
				
			|||||||
			RESTAPI_operators_list_handler, RESTAPI_service_class_handler,
 | 
								RESTAPI_operators_list_handler, RESTAPI_service_class_handler,
 | 
				
			||||||
			RESTAPI_service_class_list_handler, RESTAPI_op_contact_handler,
 | 
								RESTAPI_service_class_list_handler, RESTAPI_op_contact_handler,
 | 
				
			||||||
			RESTAPI_op_contact_list_handler, RESTAPI_op_location_handler,
 | 
								RESTAPI_op_contact_list_handler, RESTAPI_op_location_handler,
 | 
				
			||||||
			RESTAPI_op_location_list_handler, RESTAPI_overrides_handler>(Path, Bindings, L, S,
 | 
								RESTAPI_op_location_list_handler, RESTAPI_overrides_handler,
 | 
				
			||||||
																		 TransactionId);
 | 
					            RESTAPI_openroaming_gr_acct_handler, RESTAPI_openroaming_gr_list_acct_handler,
 | 
				
			||||||
 | 
					            RESTAPI_openroaming_gr_cert_handler, RESTAPI_openroaming_gr_list_certificates,
 | 
				
			||||||
 | 
					            RESTAPI_openroaming_orion_acct_handler, RESTAPI_openroaming_orion_list_acct_handler,
 | 
				
			||||||
 | 
					            RESTAPI_radiusendpoint_list_handler, RESTAPI_radius_endpoint_handler>(
 | 
				
			||||||
 | 
					                    Path, Bindings, L, S,TransactionId);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -90,9 +90,9 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!Existing.contacts.empty()) {
 | 
							if (!Existing.contacts.empty()) {
 | 
				
			||||||
			for (const auto &i : Existing.contacts)
 | 
								for (const auto &contact_uuid : Existing.contacts)
 | 
				
			||||||
				StorageService()->ContactDB().DeleteInUse(
 | 
									StorageService()->ContactDB().DeleteInUse(
 | 
				
			||||||
					"id", i, StorageService()->VenueDB().Prefix(), UUID);
 | 
										"id", contact_uuid, StorageService()->VenueDB().Prefix(), UUID);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!Existing.location.empty())
 | 
							if (!Existing.location.empty())
 | 
				
			||||||
			StorageService()->LocationDB().DeleteInUse("id", Existing.location,
 | 
								StorageService()->LocationDB().DeleteInUse("id", Existing.location,
 | 
				
			||||||
@@ -101,9 +101,9 @@ namespace OpenWifi {
 | 
				
			|||||||
			StorageService()->PolicyDB().DeleteInUse("id", Existing.managementPolicy,
 | 
								StorageService()->PolicyDB().DeleteInUse("id", Existing.managementPolicy,
 | 
				
			||||||
													 StorageService()->VenueDB().Prefix(), UUID);
 | 
																		 StorageService()->VenueDB().Prefix(), UUID);
 | 
				
			||||||
		if (!Existing.deviceConfiguration.empty()) {
 | 
							if (!Existing.deviceConfiguration.empty()) {
 | 
				
			||||||
			for (auto &i : Existing.deviceConfiguration)
 | 
								for (auto &configuration_uuid : Existing.deviceConfiguration)
 | 
				
			||||||
				StorageService()->ConfigurationDB().DeleteInUse(
 | 
									StorageService()->ConfigurationDB().DeleteInUse(
 | 
				
			||||||
					"id", i, StorageService()->VenueDB().Prefix(), UUID);
 | 
										"id", configuration_uuid, StorageService()->VenueDB().Prefix(), UUID);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (!Existing.parent.empty())
 | 
							if (!Existing.parent.empty())
 | 
				
			||||||
			StorageService()->VenueDB().DeleteChild("id", Existing.parent, UUID);
 | 
								StorageService()->VenueDB().DeleteChild("id", Existing.parent, UUID);
 | 
				
			||||||
@@ -157,6 +157,10 @@ namespace OpenWifi {
 | 
				
			|||||||
			return BadRequest(RESTAPI::Errors::EntityMustExist);
 | 
								return BadRequest(RESTAPI::Errors::EntityMustExist);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(StorageService()->VenueDB().DoesVenueNameAlreadyExist(NewObject.info.name,NewObject.entity, NewObject.parent)) {
 | 
				
			||||||
 | 
					            return BadRequest(RESTAPI::Errors::VenuesNameAlreadyExists);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!NewObject.contacts.empty()) {
 | 
							if (!NewObject.contacts.empty()) {
 | 
				
			||||||
			for (const auto &i : NewObject.contacts) {
 | 
								for (const auto &i : NewObject.contacts) {
 | 
				
			||||||
				if (!StorageService()->ContactDB().Exists("id", i)) {
 | 
									if (!StorageService()->ContactDB().Exists("id", i)) {
 | 
				
			||||||
@@ -183,7 +187,7 @@ namespace OpenWifi {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!NewObject.sourceIP.empty() && CIDR::ValidateIpRanges(NewObject.sourceIP)) {
 | 
							if (!NewObject.sourceIP.empty() && !CIDR::ValidateIpRanges(NewObject.sourceIP)) {
 | 
				
			||||||
			return BadRequest(RESTAPI::Errors::InvalidIPRanges);
 | 
								return BadRequest(RESTAPI::Errors::InvalidIPRanges);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -272,21 +276,19 @@ namespace OpenWifi {
 | 
				
			|||||||
		auto testUpdateOnly = GetBoolParameter("testUpdateOnly");
 | 
							auto testUpdateOnly = GetBoolParameter("testUpdateOnly");
 | 
				
			||||||
		if (testUpdateOnly) {
 | 
							if (testUpdateOnly) {
 | 
				
			||||||
			ProvObjects::SerialNumberList SNL;
 | 
								ProvObjects::SerialNumberList SNL;
 | 
				
			||||||
 | 
					            StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
			SNL.serialNumbers = Existing.devices;
 | 
					 | 
				
			||||||
			SNL.to_json(Answer);
 | 
								SNL.to_json(Answer);
 | 
				
			||||||
			return ReturnObject(Answer);
 | 
								return ReturnObject(Answer);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (GetBoolParameter("updateAllDevices")) {
 | 
							if (GetBoolParameter("updateAllDevices")) {
 | 
				
			||||||
			ProvObjects::SerialNumberList SNL;
 | 
								ProvObjects::SerialNumberList SNL;
 | 
				
			||||||
 | 
					            StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
			SNL.serialNumbers = Existing.devices;
 | 
					 | 
				
			||||||
			auto JobId = MicroServiceCreateUUID();
 | 
								auto JobId = MicroServiceCreateUUID();
 | 
				
			||||||
			Types::StringVec Parameters{UUID};
 | 
								Types::StringVec Parameters{UUID};
 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
			auto NewJob = new VenueConfigUpdater(JobId, "VenueConfigurationUpdater", Parameters, 0,
 | 
								auto NewJob = new VenueConfigUpdater(JobId, "VenueConfigurationUpdater", Parameters, 0,
 | 
				
			||||||
												 UserInfo_.userinfo, Logger());
 | 
																	 UserInfo_.userinfo, Logger());
 | 
				
			||||||
			JobController()->AddJob(dynamic_cast<Job *>(NewJob));
 | 
								JobController()->AddJob(dynamic_cast<Job *>(NewJob));
 | 
				
			||||||
@@ -298,11 +300,10 @@ namespace OpenWifi {
 | 
				
			|||||||
		if (GetBoolParameter("upgradeAllDevices")) {
 | 
							if (GetBoolParameter("upgradeAllDevices")) {
 | 
				
			||||||
			if (GetBoolParameter("revisionsAvailable")) {
 | 
								if (GetBoolParameter("revisionsAvailable")) {
 | 
				
			||||||
				std::set<std::string> DeviceTypes;
 | 
									std::set<std::string> DeviceTypes;
 | 
				
			||||||
				for (const auto &serialNumber : Existing.devices) {
 | 
					                std::vector<ProvObjects::InventoryTag> ExistingDevices;
 | 
				
			||||||
					ProvObjects::InventoryTag Device;
 | 
					                StorageService()->InventoryDB().GetDevicesForVenue(UUID, ExistingDevices);
 | 
				
			||||||
					if (StorageService()->InventoryDB().GetRecord("id", serialNumber, Device)) {
 | 
									for (const auto &device : ExistingDevices) {
 | 
				
			||||||
						DeviceTypes.insert(Device.deviceType);
 | 
					                    DeviceTypes.insert(device.deviceType);
 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				//  Get all the revisions for all the device types
 | 
									//  Get all the revisions for all the device types
 | 
				
			||||||
@@ -370,18 +371,17 @@ namespace OpenWifi {
 | 
				
			|||||||
				return ReturnObject(Answer);
 | 
									return ReturnObject(Answer);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ProvObjects::SerialNumberList SNL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			auto Revision = GetParameter("revision", "");
 | 
								auto Revision = GetParameter("revision", "");
 | 
				
			||||||
			if (Revision.empty()) {
 | 
								if (Revision.empty()) {
 | 
				
			||||||
				return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
									return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ProvObjects::SerialNumberList SNL;
 | 
				
			||||||
 | 
					            StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
			SNL.serialNumbers = Existing.devices;
 | 
					 | 
				
			||||||
			auto JobId = MicroServiceCreateUUID();
 | 
								auto JobId = MicroServiceCreateUUID();
 | 
				
			||||||
			Types::StringVec Parameters{UUID, Revision};
 | 
								Types::StringVec Parameters{UUID, Revision};
 | 
				
			||||||
			;
 | 
					 | 
				
			||||||
			auto NewJob = new VenueUpgrade(JobId, "VenueFirmwareUpgrade", Parameters, 0,
 | 
								auto NewJob = new VenueUpgrade(JobId, "VenueFirmwareUpgrade", Parameters, 0,
 | 
				
			||||||
										   UserInfo_.userinfo, Logger());
 | 
															   UserInfo_.userinfo, Logger());
 | 
				
			||||||
			JobController()->AddJob(dynamic_cast<Job *>(NewJob));
 | 
								JobController()->AddJob(dynamic_cast<Job *>(NewJob));
 | 
				
			||||||
@@ -392,9 +392,9 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if (GetBoolParameter("rebootAllDevices")) {
 | 
							if (GetBoolParameter("rebootAllDevices")) {
 | 
				
			||||||
			ProvObjects::SerialNumberList SNL;
 | 
								ProvObjects::SerialNumberList SNL;
 | 
				
			||||||
 | 
					            StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
			SNL.serialNumbers = Existing.devices;
 | 
					 | 
				
			||||||
			auto JobId = MicroServiceCreateUUID();
 | 
								auto JobId = MicroServiceCreateUUID();
 | 
				
			||||||
			Types::StringVec Parameters{UUID};
 | 
								Types::StringVec Parameters{UUID};
 | 
				
			||||||
			;
 | 
								;
 | 
				
			||||||
@@ -432,7 +432,7 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		std::string MoveFromEntity, MoveToEntity;
 | 
							std::string MoveFromEntity, MoveToEntity;
 | 
				
			||||||
		if (AssignIfPresent(RawObject, "entity", MoveToEntity)) {
 | 
							if (AssignIfPresent(RawObject, "entity", MoveToEntity)) {
 | 
				
			||||||
			if (!MoveToEntity.empty() && !StorageService()->EntityDB().Exists("id", MoveToEntity)) {
 | 
								if (MoveToEntity.empty() || !StorageService()->EntityDB().Exists("id", MoveToEntity)) {
 | 
				
			||||||
				return BadRequest(RESTAPI::Errors::EntityMustExist);
 | 
									return BadRequest(RESTAPI::Errors::EntityMustExist);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			MoveFromEntity = Existing.entity;
 | 
								MoveFromEntity = Existing.entity;
 | 
				
			||||||
@@ -441,7 +441,7 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		std::string MoveToVenue, MoveFromVenue;
 | 
							std::string MoveToVenue, MoveFromVenue;
 | 
				
			||||||
		if (AssignIfPresent(RawObject, "venue", MoveToVenue)) {
 | 
							if (AssignIfPresent(RawObject, "venue", MoveToVenue)) {
 | 
				
			||||||
			if (!MoveToVenue.empty() && !StorageService()->VenueDB().Exists("id", MoveToVenue)) {
 | 
								if (MoveToVenue.empty() || !StorageService()->VenueDB().Exists("id", MoveToVenue)) {
 | 
				
			||||||
				return BadRequest(RESTAPI::Errors::VenueMustExist);
 | 
									return BadRequest(RESTAPI::Errors::VenueMustExist);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			MoveFromVenue = Existing.parent;
 | 
								MoveFromVenue = Existing.parent;
 | 
				
			||||||
@@ -450,7 +450,7 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		std::string MoveFromLocation, MoveToLocation;
 | 
							std::string MoveFromLocation, MoveToLocation;
 | 
				
			||||||
		if (AssignIfPresent(RawObject, "location", MoveToLocation)) {
 | 
							if (AssignIfPresent(RawObject, "location", MoveToLocation)) {
 | 
				
			||||||
			if (!MoveToLocation.empty() &&
 | 
								if (MoveToLocation.empty() ||
 | 
				
			||||||
				!StorageService()->LocationDB().Exists("id", MoveToLocation)) {
 | 
									!StorageService()->LocationDB().Exists("id", MoveToLocation)) {
 | 
				
			||||||
				return BadRequest(RESTAPI::Errors::LocationMustExist);
 | 
									return BadRequest(RESTAPI::Errors::LocationMustExist);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -460,8 +460,8 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		Types::UUIDvec_t MoveFromContacts, MoveToContacts;
 | 
							Types::UUIDvec_t MoveFromContacts, MoveToContacts;
 | 
				
			||||||
		if (AssignIfPresent(RawObject, "contacts", MoveToContacts)) {
 | 
							if (AssignIfPresent(RawObject, "contacts", MoveToContacts)) {
 | 
				
			||||||
			for (const auto &i : NewObject.contacts) {
 | 
								for (const auto &contact : NewObject.contacts) {
 | 
				
			||||||
				if (!StorageService()->ContactDB().Exists("id", i)) {
 | 
									if (!StorageService()->ContactDB().Exists("id", contact)) {
 | 
				
			||||||
					return BadRequest(RESTAPI::Errors::ContactMustExist);
 | 
										return BadRequest(RESTAPI::Errors::ContactMustExist);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -471,7 +471,7 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		std::string MoveFromPolicy, MoveToPolicy;
 | 
							std::string MoveFromPolicy, MoveToPolicy;
 | 
				
			||||||
		if (AssignIfPresent(RawObject, "managementPolicy", MoveToPolicy)) {
 | 
							if (AssignIfPresent(RawObject, "managementPolicy", MoveToPolicy)) {
 | 
				
			||||||
			if (!MoveToPolicy.empty() && !StorageService()->PolicyDB().Exists("id", MoveToPolicy)) {
 | 
								if (MoveToPolicy.empty() || !StorageService()->PolicyDB().Exists("id", MoveToPolicy)) {
 | 
				
			||||||
				return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
 | 
									return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			MoveFromPolicy = Existing.managementPolicy;
 | 
								MoveFromPolicy = Existing.managementPolicy;
 | 
				
			||||||
@@ -481,8 +481,8 @@ namespace OpenWifi {
 | 
				
			|||||||
		Types::UUIDvec_t MoveToConfigurations, MoveFromConfigurations;
 | 
							Types::UUIDvec_t MoveToConfigurations, MoveFromConfigurations;
 | 
				
			||||||
		if (RawObject->has("deviceConfiguration")) {
 | 
							if (RawObject->has("deviceConfiguration")) {
 | 
				
			||||||
			MoveToConfigurations = NewObject.deviceConfiguration;
 | 
								MoveToConfigurations = NewObject.deviceConfiguration;
 | 
				
			||||||
			for (auto &i : MoveToConfigurations) {
 | 
								for (auto &configuration : MoveToConfigurations) {
 | 
				
			||||||
				if (!StorageService()->ConfigurationDB().Exists("id", i)) {
 | 
									if (!StorageService()->ConfigurationDB().Exists("id", configuration)) {
 | 
				
			||||||
					return BadRequest(RESTAPI::Errors::ConfigurationMustExist);
 | 
										return BadRequest(RESTAPI::Errors::ConfigurationMustExist);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@
 | 
				
			|||||||
#ifdef TIP_GATEWAY_SERVICE
 | 
					#ifdef TIP_GATEWAY_SERVICE
 | 
				
			||||||
#include "AP_WS_Server.h"
 | 
					#include "AP_WS_Server.h"
 | 
				
			||||||
#include "CapabilitiesCache.h"
 | 
					#include "CapabilitiesCache.h"
 | 
				
			||||||
 | 
					#include "RADIUSSessionTracker.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "RESTAPI_GWobjects.h"
 | 
					#include "RESTAPI_GWobjects.h"
 | 
				
			||||||
@@ -29,6 +30,7 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		field_to_json(Obj, "serialNumber", SerialNumber);
 | 
							field_to_json(Obj, "serialNumber", SerialNumber);
 | 
				
			||||||
#ifdef TIP_GATEWAY_SERVICE
 | 
					#ifdef TIP_GATEWAY_SERVICE
 | 
				
			||||||
		field_to_json(Obj, "deviceType", CapabilitiesCache::instance()->GetPlatform(Compatible));
 | 
							field_to_json(Obj, "deviceType", CapabilitiesCache::instance()->GetPlatform(Compatible));
 | 
				
			||||||
 | 
							field_to_json(Obj, "hasRADIUSSessions", RADIUSSessionTracker()->HasSessions(SerialNumber));
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		field_to_json(Obj, "macAddress", MACAddress);
 | 
							field_to_json(Obj, "macAddress", MACAddress);
 | 
				
			||||||
		field_to_json(Obj, "manufacturer", Manufacturer);
 | 
							field_to_json(Obj, "manufacturer", Manufacturer);
 | 
				
			||||||
@@ -54,6 +56,9 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		field_to_json(Obj, "pendingConfiguration", pendingConfiguration);
 | 
							field_to_json(Obj, "pendingConfiguration", pendingConfiguration);
 | 
				
			||||||
		field_to_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
 | 
							field_to_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
 | 
				
			||||||
		field_to_json(Obj, "restrictionDetails", restrictionDetails);
 | 
							field_to_json(Obj, "restrictionDetails", restrictionDetails);
 | 
				
			||||||
 | 
							field_to_json(Obj, "pendingUUID", pendingUUID);
 | 
				
			||||||
 | 
							field_to_json(Obj, "simulated", simulated);
 | 
				
			||||||
 | 
							field_to_json(Obj, "lastRecordedContact", lastRecordedContact);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
 | 
						void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
@@ -63,7 +68,7 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		ConnectionState ConState;
 | 
							ConnectionState ConState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
 | 
							if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
 | 
				
			||||||
			ConState.to_json(Obj);
 | 
								ConState.to_json(SerialNumber,Obj);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			field_to_json(Obj, "ipAddress", "");
 | 
								field_to_json(Obj, "ipAddress", "");
 | 
				
			||||||
			field_to_json(Obj, "txBytes", (uint64_t)0);
 | 
								field_to_json(Obj, "txBytes", (uint64_t)0);
 | 
				
			||||||
@@ -75,6 +80,13 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
			field_to_json(Obj, "associations_2G", (uint64_t)0);
 | 
								field_to_json(Obj, "associations_2G", (uint64_t)0);
 | 
				
			||||||
			field_to_json(Obj, "associations_5G", (uint64_t)0);
 | 
								field_to_json(Obj, "associations_5G", (uint64_t)0);
 | 
				
			||||||
			field_to_json(Obj, "associations_6G", (uint64_t)0);
 | 
								field_to_json(Obj, "associations_6G", (uint64_t)0);
 | 
				
			||||||
 | 
								field_to_json(Obj, "hasRADIUSSessions", false);
 | 
				
			||||||
 | 
								field_to_json(Obj, "hasGPS", ConState.hasGPS);
 | 
				
			||||||
 | 
								field_to_json(Obj, "sanity", ConState.sanity);
 | 
				
			||||||
 | 
								field_to_json(Obj, "memoryUsed", ConState.memoryUsed);
 | 
				
			||||||
 | 
								field_to_json(Obj, "sanity", ConState.sanity);
 | 
				
			||||||
 | 
								field_to_json(Obj, "load", ConState.load);
 | 
				
			||||||
 | 
								field_to_json(Obj, "temperature", ConState.temperature);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -84,20 +96,32 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
			field_from_json(Obj, "serialNumber", SerialNumber);
 | 
								field_from_json(Obj, "serialNumber", SerialNumber);
 | 
				
			||||||
			field_from_json(Obj, "deviceType", DeviceType);
 | 
								field_from_json(Obj, "deviceType", DeviceType);
 | 
				
			||||||
			field_from_json(Obj, "macAddress", MACAddress);
 | 
								field_from_json(Obj, "macAddress", MACAddress);
 | 
				
			||||||
 | 
								field_from_json(Obj, "manufacturer", Manufacturer);
 | 
				
			||||||
 | 
								field_from_json(Obj, "UUID", UUID);
 | 
				
			||||||
			field_from_json(Obj, "configuration", Configuration);
 | 
								field_from_json(Obj, "configuration", Configuration);
 | 
				
			||||||
			field_from_json(Obj, "notes", Notes);
 | 
								field_from_json(Obj, "notes", Notes);
 | 
				
			||||||
			field_from_json(Obj, "manufacturer", Manufacturer);
 | 
								field_from_json(Obj, "createdTimestamp", CreationTimestamp);
 | 
				
			||||||
 | 
								field_from_json(Obj, "lastConfigurationChange", LastConfigurationChange);
 | 
				
			||||||
 | 
								field_from_json(Obj, "lastConfigurationDownload", LastConfigurationDownload);
 | 
				
			||||||
 | 
								field_from_json(Obj, "lastFWUpdate", LastFWUpdate);
 | 
				
			||||||
			field_from_json(Obj, "owner", Owner);
 | 
								field_from_json(Obj, "owner", Owner);
 | 
				
			||||||
			field_from_json(Obj, "location", Location);
 | 
								field_from_json(Obj, "location", Location);
 | 
				
			||||||
			field_from_json(Obj, "venue", Venue);
 | 
								field_from_json(Obj, "venue", Venue);
 | 
				
			||||||
 | 
								field_from_json(Obj, "firmware", Firmware);
 | 
				
			||||||
			field_from_json(Obj, "compatible", Compatible);
 | 
								field_from_json(Obj, "compatible", Compatible);
 | 
				
			||||||
 | 
								field_from_json(Obj, "fwUpdatePolicy", FWUpdatePolicy);
 | 
				
			||||||
 | 
								field_from_json(Obj, "devicePassword", DevicePassword);
 | 
				
			||||||
			field_from_json(Obj, "subscriber", subscriber);
 | 
								field_from_json(Obj, "subscriber", subscriber);
 | 
				
			||||||
			field_from_json(Obj, "entity", entity);
 | 
								field_from_json(Obj, "entity", entity);
 | 
				
			||||||
 | 
								field_from_json(Obj, "modified", modified);
 | 
				
			||||||
			field_from_json(Obj, "locale", locale);
 | 
								field_from_json(Obj, "locale", locale);
 | 
				
			||||||
			field_from_json(Obj, "restrictedDevice", restrictedDevice);
 | 
								field_from_json(Obj, "restrictedDevice", restrictedDevice);
 | 
				
			||||||
			field_from_json(Obj, "pendingConfiguration", pendingConfiguration);
 | 
								field_from_json(Obj, "pendingConfiguration", pendingConfiguration);
 | 
				
			||||||
			field_from_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
 | 
								field_from_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
 | 
				
			||||||
			field_from_json(Obj, "restrictionDetails", restrictionDetails);
 | 
								field_from_json(Obj, "restrictionDetails", restrictionDetails);
 | 
				
			||||||
 | 
								field_from_json(Obj, "pendingUUID", pendingUUID);
 | 
				
			||||||
 | 
								field_from_json(Obj, "simulated", simulated);
 | 
				
			||||||
 | 
								field_from_json(Obj, "lastRecordedContact", lastRecordedContact);
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		} catch (const Poco::Exception &E) {
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -147,6 +171,31 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		field_to_json(Obj, "lastModified", LastModified);
 | 
							field_to_json(Obj, "lastModified", LastModified);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void DefaultFirmware::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
							field_to_json(Obj, "deviceType", deviceType);
 | 
				
			||||||
 | 
							field_to_json(Obj, "description", Description);
 | 
				
			||||||
 | 
							field_to_json(Obj, "uri", uri);
 | 
				
			||||||
 | 
							field_to_json(Obj, "revision", revision);
 | 
				
			||||||
 | 
							field_to_json(Obj, "imageCreationDate", imageCreationDate);
 | 
				
			||||||
 | 
							field_to_json(Obj, "created", Created);
 | 
				
			||||||
 | 
							field_to_json(Obj, "lastModified", LastModified);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool DefaultFirmware::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								field_from_json(Obj, "deviceType", deviceType);
 | 
				
			||||||
 | 
								field_from_json(Obj, "description", Description);
 | 
				
			||||||
 | 
								field_from_json(Obj, "uri", uri);
 | 
				
			||||||
 | 
								field_from_json(Obj, "revision", revision);
 | 
				
			||||||
 | 
								field_from_json(Obj, "imageCreationDate", imageCreationDate);
 | 
				
			||||||
 | 
								field_from_json(Obj, "created", Created);
 | 
				
			||||||
 | 
								field_from_json(Obj, "lastModified", LastModified);
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void CommandDetails::to_json(Poco::JSON::Object &Obj) const {
 | 
						void CommandDetails::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
		EmbedDocument("details", Obj, Details);
 | 
							EmbedDocument("details", Obj, Details);
 | 
				
			||||||
		EmbedDocument("results", Obj, Results);
 | 
							EmbedDocument("results", Obj, Results);
 | 
				
			||||||
@@ -165,6 +214,8 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		field_to_json(Obj, "waitingForFile", WaitingForFile);
 | 
							field_to_json(Obj, "waitingForFile", WaitingForFile);
 | 
				
			||||||
		field_to_json(Obj, "attachFile", AttachDate);
 | 
							field_to_json(Obj, "attachFile", AttachDate);
 | 
				
			||||||
		field_to_json(Obj, "executionTime", executionTime);
 | 
							field_to_json(Obj, "executionTime", executionTime);
 | 
				
			||||||
 | 
							field_to_json(Obj, "lastTry", lastTry);
 | 
				
			||||||
 | 
							field_to_json(Obj, "deferred", deferred);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool DefaultConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
						bool DefaultConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
@@ -198,7 +249,7 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void ConnectionState::to_json(Poco::JSON::Object &Obj) const {
 | 
						void ConnectionState::to_json([[maybe_unused]] const std::string &SerialNumber, Poco::JSON::Object &Obj)  {
 | 
				
			||||||
		field_to_json(Obj, "ipAddress", Address);
 | 
							field_to_json(Obj, "ipAddress", Address);
 | 
				
			||||||
		field_to_json(Obj, "txBytes", TX);
 | 
							field_to_json(Obj, "txBytes", TX);
 | 
				
			||||||
		field_to_json(Obj, "rxBytes", RX);
 | 
							field_to_json(Obj, "rxBytes", RX);
 | 
				
			||||||
@@ -220,6 +271,22 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		field_to_json(Obj, "connectionCompletionTime", connectionCompletionTime);
 | 
							field_to_json(Obj, "connectionCompletionTime", connectionCompletionTime);
 | 
				
			||||||
		field_to_json(Obj, "totalConnectionTime", Utils::Now() - started);
 | 
							field_to_json(Obj, "totalConnectionTime", Utils::Now() - started);
 | 
				
			||||||
		field_to_json(Obj, "certificateExpiryDate", certificateExpiryDate);
 | 
							field_to_json(Obj, "certificateExpiryDate", certificateExpiryDate);
 | 
				
			||||||
 | 
							field_to_json(Obj, "connectReason", connectReason);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef TIP_GATEWAY_SERVICE
 | 
				
			||||||
 | 
							hasRADIUSSessions = RADIUSSessionTracker()->HasSessions(SerialNumber);
 | 
				
			||||||
 | 
							AP_WS_Server()->ExtendedAttributes(SerialNumber, hasGPS, sanity,
 | 
				
			||||||
 | 
															   memoryUsed,
 | 
				
			||||||
 | 
															   load,
 | 
				
			||||||
 | 
															   temperature);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
							field_to_json(Obj, "hasRADIUSSessions", hasRADIUSSessions );
 | 
				
			||||||
 | 
							field_to_json(Obj, "hasGPS", hasGPS);
 | 
				
			||||||
 | 
							field_to_json(Obj, "sanity", sanity);
 | 
				
			||||||
 | 
							field_to_json(Obj, "memoryUsed", memoryUsed);
 | 
				
			||||||
 | 
							field_to_json(Obj, "sanity", sanity);
 | 
				
			||||||
 | 
							field_to_json(Obj, "load", load);
 | 
				
			||||||
 | 
							field_to_json(Obj, "temperature", temperature);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		switch (VerifiedCertificate) {
 | 
							switch (VerifiedCertificate) {
 | 
				
			||||||
		case NO_CERTIFICATE:
 | 
							case NO_CERTIFICATE:
 | 
				
			||||||
@@ -234,6 +301,9 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		case VERIFIED:
 | 
							case VERIFIED:
 | 
				
			||||||
			field_to_json(Obj, "verifiedCertificate", "VERIFIED");
 | 
								field_to_json(Obj, "verifiedCertificate", "VERIFIED");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
							case SIMULATED:
 | 
				
			||||||
 | 
								field_to_json(Obj, "verifiedCertificate", "SIMULATED");
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			field_to_json(Obj, "verifiedCertificate", "NO_CERTIFICATE");
 | 
								field_to_json(Obj, "verifiedCertificate", "NO_CERTIFICATE");
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
@@ -360,6 +430,10 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		field_to_json(Obj, "acctConfig", acctConfig);
 | 
							field_to_json(Obj, "acctConfig", acctConfig);
 | 
				
			||||||
		field_to_json(Obj, "coaConfig", coaConfig);
 | 
							field_to_json(Obj, "coaConfig", coaConfig);
 | 
				
			||||||
		field_to_json(Obj, "useByDefault", useByDefault);
 | 
							field_to_json(Obj, "useByDefault", useByDefault);
 | 
				
			||||||
 | 
							field_to_json(Obj, "radsecKeepAlive", radsecKeepAlive);
 | 
				
			||||||
 | 
							field_to_json(Obj, "poolProxyIp", poolProxyIp);
 | 
				
			||||||
 | 
							field_to_json(Obj, "radsecPoolType", radsecPoolType);
 | 
				
			||||||
 | 
							field_to_json(Obj, "enabled", enabled);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
						bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
@@ -370,6 +444,10 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
			field_from_json(Obj, "acctConfig", acctConfig);
 | 
								field_from_json(Obj, "acctConfig", acctConfig);
 | 
				
			||||||
			field_from_json(Obj, "coaConfig", coaConfig);
 | 
								field_from_json(Obj, "coaConfig", coaConfig);
 | 
				
			||||||
			field_from_json(Obj, "useByDefault", useByDefault);
 | 
								field_from_json(Obj, "useByDefault", useByDefault);
 | 
				
			||||||
 | 
								field_from_json(Obj, "radsecKeepAlive", radsecKeepAlive);
 | 
				
			||||||
 | 
								field_from_json(Obj, "poolProxyIp", poolProxyIp);
 | 
				
			||||||
 | 
								field_from_json(Obj, "radsecPoolType", radsecPoolType);
 | 
				
			||||||
 | 
								field_from_json(Obj, "enabled", enabled);
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		} catch (const Poco::Exception &E) {
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -490,6 +568,29 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void RangeOptions::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
							field_to_json(Obj, "NO_IR", NO_IR);
 | 
				
			||||||
 | 
							field_to_json(Obj, "AUTO_BW", AUTO_BW);
 | 
				
			||||||
 | 
							field_to_json(Obj, "DFS", DFS);
 | 
				
			||||||
 | 
							field_to_json(Obj, "NO_OUTDOOR", NO_OUTDOOR);
 | 
				
			||||||
 | 
							field_to_json(Obj, "wmmrule_ETSI", wmmrule_ETSI);
 | 
				
			||||||
 | 
							field_to_json(Obj, "NO_OFDM", NO_OFDM);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void FrequencyRange::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
							field_to_json(Obj, "from", from);
 | 
				
			||||||
 | 
							field_to_json(Obj, "to", to);
 | 
				
			||||||
 | 
							field_to_json(Obj, "channelWidth", channelWidth);
 | 
				
			||||||
 | 
							field_to_json(Obj, "powerDb", powerDb);
 | 
				
			||||||
 | 
							field_to_json(Obj, "options", options);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void RegulatoryCountryInfo::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
							field_to_json(Obj, "country", country);
 | 
				
			||||||
 | 
							field_to_json(Obj, "domain", domain);
 | 
				
			||||||
 | 
							field_to_json(Obj, "ranges", ranges);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void DeviceRestrictionsKeyInfo::to_json(Poco::JSON::Object &Obj) const {
 | 
						void DeviceRestrictionsKeyInfo::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
		field_to_json(Obj, "vendor", vendor);
 | 
							field_to_json(Obj, "vendor", vendor);
 | 
				
			||||||
		field_to_json(Obj, "algo", algo);
 | 
							field_to_json(Obj, "algo", algo);
 | 
				
			||||||
@@ -544,4 +645,74 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
				(T.commands != commands) || (T.developer != developer) || (T.ssh != ssh) ||
 | 
									(T.commands != commands) || (T.developer != developer) || (T.ssh != ssh) ||
 | 
				
			||||||
				(T.key_info != key_info) || (T.country != country));
 | 
									(T.key_info != key_info) || (T.country != country));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void RADIUSSession::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
							field_to_json(Obj, "started", started);
 | 
				
			||||||
 | 
							field_to_json(Obj, "lastTransaction", lastTransaction);
 | 
				
			||||||
 | 
							field_to_json(Obj, "destination", destination);
 | 
				
			||||||
 | 
							field_to_json(Obj, "serialNumber", serialNumber);
 | 
				
			||||||
 | 
							field_to_json(Obj, "userName", userName);
 | 
				
			||||||
 | 
							field_to_json(Obj, "accountingSessionId", accountingSessionId);
 | 
				
			||||||
 | 
							field_to_json(Obj, "accountingMultiSessionId", accountingMultiSessionId);
 | 
				
			||||||
 | 
							field_to_json(Obj, "inputPackets", inputPackets);
 | 
				
			||||||
 | 
							field_to_json(Obj, "outputPackets", outputPackets);
 | 
				
			||||||
 | 
							field_to_json(Obj, "inputOctets", inputOctets);
 | 
				
			||||||
 | 
							field_to_json(Obj, "outputOctets", outputOctets);
 | 
				
			||||||
 | 
							field_to_json(Obj, "inputGigaWords", inputGigaWords);
 | 
				
			||||||
 | 
							field_to_json(Obj, "outputGigaWords", outputGigaWords);
 | 
				
			||||||
 | 
							field_to_json(Obj, "sessionTime", sessionTime);
 | 
				
			||||||
 | 
							field_to_json(Obj, "callingStationId", callingStationId);
 | 
				
			||||||
 | 
							field_to_json(Obj, "chargeableUserIdentity", chargeableUserIdentity);
 | 
				
			||||||
 | 
							field_to_json(Obj, "interface", interface);
 | 
				
			||||||
 | 
							field_to_json(Obj, "secret", secret);
 | 
				
			||||||
 | 
							field_to_json(Obj, "nasId", nasId);
 | 
				
			||||||
 | 
							field_to_json(Obj, "calledStationId", calledStationId);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void RADIUSSessionList::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
							field_to_json(Obj, "sessions", sessions);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void RadiusCoADMParameters::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
							field_to_json(Obj, "accountingSessionId", accountingSessionId);
 | 
				
			||||||
 | 
							field_to_json(Obj, "accountingMultiSessionId", accountingMultiSessionId);
 | 
				
			||||||
 | 
							field_to_json(Obj, "callingStationId", callingStationId);
 | 
				
			||||||
 | 
							field_to_json(Obj, "chargeableUserIdentity", chargeableUserIdentity);
 | 
				
			||||||
 | 
							field_to_json(Obj, "userName", userName);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool RadiusCoADMParameters::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								field_from_json(Obj, "accountingSessionId", accountingSessionId);
 | 
				
			||||||
 | 
								field_from_json(Obj, "accountingMultiSessionId", accountingMultiSessionId);
 | 
				
			||||||
 | 
								field_from_json(Obj, "callingStationId", callingStationId);
 | 
				
			||||||
 | 
								field_from_json(Obj, "chargeableUserIdentity", chargeableUserIdentity);
 | 
				
			||||||
 | 
								field_from_json(Obj, "userName", userName);
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool DeviceTransferRequest::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								field_from_json(Obj, "serialNumber", serialNumber);
 | 
				
			||||||
 | 
								field_from_json(Obj, "server", server);
 | 
				
			||||||
 | 
								field_from_json(Obj, "port", port);
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool DeviceCertificateUpdateRequest::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								field_from_json(Obj, "serialNumber", serialNumber);
 | 
				
			||||||
 | 
								field_from_json(Obj, "encodedCertificate", encodedCertificate);
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi::GWObjects
 | 
					} // namespace OpenWifi::GWObjects
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,9 +11,13 @@
 | 
				
			|||||||
#include "Poco/JSON/Object.h"
 | 
					#include "Poco/JSON/Object.h"
 | 
				
			||||||
#include "RESTAPI_SecurityObjects.h"
 | 
					#include "RESTAPI_SecurityObjects.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef TIP_GATEWAY_SERVICE
 | 
				
			||||||
 | 
					#include <RADIUS_helpers.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi::GWObjects {
 | 
					namespace OpenWifi::GWObjects {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	enum CertificateValidation { NO_CERTIFICATE, VALID_CERTIFICATE, MISMATCH_SERIAL, VERIFIED };
 | 
						enum CertificateValidation { NO_CERTIFICATE, VALID_CERTIFICATE, MISMATCH_SERIAL, VERIFIED, SIMULATED };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct ConnectionState {
 | 
						struct ConnectionState {
 | 
				
			||||||
		uint64_t MessageCount = 0;
 | 
							uint64_t MessageCount = 0;
 | 
				
			||||||
@@ -38,8 +42,15 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		uint64_t sessionId = 0;
 | 
							uint64_t sessionId = 0;
 | 
				
			||||||
		double connectionCompletionTime = 0.0;
 | 
							double connectionCompletionTime = 0.0;
 | 
				
			||||||
		std::uint64_t certificateExpiryDate = 0;
 | 
							std::uint64_t certificateExpiryDate = 0;
 | 
				
			||||||
 | 
							std::uint64_t hasRADIUSSessions = 0;
 | 
				
			||||||
 | 
							bool hasGPS = false;
 | 
				
			||||||
 | 
							std::uint64_t sanity=0;
 | 
				
			||||||
 | 
							std::double_t memoryUsed=0.0;
 | 
				
			||||||
 | 
							std::double_t load=0.0;
 | 
				
			||||||
 | 
							std::double_t temperature=0.0;
 | 
				
			||||||
 | 
							std::string 	connectReason;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void to_json(Poco::JSON::Object &Obj) const;
 | 
							void to_json(const std::string &SerialNumber, Poco::JSON::Object &Obj) ;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct DeviceRestrictionsKeyInfo {
 | 
						struct DeviceRestrictionsKeyInfo {
 | 
				
			||||||
@@ -96,6 +107,9 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		std::string pendingConfiguration;
 | 
							std::string pendingConfiguration;
 | 
				
			||||||
		std::string pendingConfigurationCmd;
 | 
							std::string pendingConfigurationCmd;
 | 
				
			||||||
		DeviceRestrictions restrictionDetails;
 | 
							DeviceRestrictions restrictionDetails;
 | 
				
			||||||
 | 
							std::uint64_t pendingUUID = 0;
 | 
				
			||||||
 | 
							bool simulated=false;
 | 
				
			||||||
 | 
							std::uint64_t lastRecordedContact=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void to_json(Poco::JSON::Object &Obj) const;
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
		void to_json_with_status(Poco::JSON::Object &Obj) const;
 | 
							void to_json_with_status(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
@@ -168,6 +182,26 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct DefaultFirmware {
 | 
				
			||||||
 | 
							std::string deviceType;
 | 
				
			||||||
 | 
							std::string Description;
 | 
				
			||||||
 | 
							std::string uri;
 | 
				
			||||||
 | 
							std::string revision;
 | 
				
			||||||
 | 
							uint64_t imageCreationDate;
 | 
				
			||||||
 | 
							uint64_t Created;
 | 
				
			||||||
 | 
							uint64_t LastModified;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct DefaultFirmwareList {
 | 
				
			||||||
 | 
							std::vector<DefaultFirmware>	firmwares;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct CommandDetails {
 | 
						struct CommandDetails {
 | 
				
			||||||
		std::string UUID;
 | 
							std::string UUID;
 | 
				
			||||||
		std::string SerialNumber;
 | 
							std::string SerialNumber;
 | 
				
			||||||
@@ -188,7 +222,11 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		uint64_t AttachSize = 0;
 | 
							uint64_t AttachSize = 0;
 | 
				
			||||||
		std::string AttachType;
 | 
							std::string AttachType;
 | 
				
			||||||
		double executionTime = 0.0;
 | 
							double executionTime = 0.0;
 | 
				
			||||||
 | 
							std::uint64_t lastTry = 0;
 | 
				
			||||||
 | 
							bool deferred = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void to_json(Poco::JSON::Object &Obj) const;
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct BlackListedDevice {
 | 
						struct BlackListedDevice {
 | 
				
			||||||
@@ -322,6 +360,10 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		RadiusProxyServerConfig acctConfig;
 | 
							RadiusProxyServerConfig acctConfig;
 | 
				
			||||||
		RadiusProxyServerConfig coaConfig;
 | 
							RadiusProxyServerConfig coaConfig;
 | 
				
			||||||
		bool useByDefault = false;
 | 
							bool useByDefault = false;
 | 
				
			||||||
 | 
							std::string 	radsecPoolType;
 | 
				
			||||||
 | 
							std::string 	poolProxyIp;
 | 
				
			||||||
 | 
							std::uint64_t 	radsecKeepAlive=25;
 | 
				
			||||||
 | 
							bool			enabled=true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void to_json(Poco::JSON::Object &Obj) const;
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
		bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
@@ -334,4 +376,139 @@ namespace OpenWifi::GWObjects {
 | 
				
			|||||||
		bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct RangeOptions {
 | 
				
			||||||
 | 
							bool NO_IR=false;
 | 
				
			||||||
 | 
							bool AUTO_BW=false;
 | 
				
			||||||
 | 
							bool DFS=false;
 | 
				
			||||||
 | 
							bool NO_OUTDOOR=false;
 | 
				
			||||||
 | 
							bool wmmrule_ETSI=false;
 | 
				
			||||||
 | 
							bool NO_OFDM=false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct FrequencyRange {
 | 
				
			||||||
 | 
							float from = 0.0;
 | 
				
			||||||
 | 
							float to = 0.0;
 | 
				
			||||||
 | 
							int channelWidth = 0;
 | 
				
			||||||
 | 
							int powerDb = 0;
 | 
				
			||||||
 | 
							RangeOptions    options;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct RegulatoryCountryInfo {
 | 
				
			||||||
 | 
							std::string country;
 | 
				
			||||||
 | 
							std::string domain;
 | 
				
			||||||
 | 
							std::vector<FrequencyRange>   ranges;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						using RegulatoryInfoCountryMap = std::map<std::string,RegulatoryCountryInfo>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct RADIUSSession {
 | 
				
			||||||
 | 
							std::uint64_t 			started=0,
 | 
				
			||||||
 | 
													lastTransaction=0;
 | 
				
			||||||
 | 
							std::string 			serialNumber,
 | 
				
			||||||
 | 
													destination,
 | 
				
			||||||
 | 
													userName,
 | 
				
			||||||
 | 
										 			accountingSessionId,
 | 
				
			||||||
 | 
													accountingMultiSessionId,
 | 
				
			||||||
 | 
										 			callingStationId,
 | 
				
			||||||
 | 
													chargeableUserIdentity,
 | 
				
			||||||
 | 
													secret,
 | 
				
			||||||
 | 
													interface,
 | 
				
			||||||
 | 
													nasId;
 | 
				
			||||||
 | 
							std::uint64_t 			inputPackets = 0,
 | 
				
			||||||
 | 
													outputPackets = 0,
 | 
				
			||||||
 | 
													inputOctets = 0,
 | 
				
			||||||
 | 
													outputOctets = 0,
 | 
				
			||||||
 | 
													inputGigaWords = 0,
 | 
				
			||||||
 | 
													outputGigaWords = 0;
 | 
				
			||||||
 | 
							std::uint32_t 			sessionTime = 0;
 | 
				
			||||||
 | 
							std::string 			calledStationId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef TIP_GATEWAY_SERVICE
 | 
				
			||||||
 | 
							RADIUS::RadiusPacket	accountingPacket;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct RADIUSSessionList {
 | 
				
			||||||
 | 
							std::vector<RADIUSSession>	sessions;
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct RadiusCoADMParameters {
 | 
				
			||||||
 | 
							std::string 			accountingSessionId,
 | 
				
			||||||
 | 
													accountingMultiSessionId,
 | 
				
			||||||
 | 
													callingStationId,
 | 
				
			||||||
 | 
													chargeableUserIdentity,
 | 
				
			||||||
 | 
													userName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						enum class RadiusPoolStrategy {
 | 
				
			||||||
 | 
							round_robin, random, weighted, unknown
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						enum class RadiusEndpointType {
 | 
				
			||||||
 | 
							generic, radsec, globalreach, orion, unknown
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static inline RadiusEndpointType RadiusEndpointType(const std::string &T) {
 | 
				
			||||||
 | 
							if(T=="generic") return RadiusEndpointType::generic;
 | 
				
			||||||
 | 
							if(T=="radsec") return RadiusEndpointType::radsec;
 | 
				
			||||||
 | 
							if(T=="globalreach") return RadiusEndpointType::globalreach;
 | 
				
			||||||
 | 
							if(T=="orion") return RadiusEndpointType::orion;
 | 
				
			||||||
 | 
							return RadiusEndpointType::unknown;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static inline RadiusPoolStrategy RadiusPoolStrategy(const std::string &T) {
 | 
				
			||||||
 | 
							if(T=="round_robin") return RadiusPoolStrategy::round_robin;
 | 
				
			||||||
 | 
							if(T=="random") return RadiusPoolStrategy::random;
 | 
				
			||||||
 | 
							if(T=="weighted") return RadiusPoolStrategy::weighted;
 | 
				
			||||||
 | 
							return RadiusPoolStrategy::unknown;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static inline std::string to_string(enum RadiusEndpointType T) {
 | 
				
			||||||
 | 
							switch(T) {
 | 
				
			||||||
 | 
							case RadiusEndpointType::generic: return "generic";
 | 
				
			||||||
 | 
							case RadiusEndpointType::radsec: return "radsec";
 | 
				
			||||||
 | 
							case RadiusEndpointType::globalreach: return "globalreach";
 | 
				
			||||||
 | 
							case RadiusEndpointType::orion: return "orion";
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								return "unknown";
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static inline std::string to_string(enum RadiusPoolStrategy T) {
 | 
				
			||||||
 | 
							switch(T) {
 | 
				
			||||||
 | 
							case RadiusPoolStrategy::round_robin: return "round_robin";
 | 
				
			||||||
 | 
							case RadiusPoolStrategy::random: return "random";
 | 
				
			||||||
 | 
							case RadiusPoolStrategy::weighted: return "weighted";
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								return "unknown";
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct DeviceTransferRequest {
 | 
				
			||||||
 | 
							std::string 	serialNumber;
 | 
				
			||||||
 | 
							std::string 	server;
 | 
				
			||||||
 | 
							std::uint64_t 	port;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct DeviceCertificateUpdateRequest {
 | 
				
			||||||
 | 
							std::string 	serialNumber;
 | 
				
			||||||
 | 
							std::string 	encodedCertificate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi::GWObjects
 | 
					} // namespace OpenWifi::GWObjects
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -78,21 +78,22 @@ namespace OpenWifi::OWLSObjects {
 | 
				
			|||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void SimulationStatus::to_json(Poco::JSON::Object &Obj) const {
 | 
					    void SimulationStatus::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
		field_to_json(Obj, "id", id);
 | 
					        field_to_json(Obj, "id", id);
 | 
				
			||||||
		field_to_json(Obj, "simulationId", simulationId);
 | 
					        field_to_json(Obj, "simulationId", simulationId);
 | 
				
			||||||
		field_to_json(Obj, "state", state);
 | 
					        field_to_json(Obj, "state", state);
 | 
				
			||||||
		field_to_json(Obj, "tx", tx);
 | 
					        field_to_json(Obj, "tx", tx);
 | 
				
			||||||
		field_to_json(Obj, "rx", rx);
 | 
					        field_to_json(Obj, "rx", rx);
 | 
				
			||||||
		field_to_json(Obj, "msgsTx", msgsTx);
 | 
					        field_to_json(Obj, "msgsTx", msgsTx);
 | 
				
			||||||
		field_to_json(Obj, "msgsRx", msgsRx);
 | 
					        field_to_json(Obj, "msgsRx", msgsRx);
 | 
				
			||||||
		field_to_json(Obj, "liveDevices", liveDevices);
 | 
					        field_to_json(Obj, "liveDevices", liveDevices);
 | 
				
			||||||
		field_to_json(Obj, "timeToFullDevices", timeToFullDevices);
 | 
					        field_to_json(Obj, "timeToFullDevices", timeToFullDevices);
 | 
				
			||||||
		field_to_json(Obj, "startTime", startTime);
 | 
					        field_to_json(Obj, "startTime", startTime);
 | 
				
			||||||
		field_to_json(Obj, "endTime", endTime);
 | 
					        field_to_json(Obj, "endTime", endTime);
 | 
				
			||||||
		field_to_json(Obj, "errorDevices", errorDevices);
 | 
					        field_to_json(Obj, "errorDevices", errorDevices);
 | 
				
			||||||
		field_to_json(Obj, "owner", owner);
 | 
					        field_to_json(Obj, "owner", owner);
 | 
				
			||||||
	}
 | 
					        field_to_json(Obj, "expectedDevices", expectedDevices);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void Dashboard::to_json([[maybe_unused]] Poco::JSON::Object &Obj) const {}
 | 
						void Dashboard::to_json([[maybe_unused]] Poco::JSON::Object &Obj) const {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,23 +43,24 @@ namespace OpenWifi::OWLSObjects {
 | 
				
			|||||||
		bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
							bool from_json(const Poco::JSON::Object::Ptr &Obj);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct SimulationStatus {
 | 
					    struct SimulationStatus {
 | 
				
			||||||
		std::string id;
 | 
					        std::string id;
 | 
				
			||||||
		std::string simulationId;
 | 
					        std::string simulationId;
 | 
				
			||||||
		std::string state;
 | 
					        std::string state;
 | 
				
			||||||
		uint64_t tx;
 | 
					        uint64_t tx;
 | 
				
			||||||
		uint64_t rx;
 | 
					        uint64_t rx;
 | 
				
			||||||
		uint64_t msgsTx;
 | 
					        uint64_t msgsTx;
 | 
				
			||||||
		uint64_t msgsRx;
 | 
					        uint64_t msgsRx;
 | 
				
			||||||
		uint64_t liveDevices;
 | 
					        uint64_t liveDevices;
 | 
				
			||||||
		uint64_t timeToFullDevices;
 | 
					        uint64_t timeToFullDevices;
 | 
				
			||||||
		uint64_t startTime;
 | 
					        uint64_t startTime;
 | 
				
			||||||
		uint64_t endTime;
 | 
					        uint64_t endTime;
 | 
				
			||||||
		uint64_t errorDevices;
 | 
					        uint64_t errorDevices;
 | 
				
			||||||
		std::string owner;
 | 
					        std::string owner;
 | 
				
			||||||
 | 
					        uint64_t expectedDevices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void to_json(Poco::JSON::Object &Obj) const;
 | 
					        void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
	};
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct Dashboard {
 | 
						struct Dashboard {
 | 
				
			||||||
		int O;
 | 
							int O;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -587,6 +587,9 @@ namespace OpenWifi::ProvObjects {
 | 
				
			|||||||
		field_to_json(Obj, "locale", locale);
 | 
							field_to_json(Obj, "locale", locale);
 | 
				
			||||||
		field_to_json(Obj, "realMacAddress", realMacAddress);
 | 
							field_to_json(Obj, "realMacAddress", realMacAddress);
 | 
				
			||||||
		field_to_json(Obj, "doNotAllowOverrides", doNotAllowOverrides);
 | 
							field_to_json(Obj, "doNotAllowOverrides", doNotAllowOverrides);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "imported", imported);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "connected", connected);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "platform", platform);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
						bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
@@ -609,6 +612,9 @@ namespace OpenWifi::ProvObjects {
 | 
				
			|||||||
			field_from_json(Obj, "locale", locale);
 | 
								field_from_json(Obj, "locale", locale);
 | 
				
			||||||
			field_from_json(Obj, "realMacAddress", realMacAddress);
 | 
								field_from_json(Obj, "realMacAddress", realMacAddress);
 | 
				
			||||||
			field_from_json(Obj, "doNotAllowOverrides", doNotAllowOverrides);
 | 
								field_from_json(Obj, "doNotAllowOverrides", doNotAllowOverrides);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "imported", imported);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "connected", connected);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "platform", platform);
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		} catch (...) {
 | 
							} catch (...) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -1194,4 +1200,243 @@ namespace OpenWifi::ProvObjects {
 | 
				
			|||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void GLBLRAccountInfo::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        info.to_json(Obj);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "privateKey", privateKey);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "country", country);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "province", province);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "city", city);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "organization", organization);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "commonName", commonName);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "CSR", CSR);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "CSRPrivateKey", CSRPrivateKey);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "CSRPublicKey", CSRPublicKey);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "GlobalReachAcctId", GlobalReachAcctId);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool GLBLRAccountInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            info.from_json(Obj);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "privateKey", privateKey);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "country", country);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "province", province);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "city", city);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "organization", organization);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "commonName", commonName);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "CSR", CSR);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "CSRPrivateKey", CSRPrivateKey);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "CSRPublicKey", CSRPublicKey);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "GlobalReachAcctId", GlobalReachAcctId);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void GLBLRCertificateInfo::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        field_to_json(Obj, "id", id);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "name", name);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "accountId", accountId);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "csr", csr);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "certificate", certificate);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "certificateChain", certificateChain);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "certificateId", certificateId);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "expiresAt", expiresAt);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "created", created);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool GLBLRCertificateInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            field_from_json(Obj, "id", id);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "name", name);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "accountId", accountId);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "csr", csr);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "certificate", certificate);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "certificateChain", certificateChain);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "certificateId", certificateId);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "expiresAt", expiresAt);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "created", created);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void GooglOrionAccountInfo::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        info.to_json(Obj);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "privateKey", privateKey);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "certificate", certificate);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "cacerts", cacerts);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool GooglOrionAccountInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            info.from_json(Obj);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "privateKey", privateKey);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "certificate", certificate);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "cacerts", cacerts);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RADIUSServer::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Hostname", Hostname);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "IP", IP);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Port", Port);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Secret", Secret);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSServer::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Hostname", Hostname);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "IP", IP);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Port", Port);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Secret", Secret);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RADIUSEndPointRadiusType::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Authentication", Authentication);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Accounting", Accounting);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "CoA", CoA);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "AccountingInterval", AccountingInterval);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSEndPointRadiusType::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Authentication", Authentication);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Accounting", Accounting);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "CoA", CoA);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "AccountingInterval", AccountingInterval);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RADIUSEndPointRadsecType::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Hostname", Hostname);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "IP", IP);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Port", Port);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Secret", Secret);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "OpenRoamingType", OpenRoamingType);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "UseOpenRoamingAccount", UseOpenRoamingAccount);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Weight", Weight);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Certificate", Certificate);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "PrivateKey", PrivateKey);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "CaCerts", CaCerts);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "AllowSelfSigned", AllowSelfSigned);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSEndPointRadsecType::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Hostname", Hostname);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "IP", IP);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Port", Port);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Secret", Secret);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "OpenRoamingType", OpenRoamingType);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "UseOpenRoamingAccount", UseOpenRoamingAccount);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Weight", Weight);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Certificate", Certificate);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "PrivateKey", PrivateKey);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "CaCerts", CaCerts);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "AllowSelfSigned", AllowSelfSigned);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RADIUSEndPoint::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        info.to_json(Obj);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Type", Type);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "RadsecServers", RadsecServers);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "RadiusServers", RadiusServers);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "PoolStrategy", PoolStrategy);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "Index", Index);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "UsedBy", UsedBy);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "UseGWProxy", UseGWProxy);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "NasIdentifier", NasIdentifier);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "AccountingInterval", AccountingInterval);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSEndPoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            info.from_json(Obj);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Type", Type);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "RadsecServers", RadsecServers);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "RadiusServers", RadiusServers);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "PoolStrategy", PoolStrategy);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "Index", Index);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "UsedBy", UsedBy);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "UseGWProxy", UseGWProxy);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "NasIdentifier", NasIdentifier);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "AccountingInterval", AccountingInterval);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void RADIUSEndpointUpdateStatus::to_json(Poco::JSON::Object &Obj) const {
 | 
				
			||||||
 | 
					        field_to_json(Obj, "lastUpdate", lastUpdate);
 | 
				
			||||||
 | 
					        field_to_json(Obj, "lastConfigurationChange", lastConfigurationChange);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSEndpointUpdateStatus::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            field_from_json(Obj, "lastUpdate", lastUpdate);
 | 
				
			||||||
 | 
					            field_from_json(Obj, "lastConfigurationChange", lastConfigurationChange);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSEndpointUpdateStatus::Read() {
 | 
				
			||||||
 | 
					        Poco::File  F(OpenWifi::MicroServiceDataDirectory()+"/RADIUSEndpointUpdateStatus.json");
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            if (F.exists()) {
 | 
				
			||||||
 | 
					                Poco::JSON::Parser P;
 | 
				
			||||||
 | 
					                std::ifstream ifs(F.path(), std::ios_base::in | std::ios_base::binary);
 | 
				
			||||||
 | 
					                auto Obj = P.parse(ifs);
 | 
				
			||||||
 | 
					                return from_json(Obj.extract<Poco::JSON::Object::Ptr>());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (...) {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSEndpointUpdateStatus::Save() {
 | 
				
			||||||
 | 
					        Poco::File  F(OpenWifi::MicroServiceDataDirectory()+"/RADIUSEndpointUpdateStatus.json");
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            Poco::JSON::Object Obj;
 | 
				
			||||||
 | 
					            to_json(Obj);
 | 
				
			||||||
 | 
					            std::ofstream O(F.path(), std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);
 | 
				
			||||||
 | 
					            Poco::JSON::Stringifier::stringify(Obj, O);
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } catch (...) {
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool RADIUSEndpointUpdateStatus::ChangeConfiguration() {
 | 
				
			||||||
 | 
					        Read();
 | 
				
			||||||
 | 
					        lastConfigurationChange = Utils::Now();
 | 
				
			||||||
 | 
					        return Save();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi::ProvObjects
 | 
					} // namespace OpenWifi::ProvObjects
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										8
									
								
								src/RadiusEndpointTypes/GenericRadius.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/RadiusEndpointTypes/GenericRadius.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-10-18.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "GenericRadius.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										67
									
								
								src/RadiusEndpointTypes/GenericRadius.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/RadiusEndpointTypes/GenericRadius.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-10-18.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <Poco/Net/IPAddress.h>
 | 
				
			||||||
 | 
					#include <Poco/Net/SocketAddress.h>
 | 
				
			||||||
 | 
					#include <framework/utils.h>
 | 
				
			||||||
 | 
					#include <framework/SubSystemServer.h>
 | 
				
			||||||
 | 
					#include <RESTObjects/RESTAPI_ProvObjects.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    namespace GenericRadius {
 | 
				
			||||||
 | 
					        class OpenRoaming : public SubSystemServer {
 | 
				
			||||||
 | 
					        public:
 | 
				
			||||||
 | 
					            static auto instance() {
 | 
				
			||||||
 | 
					                static auto instance_ = new OpenRoaming;
 | 
				
			||||||
 | 
					                return instance_;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline int Start() override {
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline void Stop() override {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline bool Render(const OpenWifi::ProvObjects::RADIUSEndPoint &RE, const std::string &SerialNumber,
 | 
				
			||||||
 | 
					                               Poco::JSON::Object &Result) {
 | 
				
			||||||
 | 
					                if (RE.UseGWProxy) {
 | 
				
			||||||
 | 
					                    Poco::JSON::Object Auth, Acct, CoA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Auth.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    Auth.set("port", RE.RadiusServers[0].Authentication[0].Port);
 | 
				
			||||||
 | 
					                    Auth.set("secret", RE.RadiusServers[0].Authentication[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Acct.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    Acct.set("port", RE.RadiusServers[0].Accounting[0].Port);
 | 
				
			||||||
 | 
					                    Acct.set("secret", RE.RadiusServers[0].Accounting[0].Secret);
 | 
				
			||||||
 | 
					                    Acct.set("interval", RE.AccountingInterval);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    CoA.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    CoA.set("port", RE.RadiusServers[0].CoA[0].Port);
 | 
				
			||||||
 | 
					                    CoA.set("secret", RE.RadiusServers[0].CoA[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Result.set("nas-identifier", RE.NasIdentifier.empty() ? SerialNumber : RE.NasIdentifier);
 | 
				
			||||||
 | 
					                    Result.set("authentication", Auth);
 | 
				
			||||||
 | 
					                    Result.set("accounting", Acct);
 | 
				
			||||||
 | 
					                    Result.set("dynamic-authorization", CoA);
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private:
 | 
				
			||||||
 | 
					            OpenRoaming() noexcept
 | 
				
			||||||
 | 
					                    : SubSystemServer("OpenRoaming_GenericRadius", "GENRAD", "genrad") {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    inline auto OpenRoaming_GenericRadius() { return GenericRadius::OpenRoaming::instance(); }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										258
									
								
								src/RadiusEndpointTypes/GlobalReach.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										258
									
								
								src/RadiusEndpointTypes/GlobalReach.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,258 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "GlobalReach.h"
 | 
				
			||||||
 | 
					#include <Poco/JWT/Token.h>
 | 
				
			||||||
 | 
					#include <Poco/JWT/Signer.h>
 | 
				
			||||||
 | 
					#include <Poco/Net/HTTPSClientSession.h>
 | 
				
			||||||
 | 
					#include <Poco/Net/DNS.h>
 | 
				
			||||||
 | 
					#include <Poco/URI.h>
 | 
				
			||||||
 | 
					#include <Poco/TemporaryFile.h>
 | 
				
			||||||
 | 
					#include <Poco/JSON/Object.h>
 | 
				
			||||||
 | 
					#include <Poco/JSON/Parser.h>
 | 
				
			||||||
 | 
					#include <framework/RESTAPI_Handler.h>
 | 
				
			||||||
 | 
					#include <framework/MicroServiceFuncs.h>
 | 
				
			||||||
 | 
					#include <StorageService.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    namespace GlobalReach {
 | 
				
			||||||
 | 
					        int OpenRoaming::Start() {
 | 
				
			||||||
 | 
					            poco_information(Logger(), "Starting...");
 | 
				
			||||||
 | 
					            InitCache();
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void OpenRoaming::Stop() {
 | 
				
			||||||
 | 
					            poco_information(Logger(), "Stopping...");
 | 
				
			||||||
 | 
					            poco_information(Logger(), "Stopped...");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void OpenRoaming::InitCache() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            auto F = [&](const ProvObjects::GLBLRAccountInfo &Info) {
 | 
				
			||||||
 | 
					                poco_information(Logger(), fmt::format("Adding {} to cache.", Info.info.name));
 | 
				
			||||||
 | 
					                if (!Info.privateKey.empty() && !Info.GlobalReachAcctId.empty()) {
 | 
				
			||||||
 | 
					                    MakeToken(Info.GlobalReachAcctId, Info.privateKey);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            StorageService()->GLBLRAccountInfoDB().Iterate(F);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool OpenRoaming::Render(const OpenWifi::ProvObjects::RADIUSEndPoint &RE, const std::string &SerialNumber, Poco::JSON::Object &Result) {
 | 
				
			||||||
 | 
					            if(RE.UseGWProxy) {
 | 
				
			||||||
 | 
					                Poco::JSON::Object  Auth, Acct, CoA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Auth.set("host", RE.Index);
 | 
				
			||||||
 | 
					                Auth.set("port", 1812 );
 | 
				
			||||||
 | 
					                Auth.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Acct.set("host", RE.Index);
 | 
				
			||||||
 | 
					                Acct.set("port", 1813);
 | 
				
			||||||
 | 
					                Acct.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					                Acct.set("interval", RE.AccountingInterval);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                CoA.set("host", RE.Index);
 | 
				
			||||||
 | 
					                CoA.set("port", 3799);
 | 
				
			||||||
 | 
					                CoA.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Result.set("nas-identifier", RE.NasIdentifier.empty() ? SerialNumber : RE.NasIdentifier );
 | 
				
			||||||
 | 
					                Result.set("authentication", Auth);
 | 
				
			||||||
 | 
					                Result.set("accounting", Acct);
 | 
				
			||||||
 | 
					                Result.set("dynamic-authorization", CoA);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool OpenRoaming::CreateRADSECCertificate(
 | 
				
			||||||
 | 
					            const std::string &GlobalReachAccountId,
 | 
				
			||||||
 | 
					            const std::string &Name,
 | 
				
			||||||
 | 
					            const std::string &CSR,
 | 
				
			||||||
 | 
					            ProvObjects::GLBLRCertificateInfo &NewCertificate) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                auto BearerToken = MakeToken(GlobalReachAccountId);
 | 
				
			||||||
 | 
					                Poco::URI URI{"https://config.openro.am/v1/radsec/issue"};
 | 
				
			||||||
 | 
					                std::string Path(URI.getPathAndQuery());
 | 
				
			||||||
 | 
					                Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_POST, Path,
 | 
				
			||||||
 | 
					                                               Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
 | 
					                Request.add("Authorization", "Bearer " + BearerToken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
 | 
					                Session.setTimeout(Poco::Timespan(10000, 10000));
 | 
				
			||||||
 | 
					                Poco::JSON::Object CertRequestBody;
 | 
				
			||||||
 | 
					                CertRequestBody.set("name", Name);
 | 
				
			||||||
 | 
					                CertRequestBody.set("csr", CSR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                std::ostringstream os;
 | 
				
			||||||
 | 
					                CertRequestBody.stringify(os);
 | 
				
			||||||
 | 
					                Request.setContentType("application/json");
 | 
				
			||||||
 | 
					                Request.setContentLength((long) os.str().size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                auto &Body = Session.sendRequest(Request);
 | 
				
			||||||
 | 
					                Body << os.str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
					                std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
 | 
					                if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
					                    Poco::JSON::Parser P;
 | 
				
			||||||
 | 
					                    auto Result = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "certificate", NewCertificate.certificate);
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "certificate_chain", NewCertificate.certificateChain);
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "certificate_id", NewCertificate.certificateId);
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "expires_at", NewCertificate.expiresAt);
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                Poco::JSON::Parser P;
 | 
				
			||||||
 | 
					                std::ostringstream oos;
 | 
				
			||||||
 | 
					                auto Result = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
					                Result->stringify(oos);
 | 
				
			||||||
 | 
					            } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					                poco_error(Logger(),
 | 
				
			||||||
 | 
					                           fmt::format("Could not create a new RADSEC certificate: {},{}", E.name(), E.displayText()));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool OpenRoaming::GetRADSECCertificate(
 | 
				
			||||||
 | 
					                const std::string &GlobalReachAccountId,
 | 
				
			||||||
 | 
					                std::string &CertificateId,
 | 
				
			||||||
 | 
					                ProvObjects::GLBLRCertificateInfo &NewCertificate) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                Poco::URI URI{fmt::format("https://config.openro.am/v1/radsec/cert/{}", CertificateId)};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                std::string Path(URI.getPathAndQuery());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_GET, Path,
 | 
				
			||||||
 | 
					                                               Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                auto BearerToken = MakeToken(GlobalReachAccountId);
 | 
				
			||||||
 | 
					                Request.add("Authorization", "Bearer " + BearerToken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
 | 
					                Session.setTimeout(Poco::Timespan(10000, 10000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Session.sendRequest(Request);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
					                std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
 | 
					                if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
					                    Poco::JSON::Parser P;
 | 
				
			||||||
 | 
					                    auto Result = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "certificate", NewCertificate.certificate);
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "certificate_chain", NewCertificate.certificateChain);
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "certificate_id", NewCertificate.certificateId);
 | 
				
			||||||
 | 
					                    RESTAPIHandler::AssignIfPresent(Result, "expires_at", NewCertificate.expiresAt);
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					                poco_error(Logger(), fmt::format("Could not retrieve the certificate from GlobalReach: {},{}", E.name(),
 | 
				
			||||||
 | 
					                                                 E.displayText()));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::string
 | 
				
			||||||
 | 
					        OpenRoaming::MakeToken(const std::string &GlobalReachAccountId, const std::string &PrivateKey) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                Poco::JWT::Token token;
 | 
				
			||||||
 | 
					                token.setType("JWT");
 | 
				
			||||||
 | 
					                token.setAlgorithm("ES256");
 | 
				
			||||||
 | 
					                token.setIssuedAt(std::time(nullptr));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                token.payload().set("iss", GlobalReachAccountId);
 | 
				
			||||||
 | 
					                token.payload().set("iat", (unsigned long) std::time(nullptr));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Poco::SharedPtr<Poco::Crypto::ECKey> Key;
 | 
				
			||||||
 | 
					                auto KeyHash = Utils::ComputeHash(PrivateKey);
 | 
				
			||||||
 | 
					                auto KeyHint = PrivateKeys_.find(GlobalReachAccountId);
 | 
				
			||||||
 | 
					                if (KeyHint != PrivateKeys_.end() && PrivateKey.empty()) {
 | 
				
			||||||
 | 
					                    Key = KeyHint->second.second;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    if (PrivateKey.empty()) {
 | 
				
			||||||
 | 
					                        return "";
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    Poco::TemporaryFile F;
 | 
				
			||||||
 | 
					                    std::ofstream ofs(F.path().c_str(),
 | 
				
			||||||
 | 
					                                      std::ios_base::trunc | std::ios_base::out | std::ios_base::binary);
 | 
				
			||||||
 | 
					                    ofs << PrivateKey;
 | 
				
			||||||
 | 
					                    ofs.close();
 | 
				
			||||||
 | 
					                    auto NewKey = Poco::SharedPtr<Poco::Crypto::ECKey>(
 | 
				
			||||||
 | 
					                            new Poco::Crypto::ECKey("", F.path(), ""));
 | 
				
			||||||
 | 
					                    Key = NewKey;
 | 
				
			||||||
 | 
					                    PrivateKeys_[GlobalReachAccountId] = std::make_pair(KeyHash, NewKey);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                Poco::JWT::Signer Signer;
 | 
				
			||||||
 | 
					                Signer.setECKey(Key);
 | 
				
			||||||
 | 
					                Signer.addAllAlgorithms();
 | 
				
			||||||
 | 
					                return Signer.sign(token, Poco::JWT::Signer::ALGO_ES256);
 | 
				
			||||||
 | 
					            } catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
					                poco_error(Logger(),
 | 
				
			||||||
 | 
					                           fmt::format("Cannot create a Global Reach token: {},{}", E.name(), E.displayText()));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return "";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        bool
 | 
				
			||||||
 | 
					        OpenRoaming::VerifyAccount(const std::string &GlobalReachAccountId, const std::string &PrivateKey,
 | 
				
			||||||
 | 
					                                               std::string &Name) {
 | 
				
			||||||
 | 
					            auto BearerToken = MakeToken(GlobalReachAccountId, PrivateKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Poco::URI URI{"https://config.openro.am/v1/config"};
 | 
				
			||||||
 | 
					            std::string Path(URI.getPathAndQuery());
 | 
				
			||||||
 | 
					            Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_GET, Path,
 | 
				
			||||||
 | 
					                                           Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
 | 
					            Request.add("Authorization", "Bearer " + BearerToken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
 | 
					            Session.setTimeout(Poco::Timespan(10000, 10000));
 | 
				
			||||||
 | 
					            Session.sendRequest(Request);
 | 
				
			||||||
 | 
					            Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
					            std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
 | 
					            if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
					                Poco::JSON::Parser P;
 | 
				
			||||||
 | 
					                auto Result = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
					                if (Result->has("name")) {
 | 
				
			||||||
 | 
					                    Name = Result->get("name").toString();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//        static std::string ServiceName{"\"aaa+auth:radius.tls.tcp\""};
 | 
				
			||||||
 | 
					        static std::string ServiceName{"\"x-openroam:radius.tls.tcp\""};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        std::vector<Utils::HostNameServerResult> OpenRoaming::GetServers() {
 | 
				
			||||||
 | 
					            const std::string &domain = "openro.am";
 | 
				
			||||||
 | 
					            auto Naptrs = Utils::getNAPTRRecords(domain);
 | 
				
			||||||
 | 
					            std::vector<Utils::HostNameServerResult>   Results;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for(const auto &rec:Naptrs) {
 | 
				
			||||||
 | 
					                if(rec.service==ServiceName) {
 | 
				
			||||||
 | 
					                    auto Srvs = Utils::getSRVRecords(rec.replacement);
 | 
				
			||||||
 | 
					                    for(const auto &srv:Srvs) {
 | 
				
			||||||
 | 
					                        Utils::HostNameServerResult    R{srv.srvname,srv.port};
 | 
				
			||||||
 | 
					                        if(!Utils::ValidIP(srv.srvname)) {
 | 
				
			||||||
 | 
					                            auto Server = Poco::Net::DNS::hostByName(srv.srvname).addresses();
 | 
				
			||||||
 | 
					                            if(!Server.empty()) {
 | 
				
			||||||
 | 
					                                R.Hostname = Server[0].toString();
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        Results.emplace_back(R);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return Results;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
							
								
								
									
										57
									
								
								src/RadiusEndpointTypes/GlobalReach.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								src/RadiusEndpointTypes/GlobalReach.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,57 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-11.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
 | 
					#include "framework/utils.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/Object.h"
 | 
				
			||||||
 | 
					#include "RESTObjects/RESTAPI_ProvObjects.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    namespace GlobalReach {
 | 
				
			||||||
 | 
					        class OpenRoaming : public SubSystemServer {
 | 
				
			||||||
 | 
					        public:
 | 
				
			||||||
 | 
					            static auto instance() {
 | 
				
			||||||
 | 
					                static auto instance_ = new OpenRoaming;
 | 
				
			||||||
 | 
					                return instance_;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int Start() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            void Stop() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            bool CreateRADSECCertificate(const std::string &AccountName,
 | 
				
			||||||
 | 
					                                         const std::string &Name,
 | 
				
			||||||
 | 
					                                         const std::string &CSR,
 | 
				
			||||||
 | 
					                                         ProvObjects::GLBLRCertificateInfo &NewCertificate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            bool GetRADSECCertificate(const std::string &AccountName, std::string &CertificateId,
 | 
				
			||||||
 | 
					                                      ProvObjects::GLBLRCertificateInfo &NewCertificate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            bool
 | 
				
			||||||
 | 
					            VerifyAccount(const std::string &GlobalReachAccountId, const std::string &PrivateKey, std::string &Name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            void InitCache();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            bool Render(const OpenWifi::ProvObjects::RADIUSEndPoint &RE, const std::string & SerialNUmber, Poco::JSON::Object &Result);
 | 
				
			||||||
 | 
					            std::vector<Utils::HostNameServerResult> GetServers();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private:
 | 
				
			||||||
 | 
					            std::string MakeToken(const std::string &GlobalReachAccountId, const std::string &PrivateKey = "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            std::map<std::string, std::pair<std::string, Poco::SharedPtr<Poco::Crypto::ECKey>>> PrivateKeys_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            OpenRoaming() noexcept
 | 
				
			||||||
 | 
					                    : SubSystemServer("OpenRoaming_GlobalReach", "GLBL-REACH", "globalreach") {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    inline auto OpenRoaming_GlobalReach() { return GlobalReach::OpenRoaming::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										79
									
								
								src/RadiusEndpointTypes/OrionWifi.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								src/RadiusEndpointTypes/OrionWifi.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,79 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-09-28.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <Poco/Net/IPAddress.h>
 | 
				
			||||||
 | 
					#include <Poco/Net/SocketAddress.h>
 | 
				
			||||||
 | 
					#include <framework/utils.h>
 | 
				
			||||||
 | 
					#include <framework/SubSystemServer.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    namespace Orion {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        class OpenRoaming : public SubSystemServer {
 | 
				
			||||||
 | 
					        public:
 | 
				
			||||||
 | 
					            static auto instance() {
 | 
				
			||||||
 | 
					                static auto instance_ = new OpenRoaming;
 | 
				
			||||||
 | 
					                return instance_;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline int Start() override {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline void Stop() override {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            static inline const std::vector<Utils::HostNameServerResult> OrionWifiServerAddresses = {
 | 
				
			||||||
 | 
					                    {"216.239.32.91", 2083},
 | 
				
			||||||
 | 
					                    {"216.239.34.91", 2083}
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline std::vector<Utils::HostNameServerResult> GetServers() {
 | 
				
			||||||
 | 
					                return OrionWifiServerAddresses;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline bool Render(const OpenWifi::ProvObjects::RADIUSEndPoint &RE, const std::string &SerialNumber, Poco::JSON::Object &Result) {
 | 
				
			||||||
 | 
					                if(RE.UseGWProxy) {
 | 
				
			||||||
 | 
					                    Poco::JSON::Object  Auth, Acct, CoA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Auth.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    Auth.set("port", 1812 );
 | 
				
			||||||
 | 
					                    Auth.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Acct.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    Acct.set("port", 1813);
 | 
				
			||||||
 | 
					                    Acct.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					                    Acct.set("interval", RE.AccountingInterval);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    CoA.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    CoA.set("port", 3799);
 | 
				
			||||||
 | 
					                    CoA.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Result.set("nas-identifier", RE.NasIdentifier.empty() ? SerialNumber : RE.NasIdentifier );
 | 
				
			||||||
 | 
					                    Result.set("authentication", Auth);
 | 
				
			||||||
 | 
					                    Result.set("accounting", Acct);
 | 
				
			||||||
 | 
					                    Result.set("dynamic-authorization", CoA);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private:
 | 
				
			||||||
 | 
					            OpenRoaming() noexcept
 | 
				
			||||||
 | 
					                    : SubSystemServer("OpenRoaming_Orion", "ORION", "orion") {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    inline auto OpenRoaming_Orion() { return Orion::OpenRoaming::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										8
									
								
								src/RadiusEndpointTypes/Radsec.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/RadiusEndpointTypes/Radsec.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-10-03.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Radsec.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWidi {
 | 
				
			||||||
 | 
					} // OpenWidi
 | 
				
			||||||
							
								
								
									
										71
									
								
								src/RadiusEndpointTypes/Radsec.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								src/RadiusEndpointTypes/Radsec.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,71 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-10-03.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <Poco/Net/IPAddress.h>
 | 
				
			||||||
 | 
					#include <Poco/Net/SocketAddress.h>
 | 
				
			||||||
 | 
					#include <framework/utils.h>
 | 
				
			||||||
 | 
					#include <framework/SubSystemServer.h>
 | 
				
			||||||
 | 
					#include <RESTObjects/RESTAPI_ProvObjects.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    namespace Radsec {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        class OpenRoaming : public SubSystemServer {
 | 
				
			||||||
 | 
					        public:
 | 
				
			||||||
 | 
					            static auto instance() {
 | 
				
			||||||
 | 
					                static auto instance_ = new OpenRoaming;
 | 
				
			||||||
 | 
					                return instance_;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline int Start() override {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline void Stop() override {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            inline bool Render(const OpenWifi::ProvObjects::RADIUSEndPoint &RE, const std::string &SerialNumber, Poco::JSON::Object &Result) {
 | 
				
			||||||
 | 
					                if(RE.UseGWProxy) {
 | 
				
			||||||
 | 
					                    Poco::JSON::Object  Auth, Acct, CoA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Auth.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    Auth.set("port", 1812 );
 | 
				
			||||||
 | 
					                    Auth.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Acct.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    Acct.set("port", 1813);
 | 
				
			||||||
 | 
					                    Acct.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					                    Acct.set("interval", RE.AccountingInterval);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    CoA.set("host", RE.Index);
 | 
				
			||||||
 | 
					                    CoA.set("port", 3799);
 | 
				
			||||||
 | 
					                    CoA.set("secret", RE.RadsecServers[0].Secret);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    Result.set("nas-identifier", RE.NasIdentifier.empty() ? SerialNumber : RE.NasIdentifier );
 | 
				
			||||||
 | 
					                    Result.set("authentication", Auth);
 | 
				
			||||||
 | 
					                    Result.set("accounting", Acct);
 | 
				
			||||||
 | 
					                    Result.set("dynamic-authorization", CoA);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private:
 | 
				
			||||||
 | 
					            OpenRoaming() noexcept
 | 
				
			||||||
 | 
					                    : SubSystemServer("OpenRoaming_Raadsec", "RADSEC", "radsec") {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    inline auto OpenRoaming_Radsec() { return Radsec::OpenRoaming::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/RadiusEndpointUpdater.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/RadiusEndpointUpdater.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-10-02.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RadiusEndpointUpdater.h"
 | 
				
			||||||
							
								
								
									
										225
									
								
								src/RadiusEndpointUpdater.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										225
									
								
								src/RadiusEndpointUpdater.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,225 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by stephane bourque on 2023-10-02.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					#include <utility>
 | 
				
			||||||
 | 
					#include <framework/AppServiceRegistry.h>
 | 
				
			||||||
 | 
					#include <framework/utils.h>
 | 
				
			||||||
 | 
					#include <StorageService.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/OrionWifi.h>
 | 
				
			||||||
 | 
					#include <RadiusEndpointTypes/GlobalReach.h>
 | 
				
			||||||
 | 
					#include <sdks/SDK_gw.h>
 | 
				
			||||||
 | 
					#include <RESTObjects/RESTAPI_GWobjects.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					    class RadiusEndpointUpdater {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void ParseCertChain(const std::string &Chain, std::vector<std::string> &ChainVec) {
 | 
				
			||||||
 | 
					            std::istringstream os(Chain);
 | 
				
			||||||
 | 
					            std::string CurrentCert;
 | 
				
			||||||
 | 
					            bool InCert = false;
 | 
				
			||||||
 | 
					            std::string Line;
 | 
				
			||||||
 | 
					            while(std::getline(os,Line)) {
 | 
				
			||||||
 | 
					                if(Line=="-----BEGIN CERTIFICATE-----") {
 | 
				
			||||||
 | 
					                    InCert = true;
 | 
				
			||||||
 | 
					                    CurrentCert += Line;
 | 
				
			||||||
 | 
					                    CurrentCert += "\n";
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if(Line=="-----END CERTIFICATE-----" && InCert) {
 | 
				
			||||||
 | 
					                    InCert = false;
 | 
				
			||||||
 | 
					                    CurrentCert += Line;
 | 
				
			||||||
 | 
					                    CurrentCert += "\n";
 | 
				
			||||||
 | 
					                    ChainVec.emplace_back(CurrentCert);
 | 
				
			||||||
 | 
					                    continue;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                if(InCert) {
 | 
				
			||||||
 | 
					                    CurrentCert += Line;
 | 
				
			||||||
 | 
					                    CurrentCert += "\n";
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void UpdateRadiusServerEntry( GWObjects::RadiusProxyServerConfig &Config,
 | 
				
			||||||
 | 
					                                      const ProvObjects::RADIUSEndPoint &Endpoint,
 | 
				
			||||||
 | 
					                                      const std::vector<ProvObjects::RADIUSServer> &Servers) {
 | 
				
			||||||
 | 
					            Config.monitor = false;
 | 
				
			||||||
 | 
					            Config.strategy = Endpoint.PoolStrategy;
 | 
				
			||||||
 | 
					            Config.monitorMethod = "none";
 | 
				
			||||||
 | 
					            Config.strategy = "random";
 | 
				
			||||||
 | 
					            for (const auto &Server: Servers) {
 | 
				
			||||||
 | 
					                GWObjects::RadiusProxyServerEntry PE;
 | 
				
			||||||
 | 
					                PE.radsec = false;
 | 
				
			||||||
 | 
					                PE.name = Server.Hostname;
 | 
				
			||||||
 | 
					                PE.ignore = false;
 | 
				
			||||||
 | 
					                PE.ip = Server.IP;
 | 
				
			||||||
 | 
					                PE.port = PE.radsecPort = Server.Port;
 | 
				
			||||||
 | 
					                PE.allowSelfSigned = false;
 | 
				
			||||||
 | 
					                PE.weight = 10;
 | 
				
			||||||
 | 
					                PE.secret = PE.radsecSecret = "radsec";
 | 
				
			||||||
 | 
					                Config.servers.emplace_back(PE);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        inline bool UpdateEndpoints( RESTAPIHandler *Client, std::uint64_t & ErrorCode,
 | 
				
			||||||
 | 
					                                     std::string & ErrorDetails,
 | 
				
			||||||
 | 
					                                     std::string & ErrorDescription) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            std::vector<ProvObjects::RADIUSEndPoint>    Endpoints;
 | 
				
			||||||
 | 
					            GWObjects::RadiusProxyPoolList  Pools;
 | 
				
			||||||
 | 
					            StorageService()->RadiusEndpointDB().GetRecords(0,500,Endpoints);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for(const auto &Endpoint:Endpoints) {
 | 
				
			||||||
 | 
					                GWObjects::RadiusProxyPool  PP;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                PP.name = Endpoint.info.name;
 | 
				
			||||||
 | 
					                PP.description = Endpoint.info.description;
 | 
				
			||||||
 | 
					                PP.useByDefault = false;
 | 
				
			||||||
 | 
					                PP.poolProxyIp = Endpoint.Index;
 | 
				
			||||||
 | 
					                PP.radsecKeepAlive = 25;
 | 
				
			||||||
 | 
					                PP.enabled = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if(Endpoint.Type=="orion" && !Endpoint.RadsecServers.empty()) {
 | 
				
			||||||
 | 
					                    auto Svrs = OpenRoaming_Orion()->GetServers();
 | 
				
			||||||
 | 
					                    PP.radsecPoolType="orion";
 | 
				
			||||||
 | 
					                    ProvObjects::GooglOrionAccountInfo  OA;
 | 
				
			||||||
 | 
					                    if(StorageService()->OrionAccountsDB().GetRecord("id", Endpoint.RadsecServers[0].UseOpenRoamingAccount, OA)) {
 | 
				
			||||||
 | 
					                        for(auto *ServerType:{&PP.authConfig, &PP.acctConfig, &PP.coaConfig}) {
 | 
				
			||||||
 | 
					                            ServerType->monitor = false;
 | 
				
			||||||
 | 
					                            ServerType->strategy = Endpoint.PoolStrategy;
 | 
				
			||||||
 | 
					                            ServerType->monitorMethod = "none";
 | 
				
			||||||
 | 
					                            ServerType->strategy = "random";
 | 
				
			||||||
 | 
					                            int i=1;
 | 
				
			||||||
 | 
					                            for (const auto &Server: Svrs) {
 | 
				
			||||||
 | 
					                                GWObjects::RadiusProxyServerEntry PE;
 | 
				
			||||||
 | 
					                                PE.radsecCert = Utils::base64encode((const u_char *)OA.certificate.c_str(),OA.certificate.size());
 | 
				
			||||||
 | 
					                                PE.radsecKey = Utils::base64encode((const u_char *)OA.privateKey.c_str(),OA.privateKey.size());
 | 
				
			||||||
 | 
					                                for(const auto &cert:OA.cacerts) {
 | 
				
			||||||
 | 
					                                    auto C = Utils::base64encode((const u_char *)cert.c_str(),cert.size());
 | 
				
			||||||
 | 
					                                    PE.radsecCacerts.emplace_back(C);
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                PE.radsec = true;
 | 
				
			||||||
 | 
					                                PE.name = fmt::format("Server {}",i++);
 | 
				
			||||||
 | 
					                                PE.ignore = false;
 | 
				
			||||||
 | 
					                                PE.ip = Server.Hostname;
 | 
				
			||||||
 | 
					                                PE.port = PE.radsecPort = Server.Port;
 | 
				
			||||||
 | 
					                                PE.allowSelfSigned = false;
 | 
				
			||||||
 | 
					                                PE.weight = 10;
 | 
				
			||||||
 | 
					                                PE.secret = PE.radsecSecret = "radsec";
 | 
				
			||||||
 | 
					                                ServerType->servers.emplace_back(PE);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        Pools.pools.emplace_back(PP);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else if(Endpoint.Type=="globalreach" && !Endpoint.RadsecServers.empty()) {
 | 
				
			||||||
 | 
					                    auto Svrs = OpenRoaming_GlobalReach()->GetServers();
 | 
				
			||||||
 | 
					                    PP.radsecPoolType="globalreach";
 | 
				
			||||||
 | 
					                    ProvObjects::GLBLRCertificateInfo   GRCertificate;
 | 
				
			||||||
 | 
					                    ProvObjects::GLBLRAccountInfo       GRAccountInfo;
 | 
				
			||||||
 | 
					                    if( StorageService()->GLBLRCertsDB().GetRecord("id",Endpoint.RadsecServers[0].UseOpenRoamingAccount,GRCertificate) &&
 | 
				
			||||||
 | 
					                        StorageService()->GLBLRAccountInfoDB().GetRecord("id",GRCertificate.accountId,GRAccountInfo)) {
 | 
				
			||||||
 | 
					                        for(auto *ServerType:{&PP.authConfig, &PP.acctConfig, &PP.coaConfig}) {
 | 
				
			||||||
 | 
					                            ServerType->monitor = false;
 | 
				
			||||||
 | 
					                            ServerType->monitorMethod = "none";
 | 
				
			||||||
 | 
					                            ServerType->strategy = Endpoint.PoolStrategy;
 | 
				
			||||||
 | 
					                            ServerType->strategy = "random";
 | 
				
			||||||
 | 
					                            int i = 1;
 | 
				
			||||||
 | 
					                            for (const auto &Server: Svrs) {
 | 
				
			||||||
 | 
					                                GWObjects::RadiusProxyServerEntry PE;
 | 
				
			||||||
 | 
					                                PE.radsecCert = Utils::base64encode((const u_char *)GRCertificate.certificate.c_str(),GRCertificate.certificate.size());
 | 
				
			||||||
 | 
					                                PE.radsecKey = Utils::base64encode((const u_char *)GRAccountInfo.CSRPrivateKey.c_str(),GRAccountInfo.CSRPrivateKey.size());
 | 
				
			||||||
 | 
					                                std::vector<std::string> Chain;
 | 
				
			||||||
 | 
					                                ParseCertChain(GRCertificate.certificateChain,Chain);
 | 
				
			||||||
 | 
					                                for(const auto &cert:Chain) {
 | 
				
			||||||
 | 
					                                    PE.radsecCacerts.emplace_back( Utils::base64encode((const u_char *)cert.c_str(),cert.size()));
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                                PE.radsec = true;
 | 
				
			||||||
 | 
					                                PE.name = fmt::format("Server {}", i++);
 | 
				
			||||||
 | 
					                                PE.ignore = false;
 | 
				
			||||||
 | 
					                                PE.ip = Server.Hostname;
 | 
				
			||||||
 | 
					                                PE.port = PE.radsecPort = Server.Port;
 | 
				
			||||||
 | 
					                                PE.allowSelfSigned = false;
 | 
				
			||||||
 | 
					                                PE.weight = 10;
 | 
				
			||||||
 | 
					                                PE.secret = PE.radsecSecret = "radsec";
 | 
				
			||||||
 | 
					                                ServerType->servers.emplace_back(PE);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        Pools.pools.emplace_back(PP);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                } else if(Endpoint.Type=="radsec"  && !Endpoint.RadsecServers.empty()) {
 | 
				
			||||||
 | 
					                    PP.radsecPoolType="radsec";
 | 
				
			||||||
 | 
					                    for(auto *ServerType:{&PP.authConfig, &PP.acctConfig, &PP.coaConfig}) {
 | 
				
			||||||
 | 
					                        ServerType->monitor = false;
 | 
				
			||||||
 | 
					                        ServerType->strategy = Endpoint.PoolStrategy;
 | 
				
			||||||
 | 
					                        ServerType->monitorMethod = "none";
 | 
				
			||||||
 | 
					                        ServerType->strategy = "random";
 | 
				
			||||||
 | 
					                        for (const auto &Server: Endpoint.RadsecServers) {
 | 
				
			||||||
 | 
					                            GWObjects::RadiusProxyServerEntry PE;
 | 
				
			||||||
 | 
					                            PE.radsecCert = Utils::base64encode((const u_char *)Server.Certificate.c_str(), Server.Certificate.size());
 | 
				
			||||||
 | 
					                            PE.radsecKey = Utils::base64encode((const u_char *)Server.PrivateKey.c_str(),Server.PrivateKey.size());
 | 
				
			||||||
 | 
					                            for(const auto &C:Server.CaCerts) {
 | 
				
			||||||
 | 
					                                PE.radsecCacerts.emplace_back(Utils::base64encode(
 | 
				
			||||||
 | 
					                                        (const u_char *) C.c_str(),
 | 
				
			||||||
 | 
					                                        C.size()));
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            PE.radsec = true;
 | 
				
			||||||
 | 
					                            PE.name = Server.Hostname;
 | 
				
			||||||
 | 
					                            PE.ignore = false;
 | 
				
			||||||
 | 
					                            PE.ip = Server.IP;
 | 
				
			||||||
 | 
					                            PE.port = PE.radsecPort = Server.Port;
 | 
				
			||||||
 | 
					                            PE.allowSelfSigned = false;
 | 
				
			||||||
 | 
					                            PE.weight = 10;
 | 
				
			||||||
 | 
					                            PE.secret = PE.radsecSecret = "radsec";
 | 
				
			||||||
 | 
					                            ServerType->servers.emplace_back(PE);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    Pools.pools.emplace_back(PP);
 | 
				
			||||||
 | 
					                } else if(Endpoint.Type=="generic"  && !Endpoint.RadiusServers.empty()) {
 | 
				
			||||||
 | 
					                    PP.radsecPoolType="generic";
 | 
				
			||||||
 | 
					                    UpdateRadiusServerEntry(PP.authConfig, Endpoint, Endpoint.RadiusServers[0].Authentication);
 | 
				
			||||||
 | 
					                    UpdateRadiusServerEntry(PP.acctConfig, Endpoint, Endpoint.RadiusServers[0].Accounting);
 | 
				
			||||||
 | 
					                    UpdateRadiusServerEntry(PP.coaConfig, Endpoint, Endpoint.RadiusServers[0].CoA);
 | 
				
			||||||
 | 
					                    Pools.pools.emplace_back(PP);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					            Poco::JSON::Object  oo;
 | 
				
			||||||
 | 
					            Pools.to_json(oo);
 | 
				
			||||||
 | 
					            oo.stringify(std::cout,2,2);
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					            GWObjects::RadiusProxyPoolList  NewPools;
 | 
				
			||||||
 | 
					            Poco::JSON::Object ErrorObj;
 | 
				
			||||||
 | 
					            if(SDK::GW::RADIUS::SetConfiguration(Client, Pools, NewPools, ErrorObj)) {
 | 
				
			||||||
 | 
					                ProvObjects::RADIUSEndpointUpdateStatus Status;
 | 
				
			||||||
 | 
					                Status.Read();
 | 
				
			||||||
 | 
					                Status.lastConfigurationChange = Status.lastUpdate = Utils::Now();
 | 
				
			||||||
 | 
					                return Status.Save();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					            ErrorCode:
 | 
				
			||||||
 | 
					            type: integer
 | 
				
			||||||
 | 
					            ErrorDetails:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					            ErrorDescription:
 | 
				
			||||||
 | 
					            type: string
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					            if(ErrorObj.has("ErrorCode") && !ErrorObj.isNull("ErrorCode"))
 | 
				
			||||||
 | 
					                ErrorCode = ErrorObj.get("ErrorCode");
 | 
				
			||||||
 | 
					            if(ErrorObj.has("ErrorDescription") && !ErrorObj.isNull("ErrorDescription"))
 | 
				
			||||||
 | 
					                ErrorDescription = ErrorObj.get("ErrorDescription").toString();
 | 
				
			||||||
 | 
					            if(ErrorObj.has("ErrorDetails") && !ErrorObj.isNull("ErrorDetails"))
 | 
				
			||||||
 | 
					                ErrorDetails += ErrorObj.get("ErrorDetails").toString();
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // OpenWifi
 | 
				
			||||||
@@ -39,6 +39,10 @@ namespace OpenWifi {
 | 
				
			|||||||
		OpLocationDB_ = std::make_unique<OpenWifi::OpLocationDB>(dbType_, *Pool_, Logger());
 | 
							OpLocationDB_ = std::make_unique<OpenWifi::OpLocationDB>(dbType_, *Pool_, Logger());
 | 
				
			||||||
		OpContactDB_ = std::make_unique<OpenWifi::OpContactDB>(dbType_, *Pool_, Logger());
 | 
							OpContactDB_ = std::make_unique<OpenWifi::OpContactDB>(dbType_, *Pool_, Logger());
 | 
				
			||||||
		OverridesDB_ = std::make_unique<OpenWifi::OverridesDB>(dbType_, *Pool_, Logger());
 | 
							OverridesDB_ = std::make_unique<OpenWifi::OverridesDB>(dbType_, *Pool_, Logger());
 | 
				
			||||||
 | 
					        GLBLRAccountInfoDB_ = std::make_unique<OpenWifi::GLBLRAccountInfoDB>(dbType_, *Pool_, Logger());
 | 
				
			||||||
 | 
					        GLBLRCertsDB_ = std::make_unique<OpenWifi::GLBLRCertsDB>(dbType_, *Pool_, Logger());
 | 
				
			||||||
 | 
					        OrionAccountsDB_ = std::make_unique<OpenWifi::OrionAccountsDB>(dbType_, *Pool_, Logger());
 | 
				
			||||||
 | 
					        RadiusEndpointDB_ = std::make_unique<OpenWifi::RadiusEndpointDB>(dbType_, *Pool_, Logger());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		EntityDB_->Create();
 | 
							EntityDB_->Create();
 | 
				
			||||||
		PolicyDB_->Create();
 | 
							PolicyDB_->Create();
 | 
				
			||||||
@@ -59,6 +63,10 @@ namespace OpenWifi {
 | 
				
			|||||||
		OpLocationDB_->Create();
 | 
							OpLocationDB_->Create();
 | 
				
			||||||
		OpContactDB_->Create();
 | 
							OpContactDB_->Create();
 | 
				
			||||||
		OverridesDB_->Create();
 | 
							OverridesDB_->Create();
 | 
				
			||||||
 | 
					        GLBLRAccountInfoDB_->Create();
 | 
				
			||||||
 | 
					        GLBLRCertsDB_->Create();
 | 
				
			||||||
 | 
					        OrionAccountsDB_->Create();
 | 
				
			||||||
 | 
					        RadiusEndpointDB_->Create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ExistFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
							ExistFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
				
			||||||
			return EntityDB_->Exists(F, V);
 | 
								return EntityDB_->Exists(F, V);
 | 
				
			||||||
@@ -117,8 +125,22 @@ namespace OpenWifi {
 | 
				
			|||||||
		ExistFunc_[OverridesDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
							ExistFunc_[OverridesDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
				
			||||||
			return OverridesDB_->Exists(F, V);
 | 
								return OverridesDB_->Exists(F, V);
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					        ExistFunc_[GLBLRAccountInfoDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
				
			||||||
 | 
					            return GLBLRAccountInfoDB_->Exists(F, V);
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        ExistFunc_[GLBLRCertsDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
				
			||||||
 | 
					            return GLBLRCertsDB_->Exists(F, V);
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        ExistFunc_[OrionAccountsDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
				
			||||||
 | 
					            return OrionAccountsDB_->Exists(F, V);
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        ExistFunc_[RadiusEndpointDB_->Prefix()] = [=](const char *F, std::string &V) -> bool {
 | 
				
			||||||
 | 
					            return RadiusEndpointDB_->Exists(F, V);
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ExpandFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name,
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ExpandFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name,
 | 
				
			||||||
											   std::string &Description) -> bool {
 | 
																   std::string &Description) -> bool {
 | 
				
			||||||
			return EntityDB_->GetNameAndDescription(F, V, Name, Description);
 | 
								return EntityDB_->GetNameAndDescription(F, V, Name, Description);
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
@@ -206,9 +228,29 @@ namespace OpenWifi {
 | 
				
			|||||||
			[=]([[maybe_unused]] const char *F, [[maybe_unused]] std::string &V,
 | 
								[=]([[maybe_unused]] const char *F, [[maybe_unused]] std::string &V,
 | 
				
			||||||
				[[maybe_unused]] std::string &Name,
 | 
									[[maybe_unused]] std::string &Name,
 | 
				
			||||||
				[[maybe_unused]] std::string &Description) -> bool { return false; };
 | 
									[[maybe_unused]] std::string &Description) -> bool { return false; };
 | 
				
			||||||
 | 
					        ExpandFunc_[GLBLRAccountInfoDB_->Prefix()] =
 | 
				
			||||||
 | 
					                [=]([[maybe_unused]] const char *F, [[maybe_unused]] std::string &V,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Name,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Description) -> bool { return false; };
 | 
				
			||||||
 | 
					        ExpandFunc_[OverridesDB_->Prefix()] =
 | 
				
			||||||
 | 
					                [=]([[maybe_unused]] const char *F, [[maybe_unused]] std::string &V,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Name,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Description) -> bool { return false; };
 | 
				
			||||||
 | 
					        ExpandFunc_[GLBLRCertsDB_->Prefix()] =
 | 
				
			||||||
 | 
					                [=]([[maybe_unused]] const char *F, [[maybe_unused]] std::string &V,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Name,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Description) -> bool { return false; };
 | 
				
			||||||
 | 
					        ExpandFunc_[OrionAccountsDB_->Prefix()] =
 | 
				
			||||||
 | 
					                [=]([[maybe_unused]] const char *F, [[maybe_unused]] std::string &V,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Name,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Description) -> bool { return false; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		InventoryDB_->InitializeSerialCache();
 | 
					        ExpandFunc_[RadiusEndpointDB_->Prefix()] =
 | 
				
			||||||
 | 
					                [=]([[maybe_unused]] const char *F, [[maybe_unused]] std::string &V,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Name,
 | 
				
			||||||
 | 
					                    [[maybe_unused]] std::string &Description) -> bool { return false; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        InventoryDB_->InitializeSerialCache();
 | 
				
			||||||
		ConsistencyCheck();
 | 
							ConsistencyCheck();
 | 
				
			||||||
		InitializeSystemDBs();
 | 
							InitializeSystemDBs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,10 @@
 | 
				
			|||||||
#include "storage/storage_tags.h"
 | 
					#include "storage/storage_tags.h"
 | 
				
			||||||
#include "storage/storage_variables.h"
 | 
					#include "storage/storage_variables.h"
 | 
				
			||||||
#include "storage/storage_venue.h"
 | 
					#include "storage/storage_venue.h"
 | 
				
			||||||
 | 
					#include "storage/storage_glblraccounts.h"
 | 
				
			||||||
 | 
					#include "storage/storage_glblrcerts.h"
 | 
				
			||||||
 | 
					#include "storage/storage_orion_accounts.h"
 | 
				
			||||||
 | 
					#include "storage/storage_radius_endpoints.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/URI.h"
 | 
					#include "Poco/URI.h"
 | 
				
			||||||
#include "framework/ow_constants.h"
 | 
					#include "framework/ow_constants.h"
 | 
				
			||||||
@@ -47,25 +51,29 @@ namespace OpenWifi {
 | 
				
			|||||||
		typedef std::list<ProvObjects::ExpandedUseEntry> ExpandedInUseList;
 | 
							typedef std::list<ProvObjects::ExpandedUseEntry> ExpandedInUseList;
 | 
				
			||||||
		typedef std::map<std::string, ProvObjects::ExpandedUseEntryList> ExpandedListMap;
 | 
							typedef std::map<std::string, ProvObjects::ExpandedUseEntryList> ExpandedListMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		OpenWifi::EntityDB &EntityDB() { return *EntityDB_; };
 | 
							inline OpenWifi::EntityDB &EntityDB() { return *EntityDB_; };
 | 
				
			||||||
		OpenWifi::PolicyDB &PolicyDB() { return *PolicyDB_; };
 | 
					        inline OpenWifi::PolicyDB &PolicyDB() { return *PolicyDB_; };
 | 
				
			||||||
		OpenWifi::VenueDB &VenueDB() { return *VenueDB_; };
 | 
					        inline OpenWifi::VenueDB &VenueDB() { return *VenueDB_; };
 | 
				
			||||||
		OpenWifi::LocationDB &LocationDB() { return *LocationDB_; };
 | 
					        inline OpenWifi::LocationDB &LocationDB() { return *LocationDB_; };
 | 
				
			||||||
		OpenWifi::ContactDB &ContactDB() { return *ContactDB_; };
 | 
					        inline OpenWifi::ContactDB &ContactDB() { return *ContactDB_; };
 | 
				
			||||||
		OpenWifi::InventoryDB &InventoryDB() { return *InventoryDB_; };
 | 
					        inline OpenWifi::InventoryDB &InventoryDB() { return *InventoryDB_; };
 | 
				
			||||||
		OpenWifi::ManagementRoleDB &RolesDB() { return *RolesDB_; };
 | 
					        inline OpenWifi::ManagementRoleDB &RolesDB() { return *RolesDB_; };
 | 
				
			||||||
		OpenWifi::ConfigurationDB &ConfigurationDB() { return *ConfigurationDB_; };
 | 
					        inline OpenWifi::ConfigurationDB &ConfigurationDB() { return *ConfigurationDB_; };
 | 
				
			||||||
		OpenWifi::TagsDictionaryDB &TagsDictionaryDB() { return *TagsDictionaryDB_; };
 | 
					        inline OpenWifi::TagsDictionaryDB &TagsDictionaryDB() { return *TagsDictionaryDB_; };
 | 
				
			||||||
		OpenWifi::TagsObjectDB &TagsObjectDB() { return *TagsObjectDB_; };
 | 
					        inline OpenWifi::TagsObjectDB &TagsObjectDB() { return *TagsObjectDB_; };
 | 
				
			||||||
		OpenWifi::MapDB &MapDB() { return *MapDB_; };
 | 
					        inline OpenWifi::MapDB &MapDB() { return *MapDB_; };
 | 
				
			||||||
		OpenWifi::SignupDB &SignupDB() { return *SignupDB_; };
 | 
					        inline OpenWifi::SignupDB &SignupDB() { return *SignupDB_; };
 | 
				
			||||||
		OpenWifi::VariablesDB &VariablesDB() { return *VariablesDB_; };
 | 
					        inline OpenWifi::VariablesDB &VariablesDB() { return *VariablesDB_; };
 | 
				
			||||||
		OpenWifi::OperatorDB &OperatorDB() { return *OperatorDB_; };
 | 
					        inline OpenWifi::OperatorDB &OperatorDB() { return *OperatorDB_; };
 | 
				
			||||||
		OpenWifi::ServiceClassDB &ServiceClassDB() { return *ServiceClassDB_; };
 | 
					        inline OpenWifi::ServiceClassDB &ServiceClassDB() { return *ServiceClassDB_; };
 | 
				
			||||||
		OpenWifi::SubscriberDeviceDB &SubscriberDeviceDB() { return *SubscriberDeviceDB_; };
 | 
					        inline OpenWifi::SubscriberDeviceDB &SubscriberDeviceDB() { return *SubscriberDeviceDB_; };
 | 
				
			||||||
		OpenWifi::OpLocationDB &OpLocationDB() { return *OpLocationDB_; };
 | 
					        inline OpenWifi::OpLocationDB &OpLocationDB() { return *OpLocationDB_; };
 | 
				
			||||||
		OpenWifi::OpContactDB &OpContactDB() { return *OpContactDB_; };
 | 
					        inline OpenWifi::OpContactDB &OpContactDB() { return *OpContactDB_; };
 | 
				
			||||||
		OpenWifi::OverridesDB &OverridesDB() { return *OverridesDB_; };
 | 
					        inline OpenWifi::OverridesDB &OverridesDB() { return *OverridesDB_; };
 | 
				
			||||||
 | 
					        inline OpenWifi::GLBLRAccountInfoDB &GLBLRAccountInfoDB() { return *GLBLRAccountInfoDB_; }
 | 
				
			||||||
 | 
					        inline OpenWifi::GLBLRCertsDB &GLBLRCertsDB() { return *GLBLRCertsDB_; }
 | 
				
			||||||
 | 
					        inline OpenWifi::OrionAccountsDB &OrionAccountsDB() { return *OrionAccountsDB_; }
 | 
				
			||||||
 | 
					        inline OpenWifi::RadiusEndpointDB &RadiusEndpointDB() { return *RadiusEndpointDB_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool Validate(const Poco::URI::QueryParameters &P, RESTAPI::Errors::msg &Error);
 | 
							bool Validate(const Poco::URI::QueryParameters &P, RESTAPI::Errors::msg &Error);
 | 
				
			||||||
		bool Validate(const Types::StringVec &P, std::string &Error);
 | 
							bool Validate(const Types::StringVec &P, std::string &Error);
 | 
				
			||||||
@@ -125,6 +133,10 @@ namespace OpenWifi {
 | 
				
			|||||||
		std::unique_ptr<OpenWifi::OpLocationDB> OpLocationDB_;
 | 
							std::unique_ptr<OpenWifi::OpLocationDB> OpLocationDB_;
 | 
				
			||||||
		std::unique_ptr<OpenWifi::OpContactDB> OpContactDB_;
 | 
							std::unique_ptr<OpenWifi::OpContactDB> OpContactDB_;
 | 
				
			||||||
		std::unique_ptr<OpenWifi::OverridesDB> OverridesDB_;
 | 
							std::unique_ptr<OpenWifi::OverridesDB> OverridesDB_;
 | 
				
			||||||
 | 
					        std::unique_ptr<OpenWifi::GLBLRAccountInfoDB> GLBLRAccountInfoDB_;
 | 
				
			||||||
 | 
					        std::unique_ptr<OpenWifi::GLBLRCertsDB> GLBLRCertsDB_;
 | 
				
			||||||
 | 
					        std::unique_ptr<OpenWifi::OrionAccountsDB> OrionAccountsDB_;
 | 
				
			||||||
 | 
					        std::unique_ptr<OpenWifi::RadiusEndpointDB> RadiusEndpointDB_;
 | 
				
			||||||
		std::string DefaultOperator_;
 | 
							std::string DefaultOperator_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		typedef std::function<bool(const char *FieldName, std::string &Value)> exist_func;
 | 
							typedef std::function<bool(const char *FieldName, std::string &Value)> exist_func;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,42 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						[[maybe_unused]] static void ComputeAndPushConfig(const std::string &SerialNumber, const std::string &DeviceType, Poco::Logger &Logger) {
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
							Generic Helper to compute a device's config and push it down to the device.
 | 
				
			||||||
 | 
							*/
 | 
				
			||||||
 | 
							poco_information(Logger, fmt::format("Attempting to push venue config for device {}", SerialNumber));
 | 
				
			||||||
 | 
							auto DeviceConfig = std::make_shared<APConfig>(SerialNumber,
 | 
				
			||||||
 | 
																			DeviceType, Logger, false);
 | 
				
			||||||
 | 
							auto Configuration = Poco::makeShared<Poco::JSON::Object>();
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								if (DeviceConfig->Get(Configuration)) {
 | 
				
			||||||
 | 
									std::ostringstream OS;
 | 
				
			||||||
 | 
									Configuration->stringify(OS);
 | 
				
			||||||
 | 
									auto Response = Poco::makeShared<Poco::JSON::Object>();
 | 
				
			||||||
 | 
									poco_debug(Logger,
 | 
				
			||||||
 | 
												fmt::format("{}: Pushing configuration.", SerialNumber));
 | 
				
			||||||
 | 
									if (SDK::GW::Device::Configure(nullptr, SerialNumber, Configuration,
 | 
				
			||||||
 | 
																	Response)) {
 | 
				
			||||||
 | 
										Logger.debug(
 | 
				
			||||||
 | 
											fmt::format("{}: Configuration pushed.", SerialNumber));
 | 
				
			||||||
 | 
										poco_information(Logger,
 | 
				
			||||||
 | 
															fmt::format("{}: Updated.", SerialNumber));
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										poco_information(Logger,
 | 
				
			||||||
 | 
															fmt::format("{}: Not updated.", SerialNumber));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									poco_debug(Logger,
 | 
				
			||||||
 | 
												fmt::format("{}: Configuration is bad.", SerialNumber));
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} catch (...) {
 | 
				
			||||||
 | 
								poco_debug(Logger,
 | 
				
			||||||
 | 
											fmt::format("{}: Configuration is bad (caused an exception).",
 | 
				
			||||||
 | 
														SerialNumber));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class VenueDeviceConfigUpdater : public Poco::Runnable {
 | 
						class VenueDeviceConfigUpdater : public Poco::Runnable {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		VenueDeviceConfigUpdater(const std::string &UUID, const std::string &venue, Poco::Logger &L)
 | 
							VenueDeviceConfigUpdater(const std::string &UUID, const std::string &venue, Poco::Logger &L)
 | 
				
			||||||
@@ -118,8 +154,9 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				Poco::ThreadPool Pool_;
 | 
									Poco::ThreadPool Pool_;
 | 
				
			||||||
				std::list<VenueDeviceConfigUpdater *> JobList;
 | 
									std::list<VenueDeviceConfigUpdater *> JobList;
 | 
				
			||||||
 | 
					                std::vector<std::string> DeviceList;
 | 
				
			||||||
				for (const auto &uuid : Venue.devices) {
 | 
					                StorageService()->InventoryDB().GetDevicesUUIDForVenue(Venue.info.id, DeviceList);
 | 
				
			||||||
 | 
									for (const auto &uuid : DeviceList) {
 | 
				
			||||||
					auto NewTask = new VenueDeviceConfigUpdater(uuid, Venue.info.name, Logger());
 | 
										auto NewTask = new VenueDeviceConfigUpdater(uuid, Venue.info.name, Logger());
 | 
				
			||||||
					bool TaskAdded = false;
 | 
										bool TaskAdded = false;
 | 
				
			||||||
					while (!TaskAdded) {
 | 
										while (!TaskAdded) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,8 +68,10 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				Poco::ThreadPool Pool_;
 | 
									Poco::ThreadPool Pool_;
 | 
				
			||||||
				std::list<VenueDeviceRebooter *> JobList;
 | 
									std::list<VenueDeviceRebooter *> JobList;
 | 
				
			||||||
 | 
					                std::vector<std::string> DeviceList;
 | 
				
			||||||
 | 
					                StorageService()->InventoryDB().GetDevicesUUIDForVenue(Venue.info.id, DeviceList);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				for (const auto &uuid : Venue.devices) {
 | 
									for (const auto &uuid : DeviceList) {
 | 
				
			||||||
					auto NewTask = new VenueDeviceRebooter(uuid, Venue.info.name, Logger());
 | 
										auto NewTask = new VenueDeviceRebooter(uuid, Venue.info.name, Logger());
 | 
				
			||||||
					bool TaskAdded = false;
 | 
										bool TaskAdded = false;
 | 
				
			||||||
					while (!TaskAdded) {
 | 
										while (!TaskAdded) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				Storage::ApplyRules(rules_, Device.deviceRules);
 | 
									Storage::ApplyRules(rules_, Device.deviceRules);
 | 
				
			||||||
				if (Device.deviceRules.firmwareUpgrade == "no") {
 | 
									if (Device.deviceRules.firmwareUpgrade == "no") {
 | 
				
			||||||
					poco_debug(Logger(), fmt::format("Skipped Upgrade: {}", Device.serialNumber));
 | 
										poco_debug(Logger(), fmt::format("Skipped Upgrade: {} : Venue rules prevent upgrading", Device.serialNumber));
 | 
				
			||||||
					skipped_++;
 | 
										skipped_++;
 | 
				
			||||||
					done_ = true;
 | 
										done_ = true;
 | 
				
			||||||
					return;
 | 
										return;
 | 
				
			||||||
@@ -36,10 +36,15 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
				FMSObjects::Firmware F;
 | 
									FMSObjects::Firmware F;
 | 
				
			||||||
				if (SDK::FMS::Firmware::GetFirmware(Device.deviceType, revision_, F)) {
 | 
									if (SDK::FMS::Firmware::GetFirmware(Device.deviceType, revision_, F)) {
 | 
				
			||||||
					if (SDK::GW::Device::Upgrade(nullptr, Device.serialNumber, 0, F.uri)) {
 | 
					                    std::string Status;
 | 
				
			||||||
						Logger().debug(
 | 
										if (SDK::GW::Device::Upgrade(nullptr, Device.serialNumber, 0, F.uri, Status)) {
 | 
				
			||||||
							fmt::format("{}: Upgraded to {}.", Device.serialNumber, revision_));
 | 
					                        if(Status=="pending") {
 | 
				
			||||||
						upgraded_++;
 | 
					                            pending_++;
 | 
				
			||||||
 | 
					                            poco_debug(Logger(), fmt::format("Upgrade Pending: {} : {}", Device.serialNumber, Status));
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            upgraded_++;
 | 
				
			||||||
 | 
					                            poco_debug(Logger(), fmt::format("Upgrade Success: {} : {}", Device.serialNumber, Status));
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
					} else {
 | 
										} else {
 | 
				
			||||||
						poco_information(Logger(), fmt::format("{}: Not Upgraded to {}.",
 | 
											poco_information(Logger(), fmt::format("{}: Not Upgraded to {}.",
 | 
				
			||||||
															   Device.serialNumber, revision_));
 | 
																				   Device.serialNumber, revision_));
 | 
				
			||||||
@@ -53,10 +58,9 @@ namespace OpenWifi {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			done_ = true;
 | 
								done_ = true;
 | 
				
			||||||
			// std::cout << "Done push for " << Device.serialNumber << std::endl;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0;
 | 
							std::uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0, pending_ = 0;
 | 
				
			||||||
		bool started_ = false, done_ = false;
 | 
							bool started_ = false, done_ = false;
 | 
				
			||||||
		std::string SerialNumber;
 | 
							std::string SerialNumber;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -85,7 +89,7 @@ namespace OpenWifi {
 | 
				
			|||||||
			ProvWebSocketNotifications::VenueFWUpgradeList_t N;
 | 
								ProvWebSocketNotifications::VenueFWUpgradeList_t N;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ProvObjects::Venue Venue;
 | 
								ProvObjects::Venue Venue;
 | 
				
			||||||
			uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0;
 | 
								uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0, pending_=0;
 | 
				
			||||||
			if (StorageService()->VenueDB().GetRecord("id", VenueUUID_, Venue)) {
 | 
								if (StorageService()->VenueDB().GetRecord("id", VenueUUID_, Venue)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				N.content.title = fmt::format("Upgrading {} devices.", Venue.info.name);
 | 
									N.content.title = fmt::format("Upgrading {} devices.", Venue.info.name);
 | 
				
			||||||
@@ -96,8 +100,10 @@ namespace OpenWifi {
 | 
				
			|||||||
				ProvObjects::DeviceRules Rules;
 | 
									ProvObjects::DeviceRules Rules;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				StorageService()->VenueDB().EvaluateDeviceRules(Venue.info.id, Rules);
 | 
									StorageService()->VenueDB().EvaluateDeviceRules(Venue.info.id, Rules);
 | 
				
			||||||
 | 
					                std::vector<std::string> DeviceList;
 | 
				
			||||||
 | 
					                StorageService()->InventoryDB().GetDevicesUUIDForVenue(Venue.info.id, DeviceList);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				for (const auto &uuid : Venue.devices) {
 | 
									for (const auto &uuid : DeviceList) {
 | 
				
			||||||
					auto NewTask =
 | 
										auto NewTask =
 | 
				
			||||||
						new VenueDeviceUpgrade(uuid, Venue.info.name, Revision_, Rules, Logger());
 | 
											new VenueDeviceUpgrade(uuid, Venue.info.name, Revision_, Rules, Logger());
 | 
				
			||||||
					bool TaskAdded = false;
 | 
										bool TaskAdded = false;
 | 
				
			||||||
@@ -121,10 +127,13 @@ namespace OpenWifi {
 | 
				
			|||||||
								N.content.not_connected.push_back(current_job->SerialNumber);
 | 
													N.content.not_connected.push_back(current_job->SerialNumber);
 | 
				
			||||||
							else if (current_job->no_firmware_)
 | 
												else if (current_job->no_firmware_)
 | 
				
			||||||
								N.content.no_firmware.push_back(current_job->SerialNumber);
 | 
													N.content.no_firmware.push_back(current_job->SerialNumber);
 | 
				
			||||||
 | 
					                            else if (current_job->pending_)
 | 
				
			||||||
 | 
					                                N.content.pending.push_back(current_job->SerialNumber);
 | 
				
			||||||
							upgraded_ += current_job->upgraded_;
 | 
												upgraded_ += current_job->upgraded_;
 | 
				
			||||||
							skipped_ += current_job->skipped_;
 | 
												skipped_ += current_job->skipped_;
 | 
				
			||||||
							no_firmware_ += current_job->no_firmware_;
 | 
												no_firmware_ += current_job->no_firmware_;
 | 
				
			||||||
							not_connected_ += current_job->not_connected_;
 | 
												not_connected_ += current_job->not_connected_;
 | 
				
			||||||
 | 
					                            pending_ += current_job->pending_;
 | 
				
			||||||
							job_it = JobList.erase(job_it);
 | 
												job_it = JobList.erase(job_it);
 | 
				
			||||||
							delete current_job;
 | 
												delete current_job;
 | 
				
			||||||
						} else {
 | 
											} else {
 | 
				
			||||||
@@ -146,10 +155,13 @@ namespace OpenWifi {
 | 
				
			|||||||
							N.content.not_connected.push_back(current_job->SerialNumber);
 | 
												N.content.not_connected.push_back(current_job->SerialNumber);
 | 
				
			||||||
						else if (current_job->no_firmware_)
 | 
											else if (current_job->no_firmware_)
 | 
				
			||||||
							N.content.no_firmware.push_back(current_job->SerialNumber);
 | 
												N.content.no_firmware.push_back(current_job->SerialNumber);
 | 
				
			||||||
 | 
					                        else if (current_job->pending_)
 | 
				
			||||||
 | 
					                            N.content.pending.push_back(current_job->SerialNumber);
 | 
				
			||||||
						upgraded_ += current_job->upgraded_;
 | 
											upgraded_ += current_job->upgraded_;
 | 
				
			||||||
						skipped_ += current_job->skipped_;
 | 
											skipped_ += current_job->skipped_;
 | 
				
			||||||
						no_firmware_ += current_job->no_firmware_;
 | 
											no_firmware_ += current_job->no_firmware_;
 | 
				
			||||||
						not_connected_ += current_job->not_connected_;
 | 
											not_connected_ += current_job->not_connected_;
 | 
				
			||||||
 | 
					                        pending_ += current_job->pending_;
 | 
				
			||||||
						job_it = JobList.erase(job_it);
 | 
											job_it = JobList.erase(job_it);
 | 
				
			||||||
						delete current_job;
 | 
											delete current_job;
 | 
				
			||||||
					} else {
 | 
										} else {
 | 
				
			||||||
@@ -158,8 +170,8 @@ namespace OpenWifi {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				N.content.details = fmt::format(
 | 
									N.content.details = fmt::format(
 | 
				
			||||||
					"Job {} Completed: {} upgraded, {} not connected, {} skipped, {} no firmware.",
 | 
										"Job {} Completed: {} upgraded, {} not connected, {} skipped, {} no firmware, {} pending.",
 | 
				
			||||||
					JobId(), upgraded_, not_connected_, skipped_, no_firmware_);
 | 
										JobId(), upgraded_, not_connected_, skipped_, no_firmware_, pending_);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				N.content.details = fmt::format("Venue {} no longer exists.", VenueUUID_);
 | 
									N.content.details = fmt::format("Venue {} no longer exists.", VenueUUID_);
 | 
				
			||||||
				Logger().warning(N.content.details);
 | 
									Logger().warning(N.content.details);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,6 +60,7 @@ namespace OpenWifi::ProvWebSocketNotifications {
 | 
				
			|||||||
		RESTAPI_utils::field_to_json(Obj, "success", success);
 | 
							RESTAPI_utils::field_to_json(Obj, "success", success);
 | 
				
			||||||
		RESTAPI_utils::field_to_json(Obj, "notConnected", not_connected);
 | 
							RESTAPI_utils::field_to_json(Obj, "notConnected", not_connected);
 | 
				
			||||||
		RESTAPI_utils::field_to_json(Obj, "noFirmware", no_firmware);
 | 
							RESTAPI_utils::field_to_json(Obj, "noFirmware", no_firmware);
 | 
				
			||||||
 | 
					        RESTAPI_utils::field_to_json(Obj, "pending", pending);
 | 
				
			||||||
		RESTAPI_utils::field_to_json(Obj, "skipped", skipped);
 | 
							RESTAPI_utils::field_to_json(Obj, "skipped", skipped);
 | 
				
			||||||
		RESTAPI_utils::field_to_json(Obj, "timeStamp", timeStamp);
 | 
							RESTAPI_utils::field_to_json(Obj, "timeStamp", timeStamp);
 | 
				
			||||||
		RESTAPI_utils::field_to_json(Obj, "details", details);
 | 
							RESTAPI_utils::field_to_json(Obj, "details", details);
 | 
				
			||||||
@@ -71,6 +72,7 @@ namespace OpenWifi::ProvWebSocketNotifications {
 | 
				
			|||||||
			RESTAPI_utils::field_from_json(Obj, "jobId", jobId);
 | 
								RESTAPI_utils::field_from_json(Obj, "jobId", jobId);
 | 
				
			||||||
			RESTAPI_utils::field_from_json(Obj, "success", success);
 | 
								RESTAPI_utils::field_from_json(Obj, "success", success);
 | 
				
			||||||
			RESTAPI_utils::field_from_json(Obj, "notConnected", not_connected);
 | 
								RESTAPI_utils::field_from_json(Obj, "notConnected", not_connected);
 | 
				
			||||||
 | 
					            RESTAPI_utils::field_from_json(Obj, "pending", pending);
 | 
				
			||||||
			RESTAPI_utils::field_from_json(Obj, "noFirmware", no_firmware);
 | 
								RESTAPI_utils::field_from_json(Obj, "noFirmware", no_firmware);
 | 
				
			||||||
			RESTAPI_utils::field_from_json(Obj, "skipped", skipped);
 | 
								RESTAPI_utils::field_from_json(Obj, "skipped", skipped);
 | 
				
			||||||
			RESTAPI_utils::field_from_json(Obj, "timeStamp", timeStamp);
 | 
								RESTAPI_utils::field_from_json(Obj, "timeStamp", timeStamp);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@ namespace OpenWifi::ProvWebSocketNotifications {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	struct FWUpgradeList {
 | 
						struct FWUpgradeList {
 | 
				
			||||||
		std::string title, details, jobId;
 | 
							std::string title, details, jobId;
 | 
				
			||||||
		std::vector<std::string> success, skipped, no_firmware, not_connected;
 | 
							std::vector<std::string> success, skipped, no_firmware, not_connected, pending;
 | 
				
			||||||
		uint64_t timeStamp = OpenWifi::Utils::Now();
 | 
							uint64_t timeStamp = OpenWifi::Utils::Now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void to_json(Poco::JSON::Object &Obj) const;
 | 
							void to_json(Poco::JSON::Object &Obj) const;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,17 +4,19 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "ALBserver.h"
 | 
					#include "ALBserver.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/utils.h"
 | 
					 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					 | 
				
			||||||
#include "fmt/format.h"
 | 
					#include "fmt/format.h"
 | 
				
			||||||
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					#include "framework/utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void ALBRequestHandler::handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) {
 | 
						void ALBRequestHandler::handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest &Request,
 | 
				
			||||||
 | 
															  Poco::Net::HTTPServerResponse &Response) {
 | 
				
			||||||
		Utils::SetThreadName("alb-request");
 | 
							Utils::SetThreadName("alb-request");
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			if((id_ % 100) == 0) {
 | 
								if ((id_ % 100) == 0) {
 | 
				
			||||||
				Logger_.debug(fmt::format("ALB-REQUEST({}): ALB Request {}.", Request.clientAddress().toString(), id_));
 | 
									Logger_.debug(fmt::format("ALB-REQUEST({}): ALB Request {}.",
 | 
				
			||||||
 | 
															  Request.clientAddress().toString(), id_));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			Response.setChunkedTransferEncoding(true);
 | 
								Response.setChunkedTransferEncoding(true);
 | 
				
			||||||
			Response.setContentType("text/html");
 | 
								Response.setContentType("text/html");
 | 
				
			||||||
@@ -24,33 +26,29 @@ namespace OpenWifi {
 | 
				
			|||||||
			Response.set("Connection", "keep-alive");
 | 
								Response.set("Connection", "keep-alive");
 | 
				
			||||||
			Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
 | 
								Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
			std::ostream &Answer = Response.send();
 | 
								std::ostream &Answer = Response.send();
 | 
				
			||||||
			Answer << "process Alive and kicking!";
 | 
								Answer << ALBHealthCheckServer()->CallbackText();
 | 
				
			||||||
		} catch (...) {
 | 
							} catch (...) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ALBRequestHandlerFactory::ALBRequestHandlerFactory(Poco::Logger & L):
 | 
						ALBRequestHandlerFactory::ALBRequestHandlerFactory(Poco::Logger &L) : Logger_(L) {}
 | 
				
			||||||
		Logger_(L) {
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ALBRequestHandler* ALBRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest& request) {
 | 
						ALBRequestHandler *
 | 
				
			||||||
 | 
						ALBRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest &request) {
 | 
				
			||||||
		if (request.getURI() == "/")
 | 
							if (request.getURI() == "/")
 | 
				
			||||||
			return new ALBRequestHandler(Logger_, req_id_++);
 | 
								return new ALBRequestHandler(Logger_, req_id_++);
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			return nullptr;
 | 
								return nullptr;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ALBHealthCheckServer::ALBHealthCheckServer() :
 | 
						ALBHealthCheckServer::ALBHealthCheckServer()
 | 
				
			||||||
		  SubSystemServer("ALBHealthCheckServer", "ALB-SVR", "alb")
 | 
							: SubSystemServer("ALBHealthCheckServer", "ALB-SVR", "alb") {}
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int ALBHealthCheckServer::Start() {
 | 
						int ALBHealthCheckServer::Start() {
 | 
				
			||||||
		if(MicroServiceConfigGetBool("alb.enable",false)) {
 | 
							if (MicroServiceConfigGetBool("alb.enable", false)) {
 | 
				
			||||||
            poco_information(Logger(),"Starting...");
 | 
								poco_information(Logger(), "Starting...");
 | 
				
			||||||
			Running_=true;
 | 
								Running_ = true;
 | 
				
			||||||
			Port_ = (int)MicroServiceConfigGetInt("alb.port",15015);
 | 
								Port_ = (int)MicroServiceConfigGetInt("alb.port", 15015);
 | 
				
			||||||
			Poco::Net::IPAddress Addr(Poco::Net::IPAddress::wildcard(
 | 
								Poco::Net::IPAddress Addr(Poco::Net::IPAddress::wildcard(
 | 
				
			||||||
				Poco::Net::Socket::supportsIPv6() ? Poco::Net::AddressFamily::IPv6
 | 
									Poco::Net::Socket::supportsIPv6() ? Poco::Net::AddressFamily::IPv6
 | 
				
			||||||
												  : Poco::Net::AddressFamily::IPv4));
 | 
																	  : Poco::Net::AddressFamily::IPv4));
 | 
				
			||||||
@@ -60,7 +58,8 @@ namespace OpenWifi {
 | 
				
			|||||||
			Socket_ = std::make_unique<Poco::Net::ServerSocket>(SockAddr, Port_);
 | 
								Socket_ = std::make_unique<Poco::Net::ServerSocket>(SockAddr, Port_);
 | 
				
			||||||
			auto Params = new Poco::Net::HTTPServerParams;
 | 
								auto Params = new Poco::Net::HTTPServerParams;
 | 
				
			||||||
			Params->setName("ws:alb");
 | 
								Params->setName("ws:alb");
 | 
				
			||||||
			Server_ = std::make_unique<Poco::Net::HTTPServer>(new ALBRequestHandlerFactory(Logger()), *Socket_, Params);
 | 
								Server_ = std::make_unique<Poco::Net::HTTPServer>(
 | 
				
			||||||
 | 
									new ALBRequestHandlerFactory(Logger()), *Socket_, Params);
 | 
				
			||||||
			Server_->start();
 | 
								Server_->start();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -68,10 +67,10 @@ namespace OpenWifi {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void ALBHealthCheckServer::Stop() {
 | 
						void ALBHealthCheckServer::Stop() {
 | 
				
			||||||
		poco_information(Logger(),"Stopping...");
 | 
							poco_information(Logger(), "Stopping...");
 | 
				
			||||||
		if(Running_)
 | 
							if (Running_)
 | 
				
			||||||
			Server_->stopAll(true);
 | 
								Server_->stopAll(true);
 | 
				
			||||||
		poco_information(Logger(),"Stopped...");
 | 
							poco_information(Logger(), "Stopped...");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -7,37 +7,38 @@
 | 
				
			|||||||
#include "framework/SubSystemServer.h"
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/Net/HTTPRequestHandler.h"
 | 
					#include "Poco/Net/HTTPRequestHandler.h"
 | 
				
			||||||
#include "Poco/Net/HTTPServerRequest.h"
 | 
					 | 
				
			||||||
#include "Poco/Net/HTTPServerResponse.h"
 | 
					 | 
				
			||||||
#include "Poco/Net/HTTPRequestHandlerFactory.h"
 | 
					#include "Poco/Net/HTTPRequestHandlerFactory.h"
 | 
				
			||||||
#include "Poco/Net/HTTPServer.h"
 | 
					#include "Poco/Net/HTTPServer.h"
 | 
				
			||||||
 | 
					#include "Poco/Net/HTTPServerRequest.h"
 | 
				
			||||||
 | 
					#include "Poco/Net/HTTPServerResponse.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class ALBRequestHandler: public Poco::Net::HTTPRequestHandler {
 | 
						class ALBRequestHandler : public Poco::Net::HTTPRequestHandler {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit ALBRequestHandler(Poco::Logger & L, uint64_t id)
 | 
							explicit ALBRequestHandler(Poco::Logger &L, uint64_t id) : Logger_(L), id_(id) {}
 | 
				
			||||||
                : Logger_(L), id_(id) {
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override;
 | 
							void handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest &Request,
 | 
				
			||||||
 | 
											   Poco::Net::HTTPServerResponse &Response) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		Poco::Logger 	& Logger_;
 | 
							Poco::Logger &Logger_;
 | 
				
			||||||
		uint64_t 		id_;
 | 
							uint64_t id_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class ALBRequestHandlerFactory: public Poco::Net::HTTPRequestHandlerFactory
 | 
						class ALBRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit ALBRequestHandlerFactory(Poco::Logger & L);
 | 
							explicit ALBRequestHandlerFactory(Poco::Logger &L);
 | 
				
			||||||
		ALBRequestHandler* createRequestHandler(const Poco::Net::HTTPServerRequest& request) override;
 | 
							ALBRequestHandler *
 | 
				
			||||||
 | 
							createRequestHandler(const Poco::Net::HTTPServerRequest &request) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		Poco::Logger	                            &Logger_;
 | 
							Poco::Logger &Logger_;
 | 
				
			||||||
		inline static std::atomic_uint64_t 			req_id_=1;
 | 
							inline static std::atomic_uint64_t req_id_ = 1;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						typedef std::string ALBHealthMessageCallback();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class ALBHealthCheckServer : public SubSystemServer {
 | 
						class ALBHealthCheckServer : public SubSystemServer {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		ALBHealthCheckServer();
 | 
							ALBHealthCheckServer();
 | 
				
			||||||
@@ -49,15 +50,26 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		int Start() override;
 | 
							int Start() override;
 | 
				
			||||||
		void Stop() override;
 | 
							void Stop() override;
 | 
				
			||||||
 | 
							inline void RegisterExtendedHealthMessage(ALBHealthMessageCallback *F) {
 | 
				
			||||||
 | 
								Callback_=F;
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							inline std::string CallbackText() {
 | 
				
			||||||
 | 
								if(Callback_== nullptr) {
 | 
				
			||||||
 | 
									return "process Alive and kicking!";
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									return Callback_();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::unique_ptr<Poco::Net::HTTPServer>   	Server_;
 | 
							std::unique_ptr<Poco::Net::HTTPServer> Server_;
 | 
				
			||||||
		std::unique_ptr<Poco::Net::ServerSocket> 	Socket_;
 | 
							std::unique_ptr<Poco::Net::ServerSocket> Socket_;
 | 
				
			||||||
		int                                     	Port_ = 0;
 | 
							ALBHealthMessageCallback	*Callback_= nullptr;
 | 
				
			||||||
		mutable std::atomic_bool                    Running_=false;
 | 
							int Port_ = 0;
 | 
				
			||||||
 | 
							mutable std::atomic_bool Running_ = false;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto ALBHealthCheckServer() { return ALBHealthCheckServer::instance(); }
 | 
						inline auto ALBHealthCheckServer() { return ALBHealthCheckServer::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,96 +4,94 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/Logger.h"
 | 
					 | 
				
			||||||
#include "Poco/JSON/Parser.h"
 | 
					#include "Poco/JSON/Parser.h"
 | 
				
			||||||
 | 
					#include "Poco/Logger.h"
 | 
				
			||||||
 | 
					#include "Poco/Net/HTTPSClientSession.h"
 | 
				
			||||||
#include "Poco/Net/HTTPServerRequest.h"
 | 
					#include "Poco/Net/HTTPServerRequest.h"
 | 
				
			||||||
#include "Poco/Net/HTTPServerResponse.h"
 | 
					#include "Poco/Net/HTTPServerResponse.h"
 | 
				
			||||||
#include "Poco/Net/HTTPSClientSession.h"
 | 
					 | 
				
			||||||
#include "Poco/URI.h"
 | 
					#include "Poco/URI.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
    inline void API_Proxy( Poco::Logger &Logger,
 | 
						inline void API_Proxy(Poco::Logger &Logger, Poco::Net::HTTPServerRequest *Request,
 | 
				
			||||||
                    Poco::Net::HTTPServerRequest *Request,
 | 
											  Poco::Net::HTTPServerResponse *Response, const char *ServiceType,
 | 
				
			||||||
                    Poco::Net::HTTPServerResponse *Response,
 | 
											  const char *PathRewrite, uint64_t msTimeout_ = 10000) {
 | 
				
			||||||
                    const char * ServiceType,
 | 
							try {
 | 
				
			||||||
                    const char * PathRewrite,
 | 
								auto Services = MicroServiceGetServices(ServiceType);
 | 
				
			||||||
                    uint64_t msTimeout_ = 10000 ) {
 | 
								for (auto const &Svc : Services) {
 | 
				
			||||||
        try {
 | 
									Poco::URI SourceURI(Request->getURI());
 | 
				
			||||||
            auto Services = MicroServiceGetServices(ServiceType);
 | 
									Poco::URI DestinationURI(Svc.PrivateEndPoint);
 | 
				
			||||||
            for(auto const &Svc:Services) {
 | 
									DestinationURI.setPath(PathRewrite);
 | 
				
			||||||
                Poco::URI   SourceURI(Request->getURI());
 | 
									DestinationURI.setQuery(SourceURI.getQuery());
 | 
				
			||||||
                Poco::URI	DestinationURI(Svc.PrivateEndPoint);
 | 
					 | 
				
			||||||
                DestinationURI.setPath(PathRewrite);
 | 
					 | 
				
			||||||
                DestinationURI.setQuery(SourceURI.getQuery());
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // std::cout << "     Source: " << SourceURI.toString() << std::endl;
 | 
									// std::cout << "     Source: " << SourceURI.toString() << std::endl;
 | 
				
			||||||
                // std::cout << "Destination: " << DestinationURI.toString() << std::endl;
 | 
									// std::cout << "Destination: " << DestinationURI.toString() << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Poco::Net::HTTPSClientSession Session(DestinationURI.getHost(), DestinationURI.getPort());
 | 
									Poco::Net::HTTPSClientSession Session(DestinationURI.getHost(),
 | 
				
			||||||
                Session.setKeepAlive(true);
 | 
																		  DestinationURI.getPort());
 | 
				
			||||||
                Session.setTimeout(Poco::Timespan(msTimeout_/1000, msTimeout_ % 1000));
 | 
									Session.setKeepAlive(true);
 | 
				
			||||||
                Poco::Net::HTTPRequest ProxyRequest(Request->getMethod(),
 | 
									Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
                                                    DestinationURI.getPathAndQuery(),
 | 
									Poco::Net::HTTPRequest ProxyRequest(Request->getMethod(),
 | 
				
			||||||
                                                    Poco::Net::HTTPMessage::HTTP_1_1);
 | 
																		DestinationURI.getPathAndQuery(),
 | 
				
			||||||
                if(Request->has("Authorization")) {
 | 
																		Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
                    ProxyRequest.add("Authorization", Request->get("Authorization"));
 | 
									if (Request->has("Authorization")) {
 | 
				
			||||||
                } else {
 | 
										ProxyRequest.add("Authorization", Request->get("Authorization"));
 | 
				
			||||||
                    ProxyRequest.add("X-API-KEY", Svc.AccessKey);
 | 
									} else {
 | 
				
			||||||
                    ProxyRequest.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
										ProxyRequest.add("X-API-KEY", Svc.AccessKey);
 | 
				
			||||||
                }
 | 
										ProxyRequest.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if(Request->getMethod() == Poco::Net::HTTPRequest::HTTP_DELETE) {
 | 
									if (Request->getMethod() == Poco::Net::HTTPRequest::HTTP_DELETE) {
 | 
				
			||||||
                    Session.sendRequest(ProxyRequest);
 | 
										Session.sendRequest(ProxyRequest);
 | 
				
			||||||
                    Poco::Net::HTTPResponse ProxyResponse;
 | 
										Poco::Net::HTTPResponse ProxyResponse;
 | 
				
			||||||
                    Session.receiveResponse(ProxyResponse);
 | 
										Session.receiveResponse(ProxyResponse);
 | 
				
			||||||
                    Response->setStatus(ProxyResponse.getStatus());
 | 
										Response->setStatus(ProxyResponse.getStatus());
 | 
				
			||||||
                    Response->send();
 | 
										Response->send();
 | 
				
			||||||
                    return;
 | 
										return;
 | 
				
			||||||
                } else {
 | 
									} else {
 | 
				
			||||||
                    Poco::JSON::Parser P;
 | 
										Poco::JSON::Parser P;
 | 
				
			||||||
                    std::stringstream SS;
 | 
										std::stringstream SS;
 | 
				
			||||||
                    try {
 | 
										try {
 | 
				
			||||||
                        auto Body = P.parse(Request->stream()).extract<Poco::JSON::Object::Ptr>();
 | 
											auto Body = P.parse(Request->stream()).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
                        Poco::JSON::Stringifier::condense(Body,SS);
 | 
											Poco::JSON::Stringifier::condense(Body, SS);
 | 
				
			||||||
                        SS << "\r\n\r\n";
 | 
											SS << "\r\n\r\n";
 | 
				
			||||||
                    } catch(const Poco::Exception &E) {
 | 
										} catch (const Poco::Exception &E) {
 | 
				
			||||||
                        Logger.log(E);
 | 
											Logger.log(E);
 | 
				
			||||||
                    }
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if(SS.str().empty()) {
 | 
										if (SS.str().empty()) {
 | 
				
			||||||
                        Session.sendRequest(ProxyRequest);
 | 
											Session.sendRequest(ProxyRequest);
 | 
				
			||||||
                    } else {
 | 
										} else {
 | 
				
			||||||
                        ProxyRequest.setContentType("application/json");
 | 
											ProxyRequest.setContentType("application/json");
 | 
				
			||||||
                        ProxyRequest.setContentLength(SS.str().size());
 | 
											ProxyRequest.setContentLength(SS.str().size());
 | 
				
			||||||
                        std::ostream & os = Session.sendRequest(ProxyRequest);
 | 
											std::ostream &os = Session.sendRequest(ProxyRequest);
 | 
				
			||||||
                        os << SS.str() ;
 | 
											os << SS.str();
 | 
				
			||||||
                    }
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Poco::Net::HTTPResponse ProxyResponse;
 | 
										Poco::Net::HTTPResponse ProxyResponse;
 | 
				
			||||||
                    std::stringstream SSR;
 | 
										std::stringstream SSR;
 | 
				
			||||||
                    try {
 | 
										try {
 | 
				
			||||||
                        std::istream &ProxyResponseStream = Session.receiveResponse(ProxyResponse);
 | 
											std::istream &ProxyResponseStream = Session.receiveResponse(ProxyResponse);
 | 
				
			||||||
                        Poco::JSON::Parser  P2;
 | 
											Poco::JSON::Parser P2;
 | 
				
			||||||
                        auto ProxyResponseBody = P2.parse(ProxyResponseStream).extract<Poco::JSON::Object::Ptr>();
 | 
											auto ProxyResponseBody =
 | 
				
			||||||
                        Poco::JSON::Stringifier::condense(ProxyResponseBody,SSR);
 | 
												P2.parse(ProxyResponseStream).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
                        Response->setContentType("application/json");
 | 
											Poco::JSON::Stringifier::condense(ProxyResponseBody, SSR);
 | 
				
			||||||
                        Response->setContentLength(SSR.str().size());
 | 
											Response->setContentType("application/json");
 | 
				
			||||||
                        Response->setStatus(ProxyResponse.getStatus());
 | 
											Response->setContentLength(SSR.str().size());
 | 
				
			||||||
                        Response->sendBuffer(SSR.str().c_str(),SSR.str().size());
 | 
											Response->setStatus(ProxyResponse.getStatus());
 | 
				
			||||||
                        return;
 | 
											Response->sendBuffer(SSR.str().c_str(), SSR.str().size());
 | 
				
			||||||
                    } catch( const Poco::Exception & E) {
 | 
											return;
 | 
				
			||||||
 | 
										} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										Response->setStatus(ProxyResponse.getStatus());
 | 
				
			||||||
 | 
										Response->send();
 | 
				
			||||||
 | 
										return;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    }
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
                    Response->setStatus(ProxyResponse.getStatus());
 | 
								Logger.log(E);
 | 
				
			||||||
                    Response->send();
 | 
							}
 | 
				
			||||||
                    return;
 | 
						}
 | 
				
			||||||
                }
 | 
					} // namespace OpenWifi
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        } catch (const Poco::Exception &E) {
 | 
					 | 
				
			||||||
            Logger.log(E);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -4,21 +4,22 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
#include <iomanip>
 | 
					#include <iomanip>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/StreamCopier.h"
 | 
					 | 
				
			||||||
#include "Poco/File.h"
 | 
					#include "Poco/File.h"
 | 
				
			||||||
 | 
					#include "Poco/StreamCopier.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/Object.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/Parser.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "nlohmann/json.hpp"
 | 
					// #include "nlohmann/json.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	class AppServiceRegistry {
 | 
						class AppServiceRegistry {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		AppServiceRegistry() {
 | 
							AppServiceRegistry() {
 | 
				
			||||||
@@ -26,77 +27,68 @@ namespace OpenWifi {
 | 
				
			|||||||
			Poco::File F(FileName);
 | 
								Poco::File F(FileName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				if(F.exists()) {
 | 
									if (F.exists()) {
 | 
				
			||||||
					std::ostringstream  OS;
 | 
										std::ostringstream OS;
 | 
				
			||||||
					std::ifstream       IF(FileName);
 | 
										std::ifstream IF(FileName);
 | 
				
			||||||
					Poco::StreamCopier::copyStream(IF, OS);
 | 
					                    Poco::JSON::Parser  P;
 | 
				
			||||||
					Registry_ = nlohmann::json::parse(OS.str());
 | 
										Registry_ = P.parse(IF).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} catch (...) {
 | 
								} catch (...) {
 | 
				
			||||||
				Registry_ = nlohmann::json::parse("{}");
 | 
									Registry_ = Poco::makeShared<Poco::JSON::Object>();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		static AppServiceRegistry & instance() {
 | 
							static AppServiceRegistry &instance() {
 | 
				
			||||||
			static auto instance_= new AppServiceRegistry;
 | 
								static auto instance_ = new AppServiceRegistry;
 | 
				
			||||||
			return *instance_;
 | 
								return *instance_;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline ~AppServiceRegistry() {
 | 
							inline ~AppServiceRegistry() { Save(); }
 | 
				
			||||||
			Save();
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Save() {
 | 
							inline void Save() {
 | 
				
			||||||
			std::istringstream  IS( to_string(Registry_));
 | 
								std::ofstream OF;
 | 
				
			||||||
			std::ofstream       OF;
 | 
								OF.open(FileName, std::ios::binary | std::ios::trunc);
 | 
				
			||||||
			OF.open(FileName,std::ios::binary | std::ios::trunc);
 | 
					            Registry_->stringify(OF);
 | 
				
			||||||
			Poco::StreamCopier::copyStream(IS, OF);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Set(const char *Key, uint64_t Value ) {
 | 
					        void Set(const char *key, const std::vector<std::string> &V) {
 | 
				
			||||||
			Registry_[Key] = Value;
 | 
					            Poco::JSON::Array   Arr;
 | 
				
			||||||
 | 
					            for(const auto &s:V) {
 | 
				
			||||||
 | 
					                Arr.add(s);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            Registry_->set(key,Arr);
 | 
				
			||||||
 | 
					            Save();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        template<class T> void Set(const char *key, const T &Value) {
 | 
				
			||||||
 | 
					            Registry_->set(key,Value);
 | 
				
			||||||
			Save();
 | 
								Save();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Set(const char *Key, const std::string &Value ) {
 | 
					        bool Get(const char *key, std::vector<std::string> &Value) {
 | 
				
			||||||
			Registry_[Key] = Value;
 | 
					            if(Registry_->has(key) && !Registry_->isNull(key) && Registry_->isArray(key)) {
 | 
				
			||||||
			Save();
 | 
					                auto pArr = Registry_->getArray(key);
 | 
				
			||||||
		}
 | 
					                for(const auto &v : *pArr) {
 | 
				
			||||||
 | 
					                    Value.emplace_back(v.toString());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Set(const char *Key, bool Value ) {
 | 
					        template<class T> bool Get(const char *key, T &Value) {
 | 
				
			||||||
			Registry_[Key] = Value;
 | 
					            if(Registry_->has(key) && !Registry_->isNull(key)) {
 | 
				
			||||||
			Save();
 | 
					                Value = Registry_->getValue<T>(key);
 | 
				
			||||||
		}
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
		inline bool Get(const char *Key, bool & Value ) {
 | 
					            return false;
 | 
				
			||||||
			if(Registry_[Key].is_boolean()) {
 | 
					        }
 | 
				
			||||||
				Value = Registry_[Key].get<bool>();
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return false;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		inline bool Get(const char *Key, uint64_t & Value ) {
 | 
					 | 
				
			||||||
			if(Registry_[Key].is_number_unsigned()) {
 | 
					 | 
				
			||||||
				Value = Registry_[Key].get<uint64_t>();
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return false;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		inline bool Get(const char *Key, std::string & Value ) {
 | 
					 | 
				
			||||||
			if(Registry_[Key].is_string()) {
 | 
					 | 
				
			||||||
				Value = Registry_[Key].get<std::string>();
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return false;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::string         FileName;
 | 
							std::string FileName;
 | 
				
			||||||
		nlohmann::json      Registry_;
 | 
							Poco::JSON::Object::Ptr Registry_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto AppServiceRegistry() { return AppServiceRegistry::instance(); }
 | 
						inline auto AppServiceRegistry() { return AppServiceRegistry::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,41 +4,40 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "Poco/Net/HTTPServerResponse.h"
 | 
					#include "Poco/Net/HTTPServerResponse.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "fmt/format.h"
 | 
				
			||||||
#include "framework/AuthClient.h"
 | 
					#include "framework/AuthClient.h"
 | 
				
			||||||
#include "framework/MicroServiceNames.h"
 | 
					#include "framework/MicroServiceNames.h"
 | 
				
			||||||
#include "framework/OpenAPIRequests.h"
 | 
					#include "framework/OpenAPIRequests.h"
 | 
				
			||||||
#include "framework/utils.h"
 | 
					#include "framework/utils.h"
 | 
				
			||||||
#include "fmt/format.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool AuthClient::RetrieveTokenInformation(const std::string & SessionToken,
 | 
						bool AuthClient::RetrieveTokenInformation(const std::string &SessionToken,
 | 
				
			||||||
										 SecurityObjects::UserInfoAndPolicy & UInfo,
 | 
																  SecurityObjects::UserInfoAndPolicy &UInfo,
 | 
				
			||||||
										 std::uint64_t TID,
 | 
																  std::uint64_t TID, bool &Expired, bool &Contacted,
 | 
				
			||||||
										 bool & Expired, bool & Contacted, bool Sub) {
 | 
																  bool Sub) {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			Types::StringPairVec QueryData;
 | 
								Types::StringPairVec QueryData;
 | 
				
			||||||
			QueryData.push_back(std::make_pair("token",SessionToken));
 | 
								QueryData.push_back(std::make_pair("token", SessionToken));
 | 
				
			||||||
            std::string     AlternateURIForLogging = fmt::format("{}?token={}",  Sub ? "/api/v1/validateSubToken" : "/api/v1/validateToken", Utils::SanitizeToken(SessionToken));
 | 
								std::string AlternateURIForLogging = fmt::format(
 | 
				
			||||||
			OpenAPIRequestGet	Req(    uSERVICE_SECURITY,
 | 
									"{}?token={}", Sub ? "/api/v1/validateSubToken" : "/api/v1/validateToken",
 | 
				
			||||||
 | 
									Utils::SanitizeToken(SessionToken));
 | 
				
			||||||
 | 
								OpenAPIRequestGet Req(uSERVICE_SECURITY,
 | 
				
			||||||
								  Sub ? "/api/v1/validateSubToken" : "/api/v1/validateToken",
 | 
													  Sub ? "/api/v1/validateSubToken" : "/api/v1/validateToken",
 | 
				
			||||||
								  QueryData,
 | 
													  QueryData, 10000, AlternateURIForLogging);
 | 
				
			||||||
								  10000,
 | 
					 | 
				
			||||||
								  AlternateURIForLogging
 | 
					 | 
				
			||||||
                                  );
 | 
					 | 
				
			||||||
			Poco::JSON::Object::Ptr Response;
 | 
								Poco::JSON::Object::Ptr Response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			auto StatusCode = Req.Do(Response);
 | 
								auto StatusCode = Req.Do(Response);
 | 
				
			||||||
			if(StatusCode==Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT) {
 | 
								if (StatusCode == Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT) {
 | 
				
			||||||
				Contacted = false;
 | 
									Contacted = false;
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Contacted = true;
 | 
								Contacted = true;
 | 
				
			||||||
			if(StatusCode==Poco::Net::HTTPServerResponse::HTTP_OK) {
 | 
								if (StatusCode == Poco::Net::HTTPServerResponse::HTTP_OK) {
 | 
				
			||||||
				if(Response->has("tokenInfo") && Response->has("userInfo")) {
 | 
									if (Response->has("tokenInfo") && Response->has("userInfo")) {
 | 
				
			||||||
					UInfo.from_json(Response);
 | 
										UInfo.from_json(Response);
 | 
				
			||||||
					if(IsTokenExpired(UInfo.webtoken)) {
 | 
										if (IsTokenExpired(UInfo.webtoken)) {
 | 
				
			||||||
						Expired = true;
 | 
											Expired = true;
 | 
				
			||||||
						return false;
 | 
											return false;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
@@ -50,18 +49,19 @@ namespace OpenWifi {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} catch (...) {
 | 
							} catch (...) {
 | 
				
			||||||
			poco_error(Logger(),fmt::format("Failed to retrieve token={} for TID={}", Utils::SanitizeToken(SessionToken), TID));
 | 
								poco_error(Logger(), fmt::format("Failed to retrieve token={} for TID={}",
 | 
				
			||||||
 | 
																 Utils::SanitizeToken(SessionToken), TID));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Expired = false;
 | 
							Expired = false;
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool AuthClient::IsAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo,
 | 
						bool AuthClient::IsAuthorized(const std::string &SessionToken,
 | 
				
			||||||
							 std::uint64_t TID,
 | 
													  SecurityObjects::UserInfoAndPolicy &UInfo, std::uint64_t TID,
 | 
				
			||||||
							 bool & Expired, bool & Contacted, bool Sub) {
 | 
													  bool &Expired, bool &Contacted, bool Sub) {
 | 
				
			||||||
		auto User = Cache_.get(SessionToken);
 | 
							auto User = Cache_.get(SessionToken);
 | 
				
			||||||
		if(!User.isNull()) {
 | 
							if (!User.isNull()) {
 | 
				
			||||||
			if(IsTokenExpired(User->webtoken)) {
 | 
								if (IsTokenExpired(User->webtoken)) {
 | 
				
			||||||
				Expired = true;
 | 
									Expired = true;
 | 
				
			||||||
				Cache_.remove(SessionToken);
 | 
									Cache_.remove(SessionToken);
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
@@ -73,57 +73,60 @@ namespace OpenWifi {
 | 
				
			|||||||
		return RetrieveTokenInformation(SessionToken, UInfo, TID, Expired, Contacted, Sub);
 | 
							return RetrieveTokenInformation(SessionToken, UInfo, TID, Expired, Contacted, Sub);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool AuthClient::RetrieveApiKeyInformation(const std::string & SessionToken,
 | 
						bool AuthClient::RetrieveApiKeyInformation(const std::string &SessionToken,
 | 
				
			||||||
                                              SecurityObjects::UserInfoAndPolicy & UInfo,
 | 
																   SecurityObjects::UserInfoAndPolicy &UInfo,
 | 
				
			||||||
                                              std::uint64_t TID,
 | 
																   std::uint64_t TID, bool &Expired, bool &Contacted,
 | 
				
			||||||
                                              bool & Expired, bool & Contacted, [[maybe_unused]] bool & Suspended) {
 | 
																   [[maybe_unused]] bool &Suspended) {
 | 
				
			||||||
        try {
 | 
							try {
 | 
				
			||||||
            Types::StringPairVec QueryData;
 | 
								Types::StringPairVec QueryData;
 | 
				
			||||||
            QueryData.push_back(std::make_pair("apikey",SessionToken));
 | 
								QueryData.push_back(std::make_pair("apikey", SessionToken));
 | 
				
			||||||
            std::string     AlternateURIForLogging = fmt::format("/api/v1/validateApiKey?apiKey={}", Utils::SanitizeToken(SessionToken));
 | 
								std::string AlternateURIForLogging =
 | 
				
			||||||
            OpenAPIRequestGet	Req(    uSERVICE_SECURITY,
 | 
									fmt::format("/api/v1/validateApiKey?apiKey={}", Utils::SanitizeToken(SessionToken));
 | 
				
			||||||
                                         "/api/v1/validateApiKey" ,
 | 
								OpenAPIRequestGet Req(uSERVICE_SECURITY, "/api/v1/validateApiKey", QueryData, 10000,
 | 
				
			||||||
                                         QueryData,
 | 
													  AlternateURIForLogging);
 | 
				
			||||||
                                         10000,
 | 
								Poco::JSON::Object::Ptr Response;
 | 
				
			||||||
                                         AlternateURIForLogging);
 | 
					 | 
				
			||||||
            Poco::JSON::Object::Ptr Response;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            auto StatusCode = Req.Do(Response);
 | 
								auto StatusCode = Req.Do(Response);
 | 
				
			||||||
            if(StatusCode==Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT) {
 | 
								if (StatusCode == Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT) {
 | 
				
			||||||
                Contacted = false;
 | 
									Contacted = false;
 | 
				
			||||||
                return false;
 | 
									return false;
 | 
				
			||||||
            }
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Contacted = true;
 | 
								Contacted = true;
 | 
				
			||||||
            if(StatusCode==Poco::Net::HTTPServerResponse::HTTP_OK) {
 | 
								if (StatusCode == Poco::Net::HTTPServerResponse::HTTP_OK) {
 | 
				
			||||||
                if(Response->has("tokenInfo") && Response->has("userInfo") && Response->has("expiresOn")) {
 | 
									if (Response->has("tokenInfo") && Response->has("userInfo") &&
 | 
				
			||||||
                    UInfo.from_json(Response);
 | 
										Response->has("expiresOn")) {
 | 
				
			||||||
                    Expired = false;
 | 
										UInfo.from_json(Response);
 | 
				
			||||||
                    ApiKeyCache_.update(SessionToken, ApiKeyCacheEntry{ .UserInfo = UInfo, .ExpiresOn = Response->get("expiresOn")});
 | 
										Expired = false;
 | 
				
			||||||
                    return true;
 | 
										ApiKeyCache_.update(SessionToken,
 | 
				
			||||||
                } else {
 | 
															ApiKeyCacheEntry{.UserInfo = UInfo,
 | 
				
			||||||
                    return false;
 | 
																			 .ExpiresOn = Response->get("expiresOn")});
 | 
				
			||||||
                }
 | 
										return true;
 | 
				
			||||||
            }
 | 
									} else {
 | 
				
			||||||
        } catch (...) {
 | 
										return false;
 | 
				
			||||||
            poco_error(Logger(),fmt::format("Failed to retrieve api key={} for TID={}", Utils::SanitizeToken(SessionToken), TID));
 | 
									}
 | 
				
			||||||
        }
 | 
								}
 | 
				
			||||||
        Expired = false;
 | 
							} catch (...) {
 | 
				
			||||||
        return false;
 | 
								poco_error(Logger(), fmt::format("Failed to retrieve api key={} for TID={}",
 | 
				
			||||||
    }
 | 
																 Utils::SanitizeToken(SessionToken), TID));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							Expired = false;
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool AuthClient::IsValidApiKey(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy &UInfo,
 | 
						bool AuthClient::IsValidApiKey(const std::string &SessionToken,
 | 
				
			||||||
                                   std::uint64_t TID, bool &Expired, bool &Contacted, bool & Suspended) {
 | 
													   SecurityObjects::UserInfoAndPolicy &UInfo, std::uint64_t TID,
 | 
				
			||||||
        auto User = ApiKeyCache_.get(SessionToken);
 | 
													   bool &Expired, bool &Contacted, bool &Suspended) {
 | 
				
			||||||
        if (!User.isNull()) {
 | 
							auto User = ApiKeyCache_.get(SessionToken);
 | 
				
			||||||
            if(User->ExpiresOn < Utils::Now()) {
 | 
							if (!User.isNull()) {
 | 
				
			||||||
                Expired = false;
 | 
								if (User->ExpiresOn < Utils::Now()) {
 | 
				
			||||||
                UInfo = User->UserInfo;
 | 
									Expired = false;
 | 
				
			||||||
                return true;
 | 
									UInfo = User->UserInfo;
 | 
				
			||||||
            }
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			ApiKeyCache_.remove(SessionToken);
 | 
								ApiKeyCache_.remove(SessionToken);
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
        return RetrieveApiKeyInformation(SessionToken, UInfo, TID, Expired, Contacted, Suspended);
 | 
							return RetrieveApiKeyInformation(SessionToken, UInfo, TID, Expired, Contacted, Suspended);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -4,9 +4,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/SubSystemServer.h"
 | 
					 | 
				
			||||||
#include "RESTObjects/RESTAPI_SecurityObjects.h"
 | 
					 | 
				
			||||||
#include "Poco/ExpireLRUCache.h"
 | 
					#include "Poco/ExpireLRUCache.h"
 | 
				
			||||||
 | 
					#include "RESTObjects/RESTAPI_SecurityObjects.h"
 | 
				
			||||||
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
#include "framework/utils.h"
 | 
					#include "framework/utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
@@ -14,66 +14,59 @@ namespace OpenWifi {
 | 
				
			|||||||
	class AuthClient : public SubSystemServer {
 | 
						class AuthClient : public SubSystemServer {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit AuthClient() noexcept:
 | 
							explicit AuthClient() noexcept
 | 
				
			||||||
			 SubSystemServer("Authentication", "AUTH-CLNT", "authentication")
 | 
								: SubSystemServer("Authentication", "AUTH-CLNT", "authentication") {}
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		static auto instance() {
 | 
							static auto instance() {
 | 
				
			||||||
			static auto instance_ = new AuthClient;
 | 
								static auto instance_ = new AuthClient;
 | 
				
			||||||
			return instance_;
 | 
								return instance_;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        struct ApiKeyCacheEntry {
 | 
							struct ApiKeyCacheEntry {
 | 
				
			||||||
            OpenWifi::SecurityObjects::UserInfoAndPolicy    UserInfo;
 | 
								OpenWifi::SecurityObjects::UserInfoAndPolicy UserInfo;
 | 
				
			||||||
            std::uint64_t                                   ExpiresOn;
 | 
								std::uint64_t ExpiresOn;
 | 
				
			||||||
        };
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        inline int Start() override {
 | 
							inline int Start() override { return 0; }
 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Stop() override {
 | 
							inline void Stop() override {
 | 
				
			||||||
			poco_information(Logger(),"Stopping...");
 | 
								poco_information(Logger(), "Stopping...");
 | 
				
			||||||
			std::lock_guard	G(Mutex_);
 | 
								std::lock_guard G(Mutex_);
 | 
				
			||||||
			Cache_.clear();
 | 
								Cache_.clear();
 | 
				
			||||||
			poco_information(Logger(),"Stopped...");
 | 
								poco_information(Logger(), "Stopped...");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void RemovedCachedToken(const std::string &Token) {
 | 
							inline void RemovedCachedToken(const std::string &Token) {
 | 
				
			||||||
			Cache_.remove(Token);
 | 
								Cache_.remove(Token);
 | 
				
			||||||
            ApiKeyCache_.remove(Token);
 | 
								ApiKeyCache_.remove(Token);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) {
 | 
							inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) {
 | 
				
			||||||
			return ((T.expires_in_+T.created_) < Utils::Now());
 | 
								return ((T.expires_in_ + T.created_) < Utils::Now());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool RetrieveTokenInformation(const std::string & SessionToken,
 | 
							bool RetrieveTokenInformation(const std::string &SessionToken,
 | 
				
			||||||
			SecurityObjects::UserInfoAndPolicy & UInfo,
 | 
														  SecurityObjects::UserInfoAndPolicy &UInfo, std::uint64_t TID,
 | 
				
			||||||
			std::uint64_t TID,
 | 
														  bool &Expired, bool &Contacted, bool Sub = false);
 | 
				
			||||||
		bool & Expired, bool & Contacted, bool Sub=false);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool RetrieveApiKeyInformation(const std::string & SessionToken,
 | 
							bool RetrieveApiKeyInformation(const std::string &SessionToken,
 | 
				
			||||||
                                      SecurityObjects::UserInfoAndPolicy & UInfo,
 | 
														   SecurityObjects::UserInfoAndPolicy &UInfo, std::uint64_t TID,
 | 
				
			||||||
                                      std::uint64_t TID,
 | 
														   bool &Expired, bool &Contacted, bool &Suspended);
 | 
				
			||||||
                                      bool & Expired, bool & Contacted, bool & Suspended);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool IsAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo,
 | 
							bool IsAuthorized(const std::string &SessionToken,
 | 
				
			||||||
								 std::uint64_t TID,
 | 
											  SecurityObjects::UserInfoAndPolicy &UInfo, std::uint64_t TID,
 | 
				
			||||||
								 bool & Expired, bool & Contacted, bool Sub = false);
 | 
											  bool &Expired, bool &Contacted, bool Sub = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool IsValidApiKey(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo,
 | 
							bool IsValidApiKey(const std::string &SessionToken,
 | 
				
			||||||
                          std::uint64_t TID,
 | 
											   SecurityObjects::UserInfoAndPolicy &UInfo, std::uint64_t TID,
 | 
				
			||||||
                          bool & Expired, bool & Contacted, bool & Suspended) ;
 | 
											   bool &Expired, bool &Contacted, bool &Suspended);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
 | 
							Poco::ExpireLRUCache<std::string, OpenWifi::SecurityObjects::UserInfoAndPolicy> Cache_{
 | 
				
			||||||
		Poco::ExpireLRUCache<std::string,OpenWifi::SecurityObjects::UserInfoAndPolicy>      Cache_{512,1200000 };
 | 
								512, 1200000};
 | 
				
			||||||
        Poco::ExpireLRUCache<std::string,ApiKeyCacheEntry>                                  ApiKeyCache_{512,1200000 };
 | 
							Poco::ExpireLRUCache<std::string, ApiKeyCacheEntry> ApiKeyCache_{512, 1200000};
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto AuthClient() { return AuthClient::instance(); }
 | 
						inline auto AuthClient() { return AuthClient::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,13 +21,13 @@ namespace OpenWifi::CIDR {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static bool cidr6_match(const in6_addr &address, const in6_addr &network, uint8_t bits) {
 | 
						static bool cidr6_match(const in6_addr &address, const in6_addr &network, uint8_t bits) {
 | 
				
			||||||
	#ifdef __linux__
 | 
					#ifdef __linux__
 | 
				
			||||||
		const uint32_t *a = address.s6_addr32;
 | 
							const uint32_t *a = address.s6_addr32;
 | 
				
			||||||
		const uint32_t *n = network.s6_addr32;
 | 
							const uint32_t *n = network.s6_addr32;
 | 
				
			||||||
	#else
 | 
					#else
 | 
				
			||||||
		const uint32_t *a = address.__u6_addr.__u6_addr32;
 | 
							const uint32_t *a = address.__u6_addr.__u6_addr32;
 | 
				
			||||||
		const uint32_t *n = network.__u6_addr.__u6_addr32;
 | 
							const uint32_t *n = network.__u6_addr.__u6_addr32;
 | 
				
			||||||
	#endif
 | 
					#endif
 | 
				
			||||||
		int bits_whole, bits_incomplete;
 | 
							int bits_whole, bits_incomplete;
 | 
				
			||||||
		bits_whole = bits >> 5;		   // number of whole u32
 | 
							bits_whole = bits >> 5;		   // number of whole u32
 | 
				
			||||||
		bits_incomplete = bits & 0x1F; // number of bits in incomplete u32
 | 
							bits_incomplete = bits & 0x1F; // number of bits in incomplete u32
 | 
				
			||||||
@@ -152,4 +152,4 @@ namespace OpenWifi::CIDR {
 | 
				
			|||||||
	[[nodiscard]] inline bool ValidateIpRanges(const Types::StringVec &Ranges) {
 | 
						[[nodiscard]] inline bool ValidateIpRanges(const Types::StringVec &Ranges) {
 | 
				
			||||||
		return std::all_of(cbegin(Ranges), cend(Ranges), ValidateRange);
 | 
							return std::all_of(cbegin(Ranges), cend(Ranges), ValidateRange);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi::CIDR
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -7,43 +7,52 @@
 | 
				
			|||||||
#include "framework/SubSystemServer.h"
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <valijson/adapters/poco_json_adapter.hpp>
 | 
					#include <valijson/adapters/poco_json_adapter.hpp>
 | 
				
			||||||
#include <valijson/utils/poco_json_utils.hpp>
 | 
					 | 
				
			||||||
#include <valijson/schema.hpp>
 | 
					 | 
				
			||||||
#include <valijson/schema_parser.hpp>
 | 
					 | 
				
			||||||
#include <valijson/validator.hpp>
 | 
					 | 
				
			||||||
#include <valijson/constraints/constraint.hpp>
 | 
					#include <valijson/constraints/constraint.hpp>
 | 
				
			||||||
#include <valijson/constraints/constraint_visitor.hpp>
 | 
					#include <valijson/constraints/constraint_visitor.hpp>
 | 
				
			||||||
 | 
					#include <valijson/schema.hpp>
 | 
				
			||||||
 | 
					#include <valijson/schema_parser.hpp>
 | 
				
			||||||
 | 
					#include <valijson/utils/poco_json_utils.hpp>
 | 
				
			||||||
 | 
					#include <valijson/validator.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
    class ConfigurationValidator : public  SubSystemServer {
 | 
						class ConfigurationValidator : public SubSystemServer {
 | 
				
			||||||
    public:
 | 
						  public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static auto instance() {
 | 
							enum class ConfigurationType { AP = 0 , SWITCH = 1};
 | 
				
			||||||
            static auto instance_ = new ConfigurationValidator;
 | 
					 | 
				
			||||||
            return instance_;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool Validate(const std::string &C, std::vector<std::string> &Errors, bool Strict);
 | 
							static auto instance() {
 | 
				
			||||||
        int Start() override;
 | 
								static auto instance_ = new ConfigurationValidator;
 | 
				
			||||||
        void Stop() override;
 | 
								return instance_;
 | 
				
			||||||
        void reinitialize(Poco::Util::Application &self) override;
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private:
 | 
							bool Validate(ConfigurationType Type, const std::string &C, std::string &Errors, bool Strict);
 | 
				
			||||||
        bool            					Initialized_=false;
 | 
							int Start() override;
 | 
				
			||||||
        bool            					Working_=false;
 | 
							void Stop() override;
 | 
				
			||||||
        void            					Init();
 | 
							void reinitialize(Poco::Util::Application &self) override;
 | 
				
			||||||
		std::unique_ptr<valijson::Schema>						RootSchema_;
 | 
					 | 
				
			||||||
		std::unique_ptr<valijson::SchemaParser>  				SchemaParser_;
 | 
					 | 
				
			||||||
		std::unique_ptr<valijson::adapters::PocoJsonAdapter> 	PocoJsonAdapter_;
 | 
					 | 
				
			||||||
		Poco::JSON::Object::Ptr 			SchemaDocPtr_;
 | 
					 | 
				
			||||||
		bool 								SetSchema(const std::string &SchemaStr);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ConfigurationValidator():
 | 
							inline static ConfigurationType GetType(const std::string &type) {
 | 
				
			||||||
            SubSystemServer("ConfigValidator", "CFG-VALIDATOR", "config.validator") {
 | 
								std::string Type = Poco::toUpper(type);
 | 
				
			||||||
        }
 | 
								if (Type == "AP")
 | 
				
			||||||
    };
 | 
									return ConfigurationType::AP;
 | 
				
			||||||
 | 
								if (Type == "SWITCH")
 | 
				
			||||||
 | 
									return ConfigurationType::SWITCH;
 | 
				
			||||||
 | 
								return ConfigurationType::AP;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline auto ConfigurationValidator() { return ConfigurationValidator::instance(); }
 | 
						  private:
 | 
				
			||||||
    inline bool ValidateUCentralConfiguration(const std::string &C, std::vector<std::string> &Error, bool strict) { return ConfigurationValidator::instance()->Validate(C, Error, strict); }
 | 
							bool Initialized_ = false;
 | 
				
			||||||
}
 | 
							bool Working_ = false;
 | 
				
			||||||
 | 
							void Init();
 | 
				
			||||||
 | 
							std::array<valijson::Schema,2> 			RootSchema_;
 | 
				
			||||||
 | 
							bool SetSchema(ConfigurationType Type, const std::string &SchemaStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ConfigurationValidator()
 | 
				
			||||||
 | 
								: SubSystemServer("ConfigValidator", "CFG-VALIDATOR", "config.validator") {}
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						inline auto ConfigurationValidator() { return ConfigurationValidator::instance(); }
 | 
				
			||||||
 | 
						inline bool ValidateUCentralConfiguration(ConfigurationValidator::ConfigurationType Type, const std::string &C, std::string &Errors,
 | 
				
			||||||
 | 
																  bool strict) {
 | 
				
			||||||
 | 
							return ConfigurationValidator::instance()->Validate(Type, C, Errors, strict);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,268 +4,266 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <vector>
 | 
					 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
#include <utility>
 | 
					#include <utility>
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    struct CountryInfo {
 | 
					 | 
				
			||||||
        std::string     code;
 | 
					 | 
				
			||||||
        std::string     name;
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    inline static const std::vector<CountryInfo> CountryCodes {
 | 
					 | 
				
			||||||
        { .code= "US", .name= "United States" },
 | 
					 | 
				
			||||||
        { .code= "GB", .name= "United Kingdom" },
 | 
					 | 
				
			||||||
        { .code= "CA", .name= "Canada" },
 | 
					 | 
				
			||||||
        { .code= "AF", .name= "Afghanistan" },
 | 
					 | 
				
			||||||
        { .code= "AX", .name= "Aland Islands" },
 | 
					 | 
				
			||||||
        { .code= "AL", .name= "Albania" },
 | 
					 | 
				
			||||||
        { .code= "DZ", .name= "Algeria" },
 | 
					 | 
				
			||||||
        { .code= "AS", .name= "American Samoa" },
 | 
					 | 
				
			||||||
        { .code= "AD", .name= "Andorra" },
 | 
					 | 
				
			||||||
        { .code= "AO", .name= "Angola" },
 | 
					 | 
				
			||||||
        { .code= "AI", .name= "Anguilla" },
 | 
					 | 
				
			||||||
        { .code= "AQ", .name= "Antarctica" },
 | 
					 | 
				
			||||||
        { .code= "AG", .name= "Antigua And Barbuda" },
 | 
					 | 
				
			||||||
        { .code= "AR", .name= "Argentina" },
 | 
					 | 
				
			||||||
        { .code= "AM", .name= "Armenia" },
 | 
					 | 
				
			||||||
        { .code= "AN", .name= "Netherlands Antilles" },
 | 
					 | 
				
			||||||
        { .code= "AW", .name= "Aruba" },
 | 
					 | 
				
			||||||
        { .code= "AU", .name= "Australia" },
 | 
					 | 
				
			||||||
        { .code= "AT", .name= "Austria" },
 | 
					 | 
				
			||||||
        { .code= "AZ", .name= "Azerbaijan" },
 | 
					 | 
				
			||||||
        { .code= "BS", .name= "Bahamas" },
 | 
					 | 
				
			||||||
        { .code= "BH", .name= "Bahrain" },
 | 
					 | 
				
			||||||
        { .code= "BD", .name= "Bangladesh" },
 | 
					 | 
				
			||||||
        { .code= "BB", .name= "Barbados" },
 | 
					 | 
				
			||||||
        { .code= "BY", .name= "Belarus" },
 | 
					 | 
				
			||||||
        { .code= "BE", .name= "Belgium" },
 | 
					 | 
				
			||||||
        { .code= "BZ", .name= "Belize" },
 | 
					 | 
				
			||||||
        { .code= "BJ", .name= "Benin" },
 | 
					 | 
				
			||||||
        { .code= "BM", .name= "Bermuda" },
 | 
					 | 
				
			||||||
        { .code= "BT", .name= "Bhutan" },
 | 
					 | 
				
			||||||
        { .code= "BO", .name= "Bolivia" },
 | 
					 | 
				
			||||||
        { .code= "BA", .name= "Bosnia And Herzegovina" },
 | 
					 | 
				
			||||||
        { .code= "BW", .name= "Botswana" },
 | 
					 | 
				
			||||||
        { .code= "BV", .name= "Bouvet Island" },
 | 
					 | 
				
			||||||
        { .code= "BR", .name= "Brazil" },
 | 
					 | 
				
			||||||
        { .code= "IO", .name= "British Indian Ocean Territory" },
 | 
					 | 
				
			||||||
        { .code= "BN", .name= "Brunei Darussalam" },
 | 
					 | 
				
			||||||
        { .code= "BG", .name= "Bulgaria" },
 | 
					 | 
				
			||||||
        { .code= "BF", .name= "Burkina Faso" },
 | 
					 | 
				
			||||||
        { .code= "BI", .name= "Burundi" },
 | 
					 | 
				
			||||||
        { .code= "KH", .name= "Cambodia" },
 | 
					 | 
				
			||||||
        { .code= "CM", .name= "Cameroon" },
 | 
					 | 
				
			||||||
        { .code= "CA", .name= "Canada" },
 | 
					 | 
				
			||||||
        { .code= "CV", .name= "Cape Verde" },
 | 
					 | 
				
			||||||
        { .code= "KY", .name= "Cayman Islands" },
 | 
					 | 
				
			||||||
        { .code= "CF", .name= "Central African Republic" },
 | 
					 | 
				
			||||||
        { .code= "TD", .name= "Chad" },
 | 
					 | 
				
			||||||
        { .code= "CL", .name= "Chile" },
 | 
					 | 
				
			||||||
        { .code= "CN", .name= "China" },
 | 
					 | 
				
			||||||
        { .code= "CX", .name= "Christmas Island" },
 | 
					 | 
				
			||||||
        { .code= "CC", .name= "Cocos (Keeling) Islands" },
 | 
					 | 
				
			||||||
        { .code= "CO", .name= "Colombia" },
 | 
					 | 
				
			||||||
        { .code= "KM", .name= "Comoros" },
 | 
					 | 
				
			||||||
        { .code= "CG", .name= "Congo" },
 | 
					 | 
				
			||||||
        { .code= "CD", .name= "Congo, Democratic Republic" },
 | 
					 | 
				
			||||||
        { .code= "CK", .name= "Cook Islands" },
 | 
					 | 
				
			||||||
        { .code= "CR", .name= "Costa Rica" },
 | 
					 | 
				
			||||||
        { .code= "CI", .name= "Cote D\"Ivoire" },
 | 
					 | 
				
			||||||
        { .code= "HR", .name= "Croatia" },
 | 
					 | 
				
			||||||
        { .code= "CU", .name= "Cuba" },
 | 
					 | 
				
			||||||
        { .code= "CY", .name= "Cyprus" },
 | 
					 | 
				
			||||||
        { .code= "CZ", .name= "Czech Republic" },
 | 
					 | 
				
			||||||
        { .code= "DK", .name= "Denmark" },
 | 
					 | 
				
			||||||
        { .code= "DJ", .name= "Djibouti" },
 | 
					 | 
				
			||||||
        { .code= "DM", .name= "Dominica" },
 | 
					 | 
				
			||||||
        { .code= "DO", .name= "Dominican Republic" },
 | 
					 | 
				
			||||||
        { .code= "EC", .name= "Ecuador" },
 | 
					 | 
				
			||||||
        { .code= "EG", .name= "Egypt" },
 | 
					 | 
				
			||||||
        { .code= "SV", .name= "El Salvador" },
 | 
					 | 
				
			||||||
        { .code= "GQ", .name= "Equatorial Guinea" },
 | 
					 | 
				
			||||||
        { .code= "ER", .name= "Eritrea" },
 | 
					 | 
				
			||||||
        { .code= "EE", .name= "Estonia" },
 | 
					 | 
				
			||||||
        { .code= "ET", .name= "Ethiopia" },
 | 
					 | 
				
			||||||
        { .code= "FK", .name= "Falkland Islands (Malvinas)" },
 | 
					 | 
				
			||||||
        { .code= "FO", .name= "Faroe Islands" },
 | 
					 | 
				
			||||||
        { .code= "FJ", .name= "Fiji" },
 | 
					 | 
				
			||||||
        { .code= "FI", .name= "Finland" },
 | 
					 | 
				
			||||||
        { .code= "FR", .name= "France" },
 | 
					 | 
				
			||||||
        { .code= "GF", .name= "French Guiana" },
 | 
					 | 
				
			||||||
        { .code= "PF", .name= "French Polynesia" },
 | 
					 | 
				
			||||||
        { .code= "TF", .name= "French Southern Territories" },
 | 
					 | 
				
			||||||
        { .code= "GA", .name= "Gabon" },
 | 
					 | 
				
			||||||
        { .code= "GM", .name= "Gambia" },
 | 
					 | 
				
			||||||
        { .code= "GE", .name= "Georgia" },
 | 
					 | 
				
			||||||
        { .code= "DE", .name= "Germany" },
 | 
					 | 
				
			||||||
        { .code= "GH", .name= "Ghana" },
 | 
					 | 
				
			||||||
        { .code= "GI", .name= "Gibraltar" },
 | 
					 | 
				
			||||||
        { .code= "GR", .name= "Greece" },
 | 
					 | 
				
			||||||
        { .code= "GL", .name= "Greenland" },
 | 
					 | 
				
			||||||
        { .code= "GD", .name= "Grenada" },
 | 
					 | 
				
			||||||
        { .code= "GP", .name= "Guadeloupe" },
 | 
					 | 
				
			||||||
        { .code= "GU", .name= "Guam" },
 | 
					 | 
				
			||||||
        { .code= "GT", .name= "Guatemala" },
 | 
					 | 
				
			||||||
        { .code= "GG", .name= "Guernsey" },
 | 
					 | 
				
			||||||
        { .code= "GN", .name= "Guinea" },
 | 
					 | 
				
			||||||
        { .code= "GW", .name= "Guinea-Bissau" },
 | 
					 | 
				
			||||||
        { .code= "GY", .name= "Guyana" },
 | 
					 | 
				
			||||||
        { .code= "HT", .name= "Haiti" },
 | 
					 | 
				
			||||||
        { .code= "HM", .name= "Heard Island & Mcdonald Islands" },
 | 
					 | 
				
			||||||
        { .code= "VA", .name= "Holy See (Vatican City State)" },
 | 
					 | 
				
			||||||
        { .code= "HN", .name= "Honduras" },
 | 
					 | 
				
			||||||
        { .code= "HK", .name= "Hong Kong" },
 | 
					 | 
				
			||||||
        { .code= "HU", .name= "Hungary" },
 | 
					 | 
				
			||||||
        { .code= "IS", .name= "Iceland" },
 | 
					 | 
				
			||||||
        { .code= "IN", .name= "India" },
 | 
					 | 
				
			||||||
        { .code= "ID", .name= "Indonesia" },
 | 
					 | 
				
			||||||
        { .code= "IR", .name= "Iran, Islamic Republic Of" },
 | 
					 | 
				
			||||||
        { .code= "IQ", .name= "Iraq" },
 | 
					 | 
				
			||||||
        { .code= "IE", .name= "Ireland" },
 | 
					 | 
				
			||||||
        { .code= "IM", .name= "Isle Of Man" },
 | 
					 | 
				
			||||||
        { .code= "IL", .name= "Israel" },
 | 
					 | 
				
			||||||
        { .code= "IT", .name= "Italy" },
 | 
					 | 
				
			||||||
        { .code= "JM", .name= "Jamaica" },
 | 
					 | 
				
			||||||
        { .code= "JP", .name= "Japan" },
 | 
					 | 
				
			||||||
        { .code= "JE", .name= "Jersey" },
 | 
					 | 
				
			||||||
        { .code= "JO", .name= "Jordan" },
 | 
					 | 
				
			||||||
        { .code= "KZ", .name= "Kazakhstan" },
 | 
					 | 
				
			||||||
        { .code= "KE", .name= "Kenya" },
 | 
					 | 
				
			||||||
        { .code= "KI", .name= "Kiribati" },
 | 
					 | 
				
			||||||
        { .code= "KR", .name= "Korea" },
 | 
					 | 
				
			||||||
        { .code= "KW", .name= "Kuwait" },
 | 
					 | 
				
			||||||
        { .code= "KG", .name= "Kyrgyzstan" },
 | 
					 | 
				
			||||||
        { .code= "LA", .name= "Lao People\"s Democratic Republic" },
 | 
					 | 
				
			||||||
        { .code= "LV", .name= "Latvia" },
 | 
					 | 
				
			||||||
        { .code= "LB", .name= "Lebanon" },
 | 
					 | 
				
			||||||
        { .code= "LS", .name= "Lesotho" },
 | 
					 | 
				
			||||||
        { .code= "LR", .name= "Liberia" },
 | 
					 | 
				
			||||||
        { .code= "LY", .name= "Libyan Arab Jamahiriya" },
 | 
					 | 
				
			||||||
        { .code= "LI", .name= "Liechtenstein" },
 | 
					 | 
				
			||||||
        { .code= "LT", .name= "Lithuania" },
 | 
					 | 
				
			||||||
        { .code= "LU", .name= "Luxembourg" },
 | 
					 | 
				
			||||||
        { .code= "MO", .name= "Macao" },
 | 
					 | 
				
			||||||
        { .code= "MK", .name= "Macedonia" },
 | 
					 | 
				
			||||||
        { .code= "MG", .name= "Madagascar" },
 | 
					 | 
				
			||||||
        { .code= "MW", .name= "Malawi" },
 | 
					 | 
				
			||||||
        { .code= "MY", .name= "Malaysia" },
 | 
					 | 
				
			||||||
        { .code= "MV", .name= "Maldives" },
 | 
					 | 
				
			||||||
        { .code= "ML", .name= "Mali" },
 | 
					 | 
				
			||||||
        { .code= "MT", .name= "Malta" },
 | 
					 | 
				
			||||||
        { .code= "MH", .name= "Marshall Islands" },
 | 
					 | 
				
			||||||
        { .code= "MQ", .name= "Martinique" },
 | 
					 | 
				
			||||||
        { .code= "MR", .name= "Mauritania" },
 | 
					 | 
				
			||||||
        { .code= "MU", .name= "Mauritius" },
 | 
					 | 
				
			||||||
        { .code= "YT", .name= "Mayotte" },
 | 
					 | 
				
			||||||
        { .code= "MX", .name= "Mexico" },
 | 
					 | 
				
			||||||
        { .code= "FM", .name= "Micronesia, Federated States Of" },
 | 
					 | 
				
			||||||
        { .code= "MD", .name= "Moldova" },
 | 
					 | 
				
			||||||
        { .code= "MC", .name= "Monaco" },
 | 
					 | 
				
			||||||
        { .code= "MN", .name= "Mongolia" },
 | 
					 | 
				
			||||||
        { .code= "ME", .name= "Montenegro" },
 | 
					 | 
				
			||||||
        { .code= "MS", .name= "Montserrat" },
 | 
					 | 
				
			||||||
        { .code= "MA", .name= "Morocco" },
 | 
					 | 
				
			||||||
        { .code= "MZ", .name= "Mozambique" },
 | 
					 | 
				
			||||||
        { .code= "MM", .name= "Myanmar" },
 | 
					 | 
				
			||||||
        { .code= "NA", .name= "Namibia" },
 | 
					 | 
				
			||||||
        { .code= "NR", .name= "Nauru" },
 | 
					 | 
				
			||||||
        { .code= "NP", .name= "Nepal" },
 | 
					 | 
				
			||||||
        { .code= "NL", .name= "Netherlands" },
 | 
					 | 
				
			||||||
        { .code= "AN", .name= "Netherlands Antilles" },
 | 
					 | 
				
			||||||
        { .code= "NC", .name= "New Caledonia" },
 | 
					 | 
				
			||||||
        { .code= "NZ", .name= "New Zealand" },
 | 
					 | 
				
			||||||
        { .code= "NI", .name= "Nicaragua" },
 | 
					 | 
				
			||||||
        { .code= "NE", .name= "Niger" },
 | 
					 | 
				
			||||||
        { .code= "NG", .name= "Nigeria" },
 | 
					 | 
				
			||||||
        { .code= "NU", .name= "Niue" },
 | 
					 | 
				
			||||||
        { .code= "NF", .name= "Norfolk Island" },
 | 
					 | 
				
			||||||
        { .code= "MP", .name= "Northern Mariana Islands" },
 | 
					 | 
				
			||||||
        { .code= "NO", .name= "Norway" },
 | 
					 | 
				
			||||||
        { .code= "OM", .name= "Oman" },
 | 
					 | 
				
			||||||
        { .code= "PK", .name= "Pakistan" },
 | 
					 | 
				
			||||||
        { .code= "PW", .name= "Palau" },
 | 
					 | 
				
			||||||
        { .code= "PS", .name= "Palestinian Territory, Occupied" },
 | 
					 | 
				
			||||||
        { .code= "PA", .name= "Panama" },
 | 
					 | 
				
			||||||
        { .code= "PG", .name= "Papua New Guinea" },
 | 
					 | 
				
			||||||
        { .code= "PY", .name= "Paraguay" },
 | 
					 | 
				
			||||||
        { .code= "PE", .name= "Peru" },
 | 
					 | 
				
			||||||
        { .code= "PH", .name= "Philippines" },
 | 
					 | 
				
			||||||
        { .code= "PN", .name= "Pitcairn" },
 | 
					 | 
				
			||||||
        { .code= "PL", .name= "Poland" },
 | 
					 | 
				
			||||||
        { .code= "PT", .name= "Portugal" },
 | 
					 | 
				
			||||||
        { .code= "PR", .name= "Puerto Rico" },
 | 
					 | 
				
			||||||
        { .code= "QA", .name= "Qatar" },
 | 
					 | 
				
			||||||
        { .code= "RE", .name= "Reunion" },
 | 
					 | 
				
			||||||
        { .code= "RO", .name= "Romania" },
 | 
					 | 
				
			||||||
        { .code= "RU", .name= "Russian Federation" },
 | 
					 | 
				
			||||||
        { .code= "RW", .name= "Rwanda" },
 | 
					 | 
				
			||||||
        { .code= "BL", .name= "Saint Barthelemy" },
 | 
					 | 
				
			||||||
        { .code= "SH", .name= "Saint Helena" },
 | 
					 | 
				
			||||||
        { .code= "KN", .name= "Saint Kitts And Nevis" },
 | 
					 | 
				
			||||||
        { .code= "LC", .name= "Saint Lucia" },
 | 
					 | 
				
			||||||
        { .code= "MF", .name= "Saint Martin" },
 | 
					 | 
				
			||||||
        { .code= "PM", .name= "Saint Pierre And Miquelon" },
 | 
					 | 
				
			||||||
        { .code= "VC", .name= "Saint Vincent And Grenadines" },
 | 
					 | 
				
			||||||
        { .code= "WS", .name= "Samoa" },
 | 
					 | 
				
			||||||
        { .code= "SM", .name= "San Marino" },
 | 
					 | 
				
			||||||
        { .code= "ST", .name= "Sao Tome And Principe" },
 | 
					 | 
				
			||||||
        { .code= "SA", .name= "Saudi Arabia" },
 | 
					 | 
				
			||||||
        { .code= "SN", .name= "Senegal" },
 | 
					 | 
				
			||||||
        { .code= "RS", .name= "Serbia" },
 | 
					 | 
				
			||||||
        { .code= "SC", .name= "Seychelles" },
 | 
					 | 
				
			||||||
        { .code= "SL", .name= "Sierra Leone" },
 | 
					 | 
				
			||||||
        { .code= "SG", .name= "Singapore" },
 | 
					 | 
				
			||||||
        { .code= "SK", .name= "Slovakia" },
 | 
					 | 
				
			||||||
        { .code= "SI", .name= "Slovenia" },
 | 
					 | 
				
			||||||
        { .code= "SB", .name= "Solomon Islands" },
 | 
					 | 
				
			||||||
        { .code= "SO", .name= "Somalia" },
 | 
					 | 
				
			||||||
        { .code= "ZA", .name= "South Africa" },
 | 
					 | 
				
			||||||
        { .code= "GS", .name= "South Georgia And Sandwich Isl." },
 | 
					 | 
				
			||||||
        { .code= "ES", .name= "Spain" },
 | 
					 | 
				
			||||||
        { .code= "LK", .name= "Sri Lanka" },
 | 
					 | 
				
			||||||
        { .code= "SD", .name= "Sudan" },
 | 
					 | 
				
			||||||
        { .code= "SR", .name= "Suriname" },
 | 
					 | 
				
			||||||
        { .code= "SJ", .name= "Svalbard And Jan Mayen" },
 | 
					 | 
				
			||||||
        { .code= "SZ", .name= "Swaziland" },
 | 
					 | 
				
			||||||
        { .code= "SE", .name= "Sweden" },
 | 
					 | 
				
			||||||
        { .code= "CH", .name= "Switzerland" },
 | 
					 | 
				
			||||||
        { .code= "SY", .name= "Syrian Arab Republic" },
 | 
					 | 
				
			||||||
        { .code= "TW", .name= "Taiwan" },
 | 
					 | 
				
			||||||
        { .code= "TJ", .name= "Tajikistan" },
 | 
					 | 
				
			||||||
        { .code= "TZ", .name= "Tanzania" },
 | 
					 | 
				
			||||||
        { .code= "TH", .name= "Thailand" },
 | 
					 | 
				
			||||||
        { .code= "TL", .name= "Timor-Leste" },
 | 
					 | 
				
			||||||
        { .code= "TG", .name= "Togo" },
 | 
					 | 
				
			||||||
        { .code= "TK", .name= "Tokelau" },
 | 
					 | 
				
			||||||
        { .code= "TO", .name= "Tonga" },
 | 
					 | 
				
			||||||
        { .code= "TT", .name= "Trinidad And Tobago" },
 | 
					 | 
				
			||||||
        { .code= "TN", .name= "Tunisia" },
 | 
					 | 
				
			||||||
        { .code= "TR", .name= "Turkey" },
 | 
					 | 
				
			||||||
        { .code= "TM", .name= "Turkmenistan" },
 | 
					 | 
				
			||||||
        { .code= "TC", .name= "Turks And Caicos Islands" },
 | 
					 | 
				
			||||||
        { .code= "TV", .name= "Tuvalu" },
 | 
					 | 
				
			||||||
        { .code= "UG", .name= "Uganda" },
 | 
					 | 
				
			||||||
        { .code= "UA", .name= "Ukraine" },
 | 
					 | 
				
			||||||
        { .code= "AE", .name= "United Arab Emirates" },
 | 
					 | 
				
			||||||
        { .code= "GB", .name= "United Kingdom" },
 | 
					 | 
				
			||||||
        { .code= "US", .name= "United States" },
 | 
					 | 
				
			||||||
        { .code= "UM", .name= "United States Outlying Islands" },
 | 
					 | 
				
			||||||
        { .code= "UY", .name= "Uruguay" },
 | 
					 | 
				
			||||||
        { .code= "UZ", .name= "Uzbekistan" },
 | 
					 | 
				
			||||||
        { .code= "VU", .name= "Vanuatu" },
 | 
					 | 
				
			||||||
        { .code= "VE", .name= "Venezuela" },
 | 
					 | 
				
			||||||
        { .code= "VN", .name= "Viet Nam" },
 | 
					 | 
				
			||||||
        { .code= "VG", .name= "Virgin Islands, British" },
 | 
					 | 
				
			||||||
        { .code= "VI", .name= "Virgin Islands, U.S." },
 | 
					 | 
				
			||||||
        { .code= "WF", .name= "Wallis And Futuna" },
 | 
					 | 
				
			||||||
        { .code= "EH", .name= "Western Sahara" },
 | 
					 | 
				
			||||||
        { .code= "YE", .name= "Yemen" },
 | 
					 | 
				
			||||||
        { .code= "ZM", .name= "Zambia" },
 | 
					 | 
				
			||||||
        { .code= "ZW", .name= "Zimbabwe" }
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
						struct CountryInfo {
 | 
				
			||||||
 | 
							std::string code;
 | 
				
			||||||
 | 
							std::string name;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						inline static const std::vector<CountryInfo> CountryCodes{
 | 
				
			||||||
 | 
							{.code = "US", .name = "United States"},
 | 
				
			||||||
 | 
							{.code = "GB", .name = "United Kingdom"},
 | 
				
			||||||
 | 
							{.code = "CA", .name = "Canada"},
 | 
				
			||||||
 | 
							{.code = "AF", .name = "Afghanistan"},
 | 
				
			||||||
 | 
							{.code = "AX", .name = "Aland Islands"},
 | 
				
			||||||
 | 
							{.code = "AL", .name = "Albania"},
 | 
				
			||||||
 | 
							{.code = "DZ", .name = "Algeria"},
 | 
				
			||||||
 | 
							{.code = "AS", .name = "American Samoa"},
 | 
				
			||||||
 | 
							{.code = "AD", .name = "Andorra"},
 | 
				
			||||||
 | 
							{.code = "AO", .name = "Angola"},
 | 
				
			||||||
 | 
							{.code = "AI", .name = "Anguilla"},
 | 
				
			||||||
 | 
							{.code = "AQ", .name = "Antarctica"},
 | 
				
			||||||
 | 
							{.code = "AG", .name = "Antigua And Barbuda"},
 | 
				
			||||||
 | 
							{.code = "AR", .name = "Argentina"},
 | 
				
			||||||
 | 
							{.code = "AM", .name = "Armenia"},
 | 
				
			||||||
 | 
							{.code = "AN", .name = "Netherlands Antilles"},
 | 
				
			||||||
 | 
							{.code = "AW", .name = "Aruba"},
 | 
				
			||||||
 | 
							{.code = "AU", .name = "Australia"},
 | 
				
			||||||
 | 
							{.code = "AT", .name = "Austria"},
 | 
				
			||||||
 | 
							{.code = "AZ", .name = "Azerbaijan"},
 | 
				
			||||||
 | 
							{.code = "BS", .name = "Bahamas"},
 | 
				
			||||||
 | 
							{.code = "BH", .name = "Bahrain"},
 | 
				
			||||||
 | 
							{.code = "BD", .name = "Bangladesh"},
 | 
				
			||||||
 | 
							{.code = "BB", .name = "Barbados"},
 | 
				
			||||||
 | 
							{.code = "BY", .name = "Belarus"},
 | 
				
			||||||
 | 
							{.code = "BE", .name = "Belgium"},
 | 
				
			||||||
 | 
							{.code = "BZ", .name = "Belize"},
 | 
				
			||||||
 | 
							{.code = "BJ", .name = "Benin"},
 | 
				
			||||||
 | 
							{.code = "BM", .name = "Bermuda"},
 | 
				
			||||||
 | 
							{.code = "BT", .name = "Bhutan"},
 | 
				
			||||||
 | 
							{.code = "BO", .name = "Bolivia"},
 | 
				
			||||||
 | 
							{.code = "BA", .name = "Bosnia And Herzegovina"},
 | 
				
			||||||
 | 
							{.code = "BW", .name = "Botswana"},
 | 
				
			||||||
 | 
							{.code = "BV", .name = "Bouvet Island"},
 | 
				
			||||||
 | 
							{.code = "BR", .name = "Brazil"},
 | 
				
			||||||
 | 
							{.code = "IO", .name = "British Indian Ocean Territory"},
 | 
				
			||||||
 | 
							{.code = "BN", .name = "Brunei Darussalam"},
 | 
				
			||||||
 | 
							{.code = "BG", .name = "Bulgaria"},
 | 
				
			||||||
 | 
							{.code = "BF", .name = "Burkina Faso"},
 | 
				
			||||||
 | 
							{.code = "BI", .name = "Burundi"},
 | 
				
			||||||
 | 
							{.code = "KH", .name = "Cambodia"},
 | 
				
			||||||
 | 
							{.code = "CM", .name = "Cameroon"},
 | 
				
			||||||
 | 
							{.code = "CA", .name = "Canada"},
 | 
				
			||||||
 | 
							{.code = "CV", .name = "Cape Verde"},
 | 
				
			||||||
 | 
							{.code = "KY", .name = "Cayman Islands"},
 | 
				
			||||||
 | 
							{.code = "CF", .name = "Central African Republic"},
 | 
				
			||||||
 | 
							{.code = "TD", .name = "Chad"},
 | 
				
			||||||
 | 
							{.code = "CL", .name = "Chile"},
 | 
				
			||||||
 | 
							{.code = "CN", .name = "China"},
 | 
				
			||||||
 | 
							{.code = "CX", .name = "Christmas Island"},
 | 
				
			||||||
 | 
							{.code = "CC", .name = "Cocos (Keeling) Islands"},
 | 
				
			||||||
 | 
							{.code = "CO", .name = "Colombia"},
 | 
				
			||||||
 | 
							{.code = "KM", .name = "Comoros"},
 | 
				
			||||||
 | 
							{.code = "CG", .name = "Congo"},
 | 
				
			||||||
 | 
							{.code = "CD", .name = "Congo, Democratic Republic"},
 | 
				
			||||||
 | 
							{.code = "CK", .name = "Cook Islands"},
 | 
				
			||||||
 | 
							{.code = "CR", .name = "Costa Rica"},
 | 
				
			||||||
 | 
							{.code = "CI", .name = "Cote D\"Ivoire"},
 | 
				
			||||||
 | 
							{.code = "HR", .name = "Croatia"},
 | 
				
			||||||
 | 
							{.code = "CU", .name = "Cuba"},
 | 
				
			||||||
 | 
							{.code = "CY", .name = "Cyprus"},
 | 
				
			||||||
 | 
							{.code = "CZ", .name = "Czech Republic"},
 | 
				
			||||||
 | 
							{.code = "DK", .name = "Denmark"},
 | 
				
			||||||
 | 
							{.code = "DJ", .name = "Djibouti"},
 | 
				
			||||||
 | 
							{.code = "DM", .name = "Dominica"},
 | 
				
			||||||
 | 
							{.code = "DO", .name = "Dominican Republic"},
 | 
				
			||||||
 | 
							{.code = "EC", .name = "Ecuador"},
 | 
				
			||||||
 | 
							{.code = "EG", .name = "Egypt"},
 | 
				
			||||||
 | 
							{.code = "SV", .name = "El Salvador"},
 | 
				
			||||||
 | 
							{.code = "GQ", .name = "Equatorial Guinea"},
 | 
				
			||||||
 | 
							{.code = "ER", .name = "Eritrea"},
 | 
				
			||||||
 | 
							{.code = "EE", .name = "Estonia"},
 | 
				
			||||||
 | 
							{.code = "ET", .name = "Ethiopia"},
 | 
				
			||||||
 | 
							{.code = "FK", .name = "Falkland Islands (Malvinas)"},
 | 
				
			||||||
 | 
							{.code = "FO", .name = "Faroe Islands"},
 | 
				
			||||||
 | 
							{.code = "FJ", .name = "Fiji"},
 | 
				
			||||||
 | 
							{.code = "FI", .name = "Finland"},
 | 
				
			||||||
 | 
							{.code = "FR", .name = "France"},
 | 
				
			||||||
 | 
							{.code = "GF", .name = "French Guiana"},
 | 
				
			||||||
 | 
							{.code = "PF", .name = "French Polynesia"},
 | 
				
			||||||
 | 
							{.code = "TF", .name = "French Southern Territories"},
 | 
				
			||||||
 | 
							{.code = "GA", .name = "Gabon"},
 | 
				
			||||||
 | 
							{.code = "GM", .name = "Gambia"},
 | 
				
			||||||
 | 
							{.code = "GE", .name = "Georgia"},
 | 
				
			||||||
 | 
							{.code = "DE", .name = "Germany"},
 | 
				
			||||||
 | 
							{.code = "GH", .name = "Ghana"},
 | 
				
			||||||
 | 
							{.code = "GI", .name = "Gibraltar"},
 | 
				
			||||||
 | 
							{.code = "GR", .name = "Greece"},
 | 
				
			||||||
 | 
							{.code = "GL", .name = "Greenland"},
 | 
				
			||||||
 | 
							{.code = "GD", .name = "Grenada"},
 | 
				
			||||||
 | 
							{.code = "GP", .name = "Guadeloupe"},
 | 
				
			||||||
 | 
							{.code = "GU", .name = "Guam"},
 | 
				
			||||||
 | 
							{.code = "GT", .name = "Guatemala"},
 | 
				
			||||||
 | 
							{.code = "GG", .name = "Guernsey"},
 | 
				
			||||||
 | 
							{.code = "GN", .name = "Guinea"},
 | 
				
			||||||
 | 
							{.code = "GW", .name = "Guinea-Bissau"},
 | 
				
			||||||
 | 
							{.code = "GY", .name = "Guyana"},
 | 
				
			||||||
 | 
							{.code = "HT", .name = "Haiti"},
 | 
				
			||||||
 | 
							{.code = "HM", .name = "Heard Island & Mcdonald Islands"},
 | 
				
			||||||
 | 
							{.code = "VA", .name = "Holy See (Vatican City State)"},
 | 
				
			||||||
 | 
							{.code = "HN", .name = "Honduras"},
 | 
				
			||||||
 | 
							{.code = "HK", .name = "Hong Kong"},
 | 
				
			||||||
 | 
							{.code = "HU", .name = "Hungary"},
 | 
				
			||||||
 | 
							{.code = "IS", .name = "Iceland"},
 | 
				
			||||||
 | 
							{.code = "IN", .name = "India"},
 | 
				
			||||||
 | 
							{.code = "ID", .name = "Indonesia"},
 | 
				
			||||||
 | 
							{.code = "IR", .name = "Iran, Islamic Republic Of"},
 | 
				
			||||||
 | 
							{.code = "IQ", .name = "Iraq"},
 | 
				
			||||||
 | 
							{.code = "IE", .name = "Ireland"},
 | 
				
			||||||
 | 
							{.code = "IM", .name = "Isle Of Man"},
 | 
				
			||||||
 | 
							{.code = "IL", .name = "Israel"},
 | 
				
			||||||
 | 
							{.code = "IT", .name = "Italy"},
 | 
				
			||||||
 | 
							{.code = "JM", .name = "Jamaica"},
 | 
				
			||||||
 | 
							{.code = "JP", .name = "Japan"},
 | 
				
			||||||
 | 
							{.code = "JE", .name = "Jersey"},
 | 
				
			||||||
 | 
							{.code = "JO", .name = "Jordan"},
 | 
				
			||||||
 | 
							{.code = "KZ", .name = "Kazakhstan"},
 | 
				
			||||||
 | 
							{.code = "KE", .name = "Kenya"},
 | 
				
			||||||
 | 
							{.code = "KI", .name = "Kiribati"},
 | 
				
			||||||
 | 
							{.code = "KR", .name = "Korea"},
 | 
				
			||||||
 | 
							{.code = "KW", .name = "Kuwait"},
 | 
				
			||||||
 | 
							{.code = "KG", .name = "Kyrgyzstan"},
 | 
				
			||||||
 | 
							{.code = "LA", .name = "Lao People\"s Democratic Republic"},
 | 
				
			||||||
 | 
							{.code = "LV", .name = "Latvia"},
 | 
				
			||||||
 | 
							{.code = "LB", .name = "Lebanon"},
 | 
				
			||||||
 | 
							{.code = "LS", .name = "Lesotho"},
 | 
				
			||||||
 | 
							{.code = "LR", .name = "Liberia"},
 | 
				
			||||||
 | 
							{.code = "LY", .name = "Libyan Arab Jamahiriya"},
 | 
				
			||||||
 | 
							{.code = "LI", .name = "Liechtenstein"},
 | 
				
			||||||
 | 
							{.code = "LT", .name = "Lithuania"},
 | 
				
			||||||
 | 
							{.code = "LU", .name = "Luxembourg"},
 | 
				
			||||||
 | 
							{.code = "MO", .name = "Macao"},
 | 
				
			||||||
 | 
							{.code = "MK", .name = "Macedonia"},
 | 
				
			||||||
 | 
							{.code = "MG", .name = "Madagascar"},
 | 
				
			||||||
 | 
							{.code = "MW", .name = "Malawi"},
 | 
				
			||||||
 | 
							{.code = "MY", .name = "Malaysia"},
 | 
				
			||||||
 | 
							{.code = "MV", .name = "Maldives"},
 | 
				
			||||||
 | 
							{.code = "ML", .name = "Mali"},
 | 
				
			||||||
 | 
							{.code = "MT", .name = "Malta"},
 | 
				
			||||||
 | 
							{.code = "MH", .name = "Marshall Islands"},
 | 
				
			||||||
 | 
							{.code = "MQ", .name = "Martinique"},
 | 
				
			||||||
 | 
							{.code = "MR", .name = "Mauritania"},
 | 
				
			||||||
 | 
							{.code = "MU", .name = "Mauritius"},
 | 
				
			||||||
 | 
							{.code = "YT", .name = "Mayotte"},
 | 
				
			||||||
 | 
							{.code = "MX", .name = "Mexico"},
 | 
				
			||||||
 | 
							{.code = "FM", .name = "Micronesia, Federated States Of"},
 | 
				
			||||||
 | 
							{.code = "MD", .name = "Moldova"},
 | 
				
			||||||
 | 
							{.code = "MC", .name = "Monaco"},
 | 
				
			||||||
 | 
							{.code = "MN", .name = "Mongolia"},
 | 
				
			||||||
 | 
							{.code = "ME", .name = "Montenegro"},
 | 
				
			||||||
 | 
							{.code = "MS", .name = "Montserrat"},
 | 
				
			||||||
 | 
							{.code = "MA", .name = "Morocco"},
 | 
				
			||||||
 | 
							{.code = "MZ", .name = "Mozambique"},
 | 
				
			||||||
 | 
							{.code = "MM", .name = "Myanmar"},
 | 
				
			||||||
 | 
							{.code = "NA", .name = "Namibia"},
 | 
				
			||||||
 | 
							{.code = "NR", .name = "Nauru"},
 | 
				
			||||||
 | 
							{.code = "NP", .name = "Nepal"},
 | 
				
			||||||
 | 
							{.code = "NL", .name = "Netherlands"},
 | 
				
			||||||
 | 
							{.code = "AN", .name = "Netherlands Antilles"},
 | 
				
			||||||
 | 
							{.code = "NC", .name = "New Caledonia"},
 | 
				
			||||||
 | 
							{.code = "NZ", .name = "New Zealand"},
 | 
				
			||||||
 | 
							{.code = "NI", .name = "Nicaragua"},
 | 
				
			||||||
 | 
							{.code = "NE", .name = "Niger"},
 | 
				
			||||||
 | 
							{.code = "NG", .name = "Nigeria"},
 | 
				
			||||||
 | 
							{.code = "NU", .name = "Niue"},
 | 
				
			||||||
 | 
							{.code = "NF", .name = "Norfolk Island"},
 | 
				
			||||||
 | 
							{.code = "MP", .name = "Northern Mariana Islands"},
 | 
				
			||||||
 | 
							{.code = "NO", .name = "Norway"},
 | 
				
			||||||
 | 
							{.code = "OM", .name = "Oman"},
 | 
				
			||||||
 | 
							{.code = "PK", .name = "Pakistan"},
 | 
				
			||||||
 | 
							{.code = "PW", .name = "Palau"},
 | 
				
			||||||
 | 
							{.code = "PS", .name = "Palestinian Territory, Occupied"},
 | 
				
			||||||
 | 
							{.code = "PA", .name = "Panama"},
 | 
				
			||||||
 | 
							{.code = "PG", .name = "Papua New Guinea"},
 | 
				
			||||||
 | 
							{.code = "PY", .name = "Paraguay"},
 | 
				
			||||||
 | 
							{.code = "PE", .name = "Peru"},
 | 
				
			||||||
 | 
							{.code = "PH", .name = "Philippines"},
 | 
				
			||||||
 | 
							{.code = "PN", .name = "Pitcairn"},
 | 
				
			||||||
 | 
							{.code = "PL", .name = "Poland"},
 | 
				
			||||||
 | 
							{.code = "PT", .name = "Portugal"},
 | 
				
			||||||
 | 
							{.code = "PR", .name = "Puerto Rico"},
 | 
				
			||||||
 | 
							{.code = "QA", .name = "Qatar"},
 | 
				
			||||||
 | 
							{.code = "RE", .name = "Reunion"},
 | 
				
			||||||
 | 
							{.code = "RO", .name = "Romania"},
 | 
				
			||||||
 | 
							{.code = "RU", .name = "Russian Federation"},
 | 
				
			||||||
 | 
							{.code = "RW", .name = "Rwanda"},
 | 
				
			||||||
 | 
							{.code = "BL", .name = "Saint Barthelemy"},
 | 
				
			||||||
 | 
							{.code = "SH", .name = "Saint Helena"},
 | 
				
			||||||
 | 
							{.code = "KN", .name = "Saint Kitts And Nevis"},
 | 
				
			||||||
 | 
							{.code = "LC", .name = "Saint Lucia"},
 | 
				
			||||||
 | 
							{.code = "MF", .name = "Saint Martin"},
 | 
				
			||||||
 | 
							{.code = "PM", .name = "Saint Pierre And Miquelon"},
 | 
				
			||||||
 | 
							{.code = "VC", .name = "Saint Vincent And Grenadines"},
 | 
				
			||||||
 | 
							{.code = "WS", .name = "Samoa"},
 | 
				
			||||||
 | 
							{.code = "SM", .name = "San Marino"},
 | 
				
			||||||
 | 
							{.code = "ST", .name = "Sao Tome And Principe"},
 | 
				
			||||||
 | 
							{.code = "SA", .name = "Saudi Arabia"},
 | 
				
			||||||
 | 
							{.code = "SN", .name = "Senegal"},
 | 
				
			||||||
 | 
							{.code = "RS", .name = "Serbia"},
 | 
				
			||||||
 | 
							{.code = "SC", .name = "Seychelles"},
 | 
				
			||||||
 | 
							{.code = "SL", .name = "Sierra Leone"},
 | 
				
			||||||
 | 
							{.code = "SG", .name = "Singapore"},
 | 
				
			||||||
 | 
							{.code = "SK", .name = "Slovakia"},
 | 
				
			||||||
 | 
							{.code = "SI", .name = "Slovenia"},
 | 
				
			||||||
 | 
							{.code = "SB", .name = "Solomon Islands"},
 | 
				
			||||||
 | 
							{.code = "SO", .name = "Somalia"},
 | 
				
			||||||
 | 
							{.code = "ZA", .name = "South Africa"},
 | 
				
			||||||
 | 
							{.code = "GS", .name = "South Georgia And Sandwich Isl."},
 | 
				
			||||||
 | 
							{.code = "ES", .name = "Spain"},
 | 
				
			||||||
 | 
							{.code = "LK", .name = "Sri Lanka"},
 | 
				
			||||||
 | 
							{.code = "SD", .name = "Sudan"},
 | 
				
			||||||
 | 
							{.code = "SR", .name = "Suriname"},
 | 
				
			||||||
 | 
							{.code = "SJ", .name = "Svalbard And Jan Mayen"},
 | 
				
			||||||
 | 
							{.code = "SZ", .name = "Swaziland"},
 | 
				
			||||||
 | 
							{.code = "SE", .name = "Sweden"},
 | 
				
			||||||
 | 
							{.code = "CH", .name = "Switzerland"},
 | 
				
			||||||
 | 
							{.code = "SY", .name = "Syrian Arab Republic"},
 | 
				
			||||||
 | 
							{.code = "TW", .name = "Taiwan"},
 | 
				
			||||||
 | 
							{.code = "TJ", .name = "Tajikistan"},
 | 
				
			||||||
 | 
							{.code = "TZ", .name = "Tanzania"},
 | 
				
			||||||
 | 
							{.code = "TH", .name = "Thailand"},
 | 
				
			||||||
 | 
							{.code = "TL", .name = "Timor-Leste"},
 | 
				
			||||||
 | 
							{.code = "TG", .name = "Togo"},
 | 
				
			||||||
 | 
							{.code = "TK", .name = "Tokelau"},
 | 
				
			||||||
 | 
							{.code = "TO", .name = "Tonga"},
 | 
				
			||||||
 | 
							{.code = "TT", .name = "Trinidad And Tobago"},
 | 
				
			||||||
 | 
							{.code = "TN", .name = "Tunisia"},
 | 
				
			||||||
 | 
							{.code = "TR", .name = "Turkey"},
 | 
				
			||||||
 | 
							{.code = "TM", .name = "Turkmenistan"},
 | 
				
			||||||
 | 
							{.code = "TC", .name = "Turks And Caicos Islands"},
 | 
				
			||||||
 | 
							{.code = "TV", .name = "Tuvalu"},
 | 
				
			||||||
 | 
							{.code = "UG", .name = "Uganda"},
 | 
				
			||||||
 | 
							{.code = "UA", .name = "Ukraine"},
 | 
				
			||||||
 | 
							{.code = "AE", .name = "United Arab Emirates"},
 | 
				
			||||||
 | 
							{.code = "GB", .name = "United Kingdom"},
 | 
				
			||||||
 | 
							{.code = "US", .name = "United States"},
 | 
				
			||||||
 | 
							{.code = "UM", .name = "United States Outlying Islands"},
 | 
				
			||||||
 | 
							{.code = "UY", .name = "Uruguay"},
 | 
				
			||||||
 | 
							{.code = "UZ", .name = "Uzbekistan"},
 | 
				
			||||||
 | 
							{.code = "VU", .name = "Vanuatu"},
 | 
				
			||||||
 | 
							{.code = "VE", .name = "Venezuela"},
 | 
				
			||||||
 | 
							{.code = "VN", .name = "Viet Nam"},
 | 
				
			||||||
 | 
							{.code = "VG", .name = "Virgin Islands, British"},
 | 
				
			||||||
 | 
							{.code = "VI", .name = "Virgin Islands, U.S."},
 | 
				
			||||||
 | 
							{.code = "WF", .name = "Wallis And Futuna"},
 | 
				
			||||||
 | 
							{.code = "EH", .name = "Western Sahara"},
 | 
				
			||||||
 | 
							{.code = "YE", .name = "Yemen"},
 | 
				
			||||||
 | 
							{.code = "ZM", .name = "Zambia"},
 | 
				
			||||||
 | 
							{.code = "ZW", .name = "Zimbabwe"}};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,45 +4,44 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "framework/EventBusManager.h"
 | 
					#include "framework/EventBusManager.h"
 | 
				
			||||||
#include "framework/KafkaManager.h"
 | 
					#include "framework/KafkaManager.h"
 | 
				
			||||||
#include "framework/utils.h"
 | 
					 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					#include "framework/utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	EventBusManager::EventBusManager(Poco::Logger &L) :
 | 
					 | 
				
			||||||
		Logger_(L) {
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void EventBusManager::run() {
 | 
						void EventBusManager::run() {
 | 
				
			||||||
		Running_ = true;
 | 
							Running_ = true;
 | 
				
			||||||
		Utils::SetThreadName("fmwk:EventMgr");
 | 
							Utils::SetThreadName("fmwk:EventMgr");
 | 
				
			||||||
		auto Msg = MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_JOIN);
 | 
							auto Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_JOIN));
 | 
				
			||||||
		KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS,MicroServicePrivateEndPoint(),Msg, false);
 | 
							KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
 | 
				
			||||||
		while(Running_) {
 | 
														false);
 | 
				
			||||||
			Poco::Thread::trySleep((unsigned long)MicroServiceDaemonBusTimer());
 | 
							while (Running_) {
 | 
				
			||||||
			if(!Running_)
 | 
								if(!Poco::Thread::trySleep((unsigned long)MicroServiceDaemonBusTimer())) {
 | 
				
			||||||
				break;
 | 
					                break;
 | 
				
			||||||
			Msg = MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE);
 | 
					            }
 | 
				
			||||||
			KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS,MicroServicePrivateEndPoint(),Msg, false);
 | 
								Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE));
 | 
				
			||||||
 | 
								KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(),
 | 
				
			||||||
 | 
															Msg, false);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Msg = MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_LEAVE);
 | 
							Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_LEAVE));
 | 
				
			||||||
		KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS,MicroServicePrivateEndPoint(),Msg, false);
 | 
							KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
 | 
				
			||||||
 | 
														false);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void EventBusManager::Start() {
 | 
						void EventBusManager::Start() {
 | 
				
			||||||
        poco_information(Logger(),"Starting...");
 | 
							poco_information(Logger_, "Starting...");
 | 
				
			||||||
		if(KafkaManager()->Enabled()) {
 | 
							if (KafkaManager()->Enabled()) {
 | 
				
			||||||
			Thread_.start(*this);
 | 
								Thread_.start(*this);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void EventBusManager::Stop() {
 | 
						void EventBusManager::Stop() {
 | 
				
			||||||
		if(KafkaManager()->Enabled()) {
 | 
							if (KafkaManager()->Enabled()) {
 | 
				
			||||||
			poco_information(Logger(),"Stopping...");
 | 
								poco_information(Logger_, "Stopping...");
 | 
				
			||||||
			Running_ = false;
 | 
								Running_ = false;
 | 
				
			||||||
			Thread_.wakeUp();
 | 
								Thread_.wakeUp();
 | 
				
			||||||
			Thread_.join();
 | 
								Thread_.join();
 | 
				
			||||||
			poco_information(Logger(),"Stopped...");
 | 
								poco_information(Logger_, "Stopped...");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,25 +4,35 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/Runnable.h"
 | 
					 | 
				
			||||||
#include "Poco/Logger.h"
 | 
					#include "Poco/Logger.h"
 | 
				
			||||||
 | 
					#include "Poco/Runnable.h"
 | 
				
			||||||
#include "Poco/Thread.h"
 | 
					#include "Poco/Thread.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class EventBusManager : public Poco::Runnable {
 | 
						class EventBusManager : public Poco::Runnable {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit EventBusManager(Poco::Logger &L);
 | 
							EventBusManager() :
 | 
				
			||||||
 | 
								Logger_(Poco::Logger::create(
 | 
				
			||||||
 | 
									"EventBusManager", Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel())) {
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							static auto instance() {
 | 
				
			||||||
 | 
								static auto instance_ = new EventBusManager;
 | 
				
			||||||
 | 
								return instance_;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void run() final;
 | 
							void run() final;
 | 
				
			||||||
		void Start();
 | 
							void Start();
 | 
				
			||||||
		void Stop();
 | 
							void Stop();
 | 
				
			||||||
		inline Poco::Logger & Logger() { return Logger_; }
 | 
							inline Poco::Logger &Logger() { return Logger_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		mutable std::atomic_bool 	Running_ = false;
 | 
							mutable std::atomic_bool Running_ = false;
 | 
				
			||||||
		Poco::Thread		Thread_;
 | 
							Poco::Thread Thread_;
 | 
				
			||||||
		Poco::Logger		&Logger_;
 | 
							Poco::Logger &Logger_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
						inline auto EventBusManager() { return EventBusManager::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,362 +4,338 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "KafkaManager.h"
 | 
					#include "KafkaManager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					 | 
				
			||||||
#include "fmt/format.h"
 | 
					#include "fmt/format.h"
 | 
				
			||||||
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					#include "cppkafka/utils/consumer_dispatcher.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaLoggerFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &message) {
 | 
						void KafkaLoggerFun([[maybe_unused]] cppkafka::KafkaHandleBase &handle, int level,
 | 
				
			||||||
		switch ((cppkafka::LogLevel) level) {
 | 
											const std::string &facility, const std::string &message) {
 | 
				
			||||||
 | 
							switch ((cppkafka::LogLevel)level) {
 | 
				
			||||||
		case cppkafka::LogLevel::LogNotice: {
 | 
							case cppkafka::LogLevel::LogNotice: {
 | 
				
			||||||
			poco_notice(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
 | 
								poco_notice(KafkaManager()->Logger(),
 | 
				
			||||||
		}
 | 
											fmt::format("kafka-log: facility: {} message: {}", facility, message));
 | 
				
			||||||
		break;
 | 
							} break;
 | 
				
			||||||
		case cppkafka::LogLevel::LogDebug: {
 | 
							case cppkafka::LogLevel::LogDebug: {
 | 
				
			||||||
			poco_debug(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
 | 
								poco_debug(KafkaManager()->Logger(),
 | 
				
			||||||
		}
 | 
										   fmt::format("kafka-log: facility: {} message: {}", facility, message));
 | 
				
			||||||
		break;
 | 
							} break;
 | 
				
			||||||
		case cppkafka::LogLevel::LogInfo: {
 | 
							case cppkafka::LogLevel::LogInfo: {
 | 
				
			||||||
			poco_information(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
 | 
								poco_information(KafkaManager()->Logger(),
 | 
				
			||||||
		}
 | 
												 fmt::format("kafka-log: facility: {} message: {}", facility, message));
 | 
				
			||||||
		break;
 | 
							} break;
 | 
				
			||||||
		case cppkafka::LogLevel::LogWarning: {
 | 
							case cppkafka::LogLevel::LogWarning: {
 | 
				
			||||||
			poco_warning(KafkaManager()->Logger(), fmt::format("kafka-log: facility: {} message: {}",facility, message));
 | 
								poco_warning(KafkaManager()->Logger(),
 | 
				
			||||||
		}
 | 
											 fmt::format("kafka-log: facility: {} message: {}", facility, message));
 | 
				
			||||||
		break;
 | 
							} break;
 | 
				
			||||||
		case cppkafka::LogLevel::LogAlert:
 | 
							case cppkafka::LogLevel::LogAlert:
 | 
				
			||||||
		case cppkafka::LogLevel::LogCrit: {
 | 
							case cppkafka::LogLevel::LogCrit: {
 | 
				
			||||||
			poco_critical(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
 | 
								poco_critical(KafkaManager()->Logger(),
 | 
				
			||||||
		}
 | 
											  fmt::format("kafka-log: facility: {} message: {}", facility, message));
 | 
				
			||||||
		break;
 | 
							} break;
 | 
				
			||||||
		case cppkafka::LogLevel::LogErr:
 | 
							case cppkafka::LogLevel::LogErr:
 | 
				
			||||||
		case cppkafka::LogLevel::LogEmerg:
 | 
							case cppkafka::LogLevel::LogEmerg:
 | 
				
			||||||
		default: {
 | 
							default: {
 | 
				
			||||||
			poco_error(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
 | 
								poco_error(KafkaManager()->Logger(),
 | 
				
			||||||
		}
 | 
										   fmt::format("kafka-log: facility: {} message: {}", facility, message));
 | 
				
			||||||
		break;
 | 
							} break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline void KafkaErrorFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) {
 | 
						inline void KafkaErrorFun([[maybe_unused]] cppkafka::KafkaHandleBase &handle, int error,
 | 
				
			||||||
		poco_error(KafkaManager()->Logger(),fmt::format("kafka-error: {}, reason: {}", error, reason));
 | 
												  const std::string &reason) {
 | 
				
			||||||
 | 
							poco_error(KafkaManager()->Logger(),
 | 
				
			||||||
 | 
									   fmt::format("kafka-error: {}, reason: {}", error, reason));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline void AddKafkaSecurity(cppkafka::Configuration & Config) {
 | 
						inline void AddKafkaSecurity(cppkafka::Configuration &Config) {
 | 
				
			||||||
		auto CA = MicroServiceConfigGetString("openwifi.kafka.ssl.ca.location","");
 | 
							auto CA = MicroServiceConfigGetString("openwifi.kafka.ssl.ca.location", "");
 | 
				
			||||||
		auto Certificate = MicroServiceConfigGetString("openwifi.kafka.ssl.certificate.location","");
 | 
							auto Certificate =
 | 
				
			||||||
		auto Key = MicroServiceConfigGetString("openwifi.kafka.ssl.key.location","");
 | 
								MicroServiceConfigGetString("openwifi.kafka.ssl.certificate.location", "");
 | 
				
			||||||
		auto Password = MicroServiceConfigGetString("openwifi.kafka.ssl.key.password","");
 | 
							auto Key = MicroServiceConfigGetString("openwifi.kafka.ssl.key.location", "");
 | 
				
			||||||
 | 
							auto Password = MicroServiceConfigGetString("openwifi.kafka.ssl.key.password", "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(CA.empty() || Certificate.empty() || Key.empty())
 | 
							if (CA.empty() || Certificate.empty() || Key.empty())
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Config.set("ssl.ca.location", CA);
 | 
							Config.set("ssl.ca.location", CA);
 | 
				
			||||||
		Config.set("ssl.certificate.location", Certificate);
 | 
							Config.set("ssl.certificate.location", Certificate);
 | 
				
			||||||
		Config.set("ssl.key.location", Key);
 | 
							Config.set("ssl.key.location", Key);
 | 
				
			||||||
		if(!Password.empty())
 | 
							if (!Password.empty())
 | 
				
			||||||
			Config.set("ssl.key.password", Password);
 | 
								Config.set("ssl.key.password", Password);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void KafkaManager::initialize(Poco::Util::Application &self) {
 | 
				
			||||||
	void KafkaManager::initialize(Poco::Util::Application & self) {
 | 
					 | 
				
			||||||
		SubSystemServer::initialize(self);
 | 
							SubSystemServer::initialize(self);
 | 
				
			||||||
		KafkaEnabled_ = MicroServiceConfigGetBool("openwifi.kafka.enable",false);
 | 
							KafkaEnabled_ = MicroServiceConfigGetBool("openwifi.kafka.enable", false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline void KafkaProducer::run() {
 | 
						inline void KafkaProducer::run() {
 | 
				
			||||||
        Poco::Logger &Logger_ = Poco::Logger::create("KAFKA-PRODUCER", KafkaManager()->Logger().getChannel());
 | 
							Poco::Logger &Logger_ =
 | 
				
			||||||
        poco_information(Logger_,"Starting...");
 | 
								Poco::Logger::create("KAFKA-PRODUCER", KafkaManager()->Logger().getChannel());
 | 
				
			||||||
 | 
							poco_information(Logger_, "Starting...");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Utils::SetThreadName("Kafka:Prod");
 | 
							Utils::SetThreadName("Kafka:Prod");
 | 
				
			||||||
		cppkafka::Configuration Config({
 | 
							cppkafka::Configuration Config(
 | 
				
			||||||
			{ "client.id", MicroServiceConfigGetString("openwifi.kafka.client.id", "") },
 | 
								{{"client.id", MicroServiceConfigGetString("openwifi.kafka.client.id", "")},
 | 
				
			||||||
			{ "metadata.broker.list", MicroServiceConfigGetString("openwifi.kafka.brokerlist", "") }
 | 
								 {"metadata.broker.list",MicroServiceConfigGetString("openwifi.kafka.brokerlist", "")} // ,
 | 
				
			||||||
		});
 | 
								 // {"send.buffer.bytes", KafkaManager()->KafkaManagerMaximumPayloadSize() }
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					 		);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		AddKafkaSecurity(Config);
 | 
							AddKafkaSecurity(Config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Config.set_log_callback(KafkaLoggerFun);
 | 
							Config.set_log_callback(KafkaLoggerFun);
 | 
				
			||||||
		Config.set_error_callback(KafkaErrorFun);
 | 
							Config.set_error_callback(KafkaErrorFun);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		KafkaManager()->SystemInfoWrapper_ = 	R"lit({ "system" : { "id" : )lit" +
 | 
							KafkaManager()->SystemInfoWrapper_ =
 | 
				
			||||||
											 std::to_string(MicroServiceID()) +
 | 
								R"lit({ "system" : { "id" : )lit" + std::to_string(MicroServiceID()) +
 | 
				
			||||||
											 R"lit( , "host" : ")lit" + MicroServicePrivateEndPoint() +
 | 
								R"lit( , "host" : ")lit" + MicroServicePrivateEndPoint() +
 | 
				
			||||||
											 R"lit(" } , "payload" : )lit" ;
 | 
								R"lit(" } , "payload" : )lit";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cppkafka::Producer	Producer(Config);
 | 
							cppkafka::Producer Producer(Config);
 | 
				
			||||||
		Running_ = true;
 | 
							Running_ = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Poco::AutoPtr<Poco::Notification>	Note(Queue_.waitDequeueNotification());
 | 
							Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
 | 
				
			||||||
		while(Note && Running_) {
 | 
							while (Note && Running_) {
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				auto Msg = dynamic_cast<KafkaMessage *>(Note.get());
 | 
									auto Msg = dynamic_cast<KafkaMessage *>(Note.get());
 | 
				
			||||||
				if (Msg != nullptr) {
 | 
									if (Msg != nullptr) {
 | 
				
			||||||
					Producer.produce(
 | 
										auto NewMessage = cppkafka::MessageBuilder(Msg->Topic());
 | 
				
			||||||
						cppkafka::MessageBuilder(Msg->Topic()).key(Msg->Key()).payload(Msg->Payload()));
 | 
										NewMessage.key(Msg->Key());
 | 
				
			||||||
 | 
										NewMessage.partition(0);
 | 
				
			||||||
 | 
										NewMessage.payload(Msg->Payload());
 | 
				
			||||||
 | 
										Producer.produce(NewMessage);
 | 
				
			||||||
 | 
										if (Queue_.size() < 100) {
 | 
				
			||||||
 | 
											// use flush when internal queue is lightly loaded, i.e. flush after each
 | 
				
			||||||
 | 
											// message
 | 
				
			||||||
 | 
											Producer.flush();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else {
 | 
				
			||||||
 | 
											// use poll when internal queue is loaded to allow messages to be sent in
 | 
				
			||||||
 | 
											// batches
 | 
				
			||||||
 | 
											Producer.poll((std::chrono::milliseconds) 0);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} catch (const cppkafka::HandleException &E) {
 | 
								} catch (const cppkafka::HandleException &E) {
 | 
				
			||||||
				poco_warning(Logger_,fmt::format("Caught a Kafka exception (producer): {}", E.what()));
 | 
									poco_warning(Logger_,
 | 
				
			||||||
			} catch( const Poco::Exception &E) {
 | 
												 fmt::format("Caught a Kafka exception (producer): {}", E.what()));
 | 
				
			||||||
 | 
								} catch (const Poco::Exception &E) {
 | 
				
			||||||
				Logger_.log(E);
 | 
									Logger_.log(E);
 | 
				
			||||||
			} catch (...) {
 | 
								} catch (...) {
 | 
				
			||||||
				poco_error(Logger_,"std::exception");
 | 
									poco_error(Logger_, "std::exception");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if (Queue_.size() == 0) {
 | 
				
			||||||
 | 
									// message queue is empty, flush all previously sent messages
 | 
				
			||||||
 | 
									Producer.flush();
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			Note = Queue_.waitDequeueNotification();
 | 
								Note = Queue_.waitDequeueNotification();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
        poco_information(Logger_,"Stopped...");
 | 
							Producer.flush();
 | 
				
			||||||
 | 
							poco_information(Logger_, "Stopped...");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline void KafkaConsumer::run() {
 | 
						inline void KafkaConsumer::run() {
 | 
				
			||||||
		Utils::SetThreadName("Kafka:Cons");
 | 
							Utils::SetThreadName("Kafka:Cons");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Poco::Logger &Logger_ = Poco::Logger::create("KAFKA-CONSUMER", KafkaManager()->Logger().getChannel());
 | 
							Poco::Logger &Logger_ =
 | 
				
			||||||
 | 
								Poco::Logger::create("KAFKA-CONSUMER", KafkaManager()->Logger().getChannel());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        poco_information(Logger_,"Starting...");
 | 
							poco_information(Logger_, "Starting...");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cppkafka::Configuration Config({
 | 
							cppkafka::Configuration Config(
 | 
				
			||||||
			{ "client.id", MicroServiceConfigGetString("openwifi.kafka.client.id","") },
 | 
								{{"client.id", MicroServiceConfigGetString("openwifi.kafka.client.id", "")},
 | 
				
			||||||
			{ "metadata.broker.list", MicroServiceConfigGetString("openwifi.kafka.brokerlist","") },
 | 
								 {"metadata.broker.list", MicroServiceConfigGetString("openwifi.kafka.brokerlist", "")},
 | 
				
			||||||
			{ "group.id", MicroServiceConfigGetString("openwifi.kafka.group.id","") },
 | 
								 {"group.id", MicroServiceConfigGetString("openwifi.kafka.group.id", "")},
 | 
				
			||||||
			{ "enable.auto.commit", MicroServiceConfigGetBool("openwifi.kafka.auto.commit",false) },
 | 
								 {"enable.auto.commit", MicroServiceConfigGetBool("openwifi.kafka.auto.commit", false)},
 | 
				
			||||||
			{ "auto.offset.reset", "latest" } ,
 | 
								 {"auto.offset.reset", "latest"},
 | 
				
			||||||
			{ "enable.partition.eof", false }
 | 
								 {"enable.partition.eof", false}});
 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		AddKafkaSecurity(Config);
 | 
							AddKafkaSecurity(Config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Config.set_log_callback(KafkaLoggerFun);
 | 
							Config.set_log_callback(KafkaLoggerFun);
 | 
				
			||||||
		Config.set_error_callback(KafkaErrorFun);
 | 
							Config.set_error_callback(KafkaErrorFun);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cppkafka::TopicConfiguration topic_config = {
 | 
							cppkafka::TopicConfiguration topic_config = {{"auto.offset.reset", "smallest"}};
 | 
				
			||||||
			{ "auto.offset.reset", "smallest" }
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Now configure it to be the default topic config
 | 
							// Now configure it to be the default topic config
 | 
				
			||||||
		Config.set_default_topic_configuration(topic_config);
 | 
							Config.set_default_topic_configuration(topic_config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cppkafka::Consumer Consumer(Config);
 | 
							cppkafka::Consumer Consumer(Config);
 | 
				
			||||||
		Consumer.set_assignment_callback([&](cppkafka::TopicPartitionList& partitions) {
 | 
							Consumer.set_assignment_callback([&](cppkafka::TopicPartitionList &partitions) {
 | 
				
			||||||
			if(!partitions.empty()) {
 | 
								if (!partitions.empty()) {
 | 
				
			||||||
				poco_information(Logger_,fmt::format("Partition assigned: {}...",
 | 
									poco_information(Logger_, fmt::format("Partition assigned: {}...",
 | 
				
			||||||
																 partitions.front().get_partition()));
 | 
																		  partitions.front().get_partition()));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
		Consumer.set_revocation_callback([&](const cppkafka::TopicPartitionList& partitions) {
 | 
							Consumer.set_revocation_callback([&](const cppkafka::TopicPartitionList &partitions) {
 | 
				
			||||||
			if(!partitions.empty()) {
 | 
								if (!partitions.empty()) {
 | 
				
			||||||
                poco_information(Logger_,fmt::format("Partition revocation: {}...",
 | 
									poco_information(Logger_, fmt::format("Partition revocation: {}...",
 | 
				
			||||||
																 partitions.front().get_partition()));
 | 
																		  partitions.front().get_partition()));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool AutoCommit = MicroServiceConfigGetBool("openwifi.kafka.auto.commit",false);
 | 
							// bool AutoCommit = MicroServiceConfigGetBool("openwifi.kafka.auto.commit", false);
 | 
				
			||||||
		auto BatchSize = MicroServiceConfigGetInt("openwifi.kafka.consumer.batchsize",20);
 | 
							// auto BatchSize = MicroServiceConfigGetInt("openwifi.kafka.consumer.batchsize", 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Types::StringVec    Topics;
 | 
							Types::StringVec Topics;
 | 
				
			||||||
		KafkaManager()->Topics(Topics);
 | 
							std::for_each(Topics_.begin(),Topics_.end(),
 | 
				
			||||||
 | 
										  [&](const std::string & T) { Topics.emplace_back(T); });
 | 
				
			||||||
		Consumer.subscribe(Topics);
 | 
							Consumer.subscribe(Topics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Running_ = true;
 | 
							Running_ = true;
 | 
				
			||||||
		while(Running_) {
 | 
							std::vector<cppkafka::Message> MsgVec;
 | 
				
			||||||
			try {
 | 
					
 | 
				
			||||||
				std::vector<cppkafka::Message> MsgVec = Consumer.poll_batch(BatchSize, std::chrono::milliseconds(100));
 | 
							Dispatcher_ = std::make_unique<cppkafka::ConsumerDispatcher>(Consumer);
 | 
				
			||||||
				for(auto const &Msg:MsgVec) {
 | 
					
 | 
				
			||||||
					if (!Msg)
 | 
							Dispatcher_->run(
 | 
				
			||||||
						continue;
 | 
								// Callback executed whenever a new message is consumed
 | 
				
			||||||
					if (Msg.get_error()) {
 | 
								[&](cppkafka::Message msg) {
 | 
				
			||||||
						if (!Msg.is_eof()) {
 | 
									// Print the key (if any)
 | 
				
			||||||
							poco_error(Logger_,fmt::format("Error: {}", Msg.get_error().to_string()));
 | 
									std::lock_guard G(ConsumerMutex_);
 | 
				
			||||||
 | 
									auto It = Notifiers_.find(msg.get_topic());
 | 
				
			||||||
 | 
									if (It != Notifiers_.end()) {
 | 
				
			||||||
 | 
										const auto &FL = It->second;
 | 
				
			||||||
 | 
										for (const auto &[CallbackFunc, _] : FL) {
 | 
				
			||||||
 | 
											try {
 | 
				
			||||||
 | 
												CallbackFunc(msg.get_key(), msg.get_payload());
 | 
				
			||||||
 | 
											} catch(const Poco::Exception &E) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											} catch(...) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						if(!AutoCommit)
 | 
					 | 
				
			||||||
							Consumer.async_commit(Msg);
 | 
					 | 
				
			||||||
						continue;
 | 
					 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					KafkaManager()->Dispatch(Msg.get_topic(), Msg.get_key(),Msg.get_payload() );
 | 
					 | 
				
			||||||
					if (!AutoCommit)
 | 
					 | 
				
			||||||
						Consumer.async_commit(Msg);
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} catch (const cppkafka::HandleException &E) {
 | 
									Consumer.commit(msg);
 | 
				
			||||||
				poco_warning(Logger_,fmt::format("Caught a Kafka exception (consumer): {}", E.what()));
 | 
								},
 | 
				
			||||||
			} catch (const Poco::Exception &E) {
 | 
								// Whenever there's an error (other than the EOF soft error)
 | 
				
			||||||
				Logger_.log(E);
 | 
								[&Logger_](cppkafka::Error error) {
 | 
				
			||||||
			} catch (...) {
 | 
									poco_warning(Logger_,fmt::format("Error: {}", error.to_string()));
 | 
				
			||||||
				poco_error(Logger_,"std::exception");
 | 
								},
 | 
				
			||||||
 | 
								// Whenever EOF is reached on a partition, print this
 | 
				
			||||||
 | 
								[&Logger_](cppkafka::ConsumerDispatcher::EndOfFile, const cppkafka::TopicPartition& topic_partition) {
 | 
				
			||||||
 | 
									poco_debug(Logger_,fmt::format("Partition {} EOF", topic_partition.get_partition()));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Consumer.unsubscribe();
 | 
							Consumer.unsubscribe();
 | 
				
			||||||
        poco_information(Logger_,"Stopped...");
 | 
							poco_information(Logger_, "Stopped...");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaProducer::Start() {
 | 
						void KafkaProducer::Start() {
 | 
				
			||||||
		if(!Running_) {
 | 
							if (!Running_) {
 | 
				
			||||||
			Running_=true;
 | 
								Running_ = true;
 | 
				
			||||||
			Worker_.start(*this);
 | 
								Worker_.start(*this);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaProducer::Stop() {
 | 
						void KafkaProducer::Stop() {
 | 
				
			||||||
		if(Running_) {
 | 
							if (Running_) {
 | 
				
			||||||
			Running_=false;
 | 
								Running_ = false;
 | 
				
			||||||
			Queue_.wakeUpAll();
 | 
								Queue_.wakeUpAll();
 | 
				
			||||||
			Worker_.join();
 | 
								Worker_.join();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaProducer::Produce(const std::string &Topic, const std::string &Key, const std::string &Payload) {
 | 
						void KafkaProducer::Produce(const char *Topic, const std::string &Key,
 | 
				
			||||||
		std::lock_guard	G(Mutex_);
 | 
													const std::string &Payload) {
 | 
				
			||||||
		Queue_.enqueueNotification( new KafkaMessage(Topic,Key,Payload));
 | 
							std::lock_guard G(Mutex_);
 | 
				
			||||||
 | 
							Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaConsumer::Start() {
 | 
						void KafkaConsumer::Start() {
 | 
				
			||||||
		if(!Running_) {
 | 
							if (!Running_) {
 | 
				
			||||||
			Running_=true;
 | 
					 | 
				
			||||||
			Worker_.start(*this);
 | 
								Worker_.start(*this);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaConsumer::Stop() {
 | 
						void KafkaConsumer::Stop() {
 | 
				
			||||||
		if(Running_) {
 | 
							if (Running_) {
 | 
				
			||||||
			Running_=false;
 | 
								Running_ = false;
 | 
				
			||||||
			Worker_.wakeUp();
 | 
								if(Dispatcher_) {
 | 
				
			||||||
 | 
									Dispatcher_->stop();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			Worker_.join();
 | 
								Worker_.join();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaDispatcher::Start() {
 | 
						std::uint64_t KafkaConsumer::RegisterTopicWatcher(const std::string &Topic,
 | 
				
			||||||
		if(!Running_) {
 | 
																   Types::TopicNotifyFunction &F) {
 | 
				
			||||||
			Running_=true;
 | 
							std::lock_guard G(ConsumerMutex_);
 | 
				
			||||||
			Worker_.start(*this);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void KafkaDispatcher::Stop() {
 | 
					 | 
				
			||||||
		if(Running_) {
 | 
					 | 
				
			||||||
			Running_=false;
 | 
					 | 
				
			||||||
			Queue_.wakeUpAll();
 | 
					 | 
				
			||||||
			Worker_.join();
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	auto KafkaDispatcher::RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F) {
 | 
					 | 
				
			||||||
		std::lock_guard G(Mutex_);
 | 
					 | 
				
			||||||
		auto It = Notifiers_.find(Topic);
 | 
							auto It = Notifiers_.find(Topic);
 | 
				
			||||||
		if(It == Notifiers_.end()) {
 | 
							if (It == Notifiers_.end()) {
 | 
				
			||||||
			Types::TopicNotifyFunctionList L;
 | 
								Types::TopicNotifyFunctionList L;
 | 
				
			||||||
			L.emplace(L.end(),std::make_pair(F,FunctionId_));
 | 
								L.emplace(L.end(), std::make_pair(F, FunctionId_));
 | 
				
			||||||
			Notifiers_[Topic] = std::move(L);
 | 
								Notifiers_[Topic] = std::move(L);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			It->second.emplace(It->second.end(),std::make_pair(F,FunctionId_));
 | 
								It->second.emplace(It->second.end(), std::make_pair(F, FunctionId_));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							Topics_.insert(Topic);
 | 
				
			||||||
		return FunctionId_++;
 | 
							return FunctionId_++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaDispatcher::UnregisterTopicWatcher(const std::string &Topic, int Id) {
 | 
						void KafkaConsumer::UnregisterTopicWatcher(const std::string &Topic, int Id) {
 | 
				
			||||||
		std::lock_guard G(Mutex_);
 | 
							std::lock_guard G(ConsumerMutex_);
 | 
				
			||||||
		auto It = Notifiers_.find(Topic);
 | 
							auto It = Notifiers_.find(Topic);
 | 
				
			||||||
		if(It != Notifiers_.end()) {
 | 
							if (It != Notifiers_.end()) {
 | 
				
			||||||
			Types::TopicNotifyFunctionList & L = It->second;
 | 
								Types::TopicNotifyFunctionList &L = It->second;
 | 
				
			||||||
			for(auto it=L.begin(); it!=L.end(); it++)
 | 
								for (auto it = L.begin(); it != L.end(); it++)
 | 
				
			||||||
				if(it->second == Id) {
 | 
									if (it->second == Id) {
 | 
				
			||||||
					L.erase(it);
 | 
										L.erase(it);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaDispatcher::Dispatch(const std::string &Topic, const std::string &Key, const std::string &Payload) {
 | 
					 | 
				
			||||||
		std::lock_guard	G(Mutex_);
 | 
					 | 
				
			||||||
		auto It = Notifiers_.find(Topic);
 | 
					 | 
				
			||||||
		if(It!=Notifiers_.end()) {
 | 
					 | 
				
			||||||
			Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void KafkaDispatcher::run() {
 | 
					 | 
				
			||||||
        Poco::Logger &Logger_ = Poco::Logger::create("KAFKA-DISPATCHER", KafkaManager()->Logger().getChannel());
 | 
					 | 
				
			||||||
        poco_information(Logger_,"Starting...");
 | 
					 | 
				
			||||||
		Poco::AutoPtr<Poco::Notification>	Note(Queue_.waitDequeueNotification());
 | 
					 | 
				
			||||||
		Utils::SetThreadName("kafka:dispatch");
 | 
					 | 
				
			||||||
		while(Note && Running_) {
 | 
					 | 
				
			||||||
			auto Msg = dynamic_cast<KafkaMessage*>(Note.get());
 | 
					 | 
				
			||||||
			if(Msg!= nullptr) {
 | 
					 | 
				
			||||||
				auto It = Notifiers_.find(Msg->Topic());
 | 
					 | 
				
			||||||
				if (It != Notifiers_.end()) {
 | 
					 | 
				
			||||||
					const auto & FL = It->second;
 | 
					 | 
				
			||||||
					for(const auto &[CallbackFunc,_]:FL) {
 | 
					 | 
				
			||||||
						CallbackFunc(Msg->Key(), Msg->Payload());
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			Note = Queue_.waitDequeueNotification();
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
        poco_information(Logger_,"Stopped...");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void KafkaDispatcher::Topics(std::vector<std::string> &T) {
 | 
					 | 
				
			||||||
		T.clear();
 | 
					 | 
				
			||||||
		for(const auto &[TopicName,_]:Notifiers_)
 | 
					 | 
				
			||||||
			T.push_back(TopicName);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int KafkaManager::Start() {
 | 
						int KafkaManager::Start() {
 | 
				
			||||||
		if(!KafkaEnabled_)
 | 
							if (!KafkaEnabled_)
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
        ConsumerThr_.Start();
 | 
							MaxPayloadSize_ = MicroServiceConfigGetInt("openwifi.kafka.max.payload", 250000);
 | 
				
			||||||
 | 
							ConsumerThr_.Start();
 | 
				
			||||||
		ProducerThr_.Start();
 | 
							ProducerThr_.Start();
 | 
				
			||||||
		Dispatcher_.Start();
 | 
					 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaManager::Stop()  {
 | 
						void KafkaManager::Stop() {
 | 
				
			||||||
		if(KafkaEnabled_) {
 | 
							if (KafkaEnabled_) {
 | 
				
			||||||
			poco_information(Logger(),"Stopping...");
 | 
								poco_information(Logger(), "Stopping...");
 | 
				
			||||||
			Dispatcher_.Stop();
 | 
					 | 
				
			||||||
			ProducerThr_.Stop();
 | 
								ProducerThr_.Stop();
 | 
				
			||||||
			ConsumerThr_.Stop();
 | 
								ConsumerThr_.Stop();
 | 
				
			||||||
			poco_information(Logger(),"Stopped...");
 | 
								poco_information(Logger(), "Stopped...");
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaManager::PostMessage(const std::string &topic, const std::string & key, const std::string &PayLoad, bool WrapMessage ) {
 | 
						void KafkaManager::PostMessage(const char *topic, const std::string &key,
 | 
				
			||||||
		if(KafkaEnabled_) {
 | 
													   const std::string & PayLoad, bool WrapMessage) {
 | 
				
			||||||
			ProducerThr_.Produce(topic,key,WrapMessage ? WrapSystemId(PayLoad) : PayLoad);
 | 
							if (KafkaEnabled_) {
 | 
				
			||||||
 | 
								ProducerThr_.Produce(topic, key, WrapMessage ? WrapSystemId(PayLoad) : PayLoad);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaManager::Dispatch(const std::string &Topic, const std::string & Key, const std::string &Payload) {
 | 
						void KafkaManager::PostMessage(const char *topic, const std::string &key,
 | 
				
			||||||
		Dispatcher_.Dispatch(Topic, Key, Payload);
 | 
										 const Poco::JSON::Object &Object, bool WrapMessage) {
 | 
				
			||||||
 | 
							if (KafkaEnabled_) {
 | 
				
			||||||
 | 
								std::ostringstream ObjectStr;
 | 
				
			||||||
 | 
								Object.stringify(ObjectStr);
 | 
				
			||||||
 | 
								ProducerThr_.Produce(topic, key, WrapMessage ? WrapSystemId(ObjectStr.str()) : ObjectStr.str());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] std::string KafkaManager::WrapSystemId(const std::string & PayLoad) {
 | 
						[[nodiscard]] std::string KafkaManager::WrapSystemId(const std::string & PayLoad) {
 | 
				
			||||||
		return SystemInfoWrapper_ + PayLoad + "}";
 | 
							return fmt::format(	R"lit({{ "system" : {{ "id" : {}, "host" : "{}" }}, "payload" : {} }})lit",
 | 
				
			||||||
 | 
											   MicroServiceID(), MicroServicePrivateEndPoint(), PayLoad ) ;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint64_t KafkaManager::RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F) {
 | 
						void KafkaManager::PartitionAssignment(const cppkafka::TopicPartitionList &partitions) {
 | 
				
			||||||
		if(KafkaEnabled_) {
 | 
							poco_information(
 | 
				
			||||||
			return Dispatcher_.RegisterTopicWatcher(Topic,F);
 | 
								Logger(), fmt::format("Partition assigned: {}...", partitions.front().get_partition()));
 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaManager::UnregisterTopicWatcher(const std::string &Topic, uint64_t Id) {
 | 
						void KafkaManager::PartitionRevocation(const cppkafka::TopicPartitionList &partitions) {
 | 
				
			||||||
		if(KafkaEnabled_) {
 | 
							poco_information(Logger(), fmt::format("Partition revocation: {}...",
 | 
				
			||||||
			Dispatcher_.UnregisterTopicWatcher(Topic, Id);
 | 
																   partitions.front().get_partition()));
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void KafkaManager::Topics(std::vector<std::string> &T) {
 | 
					} // namespace OpenWifi
 | 
				
			||||||
		Dispatcher_.Topics(T);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void KafkaManager::PartitionAssignment(const cppkafka::TopicPartitionList& partitions) {
 | 
					 | 
				
			||||||
		poco_information(Logger(),fmt::format("Partition assigned: {}...", partitions.front().get_partition()));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void KafkaManager::PartitionRevocation(const cppkafka::TopicPartitionList& partitions) {
 | 
					 | 
				
			||||||
		poco_information(Logger(),fmt::format("Partition revocation: {}...",partitions.front().get_partition()));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace OpenWifi
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,84 +6,71 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "Poco/Notification.h"
 | 
					#include "Poco/Notification.h"
 | 
				
			||||||
#include "Poco/NotificationQueue.h"
 | 
					#include "Poco/NotificationQueue.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/Object.h"
 | 
				
			||||||
#include "framework/SubSystemServer.h"
 | 
					 | 
				
			||||||
#include "framework/OpenWifiTypes.h"
 | 
					 | 
				
			||||||
#include "framework/utils.h"
 | 
					 | 
				
			||||||
#include "framework/KafkaTopics.h"
 | 
					#include "framework/KafkaTopics.h"
 | 
				
			||||||
 | 
					#include "framework/OpenWifiTypes.h"
 | 
				
			||||||
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
 | 
					#include "framework/utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cppkafka/cppkafka.h"
 | 
					#include "cppkafka/cppkafka.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class KafkaMessage: public Poco::Notification {
 | 
						class KafkaMessage : public Poco::Notification {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		KafkaMessage( const std::string &Topic, const std::string &Key, const std::string & Payload) :
 | 
							KafkaMessage(const char * Topic, const std::string &Key, const std::string &Payload)
 | 
				
			||||||
			Topic_(Topic), Key_(Key), Payload_(Payload) {
 | 
								: Topic_(Topic), Key_(Key), Payload_(Payload) {}
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline const std::string & Topic() { return Topic_; }
 | 
							inline const char * Topic() { return Topic_; }
 | 
				
			||||||
		inline const std::string & Key() { return Key_; }
 | 
							inline const std::string &Key() { return Key_; }
 | 
				
			||||||
		inline const std::string & Payload() { return Payload_; }
 | 
							inline const std::string &Payload() { return Payload_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::string	Topic_;
 | 
							const char *Topic_;
 | 
				
			||||||
		std::string	Key_;
 | 
							std::string Key_;
 | 
				
			||||||
		std::string	Payload_;
 | 
							std::string Payload_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class KafkaProducer : public Poco::Runnable {
 | 
						class KafkaProducer : public Poco::Runnable {
 | 
				
			||||||
        public:
 | 
						  public:
 | 
				
			||||||
            void run () override;
 | 
							void run() override;
 | 
				
			||||||
            void Start();
 | 
							void Start();
 | 
				
			||||||
            void Stop();
 | 
							void Stop();
 | 
				
			||||||
            void Produce(const std::string &Topic, const std::string &Key, const std::string &Payload);
 | 
							void Produce(const char *Topic, const std::string &Key, const std::string & Payload);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
            std::recursive_mutex  		Mutex_;
 | 
							std::mutex Mutex_;
 | 
				
			||||||
            Poco::Thread        		Worker_;
 | 
							Poco::Thread Worker_;
 | 
				
			||||||
            mutable std::atomic_bool    Running_=false;
 | 
							mutable std::atomic_bool Running_ = false;
 | 
				
			||||||
            Poco::NotificationQueue		Queue_;
 | 
							Poco::NotificationQueue Queue_;
 | 
				
			||||||
    };
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class KafkaConsumer : public Poco::Runnable {
 | 
						class KafkaConsumer : public Poco::Runnable {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		void run() override;
 | 
					 | 
				
			||||||
		void Start();
 | 
							void Start();
 | 
				
			||||||
		void Stop();
 | 
							void Stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::recursive_mutex  	    Mutex_;
 | 
							std::mutex 				ConsumerMutex_;
 | 
				
			||||||
		Poco::Thread        	    Worker_;
 | 
							Types::NotifyTable 		Notifiers_;
 | 
				
			||||||
		mutable std::atomic_bool    Running_=false;
 | 
							Poco::Thread 			Worker_;
 | 
				
			||||||
	};
 | 
							mutable std::atomic_bool Running_ = false;
 | 
				
			||||||
 | 
							uint64_t 				FunctionId_ = 1;
 | 
				
			||||||
 | 
							std::unique_ptr<cppkafka::ConsumerDispatcher> 	Dispatcher_;
 | 
				
			||||||
 | 
							std::set<std::string>	Topics_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class KafkaDispatcher : public Poco::Runnable {
 | 
							void run() override;
 | 
				
			||||||
	  public:
 | 
							friend class KafkaManager;
 | 
				
			||||||
		void Start();
 | 
							std::uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
 | 
				
			||||||
		void Stop();
 | 
					 | 
				
			||||||
		auto RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
 | 
					 | 
				
			||||||
		void UnregisterTopicWatcher(const std::string &Topic, int Id);
 | 
							void UnregisterTopicWatcher(const std::string &Topic, int Id);
 | 
				
			||||||
		void Dispatch(const std::string &Topic, const std::string &Key, const std::string &Payload);
 | 
					 | 
				
			||||||
		void run() override;
 | 
					 | 
				
			||||||
		void Topics(std::vector<std::string> &T);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  private:
 | 
					 | 
				
			||||||
		std::recursive_mutex  		Mutex_;
 | 
					 | 
				
			||||||
		Types::NotifyTable      	Notifiers_;
 | 
					 | 
				
			||||||
		Poco::Thread        		Worker_;
 | 
					 | 
				
			||||||
		mutable std::atomic_bool    Running_=false;
 | 
					 | 
				
			||||||
		uint64_t          			FunctionId_=1;
 | 
					 | 
				
			||||||
		Poco::NotificationQueue		Queue_;
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class KafkaManager : public SubSystemServer {
 | 
						class KafkaManager : public SubSystemServer {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
 | 
					 | 
				
			||||||
		friend class KafkaConsumer;
 | 
							friend class KafkaConsumer;
 | 
				
			||||||
		friend class KafkaProducer;
 | 
							friend class KafkaProducer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void initialize(Poco::Util::Application & self) override;
 | 
							inline void initialize(Poco::Util::Application &self) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		static auto instance() {
 | 
							static auto instance() {
 | 
				
			||||||
			static auto instance_ = new KafkaManager;
 | 
								static auto instance_ = new KafkaManager;
 | 
				
			||||||
@@ -93,30 +80,35 @@ namespace OpenWifi {
 | 
				
			|||||||
		int Start() override;
 | 
							int Start() override;
 | 
				
			||||||
		void Stop() override;
 | 
							void Stop() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void PostMessage(const std::string &topic, const std::string & key, const std::string &PayLoad, bool WrapMessage = true  );
 | 
							void PostMessage(const char *topic, const std::string &key,
 | 
				
			||||||
		void Dispatch(const std::string &Topic, const std::string & Key, const std::string &Payload);
 | 
											 const std::string &PayLoad, bool WrapMessage = true);
 | 
				
			||||||
 | 
							void PostMessage(const char *topic, const std::string &key,
 | 
				
			||||||
 | 
											 const Poco::JSON::Object &Object, bool WrapMessage = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] std::string WrapSystemId(const std::string & PayLoad);
 | 
							[[nodiscard]] std::string WrapSystemId(const std::string & PayLoad);
 | 
				
			||||||
		[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
 | 
							[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
 | 
				
			||||||
		uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
 | 
							inline std::uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F) {
 | 
				
			||||||
		void UnregisterTopicWatcher(const std::string &Topic, uint64_t Id);
 | 
								return ConsumerThr_.RegisterTopicWatcher(Topic,F);
 | 
				
			||||||
		void Topics(std::vector<std::string> &T);
 | 
							}
 | 
				
			||||||
 | 
							inline void UnregisterTopicWatcher(const std::string &Topic, uint64_t Id) {
 | 
				
			||||||
 | 
								return ConsumerThr_.UnregisterTopicWatcher(Topic,Id);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							std::uint64_t KafkaManagerMaximumPayloadSize() const { return MaxPayloadSize_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		bool 				KafkaEnabled_ = false;
 | 
							bool KafkaEnabled_ = false;
 | 
				
			||||||
		std::string 		SystemInfoWrapper_;
 | 
							std::string SystemInfoWrapper_;
 | 
				
			||||||
		KafkaProducer       ProducerThr_;
 | 
							KafkaProducer ProducerThr_;
 | 
				
			||||||
        KafkaConsumer       ConsumerThr_;
 | 
							KafkaConsumer ConsumerThr_;
 | 
				
			||||||
		KafkaDispatcher     Dispatcher_;
 | 
							std::uint64_t MaxPayloadSize_ = 250000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void PartitionAssignment(const cppkafka::TopicPartitionList& partitions);
 | 
							void PartitionAssignment(const cppkafka::TopicPartitionList &partitions);
 | 
				
			||||||
		void PartitionRevocation(const cppkafka::TopicPartitionList& partitions);
 | 
							void PartitionRevocation(const cppkafka::TopicPartitionList &partitions);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		KafkaManager() noexcept:
 | 
							KafkaManager() noexcept : SubSystemServer("KafkaManager", "KAFKA-SVR", "openwifi.kafka") {}
 | 
				
			||||||
			SubSystemServer("KafkaManager", "KAFKA-SVR", "openwifi.kafka") {
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto KafkaManager() { return KafkaManager::instance(); }
 | 
						inline auto KafkaManager() { return KafkaManager::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,33 +10,33 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
namespace OpenWifi::KafkaTopics {
 | 
					namespace OpenWifi::KafkaTopics {
 | 
				
			||||||
	static const std::string HEALTHCHECK{"healthcheck"};
 | 
						inline const char * HEALTHCHECK = "healthcheck";
 | 
				
			||||||
	static const std::string STATE{"state"};
 | 
						inline const char * STATE = "state";
 | 
				
			||||||
	static const std::string CONNECTION{"connection"};
 | 
						inline const char * CONNECTION = "connection";
 | 
				
			||||||
	static const std::string WIFISCAN{"wifiscan"};
 | 
						inline const char * WIFISCAN = "wifiscan";
 | 
				
			||||||
	static const std::string ALERTS{"alerts"};
 | 
						inline const char * ALERTS = "alerts";
 | 
				
			||||||
	static const std::string COMMAND{"command"};
 | 
						inline const char * COMMAND = "command";
 | 
				
			||||||
	static const std::string SERVICE_EVENTS{"service_events"};
 | 
						inline const char * SERVICE_EVENTS = "service_events";
 | 
				
			||||||
	static const std::string DEVICE_EVENT_QUEUE{"device_event_queue"};
 | 
						inline const char * DEVICE_EVENT_QUEUE = "device_event_queue";
 | 
				
			||||||
	static const std::string DEVICE_TELEMETRY{"device_telemetry"};
 | 
						inline const char * DEVICE_TELEMETRY = "device_telemetry";
 | 
				
			||||||
    static const std::string PROVISIONING_CHANGE{"provisioning_change"};
 | 
						inline const char * PROVISIONING_CHANGE = "provisioning_change";
 | 
				
			||||||
 | 
						inline const char * RRM = "rrm";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	namespace ServiceEvents {
 | 
						namespace ServiceEvents {
 | 
				
			||||||
		static const std::string EVENT_JOIN{"join"};
 | 
							inline const char * EVENT_JOIN = "join";
 | 
				
			||||||
		static const std::string EVENT_LEAVE{"leave"};
 | 
							inline const char * EVENT_LEAVE = "leave";
 | 
				
			||||||
		static const std::string EVENT_KEEP_ALIVE{"keep-alive"};
 | 
							inline const char * EVENT_KEEP_ALIVE = "keep-alive";
 | 
				
			||||||
		static const std::string EVENT_REMOVE_TOKEN{"remove-token"};
 | 
							inline const char * EVENT_REMOVE_TOKEN = "remove-token";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		namespace Fields {
 | 
							namespace Fields {
 | 
				
			||||||
			static const std::string EVENT{"event"};
 | 
								inline const char * EVENT = "event";
 | 
				
			||||||
			static const std::string ID{"id"};
 | 
								inline const char * ID = "id";
 | 
				
			||||||
			static const std::string TYPE{"type"};
 | 
								inline const char * TYPE = "type";
 | 
				
			||||||
			static const std::string PUBLIC{"publicEndPoint"};
 | 
								inline const char * PUBLIC = "publicEndPoint";
 | 
				
			||||||
			static const std::string PRIVATE{"privateEndPoint"};
 | 
								inline const char * PRIVATE = "privateEndPoint";
 | 
				
			||||||
			static const std::string KEY{"key"};
 | 
								inline const char * KEY = "key";
 | 
				
			||||||
			static const std::string VRSN{"version"};
 | 
								inline const char * VRSN = "version";
 | 
				
			||||||
			static const std::string TOKEN{"token"};
 | 
								inline const char * TOKEN = "token";
 | 
				
			||||||
		}
 | 
							} // namespace Fields
 | 
				
			||||||
	}
 | 
						}	  // namespace ServiceEvents
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi::KafkaTopics
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -9,12 +9,11 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <array>
 | 
					#include <array>
 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
#include <vector>
 | 
					 | 
				
			||||||
#include <fstream>
 | 
					 | 
				
			||||||
#include <random>
 | 
					 | 
				
			||||||
#include <ctime>
 | 
					#include <ctime>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <random>
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This must be defined for poco_debug and poco_trace macros to function.
 | 
					// This must be defined for poco_debug and poco_trace macros to function.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -23,103 +22,99 @@
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
    inline uint64_t Now() { return std::time(nullptr); };
 | 
						inline uint64_t Now() { return std::time(nullptr); };
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/Util/Application.h"
 | 
					#include "Poco/AutoPtr.h"
 | 
				
			||||||
#include "Poco/Util/ServerApplication.h"
 | 
					 | 
				
			||||||
#include "Poco/Util/Option.h"
 | 
					 | 
				
			||||||
#include "Poco/Util/OptionSet.h"
 | 
					 | 
				
			||||||
#include "Poco/Crypto/RSAKey.h"
 | 
					 | 
				
			||||||
#include "Poco/Crypto/CipherFactory.h"
 | 
					 | 
				
			||||||
#include "Poco/Crypto/Cipher.h"
 | 
					#include "Poco/Crypto/Cipher.h"
 | 
				
			||||||
 | 
					#include "Poco/Crypto/CipherFactory.h"
 | 
				
			||||||
 | 
					#include "Poco/Crypto/RSAKey.h"
 | 
				
			||||||
 | 
					#include "Poco/Environment.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/Object.h"
 | 
				
			||||||
 | 
					#include "Poco/JWT/Signer.h"
 | 
				
			||||||
#include "Poco/Net/HTTPServerRequest.h"
 | 
					#include "Poco/Net/HTTPServerRequest.h"
 | 
				
			||||||
#include "Poco/Process.h"
 | 
					#include "Poco/Process.h"
 | 
				
			||||||
 | 
					#include "Poco/Util/Application.h"
 | 
				
			||||||
#include "Poco/Util/HelpFormatter.h"
 | 
					#include "Poco/Util/HelpFormatter.h"
 | 
				
			||||||
#include "Poco/JSON/Object.h"
 | 
					#include "Poco/Util/Option.h"
 | 
				
			||||||
#include "Poco/AutoPtr.h"
 | 
					#include "Poco/Util/OptionSet.h"
 | 
				
			||||||
#include "Poco/Util/PropertyFileConfiguration.h"
 | 
					#include "Poco/Util/PropertyFileConfiguration.h"
 | 
				
			||||||
#include "Poco/JWT/Signer.h"
 | 
					#include "Poco/Util/ServerApplication.h"
 | 
				
			||||||
#include "Poco/Environment.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/OpenWifiTypes.h"
 | 
					#include "framework/OpenWifiTypes.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "framework/EventBusManager.h"
 | 
				
			||||||
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
#include "framework/ow_constants.h"
 | 
					#include "framework/ow_constants.h"
 | 
				
			||||||
#include "framework/utils.h"
 | 
					#include "framework/utils.h"
 | 
				
			||||||
#include "framework/SubSystemServer.h"
 | 
					 | 
				
			||||||
#include "framework/EventBusManager.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "RESTObjects/RESTAPI_SecurityObjects.h"
 | 
					#include "RESTObjects/RESTAPI_SecurityObjects.h"
 | 
				
			||||||
#include "cppkafka/cppkafka.h"
 | 
					#include "cppkafka/cppkafka.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "fmt/core.h"
 | 
				
			||||||
#include "nlohmann/json.hpp"
 | 
					#include "nlohmann/json.hpp"
 | 
				
			||||||
#include "ow_version.h"
 | 
					#include "ow_version.h"
 | 
				
			||||||
#include "fmt/core.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl;
 | 
					 | 
				
			||||||
// #define _OWDEBUG_ Logger().debug(Poco::format("%s: %lu",__FILE__,__LINE__));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class MicroService : public Poco::Util::ServerApplication {
 | 
						class MicroService : public Poco::Util::ServerApplication {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit MicroService( 	std::string PropFile,
 | 
							explicit MicroService(std::string PropFile, std::string RootEnv, std::string ConfigVar,
 | 
				
			||||||
					 	std::string RootEnv,
 | 
												  std::string AppName, uint64_t BusTimer, SubSystemVec Subsystems)
 | 
				
			||||||
					 	std::string ConfigVar,
 | 
								: DAEMON_PROPERTIES_FILENAME(std::move(PropFile)),
 | 
				
			||||||
					 	std::string AppName,
 | 
								  DAEMON_ROOT_ENV_VAR(std::move(RootEnv)), DAEMON_CONFIG_ENV_VAR(std::move(ConfigVar)),
 | 
				
			||||||
					  	uint64_t BusTimer,
 | 
								  DAEMON_APP_NAME(std::move(AppName)), DAEMON_BUS_TIMER(BusTimer),
 | 
				
			||||||
					  	SubSystemVec Subsystems) :
 | 
								  SubSystems_(std::move(Subsystems)), Logger_(Poco::Logger::get("FRAMEWORK")) {
 | 
				
			||||||
				DAEMON_PROPERTIES_FILENAME(std::move(PropFile)),
 | 
								instance_ = this;
 | 
				
			||||||
				DAEMON_ROOT_ENV_VAR(std::move(RootEnv)),
 | 
								RandomEngine_.seed(std::chrono::steady_clock::now().time_since_epoch().count());
 | 
				
			||||||
				DAEMON_CONFIG_ENV_VAR(std::move(ConfigVar)),
 | 
					 | 
				
			||||||
				DAEMON_APP_NAME(std::move(AppName)),
 | 
					 | 
				
			||||||
				DAEMON_BUS_TIMER(BusTimer),
 | 
					 | 
				
			||||||
				SubSystems_(std::move(Subsystems)),
 | 
					 | 
				
			||||||
				Logger_(Poco::Logger::get("FRAMEWORK")) {
 | 
					 | 
				
			||||||
		    instance_ = this;
 | 
					 | 
				
			||||||
		    RandomEngine_.seed(std::chrono::steady_clock::now().time_since_epoch().count());
 | 
					 | 
				
			||||||
			// Logger_ = Poco::Logger::root().get("BASE-SVC");
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline static const char * ExtraConfigurationFilename = "/configuration_override.json";
 | 
							inline static const char *ExtraConfigurationFilename = "/configuration_override.json";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void SaveConfig() { PropConfigurationFile_->save(ConfigFileName_); }
 | 
							inline void SaveConfig() { PropConfigurationFile_->save(ConfigFileName_); }
 | 
				
			||||||
		inline auto UpdateConfig() { return PropConfigurationFile_; }
 | 
							inline auto UpdateConfig() { return PropConfigurationFile_; }
 | 
				
			||||||
		inline bool NoAPISecurity() const { return NoAPISecurity_; }
 | 
							inline bool NoAPISecurity() const { return NoAPISecurity_; }
 | 
				
			||||||
		inline Poco::ThreadPool & TimerPool() { return TimerPool_; }
 | 
							inline Poco::ThreadPool &TimerPool() { return TimerPool_; }
 | 
				
			||||||
		[[nodiscard]] std::string Version() { return Version_; }
 | 
							[[nodiscard]] std::string Version() { return Version_; }
 | 
				
			||||||
		[[nodiscard]] inline const std::string & DataDir() { return DataDir_; }
 | 
							[[nodiscard]] inline const std::string &DataDir() { return DataDir_; }
 | 
				
			||||||
		[[nodiscard]] inline const std::string & WWWAssetsDir() { return WWWAssetsDir_; }
 | 
							[[nodiscard]] inline const std::string &WWWAssetsDir() { return WWWAssetsDir_; }
 | 
				
			||||||
		[[nodiscard]] bool Debug() const { return DebugMode_; }
 | 
							[[nodiscard]] bool Debug() const { return DebugMode_; }
 | 
				
			||||||
		[[nodiscard]] uint64_t ID() const { return ID_; }
 | 
							[[nodiscard]] uint64_t ID() const { return ID_; }
 | 
				
			||||||
		[[nodiscard]] std::string Hash() const { return MyHash_; };
 | 
							[[nodiscard]] std::string Hash() const { return MyHash_; };
 | 
				
			||||||
		[[nodiscard]] std::string ServiceType() const { return DAEMON_APP_NAME; };
 | 
							[[nodiscard]] std::string ServiceType() const { return DAEMON_APP_NAME; };
 | 
				
			||||||
		[[nodiscard]] std::string PrivateEndPoint() const { return MyPrivateEndPoint_; };
 | 
							[[nodiscard]] std::string PrivateEndPoint() const { return MyPrivateEndPoint_; };
 | 
				
			||||||
		[[nodiscard]] std::string PublicEndPoint() const { return MyPublicEndPoint_; };
 | 
							[[nodiscard]] std::string PublicEndPoint() const { return MyPublicEndPoint_; };
 | 
				
			||||||
		[[nodiscard]] const SubSystemVec & GetFullSubSystems() { return SubSystems_; }
 | 
							[[nodiscard]] const SubSystemVec &GetFullSubSystems() { return SubSystems_; }
 | 
				
			||||||
		inline uint64_t DaemonBusTimer() const { return DAEMON_BUS_TIMER; };
 | 
							inline uint64_t DaemonBusTimer() const { return DAEMON_BUS_TIMER; };
 | 
				
			||||||
        [[nodiscard]] const std::string & AppName() { return DAEMON_APP_NAME; }
 | 
							[[nodiscard]] const std::string &AppName() { return DAEMON_APP_NAME; }
 | 
				
			||||||
		static inline uint64_t GetPID() { return Poco::Process::id(); };
 | 
							static inline uint64_t GetPID() { return Poco::Process::id(); };
 | 
				
			||||||
		[[nodiscard]] inline const std::string GetPublicAPIEndPoint() { return MyPublicEndPoint_ + "/api/v1"; };
 | 
							[[nodiscard]] inline std::string GetPublicAPIEndPoint() const {
 | 
				
			||||||
		[[nodiscard]] inline const std::string & GetUIURI() const { return UIURI_;};
 | 
								return MyPublicEndPoint_ + "/api/v1";
 | 
				
			||||||
		[[nodiscard]] inline uint64_t Random(uint64_t ceiling) { return (RandomEngine_() % ceiling); }
 | 
							};
 | 
				
			||||||
		[[nodiscard]] inline uint64_t Random(uint64_t min, uint64_t max) {
 | 
							[[nodiscard]] inline const std::string &GetUIURI() const { return UIURI_; };
 | 
				
			||||||
		    return ((RandomEngine_() % (max-min)) + min);
 | 
							[[nodiscard]] inline uint64_t Random(uint64_t ceiling) {
 | 
				
			||||||
 | 
								return (RandomEngine_() % ceiling);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
        virtual void GetExtraConfiguration(Poco::JSON::Object & Cfg) {
 | 
							[[nodiscard]] inline uint64_t Random(uint64_t min, uint64_t max) {
 | 
				
			||||||
            Cfg.set("additionalConfiguration",false);
 | 
								return ((RandomEngine_() % (max - min)) + min);
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
		static MicroService & instance() { return *instance_; }
 | 
							virtual void GetExtraConfiguration(Poco::JSON::Object &Cfg) {
 | 
				
			||||||
 | 
								Cfg.set("additionalConfiguration", false);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							static MicroService &instance() { return *instance_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        inline void Exit(int Reason);
 | 
							inline void Exit(int Reason) { std::exit(Reason); }
 | 
				
			||||||
		void BusMessageReceived(const std::string &Key, const std::string & Payload);
 | 
					
 | 
				
			||||||
		Types::MicroServiceMetaVec GetServices(const std::string & Type);
 | 
							void BusMessageReceived(const std::string &Key, const std::string &Payload);
 | 
				
			||||||
 | 
							Types::MicroServiceMetaVec GetServices(const std::string &Type);
 | 
				
			||||||
		Types::MicroServiceMetaVec GetServices();
 | 
							Types::MicroServiceMetaVec GetServices();
 | 
				
			||||||
		void LoadConfigurationFile();
 | 
							void LoadConfigurationFile();
 | 
				
			||||||
		void Reload();
 | 
							void Reload();
 | 
				
			||||||
		void LoadMyConfig();
 | 
							void LoadMyConfig();
 | 
				
			||||||
		void initialize(Poco::Util::Application &self) override;
 | 
							void initialize(Poco::Util::Application &self) override;
 | 
				
			||||||
		void uninitialize() override;
 | 
					        void StartEverything(Poco::Util::Application &self);
 | 
				
			||||||
 | 
					        void StopEverything(Poco::Util::Application &self);
 | 
				
			||||||
 | 
					        void uninitialize() override;
 | 
				
			||||||
		void reinitialize(Poco::Util::Application &self) override;
 | 
							void reinitialize(Poco::Util::Application &self) override;
 | 
				
			||||||
		void defineOptions(Poco::Util::OptionSet &options) override;
 | 
							void defineOptions(Poco::Util::OptionSet &options) override;
 | 
				
			||||||
		void handleHelp(const std::string &name, const std::string &value);
 | 
							void handleHelp(const std::string &name, const std::string &value);
 | 
				
			||||||
@@ -136,71 +131,91 @@ namespace OpenWifi {
 | 
				
			|||||||
		void Reload(const std::string &Sub);
 | 
							void Reload(const std::string &Sub);
 | 
				
			||||||
		Types::StringVec GetSubSystems() const;
 | 
							Types::StringVec GetSubSystems() const;
 | 
				
			||||||
		Types::StringPairVec GetLogLevels();
 | 
							Types::StringPairVec GetLogLevels();
 | 
				
			||||||
		const Types::StringVec & GetLogLevelNames();
 | 
							static const Types::StringVec &GetLogLevelNames();
 | 
				
			||||||
		uint64_t ConfigGetInt(const std::string &Key,uint64_t Default);
 | 
							uint64_t ConfigGetInt(const std::string &Key, uint64_t Default);
 | 
				
			||||||
		uint64_t ConfigGetInt(const std::string &Key);
 | 
							uint64_t ConfigGetInt(const std::string &Key);
 | 
				
			||||||
		uint64_t ConfigGetBool(const std::string &Key,bool Default);
 | 
							uint64_t ConfigGetBool(const std::string &Key, bool Default);
 | 
				
			||||||
		uint64_t ConfigGetBool(const std::string &Key);
 | 
							uint64_t ConfigGetBool(const std::string &Key);
 | 
				
			||||||
		std::string ConfigGetString(const std::string &Key,const std::string & Default);
 | 
							std::string ConfigGetString(const std::string &Key, const std::string &Default);
 | 
				
			||||||
		std::string ConfigGetString(const std::string &Key);
 | 
							std::string ConfigGetString(const std::string &Key);
 | 
				
			||||||
		std::string ConfigPath(const std::string &Key,const std::string & Default);
 | 
							std::string ConfigPath(const std::string &Key, const std::string &Default);
 | 
				
			||||||
		std::string ConfigPath(const std::string &Key);
 | 
							std::string ConfigPath(const std::string &Key);
 | 
				
			||||||
		std::string Encrypt(const std::string &S);
 | 
							std::string Encrypt(const std::string &S);
 | 
				
			||||||
		std::string Decrypt(const std::string &S);
 | 
							std::string Decrypt(const std::string &S);
 | 
				
			||||||
		std::string MakeSystemEventMessage( const std::string & Type ) const;
 | 
							std::string MakeSystemEventMessage(const std::string &Type) const;
 | 
				
			||||||
		[[nodiscard]] bool IsValidAPIKEY(const Poco::Net::HTTPServerRequest &Request);
 | 
							[[nodiscard]] bool IsValidAPIKEY(const Poco::Net::HTTPServerRequest &Request);
 | 
				
			||||||
		static void SavePID();
 | 
							static void SavePID();
 | 
				
			||||||
		int main(const ArgVec &args) override;
 | 
							int main(const ArgVec &args) override;
 | 
				
			||||||
        void InitializeLoggingSystem();
 | 
							void InitializeLoggingSystem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void DeleteOverrideConfiguration();
 | 
							void DeleteOverrideConfiguration();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] std::string Sign(Poco::JWT::Token &T, const std::string &Algo);
 | 
							[[nodiscard]] std::string Sign(Poco::JWT::Token &T, const std::string &Algo);
 | 
				
			||||||
		void AddActivity(const std::string &Activity);
 | 
							void AddActivity(const std::string &Activity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static void SetConsoleLogs(bool UseAsync, bool AllowWebSocket, const std::string & FormatterPattern);
 | 
							static void SetConsoleLogs(bool UseAsync, bool AllowWebSocket,
 | 
				
			||||||
        static void SetColorConsoleLogs(bool UseAsync, bool AllowWebSocket, const std::string & FormatterPattern);
 | 
													   const std::string &FormatterPattern);
 | 
				
			||||||
        static void SetSQLLogs(bool UseAsync, bool AllowWebSocket, const std::string & FormatterPattern);
 | 
							static void SetColorConsoleLogs(bool UseAsync, bool AllowWebSocket,
 | 
				
			||||||
        static void SetSyslogLogs(bool UseAsync, bool AllowWebSocket, const std::string & FormatterPattern);
 | 
															const std::string &FormatterPattern);
 | 
				
			||||||
        static void SetFileLogs(bool UseAsync, bool AllowWebSocket, const std::string & FormatterPattern, const std::string & root_env_var);
 | 
							static void SetSQLLogs(bool UseAsync, bool AllowWebSocket,
 | 
				
			||||||
        inline bool AllowExternalMicroServices() const { return AllowExternalMicroServices_; }
 | 
												   const std::string &FormatterPattern);
 | 
				
			||||||
 | 
							static void SetSyslogLogs(bool UseAsync, bool AllowWebSocket,
 | 
				
			||||||
 | 
													  const std::string &FormatterPattern);
 | 
				
			||||||
 | 
							static void SetFileLogs(bool UseAsync, bool AllowWebSocket,
 | 
				
			||||||
 | 
													const std::string &FormatterPattern,
 | 
				
			||||||
 | 
													const std::string &root_env_var);
 | 
				
			||||||
 | 
							inline bool AllowExternalMicroServices() const { return AllowExternalMicroServices_; }
 | 
				
			||||||
 | 
					        const ArgVec &Args() const { return Args_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        inline void SetConfigContent(const std::string &Content) { ConfigContent_ = Content; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        inline std::optional<OpenWifi::Types::MicroServiceMeta> GetPrivateEndPointServiceKey( const std::string & ServicePrivateEndPoint ) {
 | 
				
			||||||
 | 
					            std::lock_guard   G(InfraMutex_);
 | 
				
			||||||
 | 
					            auto K = Services_.find(ServicePrivateEndPoint);
 | 
				
			||||||
 | 
					            if(K==end(Services_)) {
 | 
				
			||||||
 | 
					                return std::nullopt;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return K->second;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
	    static MicroService         * instance_;
 | 
							static MicroService *instance_;
 | 
				
			||||||
		bool                        HelpRequested_ = false;
 | 
							bool HelpRequested_ = false;
 | 
				
			||||||
		std::string                 LogDir_;
 | 
							std::string LogDir_;
 | 
				
			||||||
		std::string                 ConfigFileName_;
 | 
							std::string ConfigFileName_;
 | 
				
			||||||
		uint64_t                    ID_ = 1;
 | 
					        std::string ConfigContent_;
 | 
				
			||||||
		Poco::SharedPtr<Poco::Crypto::RSAKey>	AppKey_;
 | 
							uint64_t ID_ = 1;
 | 
				
			||||||
		bool                        DebugMode_ = false;
 | 
							Poco::SharedPtr<Poco::Crypto::RSAKey> AppKey_;
 | 
				
			||||||
		std::string 				DataDir_;
 | 
							bool DebugMode_ = false;
 | 
				
			||||||
		std::string                 WWWAssetsDir_;
 | 
							std::string DataDir_;
 | 
				
			||||||
		Poco::Crypto::CipherFactory & CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory();
 | 
							std::string WWWAssetsDir_;
 | 
				
			||||||
		Poco::Crypto::Cipher        * Cipher_ = nullptr;
 | 
							Poco::Crypto::CipherFactory &CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory();
 | 
				
			||||||
		Types::MicroServiceMetaMap	Services_;
 | 
							Poco::Crypto::Cipher *Cipher_ = nullptr;
 | 
				
			||||||
		std::string 				MyHash_;
 | 
							Types::MicroServiceMetaMap Services_;
 | 
				
			||||||
		std::string 				MyPrivateEndPoint_;
 | 
							std::string MyHash_;
 | 
				
			||||||
		std::string 				MyPublicEndPoint_;
 | 
							std::string MyPrivateEndPoint_;
 | 
				
			||||||
		std::string                 UIURI_;
 | 
							std::string MyPublicEndPoint_;
 | 
				
			||||||
		std::string 				Version_{ OW_VERSION::VERSION + "("+ OW_VERSION::BUILD + ")" + " - " + OW_VERSION::HASH };
 | 
							std::string UIURI_;
 | 
				
			||||||
		std::recursive_mutex		InfraMutex_;
 | 
							std::string Version_{OW_VERSION::VERSION + "(" + OW_VERSION::BUILD + ")" + " - " +
 | 
				
			||||||
		std::default_random_engine  RandomEngine_;
 | 
												 OW_VERSION::HASH};
 | 
				
			||||||
        Poco::Util::PropertyFileConfiguration   * PropConfigurationFile_ = nullptr;
 | 
							std::recursive_mutex InfraMutex_;
 | 
				
			||||||
		std::string                 DAEMON_PROPERTIES_FILENAME;
 | 
							std::default_random_engine RandomEngine_;
 | 
				
			||||||
		std::string                 DAEMON_ROOT_ENV_VAR;
 | 
							Poco::Util::PropertyFileConfiguration *PropConfigurationFile_ = nullptr;
 | 
				
			||||||
		std::string                 DAEMON_CONFIG_ENV_VAR;
 | 
							std::string DAEMON_PROPERTIES_FILENAME;
 | 
				
			||||||
		std::string                 DAEMON_APP_NAME;
 | 
							std::string DAEMON_ROOT_ENV_VAR;
 | 
				
			||||||
		uint64_t 	                DAEMON_BUS_TIMER;
 | 
							std::string DAEMON_CONFIG_ENV_VAR;
 | 
				
			||||||
        SubSystemVec			    SubSystems_;
 | 
							std::string DAEMON_APP_NAME;
 | 
				
			||||||
        bool                        NoAPISecurity_=false;
 | 
							uint64_t DAEMON_BUS_TIMER;
 | 
				
			||||||
        bool                        NoBuiltInCrypto_=false;
 | 
							SubSystemVec SubSystems_;
 | 
				
			||||||
        bool                        AllowExternalMicroServices_=false;
 | 
							bool NoAPISecurity_ = false;
 | 
				
			||||||
        Poco::JWT::Signer	        Signer_;
 | 
							bool NoBuiltInCrypto_ = false;
 | 
				
			||||||
		Poco::Logger				&Logger_;
 | 
							bool AllowExternalMicroServices_ = false;
 | 
				
			||||||
		Poco::ThreadPool				TimerPool_{"timer:pool",2,32};
 | 
							Poco::JWT::Signer Signer_;
 | 
				
			||||||
		std::unique_ptr<EventBusManager>	EventBusManager_;
 | 
							Poco::Logger &Logger_;
 | 
				
			||||||
    };
 | 
							Poco::ThreadPool TimerPool_{"timer:pool", 2, 32};
 | 
				
			||||||
 | 
					        ArgVec Args_;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline MicroService * MicroService::instance_ = nullptr;
 | 
						inline MicroService *MicroService::instance_ = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,25 +4,24 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "fmt/format.h"
 | 
					 | 
				
			||||||
#include "Poco/Util/Application.h"
 | 
					 | 
				
			||||||
#include "Poco/ErrorHandler.h"
 | 
					#include "Poco/ErrorHandler.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/JSONException.h"
 | 
				
			||||||
 | 
					#include "Poco/JSON/Template.h"
 | 
				
			||||||
#include "Poco/Net/NetException.h"
 | 
					#include "Poco/Net/NetException.h"
 | 
				
			||||||
#include "Poco/Net/SSLException.h"
 | 
					#include "Poco/Net/SSLException.h"
 | 
				
			||||||
#include "Poco/JSON/Template.h"
 | 
					 | 
				
			||||||
#include "Poco/JSON/JSONException.h"
 | 
					 | 
				
			||||||
#include "Poco/Thread.h"
 | 
					#include "Poco/Thread.h"
 | 
				
			||||||
 | 
					#include "Poco/Util/Application.h"
 | 
				
			||||||
 | 
					#include "fmt/format.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class MicroServiceErrorHandler : public Poco::ErrorHandler {
 | 
						class MicroServiceErrorHandler : public Poco::ErrorHandler {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit MicroServiceErrorHandler(Poco::Util::Application &App) : App_(App) {
 | 
							explicit MicroServiceErrorHandler(Poco::Util::Application &App) : App_(App) {}
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void exception(const Poco::Exception & Base) override {
 | 
							inline void exception(const Poco::Exception &Base) override {
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
				if(Poco::Thread::current()!= nullptr) {
 | 
									if (Poco::Thread::current() != nullptr) {
 | 
				
			||||||
					t_name = Poco::Thread::current()->getName();
 | 
										t_name = Poco::Thread::current()->getName();
 | 
				
			||||||
					t_id = Poco::Thread::current()->id();
 | 
										t_id = Poco::Thread::current()->id();
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
@@ -34,179 +33,167 @@ namespace OpenWifi {
 | 
				
			|||||||
				Base.rethrow();
 | 
									Base.rethrow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			} catch (const Poco::Net::InvalidCertificateException &E) {
 | 
								} catch (const Poco::Net::InvalidCertificateException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::InvalidCertificateException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::Net::InvalidCertificateException thr_name={} "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
			} catch (const Poco::Net::InvalidSocketException &E) {
 | 
								} catch (const Poco::Net::InvalidSocketException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::InvalidSocketException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::Net::InvalidSocketException thr_name={} thr_id={} "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
			} catch (const Poco::Net::WebSocketException &E) {
 | 
								} catch (const Poco::Net::WebSocketException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::WebSocketException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::Net::WebSocketException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::Net::ConnectionResetException &E) {
 | 
								} catch (const Poco::Net::ConnectionResetException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::ConnectionResetException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::Net::ConnectionResetException thr_name={} thr_id={} "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
			} catch (const Poco::Net::CertificateValidationException &E) {
 | 
								} catch (const Poco::Net::CertificateValidationException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::CertificateValidationException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::Net::CertificateValidationException thr_name={} "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
			} catch (const Poco::Net::SSLConnectionUnexpectedlyClosedException &E) {
 | 
								} catch (const Poco::Net::SSLConnectionUnexpectedlyClosedException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::SSLConnectionUnexpectedlyClosedException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::Net::SSLConnectionUnexpectedlyClosedException "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
			} catch (const Poco::Net::SSLContextException &E) {
 | 
								} catch (const Poco::Net::SSLContextException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::SSLContextException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::Net::SSLContextException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::Net::SSLException &E) {
 | 
								} catch (const Poco::Net::SSLException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::SSLException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::Net::SSLException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			} catch (const Poco::Net::InvalidAddressException &E) {
 | 
								} catch (const Poco::Net::InvalidAddressException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::InvalidAddressException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::Net::InvalidAddressException thr_name={} thr_id={} "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			} catch (const Poco::Net::NetException &E) {
 | 
								} catch (const Poco::Net::NetException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Net::NetException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::Net::NetException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			} catch (const Poco::IOException &E) {
 | 
								} catch (const Poco::IOException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::IOException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
										App_.logger(),
 | 
				
			||||||
													  E.displayText(),
 | 
										fmt::format(
 | 
				
			||||||
													  E.message(),
 | 
											"Poco::IOException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.what()));
 | 
											t_name, t_id, E.code(), E.displayText(), E.message(), E.what()));
 | 
				
			||||||
			} catch (const Poco::TimeoutException &E) {
 | 
								} catch (const Poco::TimeoutException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::TimeoutException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::TimeoutException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::NoThreadAvailableException &E) {
 | 
								} catch (const Poco::NoThreadAvailableException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::NoThreadAvailableException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::NoThreadAvailableException thr_name={} thr_id={} "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
			} catch (const Poco::OutOfMemoryException &E) {
 | 
								} catch (const Poco::OutOfMemoryException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::OutOfMemoryException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::OutOfMemoryException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::BadCastException &E) {
 | 
								} catch (const Poco::BadCastException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::BadCastException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::BadCastException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::DataException &E) {
 | 
								} catch (const Poco::DataException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::DataException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
										App_.logger(),
 | 
				
			||||||
													  E.displayText(),
 | 
										fmt::format(
 | 
				
			||||||
													  E.message(),
 | 
											"Poco::DataException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.what()));
 | 
											t_name, t_id, E.code(), E.displayText(), E.message(), E.what()));
 | 
				
			||||||
			} catch (const Poco::PoolOverflowException &E) {
 | 
								} catch (const Poco::PoolOverflowException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::PoolOverflowException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::PoolOverflowException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::SystemException &E) {
 | 
								} catch (const Poco::SystemException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::SystemException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::SystemException thr_name={} thr_id={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::RuntimeException &E) {
 | 
								} catch (const Poco::RuntimeException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::RuntimeException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::RuntimeException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::JSON::JSONTemplateException &E) {
 | 
								} catch (const Poco::JSON::JSONTemplateException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::JSON::JSONTemplateException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(),
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
											   fmt::format("Poco::JSON::JSONTemplateException thr_name={} thr_id={} "
 | 
				
			||||||
													  E.displayText(),
 | 
														   "code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.message(),
 | 
														   t_name, t_id, E.code(), E.displayText(), E.message(),
 | 
				
			||||||
													  E.what()));
 | 
														   E.what()));
 | 
				
			||||||
			} catch (const Poco::JSON::JSONException &E) {
 | 
								} catch (const Poco::JSON::JSONException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::JSON::JSONException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::JSON::JSONException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::ApplicationException &E) {
 | 
								} catch (const Poco::ApplicationException &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::ApplicationException thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(App_.logger(), fmt::format("Poco::ApplicationException thr_name={} "
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
																		  "thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.displayText(),
 | 
																		  t_name, t_id, E.code(), E.displayText(),
 | 
				
			||||||
													  E.message(),
 | 
																		  E.message(), E.what()));
 | 
				
			||||||
													  E.what()));
 | 
					 | 
				
			||||||
			} catch (const Poco::Exception &E) {
 | 
								} catch (const Poco::Exception &E) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco::Exception thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
									poco_error(
 | 
				
			||||||
													  t_name, t_id, E.code(),
 | 
										App_.logger(),
 | 
				
			||||||
													  E.displayText(),
 | 
										fmt::format(
 | 
				
			||||||
													  E.message(),
 | 
											"Poco::Exception thr_name={} thr_id={} code={} text={} msg={} what={}",
 | 
				
			||||||
													  E.what()));
 | 
											t_name, t_id, E.code(), E.displayText(), E.message(), E.what()));
 | 
				
			||||||
			} catch (...) {
 | 
								} catch (...) {
 | 
				
			||||||
				poco_error(App_.logger(), fmt::format("Poco:Generic thr_name={}",t_name, t_id));
 | 
									poco_error(App_.logger(), fmt::format("Poco:Generic thr_name={}", t_name, t_id));
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void exception(const std::exception & E) override {
 | 
							inline void exception(const std::exception &E) override {
 | 
				
			||||||
			if(Poco::Thread::current()!= nullptr) {
 | 
								if (Poco::Thread::current() != nullptr) {
 | 
				
			||||||
				t_name = Poco::Thread::current()->getName();
 | 
									t_name = Poco::Thread::current()->getName();
 | 
				
			||||||
				t_id = Poco::Thread::current()->id();
 | 
									t_id = Poco::Thread::current()->id();
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				t_name = "startup_code";
 | 
									t_name = "startup_code";
 | 
				
			||||||
				t_id = 0;
 | 
									t_id = 0;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			poco_warning(App_.logger(), fmt::format("std::exception in {}: {} thr_id={}",
 | 
								poco_warning(App_.logger(),
 | 
				
			||||||
													t_name,E.what(),
 | 
											 fmt::format("std::exception in {}: {} thr_id={}", t_name, E.what(), t_id));
 | 
				
			||||||
													t_id));
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void exception() override {
 | 
							inline void exception() override {
 | 
				
			||||||
			if(Poco::Thread::current()!= nullptr) {
 | 
								if (Poco::Thread::current() != nullptr) {
 | 
				
			||||||
				t_name = Poco::Thread::current()->getName();
 | 
									t_name = Poco::Thread::current()->getName();
 | 
				
			||||||
				t_id = Poco::Thread::current()->id();
 | 
									t_id = Poco::Thread::current()->id();
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				t_name = "startup_code";
 | 
									t_name = "startup_code";
 | 
				
			||||||
				t_id = 0;
 | 
									t_id = 0;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			poco_warning(App_.logger(), fmt::format("generic exception in {} thr_id={}",
 | 
								poco_warning(App_.logger(),
 | 
				
			||||||
													t_name, t_id));
 | 
											 fmt::format("generic exception in {} thr_id={}", t_name, t_id));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		Poco::Util::Application	&App_;
 | 
							Poco::Util::Application &App_;
 | 
				
			||||||
		std::string		t_name;
 | 
							std::string t_name;
 | 
				
			||||||
		int 			t_id=0;
 | 
							int t_id = 0;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -4,8 +4,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <map>
 | 
					#include <map>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/BasicEvent.h"
 | 
					#include "Poco/BasicEvent.h"
 | 
				
			||||||
#include "Poco/ExpireLRUCache.h"
 | 
					#include "Poco/ExpireLRUCache.h"
 | 
				
			||||||
@@ -13,46 +13,40 @@
 | 
				
			|||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
	class ConfigurationEntry {
 | 
						class ConfigurationEntry {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		template <typename T> explicit ConfigurationEntry(T def) :
 | 
							template <typename T> explicit ConfigurationEntry(T def) : Default_(def), Current_(def) {}
 | 
				
			||||||
											 Default_(def),
 | 
					
 | 
				
			||||||
											 Current_(def){
 | 
							template <typename T>
 | 
				
			||||||
 | 
							explicit ConfigurationEntry(T def, T cur, const std::string &Hint = "")
 | 
				
			||||||
 | 
								: Default_(def), Current_(cur), Hint_(Hint) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							inline ConfigurationEntry() = default;
 | 
				
			||||||
 | 
							inline ~ConfigurationEntry() = default;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							template <typename T> explicit operator T() const { return std::get<T>(Current_); }
 | 
				
			||||||
 | 
							inline ConfigurationEntry &operator=(const char *v) {
 | 
				
			||||||
 | 
								Current_ = std::string(v);
 | 
				
			||||||
 | 
								return *this;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							template <typename T> ConfigurationEntry &operator=(T v) {
 | 
				
			||||||
 | 
								Current_ = (T)v;
 | 
				
			||||||
 | 
								return *this;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		template <typename T> explicit ConfigurationEntry(T def, T cur, const std::string  &Hint="") :
 | 
							void reset() { Current_ = Default_; }
 | 
				
			||||||
																				  Default_(def),
 | 
					 | 
				
			||||||
																				  Current_(cur),
 | 
					 | 
				
			||||||
																				  Hint_(Hint){
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		inline ConfigurationEntry()=default;
 | 
					 | 
				
			||||||
		inline ~ConfigurationEntry()=default;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		template <typename T> explicit operator T () const { return std::get<T>(Current_); }
 | 
					 | 
				
			||||||
		inline ConfigurationEntry & operator=(const char *v) { Current_ = std::string(v); return *this;}
 | 
					 | 
				
			||||||
		template <typename T> ConfigurationEntry &  operator=(T v) { Current_ = (T) v; return *this;}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		void reset() {
 | 
					 | 
				
			||||||
			Current_ = Default_;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::variant<bool,uint64_t,std::string> Default_, Current_;
 | 
							std::variant<bool, uint64_t, std::string> Default_, Current_;
 | 
				
			||||||
		std::string Hint_;
 | 
							std::string Hint_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	inline std::string to_string(const ConfigurationEntry &v) { return (std::string) v; }
 | 
						inline std::string to_string(const ConfigurationEntry &v) { return (std::string)v; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	typedef std::map<std::string,ConfigurationEntry>    ConfigurationMap_t;
 | 
						typedef std::map<std::string, ConfigurationEntry> ConfigurationMap_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <typename T> class FIFO {
 | 
						template <typename T> class FIFO {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit FIFO(uint32_t Size) :
 | 
							explicit FIFO(uint32_t Size) : Size_(Size) { Buffer_ = new T[Size_]; }
 | 
				
			||||||
									   Size_(Size) {
 | 
					 | 
				
			||||||
			Buffer_ = new T [Size_];
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		~FIFO() {
 | 
							~FIFO() { delete[] Buffer_; }
 | 
				
			||||||
			delete [] Buffer_;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		mutable Poco::BasicEvent<bool> Writable_;
 | 
							mutable Poco::BasicEvent<bool> Writable_;
 | 
				
			||||||
		mutable Poco::BasicEvent<bool> Readable_;
 | 
							mutable Poco::BasicEvent<bool> Readable_;
 | 
				
			||||||
@@ -84,7 +78,7 @@ namespace OpenWifi {
 | 
				
			|||||||
					Write_ = 0;
 | 
										Write_ = 0;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				Used_++;
 | 
									Used_++;
 | 
				
			||||||
				MaxEverUsed_ = std::max(Used_,MaxEverUsed_);
 | 
									MaxEverUsed_ = std::max(Used_, MaxEverUsed_);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			bool flag = true;
 | 
								bool flag = true;
 | 
				
			||||||
			Readable_.notify(this, flag);
 | 
								Readable_.notify(this, flag);
 | 
				
			||||||
@@ -93,40 +87,32 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		inline bool isFull() {
 | 
							inline bool isFull() {
 | 
				
			||||||
			std::lock_guard M(Mutex_);
 | 
								std::lock_guard M(Mutex_);
 | 
				
			||||||
			return Used_==Buffer_->capacity();
 | 
								return Used_ == Buffer_->capacity();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline auto MaxEverUser() const { return MaxEverUsed_; }
 | 
							inline auto MaxEverUser() const { return MaxEverUsed_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::recursive_mutex    Mutex_;
 | 
							std::recursive_mutex Mutex_;
 | 
				
			||||||
		uint32_t 				Size_=0;
 | 
							uint32_t Size_ = 0;
 | 
				
			||||||
		uint32_t        		Read_=0;
 | 
							uint32_t Read_ = 0;
 | 
				
			||||||
		uint32_t        		Write_=0;
 | 
							uint32_t Write_ = 0;
 | 
				
			||||||
		uint32_t 				Used_=0;
 | 
							uint32_t Used_ = 0;
 | 
				
			||||||
		uint32_t 				MaxEverUsed_=0;
 | 
							uint32_t MaxEverUsed_ = 0;
 | 
				
			||||||
		T	  					* Buffer_ = nullptr;
 | 
							T *Buffer_ = nullptr;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <class Record, typename KeyType = std::string, int Size=256, int Expiry=60000> class RecordCache {
 | 
						template <class Record, typename KeyType = std::string, int Size = 256, int Expiry = 60000>
 | 
				
			||||||
 | 
						class RecordCache {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit RecordCache( KeyType Record::* Q) :
 | 
							explicit RecordCache(KeyType Record::*Q) : MemberOffset(Q){};
 | 
				
			||||||
												   MemberOffset(Q){
 | 
							inline auto update(const Record &R) { return Cache_.update(R.*MemberOffset, R); }
 | 
				
			||||||
												   };
 | 
							inline auto get(const KeyType &K) { return Cache_.get(K); }
 | 
				
			||||||
		inline auto update(const Record &R) {
 | 
							inline auto remove(const KeyType &K) { return Cache_.remove(K); }
 | 
				
			||||||
			return Cache_.update(R.*MemberOffset, R);
 | 
							inline auto remove(const Record &R) { return Cache_.remove(R.*MemberOffset); }
 | 
				
			||||||
		}
 | 
					
 | 
				
			||||||
		inline auto get(const KeyType &K) {
 | 
					 | 
				
			||||||
			return Cache_.get(K);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		inline auto remove(const KeyType &K) {
 | 
					 | 
				
			||||||
			return Cache_.remove(K);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		inline auto remove(const Record &R) {
 | 
					 | 
				
			||||||
			return Cache_.remove(R.*MemberOffset);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		KeyType Record::* MemberOffset;
 | 
							KeyType Record::*MemberOffset;
 | 
				
			||||||
		Poco::ExpireLRUCache<KeyType,Record>  Cache_{Size,Expiry};
 | 
							Poco::ExpireLRUCache<KeyType, Record> Cache_{Size, Expiry};
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -2,125 +2,139 @@
 | 
				
			|||||||
// Created by stephane bourque on 2022-10-25.
 | 
					// Created by stephane bourque on 2022-10-25.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/MicroService.h"
 | 
					 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					#include "framework/MicroService.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "framework/ALBserver.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
    const std::string &MicroServiceDataDirectory() { return MicroService::instance().DataDir(); }
 | 
						const std::string &MicroServiceDataDirectory() { return MicroService::instance().DataDir(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Types::MicroServiceMetaVec MicroServiceGetServices(const std::string &Type) {
 | 
						Types::MicroServiceMetaVec MicroServiceGetServices(const std::string &Type) {
 | 
				
			||||||
        return MicroService::instance().GetServices(Type);
 | 
							return MicroService::instance().GetServices(Type);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Types::MicroServiceMetaVec MicroServiceGetServices() {
 | 
						Types::MicroServiceMetaVec MicroServiceGetServices() {
 | 
				
			||||||
        return MicroService::instance().GetServices();
 | 
							return MicroService::instance().GetServices();
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServicePublicEndPoint() { return MicroService::instance().PublicEndPoint(); }
 | 
						std::string MicroServicePublicEndPoint() { return MicroService::instance().PublicEndPoint(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceConfigGetString(const std::string &Key, const std::string &DefaultValue) {
 | 
						std::string MicroServiceConfigGetString(const std::string &Key,
 | 
				
			||||||
        return MicroService::instance().ConfigGetString(Key, DefaultValue);
 | 
																const std::string &DefaultValue) {
 | 
				
			||||||
    }
 | 
							return MicroService::instance().ConfigGetString(Key, DefaultValue);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool MicroServiceConfigGetBool(const std::string &Key, bool DefaultValue) {
 | 
						bool MicroServiceConfigGetBool(const std::string &Key, bool DefaultValue) {
 | 
				
			||||||
        return MicroService::instance().ConfigGetBool(Key, DefaultValue);
 | 
							return MicroService::instance().ConfigGetBool(Key, DefaultValue);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::uint64_t MicroServiceConfigGetInt(const std::string &Key, std::uint64_t DefaultValue) {
 | 
						std::uint64_t MicroServiceConfigGetInt(const std::string &Key, std::uint64_t DefaultValue) {
 | 
				
			||||||
        return MicroService::instance().ConfigGetInt(Key, DefaultValue);
 | 
							return MicroService::instance().ConfigGetInt(Key, DefaultValue);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServicePrivateEndPoint() { return MicroService::instance().PrivateEndPoint(); }
 | 
						std::string MicroServicePrivateEndPoint() { return MicroService::instance().PrivateEndPoint(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::uint64_t MicroServiceID() { return MicroService::instance().ID(); }
 | 
						std::uint64_t MicroServiceID() { return MicroService::instance().ID(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool MicroServiceIsValidAPIKEY(const Poco::Net::HTTPServerRequest &Request) {
 | 
						bool MicroServiceIsValidAPIKEY(const Poco::Net::HTTPServerRequest &Request) {
 | 
				
			||||||
        return MicroService::instance().IsValidAPIKEY(Request);
 | 
							return MicroService::instance().IsValidAPIKEY(Request);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool MicroServiceNoAPISecurity() { return MicroService::instance().NoAPISecurity(); }
 | 
						bool MicroServiceNoAPISecurity() { return MicroService::instance().NoAPISecurity(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void MicroServiceLoadConfigurationFile() { MicroService::instance().LoadConfigurationFile(); }
 | 
						void MicroServiceLoadConfigurationFile() { MicroService::instance().LoadConfigurationFile(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void MicroServiceReload() { MicroService::instance().Reload(); }
 | 
						void MicroServiceReload() { MicroService::instance().Reload(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void MicroServiceReload(const std::string &Type) { MicroService::instance().Reload(Type); }
 | 
						void MicroServiceReload(const std::string &Type) { MicroService::instance().Reload(Type); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const Types::StringVec MicroServiceGetLogLevelNames() {
 | 
						Types::StringVec MicroServiceGetLogLevelNames() {
 | 
				
			||||||
        return MicroService::instance().GetLogLevelNames();
 | 
							return MicroService::instance().GetLogLevelNames();
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const Types::StringVec MicroServiceGetSubSystems() {
 | 
						Types::StringVec MicroServiceGetSubSystems() {
 | 
				
			||||||
        return MicroService::instance().GetSubSystems();
 | 
							return MicroService::instance().GetSubSystems();
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Types::StringPairVec MicroServiceGetLogLevels() { return MicroService::instance().GetLogLevels(); }
 | 
						Types::StringPairVec MicroServiceGetLogLevels() {
 | 
				
			||||||
 | 
							return MicroService::instance().GetLogLevels();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool MicroServiceSetSubsystemLogLevel(const std::string &SubSystem, const std::string &Level) {
 | 
						bool MicroServiceSetSubsystemLogLevel(const std::string &SubSystem, const std::string &Level) {
 | 
				
			||||||
        return MicroService::instance().SetSubsystemLogLevel(SubSystem, Level);
 | 
							return MicroService::instance().SetSubsystemLogLevel(SubSystem, Level);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void MicroServiceGetExtraConfiguration(Poco::JSON::Object &Answer) {
 | 
						void MicroServiceGetExtraConfiguration(Poco::JSON::Object &Answer) {
 | 
				
			||||||
        MicroService::instance().GetExtraConfiguration(Answer);
 | 
							MicroService::instance().GetExtraConfiguration(Answer);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceVersion() { return MicroService::instance().Version(); }
 | 
						std::string MicroServiceVersion() { return MicroService::instance().Version(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::uint64_t MicroServiceUptimeTotalSeconds() {
 | 
						std::uint64_t MicroServiceUptimeTotalSeconds() {
 | 
				
			||||||
        return MicroService::instance().uptime().totalSeconds();
 | 
							return MicroService::instance().uptime().totalSeconds();
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::uint64_t MicroServiceStartTimeEpochTime() {
 | 
						std::uint64_t MicroServiceStartTimeEpochTime() {
 | 
				
			||||||
        return MicroService::instance().startTime().epochTime();
 | 
							return MicroService::instance().startTime().epochTime();
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceGetUIURI() { return MicroService::instance().GetUIURI(); }
 | 
						std::string MicroServiceGetUIURI() { return MicroService::instance().GetUIURI(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const SubSystemVec MicroServiceGetFullSubSystems() {
 | 
						SubSystemVec MicroServiceGetFullSubSystems() {
 | 
				
			||||||
        return MicroService::instance().GetFullSubSystems();
 | 
							return MicroService::instance().GetFullSubSystems();
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceCreateUUID() { return MicroService::CreateUUID(); }
 | 
						std::string MicroServiceCreateUUID() { return MicroService::CreateUUID(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::uint64_t MicroServiceDaemonBusTimer() { return MicroService::instance().DaemonBusTimer(); }
 | 
						std::uint64_t MicroServiceDaemonBusTimer() { return MicroService::instance().DaemonBusTimer(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceMakeSystemEventMessage(const std::string &Type) {
 | 
						std::string MicroServiceMakeSystemEventMessage(const char *Type) {
 | 
				
			||||||
        return MicroService::instance().MakeSystemEventMessage(Type);
 | 
							return MicroService::instance().MakeSystemEventMessage(Type);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Poco::ThreadPool &MicroServiceTimerPool() { return MicroService::instance().TimerPool(); }
 | 
						Poco::ThreadPool &MicroServiceTimerPool() { return MicroService::instance().TimerPool(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceConfigPath(const std::string &Key,
 | 
						std::string MicroServiceConfigPath(const std::string &Key, const std::string &DefaultValue) {
 | 
				
			||||||
                                       const std::string &DefaultValue) {
 | 
							return MicroService::instance().ConfigPath(Key, DefaultValue);
 | 
				
			||||||
        return MicroService::instance().ConfigPath(Key, DefaultValue);
 | 
						}
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceWWWAssetsDir() {
 | 
						std::string MicroServiceWWWAssetsDir() { return MicroService::instance().WWWAssetsDir(); }
 | 
				
			||||||
        return MicroService::instance().WWWAssetsDir();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::uint64_t MicroServiceRandom(std::uint64_t Start,std::uint64_t End) {
 | 
						std::uint64_t MicroServiceRandom(std::uint64_t Start, std::uint64_t End) {
 | 
				
			||||||
        return MicroService::instance().Random(Start, End);
 | 
							return MicroService::instance().Random(Start, End);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::uint64_t MicroServiceRandom(std::uint64_t Range) {
 | 
						std::uint64_t MicroServiceRandom(std::uint64_t Range) {
 | 
				
			||||||
        return MicroService::instance().Random(Range);
 | 
							return MicroService::instance().Random(Range);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceSign(Poco::JWT::Token &T, const std::string &Algo) {
 | 
						std::string MicroServiceSign(Poco::JWT::Token &T, const std::string &Algo) {
 | 
				
			||||||
        return MicroService::instance().Sign(T, Algo);
 | 
							return MicroService::instance().Sign(T, Algo);
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string MicroServiceGetPublicAPIEndPoint() {
 | 
						std::string MicroServiceGetPublicAPIEndPoint() {
 | 
				
			||||||
        return MicroService::instance().GetPublicAPIEndPoint();
 | 
							return MicroService::instance().GetPublicAPIEndPoint();
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void MicroServiceDeleteOverrideConfiguration() {
 | 
						void MicroServiceDeleteOverrideConfiguration() {
 | 
				
			||||||
		return MicroService::instance().DeleteOverrideConfiguration();
 | 
							return MicroService::instance().DeleteOverrideConfiguration();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool AllowExternalMicroServices() {
 | 
						bool AllowExternalMicroServices() {
 | 
				
			||||||
        return MicroService::instance().AllowExternalMicroServices();
 | 
							return MicroService::instance().AllowExternalMicroServices();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void MicroServiceALBCallback( std::string Callback()) {
 | 
				
			||||||
 | 
							return ALBHealthCheckServer()->RegisterExtendedHealthMessage(Callback);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						std::string MicroServiceAccessKey() {
 | 
				
			||||||
 | 
							return MicroService::instance().Hash();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::optional<OpenWifi::Types::MicroServiceMeta> MicroServicePrivateAccessKey(const std::string &servicePrivateEndPoint) {
 | 
				
			||||||
 | 
					        return MicroService::instance().GetPrivateEndPointServiceKey(servicePrivateEndPoint);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,21 +8,24 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "framework/OpenWifiTypes.h"
 | 
					#include "framework/OpenWifiTypes.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/Net/HTTPServerRequest.h"
 | 
					 | 
				
			||||||
#include "Poco/JSON/Object.h"
 | 
					#include "Poco/JSON/Object.h"
 | 
				
			||||||
#include "Poco/ThreadPool.h"
 | 
					 | 
				
			||||||
#include "Poco/JWT/Token.h"
 | 
					#include "Poco/JWT/Token.h"
 | 
				
			||||||
 | 
					#include "Poco/Net/HTTPServerRequest.h"
 | 
				
			||||||
 | 
					#include "Poco/ThreadPool.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
	class SubSystemServer;
 | 
						class SubSystemServer;
 | 
				
			||||||
	using SubSystemVec=std::vector<SubSystemServer *>;
 | 
						using SubSystemVec = std::vector<SubSystemServer *>;
 | 
				
			||||||
	const std::string & MicroServiceDataDirectory();
 | 
						const std::string &MicroServiceDataDirectory();
 | 
				
			||||||
	Types::MicroServiceMetaVec MicroServiceGetServices(const std::string & Type);
 | 
						Types::MicroServiceMetaVec MicroServiceGetServices(const std::string &Type);
 | 
				
			||||||
    Types::MicroServiceMetaVec MicroServiceGetServices();
 | 
						Types::MicroServiceMetaVec MicroServiceGetServices();
 | 
				
			||||||
	std::string MicroServicePublicEndPoint();
 | 
						std::string MicroServicePublicEndPoint();
 | 
				
			||||||
	std::string MicroServiceConfigGetString(const std::string &Key, const std::string &DefaultValue);
 | 
						std::string MicroServiceConfigGetString(const std::string &Key,
 | 
				
			||||||
	bool MicroServiceConfigGetBool(const std::string &Key, bool DefaultValue);
 | 
																const std::string &DefaultValue);
 | 
				
			||||||
 | 
						std::string MicroServiceAccessKey();
 | 
				
			||||||
 | 
					    std::optional<OpenWifi::Types::MicroServiceMeta> MicroServicePrivateAccessKey(const std::string &servicePrivateEndPoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool MicroServiceConfigGetBool(const std::string &Key, bool DefaultValue);
 | 
				
			||||||
	std::uint64_t MicroServiceConfigGetInt(const std::string &Key, std::uint64_t DefaultValue);
 | 
						std::uint64_t MicroServiceConfigGetInt(const std::string &Key, std::uint64_t DefaultValue);
 | 
				
			||||||
	std::string MicroServicePrivateEndPoint();
 | 
						std::string MicroServicePrivateEndPoint();
 | 
				
			||||||
	std::uint64_t MicroServiceID();
 | 
						std::uint64_t MicroServiceID();
 | 
				
			||||||
@@ -31,8 +34,8 @@ namespace OpenWifi {
 | 
				
			|||||||
	void MicroServiceLoadConfigurationFile();
 | 
						void MicroServiceLoadConfigurationFile();
 | 
				
			||||||
	void MicroServiceReload();
 | 
						void MicroServiceReload();
 | 
				
			||||||
	void MicroServiceReload(const std::string &Type);
 | 
						void MicroServiceReload(const std::string &Type);
 | 
				
			||||||
	const Types::StringVec MicroServiceGetLogLevelNames();
 | 
						Types::StringVec MicroServiceGetLogLevelNames();
 | 
				
			||||||
	const Types::StringVec MicroServiceGetSubSystems();
 | 
						Types::StringVec MicroServiceGetSubSystems();
 | 
				
			||||||
	Types::StringPairVec MicroServiceGetLogLevels();
 | 
						Types::StringPairVec MicroServiceGetLogLevels();
 | 
				
			||||||
	bool MicroServiceSetSubsystemLogLevel(const std::string &SubSystem, const std::string &Level);
 | 
						bool MicroServiceSetSubsystemLogLevel(const std::string &SubSystem, const std::string &Level);
 | 
				
			||||||
	void MicroServiceGetExtraConfiguration(Poco::JSON::Object &Answer);
 | 
						void MicroServiceGetExtraConfiguration(Poco::JSON::Object &Answer);
 | 
				
			||||||
@@ -40,18 +43,18 @@ namespace OpenWifi {
 | 
				
			|||||||
	std::uint64_t MicroServiceUptimeTotalSeconds();
 | 
						std::uint64_t MicroServiceUptimeTotalSeconds();
 | 
				
			||||||
	std::uint64_t MicroServiceStartTimeEpochTime();
 | 
						std::uint64_t MicroServiceStartTimeEpochTime();
 | 
				
			||||||
	std::string MicroServiceGetUIURI();
 | 
						std::string MicroServiceGetUIURI();
 | 
				
			||||||
	const SubSystemVec MicroServiceGetFullSubSystems();
 | 
						SubSystemVec MicroServiceGetFullSubSystems();
 | 
				
			||||||
	std::string MicroServiceCreateUUID();
 | 
						std::string MicroServiceCreateUUID();
 | 
				
			||||||
	std::uint64_t MicroServiceDaemonBusTimer();
 | 
						std::uint64_t MicroServiceDaemonBusTimer();
 | 
				
			||||||
	std::string MicroServiceMakeSystemEventMessage( const std::string & Type );
 | 
						std::string MicroServiceMakeSystemEventMessage(const char *Type);
 | 
				
			||||||
	Poco::ThreadPool & MicroServiceTimerPool();
 | 
						Poco::ThreadPool &MicroServiceTimerPool();
 | 
				
			||||||
	std::string MicroServiceConfigPath(const std::string &Key,
 | 
						std::string MicroServiceConfigPath(const std::string &Key, const std::string &DefaultValue);
 | 
				
			||||||
									   const std::string &DefaultValue);
 | 
						std::string MicroServiceWWWAssetsDir();
 | 
				
			||||||
    std::string MicroServiceWWWAssetsDir();
 | 
						std::uint64_t MicroServiceRandom(std::uint64_t Start, std::uint64_t End);
 | 
				
			||||||
    std::uint64_t MicroServiceRandom(std::uint64_t Start,std::uint64_t End);
 | 
						std::uint64_t MicroServiceRandom(std::uint64_t Range);
 | 
				
			||||||
    std::uint64_t MicroServiceRandom(std::uint64_t Range);
 | 
						std::string MicroServiceSign(Poco::JWT::Token &T, const std::string &Algo);
 | 
				
			||||||
    std::string MicroServiceSign(Poco::JWT::Token &T, const std::string &Algo);
 | 
						std::string MicroServiceGetPublicAPIEndPoint();
 | 
				
			||||||
    std::string MicroServiceGetPublicAPIEndPoint();
 | 
					 | 
				
			||||||
	void MicroServiceDeleteOverrideConfiguration();
 | 
						void MicroServiceDeleteOverrideConfiguration();
 | 
				
			||||||
    bool AllowExternalMicroServices();
 | 
						bool AllowExternalMicroServices();
 | 
				
			||||||
}
 | 
						void MicroServiceALBCallback( std::string Callback());
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,13 +10,13 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	static const std::string uSERVICE_SECURITY{"owsec"};
 | 
						static const std::string uSERVICE_SECURITY{"owsec"};
 | 
				
			||||||
	static const std::string uSERVICE_GATEWAY{"owgw"};
 | 
						static const std::string uSERVICE_GATEWAY{"owgw"};
 | 
				
			||||||
	static const std::string uSERVICE_FIRMWARE{ "owfms"};
 | 
						static const std::string uSERVICE_FIRMWARE{"owfms"};
 | 
				
			||||||
	static const std::string uSERVICE_TOPOLOGY{ "owtopo"};
 | 
						static const std::string uSERVICE_TOPOLOGY{"owtopo"};
 | 
				
			||||||
	static const std::string uSERVICE_PROVISIONING{ "owprov"};
 | 
						static const std::string uSERVICE_PROVISIONING{"owprov"};
 | 
				
			||||||
	static const std::string uSERVICE_OWLS{ "owls"};
 | 
						static const std::string uSERVICE_OWLS{"owls"};
 | 
				
			||||||
	static const std::string uSERVICE_SUBCRIBER{ "owsub"};
 | 
						static const std::string uSERVICE_SUBCRIBER{"owsub"};
 | 
				
			||||||
	static const std::string uSERVICE_INSTALLER{ "owinst"};
 | 
						static const std::string uSERVICE_INSTALLER{"owinst"};
 | 
				
			||||||
	static const std::string uSERVICE_ANALYTICS{ "owanalytics"};
 | 
						static const std::string uSERVICE_ANALYTICS{"owanalytics"};
 | 
				
			||||||
	static const std::string uSERVICE_OWRRM{ "owrrm"};
 | 
						static const std::string uSERVICE_OWRRM{"owrrm"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -4,286 +4,281 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "OpenAPIRequests.h"
 | 
					#include "OpenAPIRequests.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Poco/JSON/Parser.h"
 | 
				
			||||||
#include "Poco/Logger.h"
 | 
					#include "Poco/Logger.h"
 | 
				
			||||||
#include "Poco/URI.h"
 | 
					 | 
				
			||||||
#include "Poco/Net/HTTPRequest.h"
 | 
					#include "Poco/Net/HTTPRequest.h"
 | 
				
			||||||
#include "Poco/Net/HTTPSClientSession.h"
 | 
					#include "Poco/Net/HTTPSClientSession.h"
 | 
				
			||||||
#include "Poco/JSON/Parser.h"
 | 
					#include "Poco/URI.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "fmt/format.h"
 | 
					#include "fmt/format.h"
 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Poco::Net::HTTPServerResponse::HTTPStatus OpenAPIRequestGet::Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string & BearerToken) {
 | 
						Poco::Net::HTTPServerResponse::HTTPStatus
 | 
				
			||||||
	try {
 | 
						OpenAPIRequestGet::Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string &BearerToken) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		auto Services = MicroServiceGetServices(Type_);
 | 
								auto Services = MicroServiceGetServices(Type_);
 | 
				
			||||||
		for(auto const &Svc:Services) {
 | 
								for (auto const &Svc : Services) {
 | 
				
			||||||
			Poco::URI	URI(Svc.PrivateEndPoint);
 | 
									Poco::URI URI(Svc.PrivateEndPoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			auto Secure = (URI.getScheme() == "https");
 | 
									auto Secure = (URI.getScheme() == "https");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			URI.setPath(EndPoint_);
 | 
									URI.setPath(EndPoint_);
 | 
				
			||||||
			for (const auto &qp : QueryData_)
 | 
									for (const auto &qp : QueryData_)
 | 
				
			||||||
				URI.addQueryParameter(qp.first, qp.second);
 | 
										URI.addQueryParameter(qp.first, qp.second);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			std::string Path(URI.getPathAndQuery());
 | 
									std::string Path(URI.getPathAndQuery());
 | 
				
			||||||
			Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_GET,
 | 
									Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_GET, Path,
 | 
				
			||||||
										   Path,
 | 
																   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
										   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			poco_debug(Poco::Logger::get("REST-CALLER-GET"), fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_ ) );
 | 
									poco_debug(Poco::Logger::get("REST-CALLER-GET"),
 | 
				
			||||||
 | 
											   fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if(BearerToken.empty()) {
 | 
									if (BearerToken.empty()) {
 | 
				
			||||||
				Request.add("X-API-KEY", Svc.AccessKey);
 | 
										Request.add("X-API-KEY", Svc.AccessKey);
 | 
				
			||||||
				Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
										Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				// Authorization: Bearer ${token}
 | 
					 | 
				
			||||||
				Request.add("Authorization", "Bearer " + BearerToken);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if(Secure) {
 | 
					 | 
				
			||||||
				Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
					 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				Session.sendRequest(Request);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
					 | 
				
			||||||
				std::istream &is = Session.receiveResponse(Response);
 | 
					 | 
				
			||||||
				if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
					 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
					 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				return Response.getStatus();
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
					 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				Session.sendRequest(Request);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
					 | 
				
			||||||
				std::istream &is = Session.receiveResponse(Response);
 | 
					 | 
				
			||||||
				if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
					 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
					 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				return Response.getStatus();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	catch (const Poco::Exception &E)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		Poco::Logger::get("REST-CALLER-GET").log(E);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	Poco::Net::HTTPServerResponse::HTTPStatus OpenAPIRequestPut::Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string & BearerToken) {
 | 
					 | 
				
			||||||
	try {
 | 
					 | 
				
			||||||
		auto Services = MicroServiceGetServices(Type_);
 | 
					 | 
				
			||||||
		for(auto const &Svc:Services) {
 | 
					 | 
				
			||||||
			Poco::URI	URI(Svc.PrivateEndPoint);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			auto Secure = (URI.getScheme() == "https");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			URI.setPath(EndPoint_);
 | 
					 | 
				
			||||||
			for (const auto &qp : QueryData_)
 | 
					 | 
				
			||||||
				URI.addQueryParameter(qp.first, qp.second);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			poco_debug(Poco::Logger::get("REST-CALLER-PUT"), fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_ ) );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			std::string Path(URI.getPathAndQuery());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_PUT,
 | 
					 | 
				
			||||||
										   Path,
 | 
					 | 
				
			||||||
										   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
					 | 
				
			||||||
			std::ostringstream obody;
 | 
					 | 
				
			||||||
			Poco::JSON::Stringifier::stringify(Body_,obody);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			Request.setContentType("application/json");
 | 
					 | 
				
			||||||
			Request.setContentLength(obody.str().size());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if(BearerToken.empty()) {
 | 
					 | 
				
			||||||
				Request.add("X-API-KEY", Svc.AccessKey);
 | 
					 | 
				
			||||||
				Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				// Authorization: Bearer ${token}
 | 
					 | 
				
			||||||
				Request.add("Authorization", "Bearer " + BearerToken);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if(Secure) {
 | 
					 | 
				
			||||||
				Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
					 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				std::ostream &os = Session.sendRequest(Request);
 | 
					 | 
				
			||||||
				os << obody.str();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
					 | 
				
			||||||
				std::istream &is = Session.receiveResponse(Response);
 | 
					 | 
				
			||||||
				if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
					 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
					 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
					 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
										// Authorization: Bearer ${token}
 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
										Request.add("Authorization", "Bearer " + BearerToken);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return Response.getStatus();
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
					 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				std::ostream &os = Session.sendRequest(Request);
 | 
									if (Secure) {
 | 
				
			||||||
				os << obody.str();
 | 
										Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
										Session.sendRequest(Request);
 | 
				
			||||||
				std::istream &is = Session.receiveResponse(Response);
 | 
					
 | 
				
			||||||
				if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
										std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
										if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
										Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										Session.sendRequest(Request);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
										std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
 | 
										if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return Response.getStatus();
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
								Poco::Logger::get("REST-CALLER-GET").log(E);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	catch (const Poco::Exception &E)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		Poco::Logger::get("REST-CALLER-PUT").log(E);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Poco::Net::HTTPServerResponse::HTTPStatus OpenAPIRequestPost::Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string & BearerToken) {
 | 
						Poco::Net::HTTPServerResponse::HTTPStatus
 | 
				
			||||||
	try {
 | 
						OpenAPIRequestPut::Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string &BearerToken) {
 | 
				
			||||||
		auto Services = MicroServiceGetServices(Type_);
 | 
							try {
 | 
				
			||||||
 | 
								auto Services = MicroServiceGetServices(Type_);
 | 
				
			||||||
 | 
								for (auto const &Svc : Services) {
 | 
				
			||||||
 | 
									Poco::URI URI(Svc.PrivateEndPoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for(auto const &Svc:Services) {
 | 
									auto Secure = (URI.getScheme() == "https");
 | 
				
			||||||
			Poco::URI	URI(Svc.PrivateEndPoint);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									URI.setPath(EndPoint_);
 | 
				
			||||||
 | 
									for (const auto &qp : QueryData_)
 | 
				
			||||||
 | 
										URI.addQueryParameter(qp.first, qp.second);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			auto Secure = (URI.getScheme() == "https");
 | 
									poco_debug(Poco::Logger::get("REST-CALLER-PUT"),
 | 
				
			||||||
 | 
											   fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			URI.setPath(EndPoint_);
 | 
									std::string Path(URI.getPathAndQuery());
 | 
				
			||||||
			for (const auto &qp : QueryData_)
 | 
					 | 
				
			||||||
				URI.addQueryParameter(qp.first, qp.second);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			poco_debug(Poco::Logger::get("REST-CALLER-POST"),fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_ ) );
 | 
									Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_PUT, Path,
 | 
				
			||||||
 | 
																   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
 | 
									std::ostringstream obody;
 | 
				
			||||||
 | 
									Poco::JSON::Stringifier::stringify(Body_, obody);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			std::string Path(URI.getPathAndQuery());
 | 
									Request.setContentType("application/json");
 | 
				
			||||||
 | 
									Request.setContentLength(obody.str().size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_POST,
 | 
									if (BearerToken.empty()) {
 | 
				
			||||||
										   Path,
 | 
										Request.add("X-API-KEY", Svc.AccessKey);
 | 
				
			||||||
										   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
										Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
				
			||||||
			std::ostringstream obody;
 | 
					 | 
				
			||||||
			Poco::JSON::Stringifier::stringify(Body_,obody);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			Request.setContentType("application/json");
 | 
					 | 
				
			||||||
			Request.setContentLength(obody.str().size());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if(BearerToken.empty()) {
 | 
					 | 
				
			||||||
				Request.add("X-API-KEY", Svc.AccessKey);
 | 
					 | 
				
			||||||
				Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				// Authorization: Bearer ${token}
 | 
					 | 
				
			||||||
				Request.add("Authorization", "Bearer " + BearerToken);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if(Secure) {
 | 
					 | 
				
			||||||
				Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
					 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
					 | 
				
			||||||
				std::ostream &os = Session.sendRequest(Request);
 | 
					 | 
				
			||||||
				os << obody.str();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
					 | 
				
			||||||
				std::istream &is = Session.receiveResponse(Response);
 | 
					 | 
				
			||||||
				if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
					 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
					 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
					 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
										// Authorization: Bearer ${token}
 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
										Request.add("Authorization", "Bearer " + BearerToken);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return Response.getStatus();
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
					 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
					 | 
				
			||||||
				std::ostream &os = Session.sendRequest(Request);
 | 
					 | 
				
			||||||
				os << obody.str();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
									if (Secure) {
 | 
				
			||||||
				std::istream &is = Session.receiveResponse(Response);
 | 
										Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
				if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
					
 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
										std::ostream &os = Session.sendRequest(Request);
 | 
				
			||||||
 | 
										os << obody.str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
										std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
 | 
										if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					Poco::JSON::Parser P;
 | 
										Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
					ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										std::ostream &os = Session.sendRequest(Request);
 | 
				
			||||||
 | 
										os << obody.str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
										std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
 | 
										if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return Response.getStatus();
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
								Poco::Logger::get("REST-CALLER-PUT").log(E);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	catch (const Poco::Exception &E)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		Poco::Logger::get("REST-CALLER-POST").log(E);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Poco::Net::HTTPServerResponse::HTTPStatus OpenAPIRequestDelete::Do(const std::string & BearerToken) {
 | 
						Poco::Net::HTTPServerResponse::HTTPStatus
 | 
				
			||||||
	try {
 | 
						OpenAPIRequestPost::Do(Poco::JSON::Object::Ptr &ResponseObject,
 | 
				
			||||||
		auto Services = MicroServiceGetServices(Type_);
 | 
											   const std::string &BearerToken) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								auto Services = MicroServiceGetServices(Type_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for(auto const &Svc:Services) {
 | 
								for (auto const &Svc : Services) {
 | 
				
			||||||
			Poco::URI	URI(Svc.PrivateEndPoint);
 | 
									Poco::URI URI(Svc.PrivateEndPoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			auto Secure = (URI.getScheme() == "https");
 | 
									auto Secure = (URI.getScheme() == "https");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			URI.setPath(EndPoint_);
 | 
									URI.setPath(EndPoint_);
 | 
				
			||||||
			for (const auto &qp : QueryData_)
 | 
									for (const auto &qp : QueryData_)
 | 
				
			||||||
				URI.addQueryParameter(qp.first, qp.second);
 | 
										URI.addQueryParameter(qp.first, qp.second);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			poco_debug(Poco::Logger::get("REST-CALLER-DELETE"),fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_ ) );
 | 
									poco_debug(Poco::Logger::get("REST-CALLER-POST"),
 | 
				
			||||||
 | 
											   fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			std::string Path(URI.getPathAndQuery());
 | 
									std::string Path(URI.getPathAndQuery());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_DELETE,
 | 
									Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_POST, Path,
 | 
				
			||||||
										   Path,
 | 
																   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
										   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
									std::ostringstream obody;
 | 
				
			||||||
			if(BearerToken.empty()) {
 | 
									Poco::JSON::Stringifier::stringify(Body_, obody);
 | 
				
			||||||
				Request.add("X-API-KEY", Svc.AccessKey);
 | 
					
 | 
				
			||||||
				Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
									Request.setContentType("application/json");
 | 
				
			||||||
			} else {
 | 
									Request.setContentLength(obody.str().size());
 | 
				
			||||||
				// Authorization: Bearer ${token}
 | 
					
 | 
				
			||||||
				Request.add("Authorization", "Bearer " + BearerToken);
 | 
									if (BearerToken.empty()) {
 | 
				
			||||||
			}
 | 
										Request.add("X-API-KEY", Svc.AccessKey);
 | 
				
			||||||
 | 
										Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
				
			||||||
			if(Secure) {
 | 
									} else {
 | 
				
			||||||
				Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
										// Authorization: Bearer ${token}
 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
										Request.add("Authorization", "Bearer " + BearerToken);
 | 
				
			||||||
				Session.sendRequest(Request);
 | 
									}
 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
					
 | 
				
			||||||
				Session.receiveResponse(Response);
 | 
									if (Secure) {
 | 
				
			||||||
				return Response.getStatus();
 | 
										Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
			} else {
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
				Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
										std::ostream &os = Session.sendRequest(Request);
 | 
				
			||||||
				Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
										os << obody.str();
 | 
				
			||||||
				Session.sendRequest(Request);
 | 
					
 | 
				
			||||||
				Poco::Net::HTTPResponse Response;
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
				Session.receiveResponse(Response);
 | 
										std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
				return Response.getStatus();
 | 
										if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
 | 
										std::ostream &os = Session.sendRequest(Request);
 | 
				
			||||||
 | 
										os << obody.str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
										std::istream &is = Session.receiveResponse(Response);
 | 
				
			||||||
 | 
										if (Response.getStatus() == Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											Poco::JSON::Parser P;
 | 
				
			||||||
 | 
											ResponseObject = P.parse(is).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
								Poco::Logger::get("REST-CALLER-POST").log(E);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	catch (const Poco::Exception &E)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		Poco::Logger::get("REST-CALLER-DELETE").log(E);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Poco::Net::HTTPServerResponse::HTTPStatus
 | 
				
			||||||
 | 
						OpenAPIRequestDelete::Do(const std::string &BearerToken) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								auto Services = MicroServiceGetServices(Type_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								for (auto const &Svc : Services) {
 | 
				
			||||||
 | 
									Poco::URI URI(Svc.PrivateEndPoint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									auto Secure = (URI.getScheme() == "https");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									URI.setPath(EndPoint_);
 | 
				
			||||||
 | 
									for (const auto &qp : QueryData_)
 | 
				
			||||||
 | 
										URI.addQueryParameter(qp.first, qp.second);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									poco_debug(Poco::Logger::get("REST-CALLER-DELETE"),
 | 
				
			||||||
 | 
											   fmt::format(" {}", LoggingStr_.empty() ? URI.toString() : LoggingStr_));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									std::string Path(URI.getPathAndQuery());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									Poco::Net::HTTPRequest Request(Poco::Net::HTTPRequest::HTTP_DELETE, Path,
 | 
				
			||||||
 | 
																   Poco::Net::HTTPMessage::HTTP_1_1);
 | 
				
			||||||
 | 
									if (BearerToken.empty()) {
 | 
				
			||||||
 | 
										Request.add("X-API-KEY", Svc.AccessKey);
 | 
				
			||||||
 | 
										Request.add("X-INTERNAL-NAME", MicroServicePublicEndPoint());
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										// Authorization: Bearer ${token}
 | 
				
			||||||
 | 
										Request.add("Authorization", "Bearer " + BearerToken);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (Secure) {
 | 
				
			||||||
 | 
										Poco::Net::HTTPSClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
 | 
										Session.sendRequest(Request);
 | 
				
			||||||
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
										Session.receiveResponse(Response);
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										Poco::Net::HTTPClientSession Session(URI.getHost(), URI.getPort());
 | 
				
			||||||
 | 
										Session.setTimeout(Poco::Timespan(msTimeout_ / 1000, msTimeout_ % 1000));
 | 
				
			||||||
 | 
										Session.sendRequest(Request);
 | 
				
			||||||
 | 
										Poco::Net::HTTPResponse Response;
 | 
				
			||||||
 | 
										Session.receiveResponse(Response);
 | 
				
			||||||
 | 
										return Response.getStatus();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} catch (const Poco::Exception &E) {
 | 
				
			||||||
 | 
								Poco::Logger::get("REST-CALLER-DELETE").log(E);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return Poco::Net::HTTPServerResponse::HTTP_GATEWAY_TIMEOUT;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -15,96 +15,79 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	class OpenAPIRequestGet {
 | 
						class OpenAPIRequestGet {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit OpenAPIRequestGet( const std::string & Type,
 | 
							explicit OpenAPIRequestGet(const std::string &Type, const std::string &EndPoint,
 | 
				
			||||||
								   const std::string & EndPoint,
 | 
													   const Types::StringPairVec &QueryData, uint64_t msTimeout,
 | 
				
			||||||
								   const Types::StringPairVec & QueryData,
 | 
													   const std::string &LoggingStr = "")
 | 
				
			||||||
								   uint64_t msTimeout,
 | 
								: Type_(Type), EndPoint_(EndPoint), QueryData_(QueryData), msTimeout_(msTimeout),
 | 
				
			||||||
                                   const std::string &LoggingStr=""):
 | 
								  LoggingStr_(LoggingStr){};
 | 
				
			||||||
														 Type_(Type),
 | 
							Poco::Net::HTTPServerResponse::HTTPStatus Do(Poco::JSON::Object::Ptr &ResponseObject,
 | 
				
			||||||
														 EndPoint_(EndPoint),
 | 
																		 const std::string &BearerToken = "");
 | 
				
			||||||
														 QueryData_(QueryData),
 | 
					
 | 
				
			||||||
														 msTimeout_(msTimeout),
 | 
					 | 
				
			||||||
                                                         LoggingStr_(LoggingStr){};
 | 
					 | 
				
			||||||
		Poco::Net::HTTPServerResponse::HTTPStatus Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string & BearerToken = "");
 | 
					 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::string 			Type_;
 | 
							std::string Type_;
 | 
				
			||||||
		std::string 			EndPoint_;
 | 
							std::string EndPoint_;
 | 
				
			||||||
		Types::StringPairVec 	QueryData_;
 | 
							Types::StringPairVec QueryData_;
 | 
				
			||||||
		uint64_t 				msTimeout_;
 | 
							uint64_t msTimeout_;
 | 
				
			||||||
        std::string             LoggingStr_;
 | 
							std::string LoggingStr_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class OpenAPIRequestPut {
 | 
						class OpenAPIRequestPut {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit OpenAPIRequestPut( const std::string & Type,
 | 
							explicit OpenAPIRequestPut(const std::string &Type, const std::string &EndPoint,
 | 
				
			||||||
								   const std::string & EndPoint,
 | 
													   const Types::StringPairVec &QueryData,
 | 
				
			||||||
								   const Types::StringPairVec & QueryData,
 | 
													   const Poco::JSON::Object &Body, uint64_t msTimeout,
 | 
				
			||||||
								   const Poco::JSON::Object & Body,
 | 
													   const std::string &LoggingStr = "")
 | 
				
			||||||
								   uint64_t msTimeout,
 | 
								: Type_(Type), EndPoint_(EndPoint), QueryData_(QueryData), msTimeout_(msTimeout),
 | 
				
			||||||
                                   const std::string &LoggingStr=""):
 | 
								  Body_(Body), LoggingStr_(LoggingStr){};
 | 
				
			||||||
														 Type_(Type),
 | 
					 | 
				
			||||||
														 EndPoint_(EndPoint),
 | 
					 | 
				
			||||||
														 QueryData_(QueryData),
 | 
					 | 
				
			||||||
														 msTimeout_(msTimeout),
 | 
					 | 
				
			||||||
														 Body_(Body),
 | 
					 | 
				
			||||||
                                                         LoggingStr_(LoggingStr){};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Poco::Net::HTTPServerResponse::HTTPStatus Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string & BearerToken = "");
 | 
							Poco::Net::HTTPServerResponse::HTTPStatus Do(Poco::JSON::Object::Ptr &ResponseObject,
 | 
				
			||||||
 | 
																		 const std::string &BearerToken = "");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::string 			Type_;
 | 
							std::string Type_;
 | 
				
			||||||
		std::string 			EndPoint_;
 | 
							std::string EndPoint_;
 | 
				
			||||||
		Types::StringPairVec 	QueryData_;
 | 
							Types::StringPairVec QueryData_;
 | 
				
			||||||
		uint64_t 				msTimeout_;
 | 
							uint64_t msTimeout_;
 | 
				
			||||||
		Poco::JSON::Object      Body_;
 | 
							Poco::JSON::Object Body_;
 | 
				
			||||||
        std::string             LoggingStr_;
 | 
							std::string LoggingStr_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class OpenAPIRequestPost {
 | 
						class OpenAPIRequestPost {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit OpenAPIRequestPost( const std::string & Type,
 | 
							explicit OpenAPIRequestPost(const std::string &Type, const std::string &EndPoint,
 | 
				
			||||||
									const std::string & EndPoint,
 | 
														const Types::StringPairVec &QueryData,
 | 
				
			||||||
									const Types::StringPairVec & QueryData,
 | 
														const Poco::JSON::Object &Body, uint64_t msTimeout,
 | 
				
			||||||
									const Poco::JSON::Object & Body,
 | 
														const std::string &LoggingStr = "")
 | 
				
			||||||
									uint64_t msTimeout,
 | 
								: Type_(Type), EndPoint_(EndPoint), QueryData_(QueryData), msTimeout_(msTimeout),
 | 
				
			||||||
                                   const std::string &LoggingStr=""):
 | 
								  Body_(Body), LoggingStr_(LoggingStr){};
 | 
				
			||||||
														  Type_(Type),
 | 
							Poco::Net::HTTPServerResponse::HTTPStatus Do(Poco::JSON::Object::Ptr &ResponseObject,
 | 
				
			||||||
														  EndPoint_(EndPoint),
 | 
																		 const std::string &BearerToken = "");
 | 
				
			||||||
														  QueryData_(QueryData),
 | 
					
 | 
				
			||||||
														  msTimeout_(msTimeout),
 | 
					 | 
				
			||||||
														  Body_(Body),
 | 
					 | 
				
			||||||
                                                         LoggingStr_(LoggingStr){};
 | 
					 | 
				
			||||||
		Poco::Net::HTTPServerResponse::HTTPStatus Do(Poco::JSON::Object::Ptr &ResponseObject, const std::string & BearerToken = "");
 | 
					 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::string 			Type_;
 | 
							std::string Type_;
 | 
				
			||||||
		std::string 			EndPoint_;
 | 
							std::string EndPoint_;
 | 
				
			||||||
		Types::StringPairVec 	QueryData_;
 | 
							Types::StringPairVec QueryData_;
 | 
				
			||||||
		uint64_t 				msTimeout_;
 | 
							uint64_t msTimeout_;
 | 
				
			||||||
		Poco::JSON::Object      Body_;
 | 
							Poco::JSON::Object Body_;
 | 
				
			||||||
        std::string             LoggingStr_;
 | 
							std::string LoggingStr_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class OpenAPIRequestDelete {
 | 
						class OpenAPIRequestDelete {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		explicit OpenAPIRequestDelete(  const std::string & Type,
 | 
							explicit OpenAPIRequestDelete(const std::string &Type, const std::string &EndPoint,
 | 
				
			||||||
									    const std::string & EndPoint,
 | 
														  const Types::StringPairVec &QueryData, uint64_t msTimeout,
 | 
				
			||||||
									    const Types::StringPairVec & QueryData,
 | 
														  const std::string &LoggingStr = "")
 | 
				
			||||||
									    uint64_t msTimeout,
 | 
								: Type_(Type), EndPoint_(EndPoint), QueryData_(QueryData), msTimeout_(msTimeout),
 | 
				
			||||||
                                        const std::string &LoggingStr=""):
 | 
								  LoggingStr_(LoggingStr){};
 | 
				
			||||||
                                            Type_(Type),
 | 
							Poco::Net::HTTPServerResponse::HTTPStatus Do(const std::string &BearerToken = "");
 | 
				
			||||||
                                            EndPoint_(EndPoint),
 | 
					 | 
				
			||||||
                                            QueryData_(QueryData),
 | 
					 | 
				
			||||||
                                            msTimeout_(msTimeout),
 | 
					 | 
				
			||||||
                                            LoggingStr_(LoggingStr){};
 | 
					 | 
				
			||||||
		Poco::Net::HTTPServerResponse::HTTPStatus Do(const std::string & BearerToken = "");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::string 			Type_;
 | 
							std::string Type_;
 | 
				
			||||||
		std::string 			EndPoint_;
 | 
							std::string EndPoint_;
 | 
				
			||||||
		Types::StringPairVec 	QueryData_;
 | 
							Types::StringPairVec QueryData_;
 | 
				
			||||||
		uint64_t 				msTimeout_;
 | 
							uint64_t msTimeout_;
 | 
				
			||||||
		Poco::JSON::Object      Body_;
 | 
							Poco::JSON::Object Body_;
 | 
				
			||||||
        std::string             LoggingStr_;
 | 
							std::string LoggingStr_;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,70 +4,74 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <functional>
 | 
				
			||||||
 | 
					#include <list>
 | 
				
			||||||
#include <map>
 | 
					#include <map>
 | 
				
			||||||
 | 
					#include <queue>
 | 
				
			||||||
 | 
					#include <set>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
#include <utility>
 | 
					#include <utility>
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
#include <functional>
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <queue>
 | 
					 | 
				
			||||||
#include <list>
 | 
					 | 
				
			||||||
#include <set>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi::Types {
 | 
					namespace OpenWifi::Types {
 | 
				
			||||||
    typedef std::pair<std::string,std::string>                  StringPair;
 | 
						typedef std::pair<std::string, std::string> StringPair;
 | 
				
			||||||
    typedef std::vector<StringPair>	                            StringPairVec;
 | 
						typedef std::vector<StringPair> StringPairVec;
 | 
				
			||||||
    typedef std::queue<StringPair>	                            StringPairQueue;
 | 
						typedef std::queue<StringPair> StringPairQueue;
 | 
				
			||||||
    typedef std::vector<std::string>						    StringVec;
 | 
						typedef std::vector<std::string> StringVec;
 | 
				
			||||||
    typedef std::set<std::string>                               StringSet;
 | 
						typedef std::set<std::string> StringSet;
 | 
				
			||||||
    typedef std::map<std::string,std::set<std::string>>		    StringMapStringSet;
 | 
						typedef std::map<std::string, std::set<std::string>> StringMapStringSet;
 | 
				
			||||||
    typedef std::function<void(const std::string &, const std::string &)>       TopicNotifyFunction;
 | 
						typedef std::function<void(const std::string &, const std::string &)> TopicNotifyFunction;
 | 
				
			||||||
    typedef std::list<std::pair<TopicNotifyFunction,int>>       TopicNotifyFunctionList;
 | 
						typedef std::list<std::pair<TopicNotifyFunction, int>> TopicNotifyFunctionList;
 | 
				
			||||||
    typedef std::map<std::string, TopicNotifyFunctionList>      NotifyTable;
 | 
						typedef std::map<std::string, TopicNotifyFunctionList> NotifyTable;
 | 
				
			||||||
    typedef std::map<std::string,uint64_t>                      CountedMap;
 | 
						typedef std::map<std::string, uint64_t> CountedMap;
 | 
				
			||||||
    typedef std::vector<uint64_t>                               TagList;
 | 
						typedef std::vector<uint64_t> TagList;
 | 
				
			||||||
    typedef std::string                                         UUID_t;
 | 
						typedef std::string UUID_t;
 | 
				
			||||||
    typedef std::vector<UUID_t>                                 UUIDvec_t;
 | 
						typedef std::vector<UUID_t> UUIDvec_t;
 | 
				
			||||||
    typedef std::map<std::string,std::map<uint32_t,uint64_t>>   Counted3DMapSII;
 | 
						typedef std::map<std::string, std::map<uint32_t, uint64_t>> Counted3DMapSII;
 | 
				
			||||||
 | 
						typedef std::vector<int64_t> IntList;
 | 
				
			||||||
 | 
						typedef std::vector<uint64_t> UIntList;
 | 
				
			||||||
 | 
						typedef std::vector<double> DoubleList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct MicroServiceMeta {
 | 
						struct MicroServiceMeta {
 | 
				
			||||||
		uint64_t 		Id=0;
 | 
							uint64_t Id = 0;
 | 
				
			||||||
		std::string 	Type;
 | 
							std::string Type;
 | 
				
			||||||
		std::string 	PrivateEndPoint;
 | 
							std::string PrivateEndPoint;
 | 
				
			||||||
		std::string 	PublicEndPoint;
 | 
							std::string PublicEndPoint;
 | 
				
			||||||
		std::string 	AccessKey;
 | 
							std::string AccessKey;
 | 
				
			||||||
		std::string		Version;
 | 
							std::string Version;
 | 
				
			||||||
		uint64_t 		LastUpdate=0;
 | 
							uint64_t LastUpdate = 0;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	typedef std::map<std::string, MicroServiceMeta>				MicroServiceMetaMap;
 | 
						typedef std::map<std::string, MicroServiceMeta> MicroServiceMetaMap;
 | 
				
			||||||
	typedef std::vector<MicroServiceMeta>						MicroServiceMetaVec;
 | 
						typedef std::vector<MicroServiceMeta> MicroServiceMetaVec;
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi::Types
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline void UpdateCountedMap(OpenWifi::Types::CountedMap &M, const std::string &S, uint64_t Increment=1) {
 | 
						inline void UpdateCountedMap(OpenWifi::Types::CountedMap &M, const std::string &S,
 | 
				
			||||||
        auto it = M.find(S);
 | 
													 uint64_t Increment = 1) {
 | 
				
			||||||
        if(it==M.end())
 | 
							auto it = M.find(S);
 | 
				
			||||||
            M[S] = Increment;
 | 
							if (it == M.end())
 | 
				
			||||||
        else
 | 
								M[S] = Increment;
 | 
				
			||||||
            it->second += Increment;
 | 
							else
 | 
				
			||||||
    }
 | 
								it->second += Increment;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline void UpdateCountedMap(OpenWifi::Types::Counted3DMapSII &M, const std::string &S, uint32_t Index, uint64_t Increment=1) {
 | 
						inline void UpdateCountedMap(OpenWifi::Types::Counted3DMapSII &M, const std::string &S,
 | 
				
			||||||
        auto it = M.find(S);
 | 
													 uint32_t Index, uint64_t Increment = 1) {
 | 
				
			||||||
        if(it==M.end()) {
 | 
							auto it = M.find(S);
 | 
				
			||||||
            std::map<uint32_t,uint64_t> E;
 | 
							if (it == M.end()) {
 | 
				
			||||||
            E[Index] = Increment;
 | 
								std::map<uint32_t, uint64_t> E;
 | 
				
			||||||
            M[S] = E;
 | 
								E[Index] = Increment;
 | 
				
			||||||
        }
 | 
								M[S] = E;
 | 
				
			||||||
        else {
 | 
							} else {
 | 
				
			||||||
            std::map<uint32_t,uint64_t> & IndexMap = it->second;
 | 
								std::map<uint32_t, uint64_t> &IndexMap = it->second;
 | 
				
			||||||
            auto it_index = IndexMap.find(Index);
 | 
								auto it_index = IndexMap.find(Index);
 | 
				
			||||||
            if(it_index == IndexMap.end()) {
 | 
								if (it_index == IndexMap.end()) {
 | 
				
			||||||
                IndexMap[Index] = Increment;
 | 
									IndexMap[Index] = Increment;
 | 
				
			||||||
            } else {
 | 
								} else {
 | 
				
			||||||
                it_index->second += Increment;
 | 
									it_index->second += Increment;
 | 
				
			||||||
            }
 | 
								}
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
    }
 | 
						}
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,22 +6,23 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Poco::Net::HTTPRequestHandler *ExtRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest &Request) {
 | 
						Poco::Net::HTTPRequestHandler *
 | 
				
			||||||
 | 
						ExtRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest &Request) {
 | 
				
			||||||
		try {
 | 
							try {
 | 
				
			||||||
			Poco::URI uri(Request.getURI());
 | 
								Poco::URI uri(Request.getURI());
 | 
				
			||||||
			auto TID = NextTransactionId_++;
 | 
								auto TID = NextTransactionId_++;
 | 
				
			||||||
			Utils::SetThreadName(fmt::format("x-rest:{}",TID).c_str());
 | 
								Utils::SetThreadName(fmt::format("x-rest:{}", TID).c_str());
 | 
				
			||||||
			return RESTAPI_ExtServer()->CallServer(uri.getPath(), TID);
 | 
								return RESTAPI_ExtServer()->CallServer(uri.getPath(), TID);
 | 
				
			||||||
		} catch (...) {
 | 
							} catch (...) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return nullptr;
 | 
							return nullptr;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Poco::Net::HTTPRequestHandler *RESTAPI_ExtServer::CallServer(const std::string &Path, uint64_t Id) {
 | 
						Poco::Net::HTTPRequestHandler *RESTAPI_ExtServer::CallServer(const std::string &Path,
 | 
				
			||||||
 | 
																					 uint64_t Id) {
 | 
				
			||||||
		RESTAPIHandler::BindingMap Bindings;
 | 
							RESTAPIHandler::BindingMap Bindings;
 | 
				
			||||||
		Utils::SetThreadName(fmt::format("x-rest:{}",Id).c_str());
 | 
							Utils::SetThreadName(fmt::format("x-rest:{}", Id).c_str());
 | 
				
			||||||
		return RESTAPI_ExtRouter(Path, Bindings, Logger(), Server_, Id);
 | 
							return RESTAPI_ExtRouter(Path, Bindings, Logger(), Server_, Id);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,20 +6,23 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "Poco/Net/HTTPServer.h"
 | 
					#include "Poco/Net/HTTPServer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/SubSystemServer.h"
 | 
					 | 
				
			||||||
#include "framework/RESTAPI_Handler.h"
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
 | 
						Poco::Net::HTTPRequestHandler *
 | 
				
			||||||
													 Poco::Logger & L, RESTAPI_GenericServerAccounting & S, uint64_t Id);
 | 
						RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
 | 
				
			||||||
 | 
										  Poco::Logger &L, RESTAPI_GenericServerAccounting &S, uint64_t Id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
 | 
						class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		ExtRequestHandlerFactory() = default;
 | 
							ExtRequestHandlerFactory() = default;
 | 
				
			||||||
		Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override;
 | 
							Poco::Net::HTTPRequestHandler *
 | 
				
			||||||
 | 
							createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		static inline std::atomic_uint64_t  NextTransactionId_ = 1;
 | 
							static inline std::atomic_uint64_t NextTransactionId_ = 1;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class RESTAPI_ExtServer : public SubSystemServer {
 | 
						class RESTAPI_ExtServer : public SubSystemServer {
 | 
				
			||||||
@@ -30,16 +33,21 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline int Start() override {
 | 
							inline int Start() override {
 | 
				
			||||||
			poco_information(Logger(),"Starting.");
 | 
								poco_information(Logger(), "Starting.");
 | 
				
			||||||
			Server_.InitLogging();
 | 
								Server_.InitLogging();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for(const auto & Svr: ConfigServersList_) {
 | 
								for (const auto &Svr : ConfigServersList_) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if(MicroServiceNoAPISecurity()) {
 | 
									if (MicroServiceNoAPISecurity()) {
 | 
				
			||||||
					poco_information(Logger(),fmt::format("Starting: {}:{}. Security has been disabled for APIs.", Svr.Address(), Svr.Port()));
 | 
										poco_information(
 | 
				
			||||||
 | 
											Logger(),
 | 
				
			||||||
 | 
											fmt::format("Starting: {}:{}. Security has been disabled for APIs.",
 | 
				
			||||||
 | 
														Svr.Address(), Svr.Port()));
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					poco_information(Logger(),fmt::format("Starting: {}:{} Keyfile:{} CertFile: {}", Svr.Address(), Svr.Port(),
 | 
										poco_information(Logger(),
 | 
				
			||||||
													 Svr.KeyFile(),Svr.CertFile()));
 | 
														 fmt::format("Starting: {}:{} Keyfile:{} CertFile: {}",
 | 
				
			||||||
 | 
																	 Svr.Address(), Svr.Port(), Svr.KeyFile(),
 | 
				
			||||||
 | 
																	 Svr.CertFile()));
 | 
				
			||||||
					Svr.LogCert(Logger());
 | 
										Svr.LogCert(Logger());
 | 
				
			||||||
					if (!Svr.RootCA().empty())
 | 
										if (!Svr.RootCA().empty())
 | 
				
			||||||
						Svr.LogCas(Logger());
 | 
											Svr.LogCas(Logger());
 | 
				
			||||||
@@ -49,13 +57,15 @@ namespace OpenWifi {
 | 
				
			|||||||
				Params->setKeepAlive(true);
 | 
									Params->setKeepAlive(true);
 | 
				
			||||||
				Params->setName("ws:xrest");
 | 
									Params->setName("ws:xrest");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				std::unique_ptr<Poco::Net::HTTPServer>  NewServer;
 | 
									std::unique_ptr<Poco::Net::HTTPServer> NewServer;
 | 
				
			||||||
				if(MicroServiceNoAPISecurity()) {
 | 
									if (MicroServiceNoAPISecurity()) {
 | 
				
			||||||
					auto Sock{Svr.CreateSocket(Logger())};
 | 
										auto Sock{Svr.CreateSocket(Logger())};
 | 
				
			||||||
					NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory, Pool_, Sock, Params);
 | 
										NewServer = std::make_unique<Poco::Net::HTTPServer>(
 | 
				
			||||||
 | 
											new ExtRequestHandlerFactory, Pool_, Sock, Params);
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					auto Sock{Svr.CreateSecureSocket(Logger())};
 | 
										auto Sock{Svr.CreateSecureSocket(Logger())};
 | 
				
			||||||
					NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory, Pool_, Sock, Params);
 | 
										NewServer = std::make_unique<Poco::Net::HTTPServer>(
 | 
				
			||||||
 | 
											new ExtRequestHandlerFactory, Pool_, Sock, Params);
 | 
				
			||||||
				};
 | 
									};
 | 
				
			||||||
				NewServer->start();
 | 
									NewServer->start();
 | 
				
			||||||
				RESTServers_.push_back(std::move(NewServer));
 | 
									RESTServers_.push_back(std::move(NewServer));
 | 
				
			||||||
@@ -64,36 +74,34 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Stop() override {
 | 
							inline void Stop() override {
 | 
				
			||||||
			poco_information(Logger(),"Stopping...");
 | 
								poco_information(Logger(), "Stopping...");
 | 
				
			||||||
			for( const auto & svr : RESTServers_ )
 | 
								for (const auto &svr : RESTServers_)
 | 
				
			||||||
				svr->stopAll(true);
 | 
									svr->stopAll(true);
 | 
				
			||||||
			Pool_.stopAll();
 | 
								Pool_.stopAll();
 | 
				
			||||||
			Pool_.joinAll();
 | 
								Pool_.joinAll();
 | 
				
			||||||
			RESTServers_.clear();
 | 
								RESTServers_.clear();
 | 
				
			||||||
			poco_information(Logger(),"Stopped...");
 | 
								poco_information(Logger(), "Stopped...");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
 | 
							inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
 | 
				
			||||||
			MicroServiceLoadConfigurationFile();
 | 
								MicroServiceLoadConfigurationFile();
 | 
				
			||||||
			poco_information(Logger(),"Reinitializing.");
 | 
								poco_information(Logger(), "Reinitializing.");
 | 
				
			||||||
			Stop();
 | 
								Stop();
 | 
				
			||||||
			Start();
 | 
								Start();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Poco::Net::HTTPRequestHandler *CallServer(const std::string &Path, uint64_t Id);
 | 
							Poco::Net::HTTPRequestHandler *CallServer(const std::string &Path, uint64_t Id);
 | 
				
			||||||
		const Poco::ThreadPool & Pool() { return Pool_; }
 | 
							const Poco::ThreadPool &Pool() { return Pool_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::vector<std::unique_ptr<Poco::Net::HTTPServer>>   RESTServers_;
 | 
							std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
 | 
				
			||||||
		Poco::ThreadPool	    Pool_{"x-rest",8,128};
 | 
							Poco::ThreadPool Pool_{"x-rest", 8, 128};
 | 
				
			||||||
		RESTAPI_GenericServerAccounting   Server_;
 | 
							RESTAPI_GenericServerAccounting Server_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		RESTAPI_ExtServer() noexcept:
 | 
							RESTAPI_ExtServer() noexcept
 | 
				
			||||||
									   SubSystemServer("RESTAPI_ExtServer", "REST-XSRV", "openwifi.restapi")
 | 
								: SubSystemServer("RESTAPI_ExtServer", "REST-XSRV", "openwifi.restapi") {}
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto RESTAPI_ExtServer() { return RESTAPI_ExtServer::instance(); };
 | 
						inline auto RESTAPI_ExtServer() { return RESTAPI_ExtServer::instance(); };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -4,72 +4,70 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <array>
 | 
					#include <array>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/StringTokenizer.h"
 | 
					 | 
				
			||||||
#include "Poco/String.h"
 | 
					 | 
				
			||||||
#include "Poco/Net/HTTPRequest.h"
 | 
					#include "Poco/Net/HTTPRequest.h"
 | 
				
			||||||
 | 
					#include "Poco/String.h"
 | 
				
			||||||
 | 
					#include "Poco/StringTokenizer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/MicroServiceFuncs.h"
 | 
					#include "framework/MicroServiceFuncs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
	class RESTAPI_GenericServerAccounting {
 | 
						class RESTAPI_GenericServerAccounting {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
 | 
							enum { LOG_GET = 0, LOG_DELETE, LOG_PUT, LOG_POST };
 | 
				
			||||||
		enum {
 | 
					 | 
				
			||||||
			LOG_GET=0,
 | 
					 | 
				
			||||||
			LOG_DELETE,
 | 
					 | 
				
			||||||
			LOG_PUT,
 | 
					 | 
				
			||||||
			LOG_POST
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void inline SetFlags(bool External, const std::string &Methods) {
 | 
							void inline SetFlags(bool External, const std::string &Methods) {
 | 
				
			||||||
			Poco::StringTokenizer   Tokens(Methods,",");
 | 
								Poco::StringTokenizer Tokens(Methods, ",");
 | 
				
			||||||
			auto Offset = (External ? 0 : 4);
 | 
								auto Offset = (External ? 0 : 4);
 | 
				
			||||||
			for(const auto &i:Tokens) {
 | 
								for (const auto &i : Tokens) {
 | 
				
			||||||
				if(Poco::icompare(i,Poco::Net::HTTPRequest::HTTP_DELETE)==0)
 | 
									if (Poco::icompare(i, Poco::Net::HTTPRequest::HTTP_DELETE) == 0)
 | 
				
			||||||
					LogFlags_[Offset+LOG_DELETE]=true;
 | 
										LogFlags_[Offset + LOG_DELETE] = true;
 | 
				
			||||||
				else if(Poco::icompare(i,Poco::Net::HTTPRequest::HTTP_PUT)==0)
 | 
									else if (Poco::icompare(i, Poco::Net::HTTPRequest::HTTP_PUT) == 0)
 | 
				
			||||||
					LogFlags_[Offset+LOG_PUT]=true;
 | 
										LogFlags_[Offset + LOG_PUT] = true;
 | 
				
			||||||
				else if(Poco::icompare(i,Poco::Net::HTTPRequest::HTTP_POST)==0)
 | 
									else if (Poco::icompare(i, Poco::Net::HTTPRequest::HTTP_POST) == 0)
 | 
				
			||||||
					LogFlags_[Offset+LOG_POST]=true;
 | 
										LogFlags_[Offset + LOG_POST] = true;
 | 
				
			||||||
				else if(Poco::icompare(i,Poco::Net::HTTPRequest::HTTP_GET)==0)
 | 
									else if (Poco::icompare(i, Poco::Net::HTTPRequest::HTTP_GET) == 0)
 | 
				
			||||||
					LogFlags_[Offset+LOG_GET]=true;
 | 
										LogFlags_[Offset + LOG_GET] = true;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void InitLogging() {
 | 
							inline void InitLogging() {
 | 
				
			||||||
			std::string Public = MicroServiceConfigGetString("apilogging.public.methods","PUT,POST,DELETE");
 | 
								std::string Public =
 | 
				
			||||||
 | 
									MicroServiceConfigGetString("apilogging.public.methods", "PUT,POST,DELETE");
 | 
				
			||||||
			SetFlags(true, Public);
 | 
								SetFlags(true, Public);
 | 
				
			||||||
			std::string Private = MicroServiceConfigGetString("apilogging.private.methods","PUT,POST,DELETE");
 | 
								std::string Private =
 | 
				
			||||||
 | 
									MicroServiceConfigGetString("apilogging.private.methods", "PUT,POST,DELETE");
 | 
				
			||||||
			SetFlags(false, Private);
 | 
								SetFlags(false, Private);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			std::string PublicBadTokens = MicroServiceConfigGetString("apilogging.public.badtokens.methods","");
 | 
								std::string PublicBadTokens =
 | 
				
			||||||
			LogBadTokens_[0] = (Poco::icompare(PublicBadTokens,"true")==0);
 | 
									MicroServiceConfigGetString("apilogging.public.badtokens.methods", "");
 | 
				
			||||||
			std::string PrivateBadTokens = MicroServiceConfigGetString("apilogging.private.badtokens.methods","");
 | 
								LogBadTokens_[0] = (Poco::icompare(PublicBadTokens, "true") == 0);
 | 
				
			||||||
			LogBadTokens_[1] = (Poco::icompare(PrivateBadTokens,"true")==0);
 | 
								std::string PrivateBadTokens =
 | 
				
			||||||
 | 
									MicroServiceConfigGetString("apilogging.private.badtokens.methods", "");
 | 
				
			||||||
 | 
								LogBadTokens_[1] = (Poco::icompare(PrivateBadTokens, "true") == 0);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] inline bool LogIt(const std::string &Method, bool External) const {
 | 
							[[nodiscard]] inline bool LogIt(const std::string &Method, bool External) const {
 | 
				
			||||||
			auto Offset = (External ? 0 : 4);
 | 
								auto Offset = (External ? 0 : 4);
 | 
				
			||||||
			if(Method == Poco::Net::HTTPRequest::HTTP_GET)
 | 
								if (Method == Poco::Net::HTTPRequest::HTTP_GET)
 | 
				
			||||||
				return LogFlags_[Offset+LOG_GET];
 | 
									return LogFlags_[Offset + LOG_GET];
 | 
				
			||||||
			if(Method == Poco::Net::HTTPRequest::HTTP_POST)
 | 
								if (Method == Poco::Net::HTTPRequest::HTTP_POST)
 | 
				
			||||||
				return LogFlags_[Offset+LOG_POST];
 | 
									return LogFlags_[Offset + LOG_POST];
 | 
				
			||||||
			if(Method == Poco::Net::HTTPRequest::HTTP_PUT)
 | 
								if (Method == Poco::Net::HTTPRequest::HTTP_PUT)
 | 
				
			||||||
				return LogFlags_[Offset+LOG_PUT];
 | 
									return LogFlags_[Offset + LOG_PUT];
 | 
				
			||||||
			if(Method == Poco::Net::HTTPRequest::HTTP_DELETE)
 | 
								if (Method == Poco::Net::HTTPRequest::HTTP_DELETE)
 | 
				
			||||||
				return LogFlags_[Offset+LOG_DELETE];
 | 
									return LogFlags_[Offset + LOG_DELETE];
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] inline bool LogBadTokens(bool External) const {
 | 
							[[nodiscard]] inline bool LogBadTokens(bool External) const {
 | 
				
			||||||
			return LogBadTokens_[ (External ? 0 : 1) ];
 | 
								return LogBadTokens_[(External ? 0 : 1)];
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		std::array<bool,8>       LogFlags_{false};
 | 
							std::array<bool, 8> LogFlags_{false};
 | 
				
			||||||
		std::array<bool,2>       LogBadTokens_{false};
 | 
							std::array<bool, 2> LogBadTokens_{false};
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -4,5 +4,4 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "RESTAPI_Handler.h"
 | 
					#include "RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {} // namespace OpenWifi
 | 
				
			||||||
} // namespace OpenWifi
 | 
					 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -6,20 +6,23 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "Poco/Net/HTTPServer.h"
 | 
					#include "Poco/Net/HTTPServer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "framework/SubSystemServer.h"
 | 
					 | 
				
			||||||
#include "framework/RESTAPI_Handler.h"
 | 
					#include "framework/RESTAPI_Handler.h"
 | 
				
			||||||
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
 | 
						Poco::Net::HTTPRequestHandler *
 | 
				
			||||||
													 Poco::Logger & L, RESTAPI_GenericServerAccounting & S, uint64_t Id);
 | 
						RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
 | 
				
			||||||
 | 
										  Poco::Logger &L, RESTAPI_GenericServerAccounting &S, uint64_t Id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
 | 
						class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		inline IntRequestHandlerFactory() = default;
 | 
							inline IntRequestHandlerFactory() = default;
 | 
				
			||||||
		Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override;
 | 
							Poco::Net::HTTPRequestHandler *
 | 
				
			||||||
 | 
							createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		static inline std::atomic_uint64_t  NextTransactionId_ = 1;
 | 
							static inline std::atomic_uint64_t NextTransactionId_ = 1;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class RESTAPI_IntServer : public SubSystemServer {
 | 
						class RESTAPI_IntServer : public SubSystemServer {
 | 
				
			||||||
@@ -30,16 +33,21 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline int Start() override {
 | 
							inline int Start() override {
 | 
				
			||||||
			poco_information(Logger(),"Starting.");
 | 
								poco_information(Logger(), "Starting.");
 | 
				
			||||||
			Server_.InitLogging();
 | 
								Server_.InitLogging();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for(const auto & Svr: ConfigServersList_) {
 | 
								for (const auto &Svr : ConfigServersList_) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if(MicroServiceNoAPISecurity()) {
 | 
									if (MicroServiceNoAPISecurity()) {
 | 
				
			||||||
					poco_information(Logger(),fmt::format("Starting: {}:{}. Security has been disabled for APIs.", Svr.Address(), Svr.Port()));
 | 
										poco_information(
 | 
				
			||||||
 | 
											Logger(),
 | 
				
			||||||
 | 
											fmt::format("Starting: {}:{}. Security has been disabled for APIs.",
 | 
				
			||||||
 | 
														Svr.Address(), Svr.Port()));
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					poco_information(Logger(),fmt::format("Starting: {}:{}. Keyfile:{} CertFile: {}", Svr.Address(), Svr.Port(),
 | 
										poco_information(Logger(),
 | 
				
			||||||
													 Svr.KeyFile(),Svr.CertFile()));
 | 
														 fmt::format("Starting: {}:{}. Keyfile:{} CertFile: {}",
 | 
				
			||||||
 | 
																	 Svr.Address(), Svr.Port(), Svr.KeyFile(),
 | 
				
			||||||
 | 
																	 Svr.CertFile()));
 | 
				
			||||||
					Svr.LogCert(Logger());
 | 
										Svr.LogCert(Logger());
 | 
				
			||||||
					if (!Svr.RootCA().empty())
 | 
										if (!Svr.RootCA().empty())
 | 
				
			||||||
						Svr.LogCas(Logger());
 | 
											Svr.LogCas(Logger());
 | 
				
			||||||
@@ -49,13 +57,15 @@ namespace OpenWifi {
 | 
				
			|||||||
				Params->setKeepAlive(true);
 | 
									Params->setKeepAlive(true);
 | 
				
			||||||
				Params->setName("ws:irest");
 | 
									Params->setName("ws:irest");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				std::unique_ptr<Poco::Net::HTTPServer>  NewServer;
 | 
									std::unique_ptr<Poco::Net::HTTPServer> NewServer;
 | 
				
			||||||
				if(MicroServiceNoAPISecurity()) {
 | 
									if (MicroServiceNoAPISecurity()) {
 | 
				
			||||||
					auto Sock{Svr.CreateSocket(Logger())};
 | 
										auto Sock{Svr.CreateSocket(Logger())};
 | 
				
			||||||
					NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory, Pool_, Sock, Params);
 | 
										NewServer = std::make_unique<Poco::Net::HTTPServer>(
 | 
				
			||||||
 | 
											new IntRequestHandlerFactory, Pool_, Sock, Params);
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					auto Sock{Svr.CreateSecureSocket(Logger())};
 | 
										auto Sock{Svr.CreateSecureSocket(Logger())};
 | 
				
			||||||
					NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory, Pool_, Sock, Params);
 | 
										NewServer = std::make_unique<Poco::Net::HTTPServer>(
 | 
				
			||||||
 | 
											new IntRequestHandlerFactory, Pool_, Sock, Params);
 | 
				
			||||||
				};
 | 
									};
 | 
				
			||||||
				NewServer->start();
 | 
									NewServer->start();
 | 
				
			||||||
				RESTServers_.push_back(std::move(NewServer));
 | 
									RESTServers_.push_back(std::move(NewServer));
 | 
				
			||||||
@@ -65,40 +75,37 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Stop() override {
 | 
							inline void Stop() override {
 | 
				
			||||||
			poco_information(Logger(),"Stopping...");
 | 
								poco_information(Logger(), "Stopping...");
 | 
				
			||||||
			for( const auto & svr : RESTServers_ )
 | 
								for (const auto &svr : RESTServers_)
 | 
				
			||||||
				svr->stopAll(true);
 | 
									svr->stopAll(true);
 | 
				
			||||||
			Pool_.stopAll();
 | 
								Pool_.stopAll();
 | 
				
			||||||
			Pool_.joinAll();
 | 
								Pool_.joinAll();
 | 
				
			||||||
			poco_information(Logger(),"Stopped...");
 | 
								poco_information(Logger(), "Stopped...");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
 | 
							inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
 | 
				
			||||||
			MicroServiceLoadConfigurationFile();
 | 
								MicroServiceLoadConfigurationFile();
 | 
				
			||||||
			poco_information(Logger(),"Reinitializing.");
 | 
								poco_information(Logger(), "Reinitializing.");
 | 
				
			||||||
			Stop();
 | 
								Stop();
 | 
				
			||||||
			Start();
 | 
								Start();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline Poco::Net::HTTPRequestHandler *CallServer(const std::string &Path, uint64_t Id) {
 | 
							inline Poco::Net::HTTPRequestHandler *CallServer(const std::string &Path, uint64_t Id) {
 | 
				
			||||||
			RESTAPIHandler::BindingMap Bindings;
 | 
								RESTAPIHandler::BindingMap Bindings;
 | 
				
			||||||
			Utils::SetThreadName(fmt::format("i-rest:{}",Id).c_str());
 | 
								Utils::SetThreadName(fmt::format("i-rest:{}", Id).c_str());
 | 
				
			||||||
			return RESTAPI_IntRouter(Path, Bindings, Logger(), Server_, Id);
 | 
								return RESTAPI_IntRouter(Path, Bindings, Logger(), Server_, Id);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		const Poco::ThreadPool & Pool() { return Pool_; }
 | 
							const Poco::ThreadPool &Pool() { return Pool_; }
 | 
				
			||||||
	  private:
 | 
					 | 
				
			||||||
		std::vector<std::unique_ptr<Poco::Net::HTTPServer>>   RESTServers_;
 | 
					 | 
				
			||||||
		Poco::ThreadPool	    Pool_{"i-rest",4,64};
 | 
					 | 
				
			||||||
		RESTAPI_GenericServerAccounting   Server_;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		RESTAPI_IntServer() noexcept:
 | 
						  private:
 | 
				
			||||||
									   SubSystemServer("RESTAPI_IntServer", "REST-ISRV", "openwifi.internal.restapi")
 | 
							std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
 | 
				
			||||||
		{
 | 
							Poco::ThreadPool Pool_{"i-rest", 4, 64};
 | 
				
			||||||
		}
 | 
							RESTAPI_GenericServerAccounting Server_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							RESTAPI_IntServer() noexcept
 | 
				
			||||||
 | 
								: SubSystemServer("RESTAPI_IntServer", "REST-ISRV", "openwifi.internal.restapi") {}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto RESTAPI_IntServer() { return RESTAPI_IntServer::instance(); };
 | 
						inline auto RESTAPI_IntServer() { return RESTAPI_IntServer::instance(); };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,29 +4,26 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include "Poco/Net/PartHandler.h"
 | 
					 | 
				
			||||||
#include "Poco/Net/MessageHeader.h"
 | 
					 | 
				
			||||||
#include "Poco/CountingStream.h"
 | 
					#include "Poco/CountingStream.h"
 | 
				
			||||||
 | 
					#include "Poco/Net/MessageHeader.h"
 | 
				
			||||||
 | 
					#include "Poco/Net/PartHandler.h"
 | 
				
			||||||
#include "Poco/NullStream.h"
 | 
					#include "Poco/NullStream.h"
 | 
				
			||||||
#include "Poco/StreamCopier.h"
 | 
					#include "Poco/StreamCopier.h"
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
	class RESTAPI_PartHandler: public Poco::Net::PartHandler {
 | 
						class RESTAPI_PartHandler : public Poco::Net::PartHandler {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		RESTAPI_PartHandler():
 | 
							RESTAPI_PartHandler() : _length(0) {}
 | 
				
			||||||
								_length(0)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void handlePart(const Poco::Net::MessageHeader& header, std::istream& stream) override
 | 
							inline void handlePart(const Poco::Net::MessageHeader &header,
 | 
				
			||||||
		{
 | 
												   std::istream &stream) override {
 | 
				
			||||||
			_type = header.get("Content-Type", "(unspecified)");
 | 
								_type = header.get("Content-Type", "(unspecified)");
 | 
				
			||||||
			if (header.has("Content-Disposition"))
 | 
								if (header.has("Content-Disposition")) {
 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				std::string disp;
 | 
									std::string disp;
 | 
				
			||||||
				Poco::Net::NameValueCollection params;
 | 
									Poco::Net::NameValueCollection params;
 | 
				
			||||||
				Poco::Net::MessageHeader::splitParameters(header["Content-Disposition"], disp, params);
 | 
									Poco::Net::MessageHeader::splitParameters(header["Content-Disposition"], disp,
 | 
				
			||||||
 | 
																			  params);
 | 
				
			||||||
				_name = params.get("name", "(unnamed)");
 | 
									_name = params.get("name", "(unnamed)");
 | 
				
			||||||
				_fileName = params.get("filename", "(unnamed)");
 | 
									_fileName = params.get("filename", "(unnamed)");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -37,25 +34,13 @@ namespace OpenWifi {
 | 
				
			|||||||
			_length = (int)istr.chars();
 | 
								_length = (int)istr.chars();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] inline int length() const
 | 
							[[nodiscard]] inline int length() const { return _length; }
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			return _length;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] inline const std::string& name() const
 | 
							[[nodiscard]] inline const std::string &name() const { return _name; }
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			return _name;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] inline const std::string& fileName() const
 | 
							[[nodiscard]] inline const std::string &fileName() const { return _fileName; }
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			return _fileName;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[[nodiscard]] inline const std::string& contentType() const
 | 
							[[nodiscard]] inline const std::string &contentType() const { return _type; }
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			return _type;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		int _length;
 | 
							int _length;
 | 
				
			||||||
@@ -63,4 +48,4 @@ namespace OpenWifi {
 | 
				
			|||||||
		std::string _name;
 | 
							std::string _name;
 | 
				
			||||||
		std::string _fileName;
 | 
							std::string _fileName;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
}
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,9 +6,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "framework/SubSystemServer.h"
 | 
					#include "framework/SubSystemServer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Poco/URI.h"
 | 
					 | 
				
			||||||
#include "Poco/Net/HTTPServerRequest.h"
 | 
					 | 
				
			||||||
#include "Poco/ExpireLRUCache.h"
 | 
					#include "Poco/ExpireLRUCache.h"
 | 
				
			||||||
 | 
					#include "Poco/Net/HTTPServerRequest.h"
 | 
				
			||||||
 | 
					#include "Poco/URI.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "fmt/format.h"
 | 
					#include "fmt/format.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -16,10 +16,9 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	class RESTAPI_RateLimiter : public SubSystemServer {
 | 
						class RESTAPI_RateLimiter : public SubSystemServer {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
 | 
					 | 
				
			||||||
		struct ClientCacheEntry {
 | 
							struct ClientCacheEntry {
 | 
				
			||||||
			int64_t  Start=0;
 | 
								int64_t Start = 0;
 | 
				
			||||||
			int      Count=0;
 | 
								int Count = 0;
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		static auto instance() {
 | 
							static auto instance() {
 | 
				
			||||||
@@ -27,49 +26,47 @@ namespace OpenWifi {
 | 
				
			|||||||
			return instance_;
 | 
								return instance_;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline int Start() final { return 0;};
 | 
							inline int Start() final { return 0; };
 | 
				
			||||||
		inline void Stop() final { };
 | 
							inline void Stop() final{};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline bool IsRateLimited(const Poco::Net::HTTPServerRequest &R, int64_t Period, int64_t MaxCalls) {
 | 
							inline bool IsRateLimited(const Poco::Net::HTTPServerRequest &R, int64_t Period,
 | 
				
			||||||
			Poco::URI   uri(R.getURI());
 | 
													  int64_t MaxCalls) {
 | 
				
			||||||
 | 
								Poco::URI uri(R.getURI());
 | 
				
			||||||
			auto H = str_hash(uri.getPath() + R.clientAddress().host().toString());
 | 
								auto H = str_hash(uri.getPath() + R.clientAddress().host().toString());
 | 
				
			||||||
			auto E = Cache_.get(H);
 | 
								auto E = Cache_.get(H);
 | 
				
			||||||
			auto Now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
 | 
								auto Now = std::chrono::duration_cast<std::chrono::milliseconds>(
 | 
				
			||||||
			if(E.isNull()) {
 | 
											   std::chrono::system_clock::now().time_since_epoch())
 | 
				
			||||||
				Cache_.add(H,ClientCacheEntry{.Start=Now, .Count=1});
 | 
											   .count();
 | 
				
			||||||
 | 
								if (E.isNull()) {
 | 
				
			||||||
 | 
									Cache_.add(H, ClientCacheEntry{.Start = Now, .Count = 1});
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if((Now-E->Start)<Period) {
 | 
								if ((Now - E->Start) < Period) {
 | 
				
			||||||
				E->Count++;
 | 
									E->Count++;
 | 
				
			||||||
				Cache_.update(H,E);
 | 
									Cache_.update(H, E);
 | 
				
			||||||
				if(E->Count > MaxCalls) {
 | 
									if (E->Count > MaxCalls) {
 | 
				
			||||||
					poco_warning(Logger(),fmt::format("RATE-LIMIT-EXCEEDED: from '{}'", R.clientAddress().toString()));
 | 
										poco_warning(Logger(), fmt::format("RATE-LIMIT-EXCEEDED: from '{}'",
 | 
				
			||||||
 | 
																		   R.clientAddress().toString()));
 | 
				
			||||||
					return true;
 | 
										return true;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return false;
 | 
									return false;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			E->Start = Now;
 | 
								E->Start = Now;
 | 
				
			||||||
			E->Count = 1;
 | 
								E->Count = 1;
 | 
				
			||||||
			Cache_.update(H,E);
 | 
								Cache_.update(H, E);
 | 
				
			||||||
			return false;
 | 
								return false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Clear() {
 | 
							inline void Clear() { Cache_.clear(); }
 | 
				
			||||||
			Cache_.clear();
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		Poco::ExpireLRUCache<uint64_t,ClientCacheEntry>      Cache_{2048};
 | 
							Poco::ExpireLRUCache<uint64_t, ClientCacheEntry> Cache_{2048};
 | 
				
			||||||
		std::hash<std::string>          str_hash;
 | 
							std::hash<std::string> str_hash;
 | 
				
			||||||
 | 
					 | 
				
			||||||
		RESTAPI_RateLimiter() noexcept:
 | 
					 | 
				
			||||||
										 SubSystemServer("RateLimiter", "RATE-LIMITER", "rate.limiter")
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							RESTAPI_RateLimiter() noexcept
 | 
				
			||||||
 | 
								: SubSystemServer("RateLimiter", "RATE-LIMITER", "rate.limiter") {}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto RESTAPI_RateLimiter() { return RESTAPI_RateLimiter::instance(); }
 | 
						inline auto RESTAPI_RateLimiter() { return RESTAPI_RateLimiter::instance(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // namespace OpenWifi
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user