2
* Off-the-Record Messaging (OTR) module for the irssi IRC client
3
* Copyright (C) 2008 Uli Meis <a.sporto+bee@gmail.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA
26
#include <libotr/proto.h>
27
#include <libotr/context.h>
28
#include <libotr/message.h>
29
#include <libotr/privkey.h>
34
#include <glib/gprintf.h>
35
#include <glib/gstdio.h>
40
#include <irssi_otr.h>
46
#include <xchat_otr.h>
56
#define otr_logst(level,format,...) \
57
otr_log(NULL,NULL,level,format, ## __VA_ARGS__)
59
void otr_log(IRC_CTX *server, const char *to,
60
int level, const char *format, ...);
64
#include "io-config.h"
66
/* irssi module name */
67
#define MODULE_NAME "otr"
69
#include "otr-formats.h"
72
* maybe this should be configurable?
73
* I believe bitlbee has something >500.
75
#define OTR_MAX_MSG_SIZE 400
78
#define PROTOCOLID "IRC"
80
#define KEYFILE "/otr/otr.key"
81
#define TMPKEYFILE "/otr/otr.key.tmp"
82
#define FPSFILE "/otr/otr.fp"
85
#define IO_DEFAULT_POLICY "*@localhost opportunistic,*bitlbee* opportunistic,*@im.* opportunistic, *serv@irc* never"
86
#define IO_DEFAULT_POLICY_KNOWN "* always"
87
#define IO_DEFAULT_IGNORE "xmlconsole[0-9]*"
89
/* one for each OTR context (=communication pair) */
91
char *msgqueue; /* holds partially reconstructed base64
93
IRC_CTX *ircctx; /* irssi server object for this peer */
94
int received_smp_init; /* received SMP init msg */
95
int smp_failed; /* last SMP failed */
96
char better_msg_two[256]; /* what the second line of the "better"
97
default query msg should like. Eat it
98
up when it comes in */
99
int finished; /* true after you've /otr finished */
102
/* these are returned by /otr contexts */
106
enum { NOAUTH,AUTHSMP,AUTHMAN } authby;
107
struct fplist_ *next;
113
enum { STUNENCRYPTED,STENCRYPTED,STFINISHED,STUNKNOWN } state;
114
struct fplist_ *fplist;
115
struct ctxlist_ *next;
118
/* policy list generated from /set otr_policy */
121
GPatternSpec *namepat;
125
/* used by the logging functions below */
128
void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg);
129
IRC_CTX *server_find_address(char *address);
134
void otrlib_deinit();
136
void otr_setpolicies(const char *policies, int known);
138
/* basic send/receive/status stuff */
140
char *otr_send(IRC_CTX *server,const char *msg,const char *to);
141
char *otr_receive(IRC_CTX *server,const char *msg,const char *from);
142
int otr_getstatus(char *mynick, char *nick, char *server);
143
ConnContext *otr_getcontext(const char *accname,const char *nick,int create,void *data);
145
/* user interaction */
147
void otr_trust(IRC_CTX *server, char *nick, const char *peername);
148
void otr_finish(IRC_CTX *server, char *nick, const char *peername, int inquery);
149
void otr_auth(IRC_CTX *server, char *nick, const char *peername, const char *secret);
150
void otr_authabort(IRC_CTX *server, char *nick, const char *peername);
151
struct ctxlist_ *otr_contexts();
152
void otr_finishall();
155
/* key/fingerprint stuff */
157
void keygen_run(const char *accname);