1 /* 2 * Copyright (c) 2015, 2021, Oracle and/or its affiliates. 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License, version 2.0, 6 * as published by the Free Software Foundation. 7 * 8 * This program is also distributed with certain software (including 9 * but not limited to OpenSSL) that is licensed under separate terms, 10 * as designated in a particular file or component or in included license 11 * documentation. The authors of MySQL hereby grant you an additional 12 * permission to link the program and your derivative works with the 13 * separately licensed software that they have included with MySQL. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License, version 2.0, for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 23 * 02110-1301 USA 24 */ 25 26 #ifndef _NGS_CLIENT_INTERFACE_H_ 27 #define _NGS_CLIENT_INTERFACE_H_ 28 29 #include "ngs_common/chrono.h" 30 #include "ngs/interface/session_interface.h" 31 #include "ngs_common/connection_vio.h" 32 33 namespace ngs 34 { 35 36 class Server_interface; 37 38 class Client_interface 39 { 40 public: 41 typedef uint64_t Client_id; 42 43 enum Client_state 44 { 45 Client_invalid, 46 Client_accepted, 47 Client_accepted_with_session, 48 Client_authenticating_first, 49 Client_running, 50 Client_closing, 51 Client_closed 52 }; 53 54 public: ~Client_interface()55 virtual ~Client_interface() { } 56 57 virtual Server_interface &server() const = 0; 58 virtual Connection_vio &connection() = 0; 59 60 virtual void activate_tls() = 0; 61 62 public: // Notifications from Server object 63 virtual void on_auth_timeout() = 0; 64 virtual void on_server_shutdown() = 0; 65 66 virtual void run(const bool skip_resolve_name) = 0; 67 virtual Mutex &get_session_exit_mutex() = 0; 68 69 public: 70 virtual const char *client_address() const = 0; 71 virtual const char *client_hostname() const = 0; 72 virtual const char *client_id() const = 0; 73 virtual Client_id client_id_num() const = 0; 74 virtual int client_port() const = 0; 75 76 virtual void reset_accept_time() = 0; 77 virtual chrono::time_point get_accept_time() const = 0; 78 virtual Client_state get_state() const = 0; 79 virtual bool supports_expired_passwords() = 0; 80 81 82 virtual ngs::shared_ptr<Session_interface> session() = 0; 83 84 public: 85 virtual void on_session_reset(Session_interface &s) = 0; 86 virtual void on_session_close(Session_interface &s) = 0; 87 virtual void on_session_auth_success(Session_interface &s) = 0; 88 89 virtual void disconnect_and_trigger_close() = 0; 90 91 }; 92 93 } // namespace ngs 94 95 #endif // _NGS_CLIENT_INTERFACE_H_ 96