NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference
#include "config.h"
#include "connaccount.h"
#include "connection.h"
#include "sasl_plain.h"
#include "socket.h"
#include "sasl.h"
#include "zstrm.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int mutt_ssl_starttls (struct Connection *conn)
 Negotiate TLS over an already opened connection. More...
 
int getdnsdomainname (struct Buffer *result)
 Lookup the host's name using DNS. More...
 

Variables

bool C_SslForceTls
 Config: (ssl) Require TLS encryption for all connections. More...
 
unsigned char C_SslStarttls
 Config: (ssl) Use STARTTLS on servers advertising the capability. More...
 
const char * C_Tunnel
 Config: Shell command to establish a tunnel. More...
 

Detailed Description

Connection Library

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file lib.h.

Function Documentation

◆ mutt_ssl_starttls()

int mutt_ssl_starttls ( struct Connection conn)

Negotiate TLS over an already opened connection.

Parameters
connConnection to a server
Return values
0Success
-1Error

Definition at line 1136 of file gnutls.c.

1137 {
1138  if (tls_init() < 0)
1139  return -1;
1140 
1141  if (tls_negotiate(conn) < 0)
1142  return -1;
1143 
1144  conn->read = tls_socket_read;
1145  conn->write = tls_socket_write;
1146  conn->close = tls_starttls_close;
1147  conn->poll = tls_socket_poll;
1148 
1149  return 0;
1150 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getdnsdomainname()

int getdnsdomainname ( struct Buffer result)

Lookup the host's name using DNS.

Parameters
resultBuffer were result of the domain name lookup will be stored
Return values
0Success
-1Error

Definition at line 118 of file getdomain.c.

119 {
120  assert(result);
121  int rc = -1;
122 
123 #if defined(HAVE_GETADDRINFO) || defined(HAVE_GETADDRINFO_A)
124  char node[256];
125  if (gethostname(node, sizeof(node)) != 0)
126  return rc;
127 
128  struct addrinfo *lookup_result = NULL;
129  struct addrinfo hints;
130 
131  mutt_buffer_reset(result);
132  memset(&hints, 0, sizeof(struct addrinfo));
133  hints.ai_flags = AI_CANONNAME;
134  hints.ai_family = AF_UNSPEC;
135 
136 #ifdef HAVE_GETADDRINFO_A
137  lookup_result = mutt_getaddrinfo_a(node, &hints);
138 #else
139  lookup_result = mutt_getaddrinfo(node, &hints);
140 #endif
141 
142  char *hostname = NULL;
143  if (lookup_result && lookup_result->ai_canonname)
144  hostname = strchr(lookup_result->ai_canonname, '.');
145 
146  if (hostname)
147  {
148  mutt_buffer_strcpy(result, ++hostname);
149  rc = 0;
150  mutt_debug(LL_DEBUG1, "Hostname: %s\n", mutt_buffer_string(result));
151  }
152  freeaddrinfo(lookup_result);
153 #endif
154 
155  return rc;
156 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_SslForceTls

bool C_SslForceTls

Config: (ssl) Require TLS encryption for all connections.

Definition at line 46 of file config.c.

◆ C_SslStarttls

unsigned char C_SslStarttls

Config: (ssl) Use STARTTLS on servers advertising the capability.

Definition at line 47 of file config.c.

◆ C_Tunnel

const char* C_Tunnel

Config: Shell command to establish a tunnel.

Definition at line 39 of file config.c.

tls_socket_read
static int tls_socket_read(struct Connection *conn, char *buf, size_t count)
Read data from a TLS socket - Implements Connection::read()
Definition: gnutls.c:1036
tls_socket_poll
static int tls_socket_poll(struct Connection *conn, time_t wait_secs)
Check whether a socket read would block - Implements Connection::poll()
Definition: gnutls.c:979
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
tls_socket_write
static int tls_socket_write(struct Connection *conn, const char *buf, size_t count)
Write data to a TLS socket - Implements Connection::write()
Definition: gnutls.c:1063
mutt_buffer_reset
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
Connection::close
int(* close)(struct Connection *conn)
Close a socket Connection.
Definition: connection.h:100
tls_negotiate
static int tls_negotiate(struct Connection *conn)
Negotiate TLS connection.
Definition: gnutls.c:867
tls_starttls_close
static int tls_starttls_close(struct Connection *conn)
Close a TLS connection - Implements Connection::close()
Definition: gnutls.c:1097
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
Connection::write
int(* write)(struct Connection *conn, const char *buf, size_t count)
Write to a socket Connection.
Definition: connection.h:82
tls_init
static int tls_init(void)
Set up Gnu TLS.
Definition: gnutls.c:89
mutt_getaddrinfo
static struct addrinfo * mutt_getaddrinfo(const char *node, const struct addrinfo *hints)
Lookup the host's name using getaddrinfo()
Definition: getdomain.c:96
Connection::poll
int(* poll)(struct Connection *conn, time_t wait_secs)
Check whether a socket read would block.
Definition: connection.h:92
mutt_buffer_strcpy
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
Connection::read
int(* read)(struct Connection *conn, char *buf, size_t count)
Read from a socket Connection.
Definition: connection.h:72