diff options
Diffstat (limited to 'apps/http-proxy/includes/hicn/http-proxy/http_proxy.h')
-rw-r--r-- | apps/http-proxy/includes/hicn/http-proxy/http_proxy.h | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h b/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h index a4139a620..567ab4540 100644 --- a/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h +++ b/apps/http-proxy/includes/hicn/http-proxy/http_proxy.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -15,6 +15,7 @@ #pragma once +#include <hicn/apps/utils/logger.h> #include <hicn/transport/interfaces/socket_consumer.h> #include <hicn/transport/utils/event_thread.h> @@ -22,7 +23,9 @@ #include "http_session.h" #include "icn_receiver.h" +#ifndef ASIO_STANDALONE #define ASIO_STANDALONE +#endif #include <asio.hpp> #include <asio/version.hpp> #include <unordered_set> @@ -31,7 +34,8 @@ class TcpListener { public: using AcceptCallback = std::function<void(asio::ip::tcp::socket&&)>; - TcpListener(asio::io_service& io_service, short port, AcceptCallback callback) + TcpListener(asio::io_service& io_service, short port, + const AcceptCallback& callback) : acceptor_(io_service), #if ((ASIO_VERSION / 100 % 1000) < 12) socket_(io_service), @@ -46,13 +50,12 @@ class TcpListener { acceptor_.listen(); } - public: void doAccept() { #if ((ASIO_VERSION / 100 % 1000) >= 12) acceptor_.async_accept( - [this](std::error_code ec, asio::ip::tcp::socket socket) { + [this](const std::error_code& ec, asio::ip::tcp::socket socket) { #else - acceptor_.async_accept(socket_, [this](std::error_code ec) { + acceptor_.async_accept(socket_, [this](const std::error_code& ec) { auto socket = std::move(socket_); #endif if (!ec) { @@ -77,7 +80,7 @@ class HTTPClientConnectionCallback; class Receiver { public: - Receiver() : thread_() {} + Receiver() {} virtual ~Receiver() = default; void stopAndJoinThread() { thread_.stop(); } virtual void stop() = 0; @@ -112,13 +115,13 @@ class TcpReceiver : public Receiver { std::deque<HTTPClientConnectionCallback*> http_clients_; std::unordered_set<HTTPClientConnectionCallback*> used_http_clients_; ForwarderConfig forwarder_config_; - bool stopped_; + bool stopped_ = false; }; class IcnReceiver : public Receiver { public: template <typename... Args> - IcnReceiver(Args&&... args) + explicit IcnReceiver(Args&&... args) : Receiver(), icn_consum_producer_(thread_.getIoService(), std::forward<Args>(args)...) { @@ -145,20 +148,18 @@ class HTTPProxy { std::string prefix; std::string first_ipv6_word; - virtual void printParams() { std::cout << "Parameters: " << std::endl; }; + virtual ~CommonParams() {} + virtual void printParams() { LoggerInfo() << "Parameters: "; }; }; struct ClientParams : virtual CommonParams { short tcp_listen_port; void printParams() override { - std::cout << "Running HTTP/TCP -> HTTP/hICN proxy." << std::endl; + LoggerInfo() << "Running HTTP/TCP -> HTTP/hICN proxy."; CommonParams::printParams(); - std::cout << "\t" - << "HTTP listen port: " << tcp_listen_port << std::endl; - std::cout << "\t" - << "Consumer Prefix: " << prefix << std::endl; - std::cout << "\t" - << "Prefix first word: " << first_ipv6_word << std::endl; + LoggerInfo() << "\tHTTP listen port: " << tcp_listen_port; + LoggerInfo() << "\tConsumer Prefix: " << prefix; + LoggerInfo() << "\tPrefix first word: " << first_ipv6_word; } }; @@ -171,25 +172,24 @@ class HTTPProxy { bool manifest; void printParams() override { - std::cout << "Running HTTP/hICN -> HTTP/TCP proxy." << std::endl; + LoggerInfo() << "Running HTTP/hICN -> HTTP/TCP proxy."; CommonParams::printParams(); - std::cout << "\t" - << "Origin address: " << origin_address << std::endl; - std::cout << "\t" - << "Origin port: " << origin_port << std::endl; - std::cout << "\t" - << "Producer cache size: " << cache_size << std::endl; - std::cout << "\t" - << "hICN MTU: " << mtu << std::endl; - std::cout << "\t" - << "Default content lifetime: " << content_lifetime - << std::endl; - std::cout << "\t" - << "Producer Prefix: " << prefix << std::endl; - std::cout << "\t" - << "Prefix first word: " << first_ipv6_word << std::endl; - std::cout << "\t" - << "Use manifest: " << manifest << std::endl; + LoggerInfo() << "\t" + << "Origin address: " << origin_address; + LoggerInfo() << "\t" + << "Origin port: " << origin_port; + LoggerInfo() << "\t" + << "Producer cache size: " << cache_size; + LoggerInfo() << "\t" + << "hICN MTU: " << mtu; + LoggerInfo() << "\t" + << "Default content lifetime: " << content_lifetime; + LoggerInfo() << "\t" + << "Producer Prefix: " << prefix; + LoggerInfo() << "\t" + << "Prefix first word: " << first_ipv6_word; + LoggerInfo() << "\t" + << "Use manifest: " << manifest; } }; @@ -207,4 +207,4 @@ class HTTPProxy { asio::signal_set signals_; }; -} // namespace transport
\ No newline at end of file +} // namespace transport |