mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ucentralgw.git
				synced 2025-11-04 04:37:46 +00:00 
			
		
		
		
	Compare commits
	
		
			9 Commits
		
	
	
		
			v3.1.0_pat
			...
			WIFI-14038
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					9c5aeda5dd | ||
| 
						 | 
					783ec99930 | ||
| 
						 | 
					0c661b8b93 | ||
| 
						 | 
					9d7f4da504 | ||
| 
						 | 
					a3b6e7c315 | ||
| 
						 | 
					451680cd5a | ||
| 
						 | 
					7be48c3cfc | ||
| 
						 | 
					b59d1cb4da | ||
| 
						 | 
					c3a709c2b9 | 
@@ -1,7 +1,7 @@
 | 
				
			|||||||
ARG DEBIAN_VERSION=11.5-slim
 | 
					ARG DEBIAN_VERSION=11.5-slim
 | 
				
			||||||
ARG POCO_VERSION=poco-tip-v2
 | 
					ARG POCO_VERSION=poco-tip-v2
 | 
				
			||||||
ARG CPPKAFKA_VERSION=tip-v1
 | 
					ARG CPPKAFKA_VERSION=tip-v1
 | 
				
			||||||
ARG VALIJASON_VERSION=tip-v1
 | 
					ARG VALIJASON_VERSION=tip-v1.0.2
 | 
				
			||||||
ARG APP_NAME=owgw
 | 
					ARG APP_NAME=owgw
 | 
				
			||||||
