class AsioFrontend {
RGWProcessEnv env;
+ RGWFrontendConfig* conf;
boost::asio::io_service service;
tcp::acceptor acceptor;
void accept(boost::system::error_code ec);
public:
- AsioFrontend(const RGWProcessEnv& env)
- : env(env), acceptor(service), peer_socket(service) {}
+ AsioFrontend(const RGWProcessEnv& env, RGWFrontendConfig* conf)
+ : env(env), conf(conf), acceptor(service), peer_socket(service) {}
int init();
int run();
int AsioFrontend::init()
{
- auto ep = tcp::endpoint{tcp::v4(), static_cast<unsigned short>(env.port)};
- ldout(ctx(), 4) << "frontend listening on " << ep << dendl;
+ std::string port_str;
+ conf->get_val("port", "80", &port_str);
+ unsigned short port;
+ boost::asio::ip::address addr; // default to 'any'
boost::system::error_code ec;
+
+ auto colon = port_str.find(':');
+ if (colon != port_str.npos) {
+ addr = boost::asio::ip::make_address(port_str.substr(0, colon), ec);
+ if (ec) {
+ lderr(ctx()) << "failed to parse address '" << port_str << "': " << ec.message() << dendl;
+ return -ec.value();
+ }
+ port = std::stoul(port_str.substr(colon + 1), nullptr, 0);
+ } else {
+ port = std::stoul(port_str, nullptr, 0);
+ }
+
+ tcp::endpoint ep = {addr, port};
+ ldout(ctx(), 4) << "frontend listening on " << ep << dendl;
+
acceptor.open(ep.protocol(), ec);
if (ec) {
lderr(ctx()) << "failed to open socket: " << ec.message() << dendl;
class RGWAsioFrontend::Impl : public AsioFrontend {
public:
- Impl(const RGWProcessEnv& env) : AsioFrontend(env) {}
+ Impl(const RGWProcessEnv& env, RGWFrontendConfig* conf) : AsioFrontend(env, conf) {}
};
-RGWAsioFrontend::RGWAsioFrontend(const RGWProcessEnv& env)
- : impl(new Impl(env))
+RGWAsioFrontend::RGWAsioFrontend(const RGWProcessEnv& env,
+ RGWFrontendConfig* conf)
+ : impl(new Impl(env, conf))
{
}