|
jabberd14 1.6.2
|
header for the dialback implementation More...
#include <jabberd.h>Go to the source code of this file.
header for the dialback implementation
| typedef struct dbic_struct _dbic |
| typedef struct dboq_struct _dboq |
| typedef struct miod_struct _miod |
| typedef struct dbic_struct * dbic |
incoming dialback streams
| typedef struct dboq_struct * dboq |
simple queue for out_queue
| typedef struct miod_struct * miod |
wrap an mio and track the idle time of it
| enum db_connection_state |
enumeration of connection establishment states an outgoing connection can have
used for more detailed logging of failed connections
| enum db_request |
enumeration of dialback request states an outgoing connection can have
| 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().
callback for mio for accepted sockets
Our task is:
| m | the connection on which the stream root element has been received |
| flags | the mio action, everything but MIO_XML_ROOT is ignored |
| arg | the db instance |
| x | the stream root element |
| unused1 | unused/ignored |
| unused2 | unused/ignored |
References mio_st::authed_other_side, dbic_struct::d, dialback_get_loopcheck_token(), dialback_in_read_db(), dialback_miod_hash(), dialback_miod_new(), mio_st::fd, xmppd::ns_decl_list::get_nsprefix(), db_struct::hosts_auth, db_struct::hosts_tls, db_struct::hosts_xmpp, dbic_struct::id, db_struct::in_ok_db, mio_st::in_root, j_atoi(), j_strcmp(), jid_full(), jid_new(), JID_RESOURCE, jid_set(), JID_USER, log_debug2, LOGT_IO, dbic_struct::m, mio_close(), mio_is_encrypted(), mio_reset(), mio_ssl_starttls_possible(), mio_ssl_verify(), mio_write(), mio_write_root(), MIO_XML_ROOT, NS_DIALBACK, NS_JABBERD_LOOPCHECK, NS_STREAM, NS_XMLNS, NS_XMPP_SASL, NS_XMPP_TLS, dbic_struct::other_domain, dbic_struct::we_domain, xhash_get_by_domain(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_insert_cdata(), xmlnode_insert_tag_ns(), xmlnode_new_tag_ns(), xmlnode_pool(), xmlnode_put_attrib_ns(), xmlnode_serialize_string(), dbic_struct::xmpp_version, xstream_header(), and ZONE.
Referenced by dialback(), and dialback_in_read_db().
Handle db:verify packets, that we got as a result to our dialback to the authoritive server.
We expect the to attribute to be our name and the from attribute to be the remote name.
We have to do:
| d | the db instance |
| x | the db:verify answer packet |
References dbic_struct::d, dialback_check_settings(), dialback_miod_hash(), dialback_miod_new(), xmppd::jabberid::get_resource(), db_struct::i, dbic_struct::id, instance_struct::id, db_struct::in_id, db_struct::in_ok_db, j_strcmp(), jid_full(), jid_new(), JID_RESOURCE, jid_set(), JID_USER, log_debug2, log_warn(), LOGT_AUTH, dbic_struct::m, mio_write(), NS_DIALBACK, dbic_struct::results, db_struct::std_ns_prefixes, xhash_get(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_get_list_item(), xmlnode_get_tags(), xmlnode_hide(), xmlnode_new_tag_pool_ns(), xmlnode_pool(), xmlnode_put_attrib_ns(), xmlnode_serialize_string(), dbic_struct::xmpp_version, and ZONE.
Referenced by dialback_out_connection_cleanup(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), and dialback_packets().
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().
| result dialback_out_beat_packets | ( | void * | arg | ) |
start walking the connection hash tree, to see if connections dig not get authorizsed in time
| arg | the dialback instance |
References _dialback_out_beat_packets(), db_struct::out_connecting, r_DONE, and xhash_walk().
Referenced by dialback().
handle packets we receive from our router for other hosts
(packets to our instances address are not handled here, but in dialback_in_verify())
We have to:
| d | the dialback instance |
| x | the packet |
| ip | where to connect to (if necessary) |
References dialback_in_verify(), dialback_ip_get(), dialback_miod_write(), dialback_out_connection(), xmppd::jabberid::get_domain(), db_struct::i, instance_struct::id, j_strcmp(), jid_full(), jid_new(), JID_RESOURCE, jid_set(), jutil_tofrom(), log_debug2, log_warn(), LOGT_IO, dboc::m, mio_write(), dboq_struct::next, not_requested, NS_DIALBACK, db_struct::out_ok_db, pmalloco(), dboc::q, register_instance(), dboq_struct::stamp, dboc::verifies, want_request, dboq_struct::x, xhash_get(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_get_localname(), xmlnode_get_namespace(), xmlnode_hide_attrib_ns(), xmlnode_insert_tag_node(), xmlnode_pool(), xmlnode_put_attrib_ns(), xmlnode_serialize_string(), and ZONE.
Referenced by dialback_packets().
| 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.7.4