pidgin/pidgin

Implement SNI support for the gnutls SSL plugin.
release-2.x.y
2019-12-16, Mihai Moldovan
6dba8046e1b1
Implement SNI support for the gnutls SSL plugin.

Note that gnutls is picky in regard to what it accepts as the server name - it
MUST be a domain name. IP addresses are not supported according to the
documentation.

Hence, filter out IP addresses and hope that whatever is not recognized as
such an address is actually a domain name. This will probably fail for more
exotic addresses (especially in IPv6 realm), but wiring up a full-blown parser
is too much effort and SSL plugins are not part of purple-3 anyway.

Fixes #17300
#ifndef __CC_NETWORK_H__
#define __CC_NETWORK_H__
#include "account.h"
#include "conversation.h"
#include "crazychat.h"
/* --- begin constant definition --- */
#define DEFAULT_CC_PORT 6543
#define CRAZYCHAT_INVITE_CODE "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" \
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
#define CRAZYCHAT_ACCEPT_CODE "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" \
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" \
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" \
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" \
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" \
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
#define CRAZYCHAT_READY_CODE "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" \
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" \
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" \
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" \
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" \
"CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
/* --- begin function declarations --- */
/**
* Creates a new CrazyChat session if one doesn't exist and sends the invite.
* @param cc global crazychat data structure
* @param name the peer name
* @param account the purple account
*/
void cc_net_send_invite(struct crazychat *cc, char *name, PurpleAccount *account);
/**
* Pops up the CrazyChat invitation accept window if a CrazyChat session does
* not exist yet for this peer.
* @param account purple account
* @param cc global crazychat data structure
* @param name the peer name
* @param peer_ip the peer's ip address
* @param peer_port the peer's tcp port
*/
void cc_net_recv_invite(PurpleAccount *account, struct crazychat *cc, char *name,
const char *peer_ip, const char *peer_port);
/**
* Accepts the CrazyChat invitation and sends the response.
* @param session the CrazyChat session
*/
void cc_net_send_accept(struct cc_session *session);
/**
* Receives a CrazyChat accept message, and if appropriate, creates a server
* socket and sends the ready message.
* @param account the purple account which received the message
* @param cc global crazychat data structure
* @param name the peer name
* @param peer_ip the peer's ip address
*/
void cc_net_recv_accept(PurpleAccount *account, struct crazychat *cc, char *name,
const char *peer_ip);
/**
* Receives a CrazyChat ready message, and if appropriate, connects to peer
* @param account the purple account which received the message
* @param cc global crazychat data structure
* @param name the peer name
*/
void cc_net_recv_ready(PurpleAccount *account, struct crazychat *cc, char *name);
#endif