2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef ANBOX_CONTAINER_SERVICE_H_
19 #define ANBOX_CONTAINER_SERVICE_H_
21 #include "anbox/common/dispatcher.h"
22 #include "anbox/container/container.h"
23 #include "anbox/network/connections.h"
24 #include "anbox/network/credentials.h"
25 #include "anbox/network/published_socket_connector.h"
26 #include "anbox/network/socket_connection.h"
27 #include "anbox/runtime.h"
31 class Service : public std::enable_shared_from_this<Service> {
33 struct Configuration {
34 bool privileged = false;
35 bool rootfs_overlay = true;
36 std::string container_network_address;
37 std::string container_network_gateway;
38 std::vector<std::string> container_network_dns_servers;
41 static std::shared_ptr<Service> create(const std::shared_ptr<Runtime> &rt,
42 const Configuration &config);
47 Service(const std::shared_ptr<Runtime> &rt, const Configuration &config);
50 void new_client(std::shared_ptr<
51 boost::asio::local::stream_protocol::socket> const &socket);
53 std::shared_ptr<common::Dispatcher> dispatcher_;
54 std::shared_ptr<network::PublishedSocketConnector> connector_;
55 std::atomic<int> next_connection_id_;
56 std::shared_ptr<network::Connections<network::SocketConnection>> connections_;
57 std::shared_ptr<Container> backend_;
58 Configuration config_;
60 } // namespace container