ARG APP_HOME_DIR=/openwifi
 | 
					ARG APP_HOME_DIR=/openwifi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,10 +25,24 @@ namespace OpenWifi::RESTAPI_RPC {
 | 
				
			|||||||
		if (StorageService()->AddCommand(Cmd.SerialNumber, Cmd, Status)) {
 | 
							if (StorageService()->AddCommand(Cmd.SerialNumber, Cmd, Status)) {
 | 
				
			||||||
			Poco::JSON::Object RetObj;
 | 
								Poco::JSON::Object RetObj;
 | 
				
			||||||
			Cmd.to_json(RetObj);
 | 
								Cmd.to_json(RetObj);
 | 
				
			||||||
			if (Handler != nullptr)
 | 
								if (Handler == nullptr) {
 | 
				
			||||||
				return Handler->ReturnObject(RetObj);
 | 
									// nothing to process/return
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								Poco::Net::HTTPResponse::HTTPStatus cmd_status = Poco::Net::HTTPResponse::HTTP_OK;
 | 
				
			||||||
 | 
					            if (Cmd.ErrorCode > 0) {
 | 
				
			||||||
 | 
									// command returned error
 | 
				
			||||||
 | 
									cmd_status = Poco::Net::HTTPResponse::HTTP_BAD_REQUEST;
 | 
				
			||||||
 | 
									if (Cmd.Command == uCentralProtocol::CONFIGURE) {
 | 
				
			||||||
 | 
										// special handling for configure command
 | 
				
			||||||
 | 
										if (!Handler->GetBoolParameter("strict", false)) {
 | 
				
			||||||
 | 
											// in non-strict mode return success for failed configure command
 | 
				
			||||||
 | 
											cmd_status = Poco::Net::HTTPResponse::HTTP_OK;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return Handler->ReturnObject(RetObj, cmd_status);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if (Handler != nullptr)
 | 
							if (Handler != nullptr)
 | 
				
			||||||
			return Handler->ReturnStatus(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
 | 
								return Handler->ReturnStatus(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -167,6 +181,20 @@ namespace OpenWifi::RESTAPI_RPC {
 | 
				
			|||||||
				Cmd.AttachType = "";
 | 
									Cmd.AttachType = "";
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// If the command fails on the device we should show it as failed and not return 200 OK
 | 
				
			||||||
 | 
								// exception is configure command which only reported failed in strict validation mode
 | 
				
			||||||
 | 
								if (Cmd.ErrorCode &&
 | 
				
			||||||
 | 
									(Cmd.Command != uCentralProtocol::CONFIGURE ||
 | 
				
			||||||
 | 
										(Cmd.Command == uCentralProtocol::CONFIGURE && Handler->GetBoolParameter("strict", false))
 | 
				
			||||||
 | 
									))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Logger.information(fmt::format(
 | 
				
			||||||
 | 
									"Command failed with error on device: {}  Reason: {}.",
 | 
				
			||||||
 | 
									Cmd.ErrorCode, Cmd.ErrorText));
 | 
				
			||||||
 | 
									return SetCommandStatus(Cmd, Request, Response, Handler,
 | 
				
			||||||
 | 
													Storage::CommandExecutionType::COMMAND_FAILED, Logger);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (Cmd.ErrorCode == 0 && Cmd.Command == uCentralProtocol::CONFIGURE) {
 | 
								if (Cmd.ErrorCode == 0 && Cmd.Command == uCentralProtocol::CONFIGURE) {
 | 
				
			||||||
				//	we need to post a kafka event for this.
 | 
									//	we need to post a kafka event for this.
 | 
				
			||||||
				if (Params.has(uCentralProtocol::CONFIG) && Params.isObject(uCentralProtocol::CONFIG)) {
 | 
									if (Params.has(uCentralProtocol::CONFIG) && Params.isObject(uCentralProtocol::CONFIG)) {
 | 
				
			||||||
@@ -175,6 +203,7 @@ namespace OpenWifi::RESTAPI_RPC {
 | 
				
			|||||||
					DeviceConfigurationChangeKafkaEvent KEvent(
 | 
										DeviceConfigurationChangeKafkaEvent KEvent(
 | 
				
			||||||
						Utils::SerialNumberToInt(Cmd.SerialNumber), Utils::Now(),
 | 
											Utils::SerialNumberToInt(Cmd.SerialNumber), Utils::Now(),
 | 
				
			||||||
						Config);
 | 
											Config);
 | 
				
			||||||
 | 
											
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,6 +118,10 @@ namespace OpenWifi {
 | 
				
			|||||||
						Producer.poll((std::chrono::milliseconds) 0);
 | 
											Producer.poll((std::chrono::milliseconds) 0);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									if (Queue_.size() == 0) {
 | 
				
			||||||
 | 
										// message queue is empty, flush all previously sent messages
 | 
				
			||||||
 | 
										Producer.flush();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			} catch (const cppkafka::HandleException &E) {
 | 
								} catch (const cppkafka::HandleException &E) {
 | 
				
			||||||
				poco_warning(Logger_,
 | 
									poco_warning(Logger_,
 | 
				
			||||||
							 fmt::format("Caught a Kafka exception (producer): {}", E.what()));
 | 
												 fmt::format("Caught a Kafka exception (producer): {}", E.what()));
 | 
				
			||||||
@@ -126,10 +130,6 @@ namespace OpenWifi {
 | 
				
			|||||||
			} 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();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Producer.flush();
 | 
							Producer.flush();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -552,8 +552,8 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		inline bool IsAuthorized(bool &Expired, bool &Contacted, bool SubOnly = false);
 | 
							inline bool IsAuthorized(bool &Expired, bool &Contacted, bool SubOnly = false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void ReturnObject(Poco::JSON::Object &Object) {
 | 
							inline void ReturnObject(Poco::JSON::Object &Object, Poco::Net::HTTPResponse::HTTPStatus Status = Poco::Net::HTTPResponse::HTTP_OK) {
 | 
				
			||||||
			PrepareResponse();
 | 
								PrepareResponse(Status);
 | 
				
			||||||
			if (Request != nullptr) {
 | 
								if (Request != nullptr) {
 | 
				
			||||||
				//   can we compress ???
 | 
									//   can we compress ???
 | 
				
			||||||
				auto AcceptedEncoding = Request->find("Accept-Encoding");
 | 
									auto AcceptedEncoding = Request->find("Accept-Encoding");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user