bool master_service::on_accept(acl::aio_socket_stream* client) { if (0) logger("connect from %s, fd %d", client->get_peer(true), client->sock_handle()); acl_non_blocking(client->sock_handle(), ACL_BLOCKING); // 根据客户端连接服务端口号的不同来区分不同的服务应用协议 const char* local = client->get_local(true); if (acl_strrncasecmp(local, var_cfg_backend_service, strlen(var_cfg_backend_service)) == 0) { // 创建服务对象处理来自于后端服务模块的请求 IConnection* conn = new ServerConnection(client); conn->run(); return true; } else { // 创建对象处理来自于前端客户端模块的请求 IConnection* conn = new ClientConnection(client, var_cfg_conn_expired); conn->run(); return true; } return true; }
bool master_service::on_accept(acl::aio_socket_stream* client) { if (0) logger("connect from %s, fd %d", client->get_peer(true), client->sock_handle()); acl_non_blocking(client->sock_handle(), ACL_BLOCKING); IConnection* conn; // 根据客户端连接服务端口号的不同来区分不同的服务应用协议 const char* local = client->get_local(true); if (acl_strrncasecmp(local, var_cfg_backend_service, strlen(var_cfg_backend_service)) == 0) { // 创建服务对象处理来自于后端服务模块的请求 conn = new ServerConnection(client); } else if (acl_strrncasecmp(local, var_cfg_status_service, strlen(var_cfg_status_service)) == 0) { const char* ip = client->get_peer(); if (ip == NULL || *ip == 0) { logger_error("can't get peer ip"); return false; } if (allow_list::get_instance().allow_manager(ip) == false) { logger_warn("deny manager ip: %s", ip); return false; } // 创建服务对象处理状态汇报的请求 conn = new StatusConnection(client); } else // 创建对象处理来自于前端客户端模块的请求 conn = new ClientConnection(client, var_cfg_conn_expired); conn->run(); return true; }