MXS-2196: Rename SERV_LISTENER to Listener
This commit is contained in:
@ -23,7 +23,7 @@
|
||||
#include <maxbase/jansson.h>
|
||||
#include <maxscale/buffer.h>
|
||||
|
||||
class SERV_LISTENER;
|
||||
class Listener;
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
@ -97,8 +97,8 @@ typedef struct mxs_authenticator
|
||||
int (* authenticate)(struct dcb*);
|
||||
void (* free)(struct dcb*);
|
||||
void (* destroy)(void*);
|
||||
int (* loadusers)(SERV_LISTENER*);
|
||||
void (* diagnostic)(struct dcb*, SERV_LISTENER*);
|
||||
int (* loadusers)(Listener*);
|
||||
void (* diagnostic)(struct dcb*, Listener*);
|
||||
|
||||
/**
|
||||
* @brief Return diagnostic information about the authenticator
|
||||
@ -112,7 +112,7 @@ typedef struct mxs_authenticator
|
||||
*
|
||||
* @see jansson.h
|
||||
*/
|
||||
json_t* (*diagnostic_json)(const SERV_LISTENER * listener);
|
||||
json_t* (*diagnostic_json)(const Listener * listener);
|
||||
|
||||
/** This entry point was added to avoid calling authenticator functions
|
||||
* directly when a COM_CHANGE_USER command is executed. */
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <maxscale/ssl.h>
|
||||
|
||||
class SERVICE;
|
||||
class SERV_LISTENER;
|
||||
class Listener;
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
@ -189,7 +189,7 @@ typedef struct dcb
|
||||
size_t protocol_packet_length; /**< How long the protocol specific packet is */
|
||||
size_t protocol_bytes_processed; /**< How many bytes of a packet have been read */
|
||||
struct session* session; /**< The owning session */
|
||||
SERV_LISTENER* listener; /**< For a client DCB, the listener data */
|
||||
Listener* listener; /**< For a client DCB, the listener data */
|
||||
MXS_PROTOCOL func; /**< The protocol functions for this descriptor */
|
||||
MXS_AUTHENTICATOR authfunc; /**< The authenticator functions for this descriptor
|
||||
* */
|
||||
@ -261,7 +261,7 @@ void dcb_global_init();
|
||||
|
||||
int dcb_write(DCB*, GWBUF*);
|
||||
DCB* dcb_accept(DCB* listener);
|
||||
DCB* dcb_alloc(dcb_role_t, SERV_LISTENER*, SERVICE* service);
|
||||
DCB* dcb_alloc(dcb_role_t, Listener*, SERVICE* service);
|
||||
DCB* dcb_connect(struct server*, struct session*, const char*);
|
||||
int dcb_read(DCB*, GWBUF**, int);
|
||||
int dcb_drain_writeq(DCB*);
|
||||
|
@ -31,8 +31,7 @@ class SERVICE;
|
||||
* The Listener class is used to link a network port to a service. It defines the name of the
|
||||
* protocol module that should be loaded as well as the authenticator that is used.
|
||||
*/
|
||||
// TODO: Rename to Listener
|
||||
class SERV_LISTENER
|
||||
class Listener
|
||||
{
|
||||
public:
|
||||
|
||||
@ -49,10 +48,10 @@ public:
|
||||
* @param auth_instance The authenticator instance
|
||||
* @param ssl The SSL configuration
|
||||
*/
|
||||
SERV_LISTENER(SERVICE* service, const std::string& name, const std::string& address, uint16_t port,
|
||||
Listener(SERVICE* service, const std::string& name, const std::string& address, uint16_t port,
|
||||
const std::string& protocol, const std::string& authenticator,
|
||||
const std::string& auth_opts, void* auth_instance, SSL_LISTENER* ssl);
|
||||
~SERV_LISTENER();
|
||||
~Listener();
|
||||
|
||||
/**
|
||||
* Start listening on the configured port
|
||||
@ -183,7 +182,7 @@ private:
|
||||
std::atomic<bool> m_active; /**< True if the port has not been deleted */
|
||||
};
|
||||
|
||||
using SListener = std::shared_ptr<SERV_LISTENER>;
|
||||
using SListener = std::shared_ptr<Listener>;
|
||||
|
||||
/**
|
||||
* @brief Serialize a listener to a file
|
||||
|
@ -144,7 +144,7 @@ USERS* users_from_json(json_t* json);
|
||||
* @param port Listener configuration
|
||||
* @return Always AUTH_LOADUSERS_OK
|
||||
*/
|
||||
int users_default_loadusers(SERV_LISTENER* port);
|
||||
int users_default_loadusers(Listener* port);
|
||||
|
||||
/**
|
||||
* @brief Default authenticator diagnostic function
|
||||
@ -152,14 +152,14 @@ int users_default_loadusers(SERV_LISTENER* port);
|
||||
* @param dcb DCB where data is printed
|
||||
* @param port Port whose data is to be printed
|
||||
*/
|
||||
void users_default_diagnostic(DCB* dcb, SERV_LISTENER* port);
|
||||
void users_default_diagnostic(DCB* dcb, Listener* port);
|
||||
|
||||
/**
|
||||
* @brief Default authenticator diagnostic function
|
||||
*
|
||||
* @param port Port whose data is to be printed
|
||||
*/
|
||||
json_t* users_default_diagnostic_json(const SERV_LISTENER* port);
|
||||
json_t* users_default_diagnostic_json(const Listener* port);
|
||||
|
||||
/**
|
||||
* Print users to a DCB
|
||||
|
@ -180,7 +180,7 @@ static void dcb_initialize(DCB* dcb)
|
||||
*
|
||||
* @return An available DCB or NULL if none could be allocated.
|
||||
*/
|
||||
DCB* dcb_alloc(dcb_role_t role, SERV_LISTENER* listener, SERVICE* service)
|
||||
DCB* dcb_alloc(dcb_role_t role, Listener* listener, SERVICE* service)
|
||||
{
|
||||
DCB* newdcb;
|
||||
|
||||
|
@ -43,7 +43,7 @@ static RSA* rsa_512 = NULL;
|
||||
static RSA* rsa_1024 = NULL;
|
||||
static RSA* tmp_rsa_callback(SSL* s, int is_export, int keylength);
|
||||
|
||||
SERV_LISTENER::SERV_LISTENER(SERVICE* service, const std::string& name, const std::string& address,
|
||||
Listener::Listener(SERVICE* service, const std::string& name, const std::string& address,
|
||||
uint16_t port, const std::string& protocol, const std::string& authenticator,
|
||||
const std::string& auth_opts, void* auth_instance, SSL_LISTENER* ssl)
|
||||
: m_name(name)
|
||||
@ -61,7 +61,7 @@ SERV_LISTENER::SERV_LISTENER(SERVICE* service, const std::string& name, const st
|
||||
{
|
||||
}
|
||||
|
||||
SERV_LISTENER::~SERV_LISTENER()
|
||||
Listener::~Listener()
|
||||
{
|
||||
if (m_users)
|
||||
{
|
||||
@ -104,7 +104,7 @@ SListener listener_alloc(SERVICE* service,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SListener listener(new(std::nothrow) SERV_LISTENER(service, name, address, port, protocol, authenticator,
|
||||
SListener listener(new(std::nothrow) Listener(service, name, address, port, protocol, authenticator,
|
||||
auth_options, auth_instance, ssl));
|
||||
|
||||
if (listener)
|
||||
@ -122,7 +122,7 @@ void listener_free(const SListener& listener)
|
||||
all_listeners.remove(listener);
|
||||
}
|
||||
|
||||
void SERV_LISTENER::close()
|
||||
void Listener::close()
|
||||
{
|
||||
deactivate();
|
||||
stop();
|
||||
@ -133,7 +133,7 @@ void SERV_LISTENER::close()
|
||||
m_listener->fd = -1;
|
||||
}
|
||||
|
||||
bool SERV_LISTENER::stop()
|
||||
bool Listener::stop()
|
||||
{
|
||||
bool rval = false;
|
||||
mxb_assert(m_listener);
|
||||
@ -148,7 +148,7 @@ bool SERV_LISTENER::stop()
|
||||
return rval;
|
||||
}
|
||||
|
||||
bool SERV_LISTENER::start()
|
||||
bool Listener::start()
|
||||
{
|
||||
bool rval = true;
|
||||
mxb_assert(m_listener);
|
||||
@ -492,7 +492,7 @@ static RSA* tmp_rsa_callback(SSL* s, int is_export, int keylength)
|
||||
* @param filename Filename where configuration is written
|
||||
* @return True on success, false on error
|
||||
*/
|
||||
bool SERV_LISTENER::create_listener_config(const char* filename)
|
||||
bool Listener::create_listener_config(const char* filename)
|
||||
{
|
||||
int file = open(filename, O_EXCL | O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
@ -572,7 +572,7 @@ bool listener_serialize(const SListener& listener)
|
||||
return rval;
|
||||
}
|
||||
|
||||
json_t* SERV_LISTENER::to_json() const
|
||||
json_t* Listener::to_json() const
|
||||
{
|
||||
json_t* param = json_object();
|
||||
json_object_set_new(param, "address", json_string(m_address.c_str()));
|
||||
@ -616,57 +616,57 @@ json_t* SERV_LISTENER::to_json() const
|
||||
return rval;
|
||||
}
|
||||
|
||||
void SERV_LISTENER::deactivate()
|
||||
void Listener::deactivate()
|
||||
{
|
||||
m_active = false;
|
||||
}
|
||||
|
||||
bool SERV_LISTENER::is_active() const
|
||||
bool Listener::is_active() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
const char* SERV_LISTENER::name() const
|
||||
const char* Listener::name() const
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
const char* SERV_LISTENER::address() const
|
||||
const char* Listener::address() const
|
||||
{
|
||||
return m_address.c_str();
|
||||
}
|
||||
|
||||
uint16_t SERV_LISTENER::port() const
|
||||
uint16_t Listener::port() const
|
||||
{
|
||||
return m_port;
|
||||
}
|
||||
|
||||
SERVICE* SERV_LISTENER::service() const
|
||||
SERVICE* Listener::service() const
|
||||
{
|
||||
return m_service;
|
||||
}
|
||||
|
||||
const char* SERV_LISTENER::authenticator() const
|
||||
const char* Listener::authenticator() const
|
||||
{
|
||||
return m_authenticator.c_str();
|
||||
}
|
||||
|
||||
const char* SERV_LISTENER::protocol() const
|
||||
const char* Listener::protocol() const
|
||||
{
|
||||
return m_protocol.c_str();
|
||||
}
|
||||
|
||||
void* SERV_LISTENER::auth_instance() const
|
||||
void* Listener::auth_instance() const
|
||||
{
|
||||
return m_auth_instance;
|
||||
}
|
||||
|
||||
SSL_LISTENER* SERV_LISTENER::ssl() const
|
||||
SSL_LISTENER* Listener::ssl() const
|
||||
{
|
||||
return m_ssl;
|
||||
}
|
||||
|
||||
const char* SERV_LISTENER::state() const
|
||||
const char* Listener::state() const
|
||||
{
|
||||
if (m_listener && m_listener->session)
|
||||
{
|
||||
@ -689,7 +689,7 @@ const char* SERV_LISTENER::state() const
|
||||
}
|
||||
}
|
||||
|
||||
void SERV_LISTENER::print_users(DCB* dcb)
|
||||
void Listener::print_users(DCB* dcb)
|
||||
{
|
||||
if (m_listener && m_listener->authfunc.diagnostic)
|
||||
{
|
||||
@ -701,7 +701,7 @@ void SERV_LISTENER::print_users(DCB* dcb)
|
||||
}
|
||||
}
|
||||
|
||||
int SERV_LISTENER::load_users()
|
||||
int Listener::load_users()
|
||||
{
|
||||
int rval = MXS_AUTH_LOADUSERS_OK;
|
||||
|
||||
@ -713,18 +713,18 @@ int SERV_LISTENER::load_users()
|
||||
return rval;
|
||||
}
|
||||
|
||||
struct users* SERV_LISTENER::users() const
|
||||
struct users* Listener::users() const
|
||||
{
|
||||
return m_users;
|
||||
}
|
||||
|
||||
|
||||
void SERV_LISTENER::set_users(struct users* u)
|
||||
void Listener::set_users(struct users* u)
|
||||
{
|
||||
m_users = u;
|
||||
}
|
||||
|
||||
bool SERV_LISTENER::listen()
|
||||
bool Listener::listen()
|
||||
{
|
||||
m_listener = dcb_alloc(DCB_ROLE_SERVICE_LISTENER, this, m_service);
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
static int test1()
|
||||
{
|
||||
DCB* dcb;
|
||||
SERV_LISTENER* dummy = nullptr;
|
||||
Listener* dummy = nullptr;
|
||||
/* Single buffer tests */
|
||||
fprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_INTERNAL");
|
||||
dcb = dcb_alloc(DCB_ROLE_INTERNAL, dummy, NULL);
|
||||
|
@ -49,7 +49,7 @@ static int test1()
|
||||
DCB* dcb;
|
||||
int result;
|
||||
int eno = 0;
|
||||
SERV_LISTENER* dummy = nullptr;
|
||||
Listener* dummy = nullptr;
|
||||
|
||||
SERVICE service;
|
||||
service.routerModule = (char*)"required by a check in dcb.cc";
|
||||
|
@ -326,7 +326,7 @@ json_t* users_diagnostic_json(USERS* users)
|
||||
return u->diagnostic_json();
|
||||
}
|
||||
|
||||
void users_default_diagnostic(DCB* dcb, SERV_LISTENER* port)
|
||||
void users_default_diagnostic(DCB* dcb, Listener* port)
|
||||
{
|
||||
if (port->users)
|
||||
{
|
||||
@ -334,12 +334,12 @@ void users_default_diagnostic(DCB* dcb, SERV_LISTENER* port)
|
||||
}
|
||||
}
|
||||
|
||||
json_t* users_default_diagnostic_json(const SERV_LISTENER* port)
|
||||
json_t* users_default_diagnostic_json(const Listener* port)
|
||||
{
|
||||
return port->users ? users_diagnostic_json(port->users) : json_array();
|
||||
}
|
||||
|
||||
int users_default_loadusers(SERV_LISTENER* port)
|
||||
int users_default_loadusers(Listener* port)
|
||||
{
|
||||
users_free(port->users);
|
||||
port->users = users_alloc();
|
||||
|
@ -52,8 +52,8 @@ static bool cdc_auth_is_client_ssl_capable(DCB* dcb);
|
||||
static int cdc_auth_authenticate(DCB* dcb);
|
||||
static void cdc_auth_free_client_data(DCB* dcb);
|
||||
|
||||
static int cdc_set_service_user(SERV_LISTENER* listener);
|
||||
static int cdc_replace_users(SERV_LISTENER* listener);
|
||||
static int cdc_set_service_user(Listener* listener);
|
||||
static int cdc_replace_users(Listener* listener);
|
||||
|
||||
static int cdc_auth_check(DCB* dcb,
|
||||
CDC_protocol* protocol,
|
||||
@ -437,7 +437,7 @@ static void cdc_auth_free_client_data(DCB* dcb)
|
||||
* @param service The current service
|
||||
* @return 0 on success, 1 on failure
|
||||
*/
|
||||
static int cdc_set_service_user(SERV_LISTENER* listener)
|
||||
static int cdc_set_service_user(Listener* listener)
|
||||
{
|
||||
SERVICE* service = listener->service;
|
||||
char* dpwd = NULL;
|
||||
@ -538,7 +538,7 @@ static int cdc_read_users(USERS* users, char* usersfile)
|
||||
*
|
||||
* @param service The current service
|
||||
*/
|
||||
int cdc_replace_users(SERV_LISTENER* listener)
|
||||
int cdc_replace_users(Listener* listener)
|
||||
{
|
||||
int rc = MXS_AUTH_LOADUSERS_ERROR;
|
||||
USERS* newusers = users_alloc();
|
||||
|
@ -622,7 +622,7 @@ static void add_gssapi_user(sqlite3* handle,
|
||||
* @param listener Listener definition
|
||||
* @return MXS_AUTH_LOADUSERS_OK on success, MXS_AUTH_LOADUSERS_ERROR on error
|
||||
*/
|
||||
int gssapi_auth_load_users(SERV_LISTENER* listener)
|
||||
int gssapi_auth_load_users(Listener* listener)
|
||||
{
|
||||
const char* user;
|
||||
const char* password;
|
||||
|
@ -141,7 +141,7 @@ enum server_category_t
|
||||
SERVER_CLUSTRIX
|
||||
};
|
||||
|
||||
static int get_users(SERV_LISTENER* listener, bool skip_local);
|
||||
static int get_users(Listener* listener, bool skip_local);
|
||||
static MYSQL* gw_mysql_init(void);
|
||||
static int gw_mysql_set_timeouts(MYSQL* handle);
|
||||
static char* mysql_format_user_entry(void* data);
|
||||
@ -226,7 +226,7 @@ static char* get_users_query(const char* server_version, int version, bool inclu
|
||||
return rval;
|
||||
}
|
||||
|
||||
int replace_mysql_users(SERV_LISTENER* listener, bool skip_local)
|
||||
int replace_mysql_users(Listener* listener, bool skip_local)
|
||||
{
|
||||
int i = get_users(listener, skip_local);
|
||||
return i;
|
||||
@ -1096,7 +1096,7 @@ bool query_and_process_users(const char* query,
|
||||
return rval;
|
||||
}
|
||||
|
||||
int get_users_from_server(MYSQL* con, SERVER_REF* server_ref, SERVICE* service, SERV_LISTENER* listener)
|
||||
int get_users_from_server(MYSQL* con, SERVER_REF* server_ref, SERVICE* service, Listener* listener)
|
||||
{
|
||||
if (server_ref->server->version_string[0] == 0)
|
||||
{
|
||||
@ -1178,7 +1178,7 @@ int get_users_from_server(MYSQL* con, SERVER_REF* server_ref, SERVICE* service,
|
||||
* @param users The users table into which to load the users
|
||||
* @return -1 on any error or the number of users inserted
|
||||
*/
|
||||
static int get_users(SERV_LISTENER* listener, bool skip_local)
|
||||
static int get_users(Listener* listener, bool skip_local)
|
||||
{
|
||||
const char* service_user = NULL;
|
||||
const char* service_passwd = NULL;
|
||||
|
@ -42,7 +42,7 @@ static bool mysql_auth_set_protocol_data(DCB* dcb, GWBUF* buf);
|
||||
static bool mysql_auth_is_client_ssl_capable(DCB* dcb);
|
||||
static int mysql_auth_authenticate(DCB* dcb);
|
||||
static void mysql_auth_free_client_data(DCB* dcb);
|
||||
static int mysql_auth_load_users(SERV_LISTENER* port);
|
||||
static int mysql_auth_load_users(Listener* port);
|
||||
static void* mysql_auth_create(void* instance);
|
||||
static void mysql_auth_destroy(void* data);
|
||||
|
||||
@ -58,8 +58,8 @@ static bool mysql_auth_set_client_data(MYSQL_session* client_data,
|
||||
MySQLProtocol* protocol,
|
||||
GWBUF* buffer);
|
||||
|
||||
void mysql_auth_diagnostic(DCB* dcb, SERV_LISTENER* port);
|
||||
json_t* mysql_auth_diagnostic_json(const SERV_LISTENER* port);
|
||||
void mysql_auth_diagnostic(DCB* dcb, Listener* port);
|
||||
json_t* mysql_auth_diagnostic_json(const Listener* port);
|
||||
|
||||
int mysql_auth_reauthenticate(DCB* dcb,
|
||||
const char* user,
|
||||
@ -552,7 +552,7 @@ static void mysql_auth_free_client_data(DCB* dcb)
|
||||
* @param port Service listener
|
||||
* @return True on success, false on error
|
||||
*/
|
||||
static bool add_service_user(SERV_LISTENER* port)
|
||||
static bool add_service_user(Listener* port)
|
||||
{
|
||||
const char* user = NULL;
|
||||
const char* password = NULL;
|
||||
@ -607,7 +607,7 @@ static bool service_has_servers(SERVICE* service)
|
||||
* @return MXS_AUTH_LOADUSERS_OK on success, MXS_AUTH_LOADUSERS_ERROR and
|
||||
* MXS_AUTH_LOADUSERS_FATAL on fatal error
|
||||
*/
|
||||
static int mysql_auth_load_users(SERV_LISTENER* port)
|
||||
static int mysql_auth_load_users(Listener* port)
|
||||
{
|
||||
int rc = MXS_AUTH_LOADUSERS_OK;
|
||||
SERVICE* service = port->listener->service;
|
||||
@ -721,7 +721,7 @@ int diag_cb(void* data, int columns, char** row, char** field_names)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mysql_auth_diagnostic(DCB* dcb, SERV_LISTENER* port)
|
||||
void mysql_auth_diagnostic(DCB* dcb, Listener* port)
|
||||
{
|
||||
MYSQL_AUTH* instance = (MYSQL_AUTH*)port->auth_instance;
|
||||
sqlite3* handle = get_handle(instance);
|
||||
@ -750,7 +750,7 @@ int diag_cb_json(void* data, int columns, char** row, char** field_names)
|
||||
return 0;
|
||||
}
|
||||
|
||||
json_t* mysql_auth_diagnostic_json(const SERV_LISTENER* port)
|
||||
json_t* mysql_auth_diagnostic_json(const Listener* port)
|
||||
{
|
||||
json_t* rval = json_array();
|
||||
|
||||
|
@ -187,7 +187,7 @@ bool dbusers_save(sqlite3* src, const char* filename);
|
||||
*
|
||||
* @return -1 on any error or the number of users inserted (0 means no users at all)
|
||||
*/
|
||||
int replace_mysql_users(SERV_LISTENER* listener, bool skip_local);
|
||||
int replace_mysql_users(Listener* listener, bool skip_local);
|
||||
|
||||
/**
|
||||
* @brief Verify the user has access to the database
|
||||
|
@ -134,19 +134,19 @@ static void pam_auth_free_data(DCB* dcb)
|
||||
*
|
||||
* @return MXS_AUTH_LOADUSERS_OK on success, MXS_AUTH_LOADUSERS_ERROR on error
|
||||
*/
|
||||
static int pam_auth_load_users(SERV_LISTENER* listener)
|
||||
static int pam_auth_load_users(Listener* listener)
|
||||
{
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance);
|
||||
return inst->load_users(listener->service);
|
||||
}
|
||||
|
||||
static void pam_auth_diagnostic(DCB* dcb, SERV_LISTENER* listener)
|
||||
static void pam_auth_diagnostic(DCB* dcb, Listener* listener)
|
||||
{
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance);
|
||||
inst->diagnostic(dcb);
|
||||
}
|
||||
|
||||
static json_t* pam_auth_diagnostic_json(const SERV_LISTENER* listener)
|
||||
static json_t* pam_auth_diagnostic_json(const Listener* listener)
|
||||
{
|
||||
PamInstance* inst = static_cast<PamInstance*>(listener->auth_instance);
|
||||
return inst->diagnostic_json();
|
||||
|
@ -79,7 +79,7 @@ typedef enum
|
||||
} slave_eof_action_t;
|
||||
|
||||
static char* get_next_token(char* str, const char* delim, char** saveptr);
|
||||
extern int load_mysql_users(SERV_LISTENER* listener);
|
||||
extern int load_mysql_users(Listener* listener);
|
||||
extern void blr_master_close(ROUTER_INSTANCE* router);
|
||||
extern int blr_file_new_binlog(ROUTER_INSTANCE* router, char* file);
|
||||
extern int blr_file_write_master_config(ROUTER_INSTANCE* router, char* error);
|
||||
|
Reference in New Issue
Block a user