mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
registration: remove auth param and excess functions
This commit is contained in:
parent
f53b4353fd
commit
87d2c95c87
@ -2649,7 +2649,7 @@ static struct cmd_t command_defs[] = {
|
||||
CMD_TAGS(
|
||||
CMD_TAG_CONNECTION)
|
||||
CMD_SYN(
|
||||
"/register <username> <server> [port <port>] [tls force|allow|trust|legacy|disable] [auth default|legacy]")
|
||||
"/register <username> <server> [port <port>] [tls force|allow|trust|legacy|disable]")
|
||||
CMD_DESC(
|
||||
"Register an account on a server.")
|
||||
CMD_ARGS(
|
||||
@ -2660,9 +2660,7 @@ static struct cmd_t command_defs[] = {
|
||||
{ "tls allow", "Use TLS for the connection if it is available." },
|
||||
{ "tls trust", "Force TLS connection and trust the server's certificate." },
|
||||
{ "tls legacy", "Use legacy TLS for the connection. This forces TLS just after the TCP connection is established. Use when a server doesn't support STARTTLS." },
|
||||
{ "tls disable", "Disable TLS for the connection." },
|
||||
{ "auth default", "Default authentication process." },
|
||||
{ "auth legacy", "Allow legacy authentication." })
|
||||
{ "tls disable", "Disable TLS for the connection." })
|
||||
CMD_EXAMPLES(
|
||||
"/register odin valhalla.edda ",
|
||||
"/register freyr vanaheimr.edda port 5678",
|
||||
|
@ -9579,14 +9579,6 @@ cmd_register(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
}
|
||||
|
||||
char* auth_policy = g_hash_table_lookup(options, "auth");
|
||||
if (auth_policy && (g_strcmp0(auth_policy, "default") != 0) && (g_strcmp0(auth_policy, "legacy") != 0)) {
|
||||
cons_bad_cmd_usage(command);
|
||||
cons_show("");
|
||||
options_destroy(options);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
char* username = args[0];
|
||||
char* server = args[1];
|
||||
|
||||
@ -9595,7 +9587,7 @@ cmd_register(ProfWin* window, const char* const command, gchar** args)
|
||||
|
||||
if (g_strcmp0(passwd, confirm_passwd) == 0) {
|
||||
log_info("Attempting to register account %s on server %s.", username, server);
|
||||
connection_register(server, port, tls_policy, auth_policy, username, passwd);
|
||||
connection_register(server, port, tls_policy, username, passwd);
|
||||
} else {
|
||||
cons_show("The two passwords do not match.");
|
||||
}
|
||||
|
@ -81,13 +81,6 @@ cl_ev_connect_account(ProfAccount* account)
|
||||
return session_connect_with_account(account);
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
cl_ev_connect_raw(const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy)
|
||||
{
|
||||
cons_show("Raw connecting to %s", altdomain);
|
||||
return session_connect_raw(altdomain, port, tls_policy, auth_policy);
|
||||
}
|
||||
|
||||
void
|
||||
cl_ev_disconnect(void)
|
||||
{
|
||||
|
@ -40,7 +40,6 @@
|
||||
|
||||
jabber_conn_status_t cl_ev_connect_jid(const char* const jid, const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
|
||||
jabber_conn_status_t cl_ev_connect_account(ProfAccount* account);
|
||||
jabber_conn_status_t cl_ev_connect_raw(const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
|
||||
|
||||
void cl_ev_disconnect(void);
|
||||
|
||||
|
@ -251,111 +251,6 @@ connection_connect(const char* const jid, const char* const passwd, const char*
|
||||
return conn.conn_status;
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
connection_connect_raw(const char* const altdomain, int port,
|
||||
const char* const tls_policy, const char* const auth_policy)
|
||||
{
|
||||
long flags;
|
||||
|
||||
Jid* jidp = jid_create(altdomain);
|
||||
if (jidp == NULL) {
|
||||
log_error("Malformed JID not able to connect: %s", altdomain);
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
return conn.conn_status;
|
||||
}
|
||||
|
||||
_compute_identifier(jidp->barejid);
|
||||
jid_destroy(jidp);
|
||||
|
||||
if (conn.xmpp_log) {
|
||||
free(conn.xmpp_log);
|
||||
}
|
||||
conn.xmpp_log = _xmpp_get_file_logger();
|
||||
|
||||
if (conn.xmpp_conn) {
|
||||
xmpp_conn_release(conn.xmpp_conn);
|
||||
}
|
||||
if (conn.xmpp_ctx) {
|
||||
xmpp_ctx_free(conn.xmpp_ctx);
|
||||
}
|
||||
conn.xmpp_ctx = xmpp_ctx_new(NULL, conn.xmpp_log);
|
||||
if (conn.xmpp_ctx == NULL) {
|
||||
log_warning("Failed to get libstrophe ctx during connect");
|
||||
return JABBER_DISCONNECTED;
|
||||
}
|
||||
conn.xmpp_conn = xmpp_conn_new(conn.xmpp_ctx);
|
||||
if (conn.xmpp_conn == NULL) {
|
||||
log_warning("Failed to get libstrophe conn during connect");
|
||||
return JABBER_DISCONNECTED;
|
||||
}
|
||||
xmpp_conn_set_jid(conn.xmpp_conn, altdomain);
|
||||
|
||||
flags = xmpp_conn_get_flags(conn.xmpp_conn);
|
||||
|
||||
if (!tls_policy || (g_strcmp0(tls_policy, "force") == 0)) {
|
||||
flags |= XMPP_CONN_FLAG_MANDATORY_TLS;
|
||||
} else if (g_strcmp0(tls_policy, "trust") == 0) {
|
||||
flags |= XMPP_CONN_FLAG_MANDATORY_TLS;
|
||||
flags |= XMPP_CONN_FLAG_TRUST_TLS;
|
||||
} else if (g_strcmp0(tls_policy, "disable") == 0) {
|
||||
flags |= XMPP_CONN_FLAG_DISABLE_TLS;
|
||||
} else if (g_strcmp0(tls_policy, "legacy") == 0) {
|
||||
flags |= XMPP_CONN_FLAG_LEGACY_SSL;
|
||||
}
|
||||
|
||||
if (auth_policy && (g_strcmp0(auth_policy, "legacy") == 0)) {
|
||||
flags |= XMPP_CONN_FLAG_LEGACY_AUTH;
|
||||
}
|
||||
|
||||
xmpp_conn_set_flags(conn.xmpp_conn, flags);
|
||||
|
||||
/* Print debug logs that can help when users share the logs */
|
||||
if (flags != 0) {
|
||||
log_debug("Connecting with flags (0x%lx):", flags);
|
||||
#define LOG_FLAG_IF_SET(name) \
|
||||
if (flags & name) { \
|
||||
log_debug(" " #name); \
|
||||
}
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_MANDATORY_TLS);
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_TRUST_TLS);
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_DISABLE_TLS);
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_LEGACY_SSL);
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_LEGACY_AUTH);
|
||||
#undef LOG_FLAG_IF_SET
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBMESODE
|
||||
char* cert_path = prefs_get_tls_certpath();
|
||||
if (cert_path) {
|
||||
xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path);
|
||||
free(cert_path);
|
||||
}
|
||||
|
||||
int connect_status = xmpp_connect_raw(
|
||||
conn.xmpp_conn,
|
||||
altdomain,
|
||||
port,
|
||||
_connection_certfail_cb,
|
||||
_connection_handler,
|
||||
conn.xmpp_ctx);
|
||||
#else
|
||||
int connect_status = xmpp_connect_raw(
|
||||
conn.xmpp_conn,
|
||||
altdomain,
|
||||
port,
|
||||
_connection_handler,
|
||||
conn.xmpp_ctx);
|
||||
#endif
|
||||
|
||||
if (connect_status == 0) {
|
||||
conn.conn_status = JABBER_RAW_CONNECTING;
|
||||
} else {
|
||||
conn.conn_status = JABBER_DISCONNECTED;
|
||||
}
|
||||
|
||||
return conn.conn_status;
|
||||
}
|
||||
|
||||
static int iq_reg2_cb(xmpp_conn_t *xmpp_conn, xmpp_stanza_t *stanza, void *userdata)
|
||||
{
|
||||
const char *type;
|
||||
@ -578,8 +473,7 @@ _register_handler(xmpp_conn_t *xmpp_conn,
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
connection_register(const char* const altdomain, int port,
|
||||
const char* const tls_policy, const char* const auth_policy,
|
||||
connection_register(const char* const altdomain, int port, const char* const tls_policy,
|
||||
const char* const username, const char* const password)
|
||||
{
|
||||
long flags;
|
||||
@ -630,10 +524,6 @@ connection_register(const char* const altdomain, int port,
|
||||
flags |= XMPP_CONN_FLAG_LEGACY_SSL;
|
||||
}
|
||||
|
||||
if (auth_policy && (g_strcmp0(auth_policy, "legacy") == 0)) {
|
||||
flags |= XMPP_CONN_FLAG_LEGACY_AUTH;
|
||||
}
|
||||
|
||||
xmpp_conn_set_flags(conn.xmpp_conn, flags);
|
||||
|
||||
/* Print debug logs that can help when users share the logs */
|
||||
@ -647,7 +537,6 @@ connection_register(const char* const altdomain, int port,
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_TRUST_TLS);
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_DISABLE_TLS);
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_LEGACY_SSL);
|
||||
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_LEGACY_AUTH);
|
||||
#undef LOG_FLAG_IF_SET
|
||||
}
|
||||
|
||||
@ -670,7 +559,6 @@ connection_register(const char* const altdomain, int port,
|
||||
|
||||
int connect_status = xmpp_connect_raw(
|
||||
conn.xmpp_conn,
|
||||
//strdup(altdomain),
|
||||
altdomain,
|
||||
port,
|
||||
_connection_certfail_cb,
|
||||
@ -679,7 +567,6 @@ connection_register(const char* const altdomain, int port,
|
||||
#else
|
||||
int connect_status = xmpp_connect_raw(
|
||||
conn.xmpp_conn,
|
||||
//strdup(altdomain),
|
||||
altdomain,
|
||||
port,
|
||||
_register_handler,
|
||||
|
@ -46,10 +46,7 @@ void connection_check_events(void);
|
||||
|
||||
jabber_conn_status_t connection_connect(const char* const fulljid, const char* const passwd, const char* const altdomain, int port,
|
||||
const char* const tls_policy, const char* const auth_policy);
|
||||
jabber_conn_status_t connection_connect_raw(const char* const altdomain, int port,
|
||||
const char* const tls_policy, const char* const auth_policy);
|
||||
jabber_conn_status_t connection_register(const char* const altdomain, int port,
|
||||
const char* const tls_policy, const char* const auth_policy,
|
||||
jabber_conn_status_t connection_register(const char* const altdomain, int port, const char* const tls_policy,
|
||||
const char* const username, const char* const password);
|
||||
void connection_disconnect(void);
|
||||
void connection_set_disconnected(void);
|
||||
|
@ -150,7 +150,6 @@ static int _command_list_result_handler(xmpp_stanza_t* const stanza, void* const
|
||||
static int _command_exec_response_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _register_change_password_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
static int _register_new_account_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
|
||||
|
||||
static void _iq_free_room_data(ProfRoomInfoData* roominfo);
|
||||
static void _iq_free_affiliation_set(ProfPrivilegeSet* affiliation_set);
|
||||
@ -2655,37 +2654,6 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
iq_register_new_account(const char* const user, const char* const password)
|
||||
{
|
||||
xmpp_ctx_t* const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t* iq = stanza_register_new_account(ctx, user, password);
|
||||
|
||||
const char* id = xmpp_stanza_get_id(iq);
|
||||
iq_id_handler_add(id, _register_new_account_result_id_handler, NULL, NULL); // FIXME: function doesn't seem to ever run?
|
||||
|
||||
log_debug("HI hi sending registration stanza");
|
||||
iq_send_stanza(iq);
|
||||
log_debug("registration stanza has been sent");
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
|
||||
static int
|
||||
_register_new_account_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
{
|
||||
const char* type = xmpp_stanza_get_type(stanza);
|
||||
if (g_strcmp0(type, "error") == 0) {
|
||||
char* error_message = stanza_get_error_message(stanza);
|
||||
cons_show_error("Server error: %s", error_message);
|
||||
log_debug("Registration error: %s", error_message);
|
||||
free(error_message);
|
||||
} else {
|
||||
cons_show("Registration successful.");
|
||||
log_debug("Registration successful.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
iq_register_change_password(const char* const user, const char* const password)
|
||||
{
|
||||
|
@ -204,43 +204,6 @@ session_connect_with_details(const char* const jid, const char* const passwd, co
|
||||
saved_details.auth_policy);
|
||||
}
|
||||
|
||||
jabber_conn_status_t
|
||||
session_connect_raw(const char* const altdomain, const int port, const char* const tls_policy,
|
||||
const char* const auth_policy)
|
||||
{
|
||||
assert(altdomain != NULL);
|
||||
|
||||
_session_free_saved_account();
|
||||
_session_free_saved_details();
|
||||
|
||||
// save details for reconnect
|
||||
saved_details.altdomain = strdup(altdomain);
|
||||
if (port != 0) {
|
||||
saved_details.port = port;
|
||||
} else {
|
||||
saved_details.port = 0;
|
||||
}
|
||||
if (tls_policy) {
|
||||
saved_details.tls_policy = strdup(tls_policy);
|
||||
} else {
|
||||
saved_details.tls_policy = NULL;
|
||||
}
|
||||
if (auth_policy) {
|
||||
saved_details.auth_policy = strdup(auth_policy);
|
||||
} else {
|
||||
saved_details.auth_policy = NULL;
|
||||
}
|
||||
|
||||
// raw connect
|
||||
log_info("Raw connecting to server: %s", altdomain);
|
||||
|
||||
return connection_connect_raw(
|
||||
saved_details.altdomain,
|
||||
saved_details.port,
|
||||
saved_details.tls_policy,
|
||||
saved_details.auth_policy);
|
||||
}
|
||||
|
||||
void
|
||||
session_autoping_fail(void)
|
||||
{
|
||||
|
@ -186,7 +186,6 @@ jabber_conn_status_t session_connect_with_details(const char* const jid, const c
|
||||
const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
|
||||
jabber_conn_status_t session_connect_with_account(const ProfAccount* const account);
|
||||
|
||||
jabber_conn_status_t session_connect_raw(const char* const altdomain, const int port, const char* const tls_policy, const char* const auth_policy);
|
||||
void session_disconnect(void);
|
||||
void session_shutdown(void);
|
||||
void session_process_events(void);
|
||||
@ -270,7 +269,6 @@ void iq_command_list(const char* const target);
|
||||
void iq_command_exec(const char* const target, const char* const command);
|
||||
void iq_mam_request(ProfChatWin* win);
|
||||
void iq_register_change_password(const char* const user, const char* const password);
|
||||
void iq_register_new_account(const char* const user, const char* const password);
|
||||
void iq_muc_register_nick(const char* const roomjid);
|
||||
|
||||
EntityCapabilities* caps_lookup(const char* const jid);
|
||||
|
Loading…
Reference in New Issue
Block a user