#include "dialback.h"
Data Structures | |
| struct | _dialback_jid_with_xmlnode |
| struct | miodc |
| little wrapper to keep our hash tables in check More... | |
Functions | |
| int | dialback_check_settings (db d, mio m, const char *server, int is_outgoing, int auth_type, int version) |
| char * | dialback_randstr (void) |
| char * | dialback_merlin (pool p, char const *secret, char const *to, char const *from, char const *challenge) |
| void | dialback_miod_write (miod md, xmlnode x) |
| void | dialback_miod_read (miod md, xmlnode x) |
| miod | dialback_miod_new (db d, mio m) |
| void | _dialback_miod_hash_cleanup (void *arg) |
| void | dialback_miod_hash (miod md, xht ht, jid key) |
| char * | dialback_ip_get (db d, jid host, char *ip) |
| void | dialback_ip_set (db d, jid host, char *ip) |
| void | _dialback_walk_out_established (xht h, const char *key, void *value, void *arg) |
| void | _dialback_walk_out_connecting (xht h, const char *key, void *value, void *arg) |
| void | _dialback_walk_in_established (xht h, const char *key, void *value, void *arg) |
| void | _dialback_walk_in_connecting (xht h, const char *key, void *value, void *arg) |
| result | dialback_packets (instance i, dpacket dp, void *arg) |
| void | _dialback_beat_idle (xht h, const char *key, void *data, void *arg) |
| void | _dialback_beat_in_idle (xht h, const char *key, void *data, void *arg) |
| void | _dialback_beat_out_idle (xht h, const char *key, void *data, void *arg) |
| result | dialback_beat_idle (void *arg) |
| const char * | dialback_get_loopcheck_token (db d) |
| void | dialback (instance i, xmlnode x) |
This is the main file of the dialback component (module) of the Jabber server.
The dialback protocol is documented in XMPP-core. This module only supports identity verification using dialback, SASL is not supported.
| void _dialback_beat_idle | ( | xht | h, | |
| const char * | key, | |||
| void * | data, | |||
| void * | arg | |||
| ) |
callback for walking each miod-value host hash tree, close connections that have been idle to long
The timeout value is configured in the dialback component configuration using the <idletimeout/> element.
| h | the hash table containing all connections | |
| key | unused/ignored (the key of the value in the hash table) | |
| data | the value in the hash table = the structure holding the connection | |
| arg | unused/ignored |
References miod_struct::d, mio_st::fd, miod_struct::last, log_debug2, LOGT_IO, miod_struct::m, mio_close(), mio_ip, mio_write(), db_struct::timeout_idle, and ZONE.
Referenced by dialback_beat_idle().
| void _dialback_beat_in_idle | ( | xht | h, | |
| const char * | key, | |||
| void * | data, | |||
| void * | arg | |||
| ) |
callback for walking incoming connections, that are not authorized yet, checking for timeotus
| h | the hash table containing all connections | |
| key | unused/ignored (the key of the value in the hash table) | |
| data | the value in the hash table = the structure holding the connection | |
| arg | unused/ignored |
References dbic_struct::d, mio_st::fd, log_debug2, LOGT_IO, dbic_struct::m, mio_close(), mio_ip, mio_write(), dbic_struct::stamp, db_struct::timeout_auth, and ZONE.
Referenced by dialback_beat_idle().
| void _dialback_beat_out_idle | ( | xht | h, | |
| const char * | key, | |||
| void * | data, | |||
| void * | arg | |||
| ) |
callback for walking outgoing connections, that are not authorized yet, checking for timeotus
| h | the hash table containing all connections | |
| key | unused/ignored (the key of the value in the hash table) | |
| data | the value in the hash table = the structure holding the connection | |
| arg | unused/ignored |
References dboc::d, mio_st::fd, log_debug2, LOGT_IO, dboc::m, mio_close(), mio_ip, mio_write(), dboc::stamp, db_struct::timeout_auth, and ZONE.
Referenced by dialback_beat_idle().
| void _dialback_miod_hash_cleanup | ( | void * | arg | ) |
Unregister outgoing routings, that have been routed over this connection, that is closed now.
clean up a hashtable entry containing this miod
This function is called if the pool assocciated with the miod is freed.
| arg | pointer to the miodc structure |
References miod_struct::count, miod_struct::d, mio_st::fd, xmppd::jabberid::get_domain(), xmppd::jabberid::get_resource(), miodc::ht, db_struct::i, db_struct::in_ok_db, jid_full(), miodc::key, log_debug2, log_record(), LOGT_AUTH, LOGT_CLEANUP, miod_struct::m, miodc::md, mio_ip, db_struct::out_ok_db, unregister_instance(), xhash_get(), xhash_zap(), and ZONE.
Referenced by dialback_miod_hash().
| void _dialback_walk_in_connecting | ( | xht | h, | |
| const char * | key, | |||
| void * | value, | |||
| void * | arg | |||
| ) |
iterate the xhash of connecting incomming connections and add items for them to a disco::items query
References _dialback_jid_with_xmlnode::id, jid_full(), JID_RESOURCE, jid_set(), NS_DISCO_ITEMS, _dialback_jid_with_xmlnode::x, xmlnode_insert_tag_ns(), and xmlnode_put_attrib_ns().
| void _dialback_walk_in_established | ( | xht | h, | |
| const char * | key, | |||
| void * | value, | |||
| void * | arg | |||
| ) |
iterate the xhash of established incomming connections and add items for them to a disco::items query
References _dialback_jid_with_xmlnode::id, jid_full(), JID_RESOURCE, jid_set(), NS_DISCO_ITEMS, _dialback_jid_with_xmlnode::x, xmlnode_insert_tag_ns(), and xmlnode_put_attrib_ns().
| void _dialback_walk_out_connecting | ( | xht | h, | |
| const char * | key, | |||
| void * | value, | |||
| void * | arg | |||
| ) |
iterate the xhash of connecting outgoing connections and add items for them to a disco::items query
References _dialback_jid_with_xmlnode::id, jid_full(), JID_RESOURCE, jid_set(), NS_DISCO_ITEMS, _dialback_jid_with_xmlnode::x, xmlnode_insert_tag_ns(), and xmlnode_put_attrib_ns().
| void _dialback_walk_out_established | ( | xht | h, | |
| const char * | key, | |||
| void * | value, | |||
| void * | arg | |||
| ) |
iterate the xhash of established outgoing connections and add items for them to a disco::items query
References _dialback_jid_with_xmlnode::id, jid_full(), JID_RESOURCE, jid_set(), NS_DISCO_ITEMS, _dialback_jid_with_xmlnode::x, xmlnode_insert_tag_ns(), and xmlnode_put_attrib_ns().
init and register the dialback component in the server
| i | the jabber server's data about this instance | |
| x | xmlnode of this instances configuration (???) |
References karma::dec, dialback_beat_idle(), dialback_in_read(), dialback_out_beat_packets(), dialback_packets(), dialback_randstr(), db_struct::hosts_auth, db_struct::hosts_tls, db_struct::hosts_xmpp, db_struct::i, db_struct::in_id, db_struct::in_ok_db, karma::inc, j_atoi(), jid_new(), KARMA_DEC, KARMA_INC, KARMA_INIT, KARMA_MAX, KARMA_PENALTY, KARMA_RESETMETER, KARMA_RESTORE, log_debug2, LOGT_INIT, karma::max, mio_karma2(), mio_listen(), MIO_LISTEN_XML, mio_rate(), NS_DIALBACK, NS_DISCO_INFO, NS_DISCO_ITEMS, NS_JABBERD_CONFIG_DIALBACK, NS_JABBERD_WRAPPER, NS_SERVER, NS_STREAM, NS_XMPP_SASL, NS_XMPP_TLS, db_struct::nscache, o_DELIVER, db_struct::out_connecting, db_struct::out_ok_db, instance_struct::p, karma::penalty, pmalloco(), pool_cleanup(), pstrdup(), register_beat(), register_phandler(), karma::reset_meter, karma::restore, db_struct::secret, db_struct::std_ns_prefixes, db_struct::timeout_auth, db_struct::timeout_idle, db_struct::timeout_packets, karma::val, db_struct::xc, xdb_cache(), xdb_get(), xhash_free(), xhash_new(), xhash_put(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_get_data(), xmlnode_get_list_item(), xmlnode_get_list_item_data(), xmlnode_get_tags(), xmlnode_pool(), and ZONE.
| result dialback_beat_idle | ( | void * | arg | ) |
initiate walking the hash of existing s2s connections to check if they have been idle to long
called as a heartbeat function
| arg | pointer to the structure holding the context of the dialback component instance |
References _dialback_beat_idle(), _dialback_beat_in_idle(), _dialback_beat_out_idle(), db_struct::in_id, db_struct::in_ok_db, log_debug2, LOGT_EXECFLOW, db_struct::out_connecting, db_struct::out_ok_db, r_DONE, xhash_walk(), and ZONE.
Referenced by dialback().
| int dialback_check_settings | ( | db | d, | |
| mio | m, | |||
| const char * | server, | |||
| int | is_outgoing, | |||
| int | auth_type, | |||
| int | version | |||
| ) |
check TLS and authentication settings for a s2s connection
| d | the dialback instance | |
| m | the connection | |
| server | the host at the other end of the connection | |
| is_outgoing | 0 for an outgoing connection, 1 for an incoming connection | |
| auth_type | 0 for dialback, 1 for sasl | |
| version | 0 for a preXMPP stream, 1 for a XMPP1.0 stream |
References db_struct::hosts_auth, db_struct::hosts_tls, db_struct::i, instance_struct::id, j_atoi(), j_strcmp(), j_strncmp(), log_debug2, log_notice(), log_warn(), LOGT_IO, mio_close(), mio_is_encrypted(), mio_ssl_verify(), mio_tls_get_certtype(), mio_tls_get_characteristics(), mio_tls_get_compression(), mio_write(), mio_st::ssl, xhash_get_by_domain(), and ZONE.
Referenced by dialback_in_read_db(), dialback_in_verify(), and dialback_out_read().
| const char* dialback_get_loopcheck_token | ( | db | d | ) |
we pass a token in the stream root to identify a looping connection to ourself. This generated the token of the server.
| d | the dialback instance |
References hmac_sha1_ascii_r(), and db_struct::secret.
Referenced by dialback_in_read(), and dialback_out_read().
get the cached IP address for an external server
| d | db structure which contains the context of the dialback component instance | |
| host | the host for which we need the IP address | |
| ip | the IP if the caller already knows it (conveniance parameter) |
References xmppd::jabberid::get_domain(), xmppd::jabberid_pool::get_pool(), log_debug2, LOGT_IO, db_struct::nscache, pstrdup(), xhash_get(), xmlnode_get_attrib_ns(), and ZONE.
Referenced by dialback_out_packet().
put an IP address in our DNS cache
| d | db structure which contains the context of the dialback component instance | |
| host | the host for which we put the IP address | |
| ip | the IP address |
References xmppd::jabberid::get_domain(), log_debug2, LOGT_IO, NS_JABBERD_WRAPPER, db_struct::nscache, xhash_get(), xhash_put(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_new_tag_ns(), xmlnode_put_attrib_ns(), and ZONE.
Referenced by dialback_miod_hash().
| char* dialback_merlin | ( | pool | p, | |
| char const * | secret, | |||
| char const * | to, | |||
| char const * | from, | |||
| char const * | challenge | |||
| ) |
convenience function to generate your dialback key (not thread-safe)
| p | the memory pool used | |
| secret | our dialback secret | |
| to | the destination of the stream | |
| from | the source host of the stream | |
| challenge | the stream ID that should be verified |
References hmac_sha1_ascii_r(), log_debug2, LOGT_AUTH, pmalloco(), and ZONE.
Referenced by dialback_in_read_db(), dialback_out_connection(), and dialback_out_read().
registering a connection in the hash of outgoing connections
| md | structure representing the outgoing connection | |
| ht | hash table containing all outgoing s2s connections | |
| key | destination with our source domain as the resource |
References _dialback_miod_hash_cleanup(), miod_struct::d, dialback_ip_set(), mio_st::fd, xmppd::jabberid::get_domain(), miodc::ht, db_struct::i, jid_full(), jid_new(), miodc::key, log_debug2, LOGT_AUTH, miod_struct::m, miodc::md, mio_ip, db_struct::out_ok_db, mio_st::p, pmalloco(), pool_cleanup(), register_instance(), xhash_put(), and ZONE.
Referenced by dialback_in_read(), dialback_in_verify(), and dialback_out_read().
create a new wrapper around a managed I/O connection to be able to keep track about idle connections and the state of the dialback
| d | structure that holds the context of the dialback component instance | |
| m | the managed I/O connection |
References miod_struct::d, miod_struct::last, miod_struct::m, mio_st::p, and pmalloco().
Referenced by dialback_in_read(), dialback_in_verify(), and dialback_out_read().
process a packet that has been read from a managed I/O connection and update the idle time values
| md | structure holding the elements to keep track of idle time (and other elements) | |
| x | the xmlnode that has been read from the connection |
References miod_struct::count, miod_struct::d, deliver(), dpacket_new(), db_struct::i, instance_struct::id, jpacket_new(), miod_struct::last, log_warn(), xmlnode_free(), and xmlnode_serialize_string().
Referenced by dialback_in_read_db().
write to a managed I/O connection and update the idle time values
| md | structure holding the mio handle and the elements to keep track of idle time | |
| x | the xmlnode that should be written to the connection |
References miod_struct::count, miod_struct::last, miod_struct::m, and mio_write().
Referenced by dialback_out_packet(), and dialback_out_qflush().
phandler callback, send packets to another server
This is where the dialback instance receives packets from the jabberd framework
| i | the dialback instance we are running in | |
| dp | the dialback packet | |
| arg | pointer to the db structure with the context of the dialback component instance |
References dialback_in_verify(), dialback_out_packet(), xmppd::jabberid::get_domain(), db_struct::i, instance_struct::id, j_strcmp(), jid_new(), NS_DIALBACK, p_ROUTE, r_DONE, db_struct::std_ns_prefixes, dpacket_struct::type, dpacket_struct::x, xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_get_firstchild(), xmlnode_get_list_item(), xmlnode_get_name(), xmlnode_get_namespace(), xmlnode_get_tags(), xmlnode_hide_attrib_ns(), xmlnode_pool(), and xmlnode_put_attrib_ns().
Referenced by dialback().
| char* dialback_randstr | ( | void | ) |
generate a random string (not thead-safe)
This function generates a random ASCII string.
References shahash_r().
Referenced by dialback().
1.5.5