| 3520 | } |
| 3521 | |
| 3522 | std::unique_ptr<TCPProtocolStackFactory> Server::buildProtocolStackFromConfig( |
| 3523 | const Poco::Util::AbstractConfiguration & config, |
| 3524 | const ServerSettings & server_settings, |
| 3525 | const std::string & protocol, |
| 3526 | Poco::Net::HTTPServerParams::Ptr http_params, |
| 3527 | AsynchronousMetrics & async_metrics, |
| 3528 | bool & is_secure) |
| 3529 | { |
| 3530 | auto create_factory = [&](const std::string & type, const std::string & conf_name) -> TCPServerConnectionFactory::Ptr |
| 3531 | { |
| 3532 | if (type == "tcp") |
| 3533 | return TCPServerConnectionFactory::Ptr(new TCPHandlerFactory(*this, false, false, ProfileEvents::InterfaceNativeReceiveBytes, ProfileEvents::InterfaceNativeSendBytes)); |
| 3534 | |
| 3535 | if (type == "tls") |
| 3536 | #if USE_SSL |
| 3537 | return TCPServerConnectionFactory::Ptr(new TLSHandlerFactory(*this, conf_name)); |
| 3538 | #else |
| 3539 | throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "SSL support for TCP protocol is disabled because Poco library was built without NetSSL support."); |
| 3540 | #endif |
| 3541 | |
| 3542 | if (type == "proxy1") |
| 3543 | return TCPServerConnectionFactory::Ptr(new ProxyV1HandlerFactory(*this, conf_name)); |
| 3544 | if (type == "mysql") |
| 3545 | return TCPServerConnectionFactory::Ptr(new MySQLHandlerFactory(*this, server_settings[ServerSetting::mysql_require_secure_transport], ProfileEvents::InterfaceMySQLReceiveBytes, ProfileEvents::InterfaceMySQLSendBytes)); |
| 3546 | if (type == "postgres") |
| 3547 | #if USE_SSL |
| 3548 | return TCPServerConnectionFactory::Ptr(new PostgreSQLHandlerFactory(*this, server_settings[ServerSetting::postgresql_require_secure_transport], conf_name + ".", ProfileEvents::InterfacePostgreSQLReceiveBytes, ProfileEvents::InterfacePostgreSQLSendBytes)); |
| 3549 | #else |
| 3550 | return TCPServerConnectionFactory::Ptr(new PostgreSQLHandlerFactory(*this, server_settings[ServerSetting::postgresql_require_secure_transport], ProfileEvents::InterfacePostgreSQLReceiveBytes, ProfileEvents::InterfacePostgreSQLSendBytes)); |
| 3551 | #endif |
| 3552 | if (type == "http") |
| 3553 | { |
| 3554 | /// Allow custom http_handlers configuration for this protocol endpoint. |
| 3555 | /// E.g. <protocols><my_http><type>http</type><handlers>http_handlers_alt</handlers></my_http></protocols> |
| 3556 | String handlers_config_key; |
| 3557 | if (config.has(conf_name + ".handlers")) |
| 3558 | handlers_config_key = config.getString(conf_name + ".handlers"); |
| 3559 | return TCPServerConnectionFactory::Ptr( |
| 3560 | new HTTPServerConnectionFactory(httpContext(), http_params, createHandlerFactory(*this, config, async_metrics, "HTTPHandler-factory", handlers_config_key), ProfileEvents::InterfaceHTTPReceiveBytes, ProfileEvents::InterfaceHTTPSendBytes) |
| 3561 | ); |
| 3562 | } |
| 3563 | if (type == "prometheus") |
| 3564 | { |
| 3565 | const std::string handler_name = server_settings[ServerSetting::prometheus_keeper_metrics_only] ? "KeeperPrometheusHandler-factory" : "PrometheusHandler-factory"; |
| 3566 | return TCPServerConnectionFactory::Ptr( |
| 3567 | new HTTPServerConnectionFactory(httpContext(), http_params, createHandlerFactory(*this, config, async_metrics, handler_name), ProfileEvents::InterfacePrometheusReceiveBytes, ProfileEvents::InterfacePrometheusSendBytes) |
| 3568 | ); |
| 3569 | } |
| 3570 | if (type == "interserver") |
| 3571 | return TCPServerConnectionFactory::Ptr( |
| 3572 | new HTTPServerConnectionFactory(httpContext(), http_params, createHandlerFactory(*this, config, async_metrics, "InterserverIOHTTPHandler-factory"), ProfileEvents::InterfaceInterserverReceiveBytes, ProfileEvents::InterfaceInterserverSendBytes) |
| 3573 | ); |
| 3574 | |
| 3575 | throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER, "Protocol configuration error, unknown protocol name '{}'", type); |
| 3576 | }; |
| 3577 | |
| 3578 | std::string conf_name = "protocols." + protocol; |
| 3579 | std::string prefix = conf_name + "."; |
nothing calls this directly
no test coverage detected