aboutsummaryrefslogtreecommitdiffstats
path: root/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c110
1 files changed, 86 insertions, 24 deletions
diff --git a/irc.c b/irc.c
index 22bb9fa6..858f3edd 100644
--- a/irc.c
+++ b/irc.c
@@ -28,8 +28,11 @@
#include "sock.h"
#include "crypting.h"
#include "ipc.h"
+#include <sys/types.h>
+#include <sys/wait.h>
static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond );
+static void irc_welcome( irc_t* irc );
GSList *irc_connection_list = NULL;
@@ -176,24 +179,28 @@ irc_t *irc_new( int fd )
irc_write( irc, ":%s NOTICE AUTH :%s", irc->myhost, "BitlBee-IRCd initialized, please go on" );
irc_connection_list = g_slist_append( irc_connection_list, irc );
+
s = set_add( &irc->set, "away", NULL, set_eval_away_status, irc );
s->flags |= SET_NULL_OK;
- s = set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc );
s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );
s = set_add( &irc->set, "auto_reconnect", "true", set_eval_bool, irc );
s = set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc );
s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc );
s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc );
s = set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc );
+ s = set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc );
s = set_add( &irc->set, "control_channel", irc->channel, set_eval_control_channel, irc );
s = set_add( &irc->set, "debug", "false", set_eval_bool, irc );
s = set_add( &irc->set, "default_target", "root", NULL, irc );
s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc );
s = set_add( &irc->set, "display_timestamps", "true", set_eval_bool, irc );
s = set_add( &irc->set, "handle_unknown", "root", NULL, irc );
+ s = set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc );
s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc );
- s = set_add( &irc->set, "ops", "both", set_eval_ops, irc );
+ s = set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc );
+ s = set_add( &irc->set, "op_root", "true", set_eval_op_root, irc );
+ s = set_add( &irc->set, "otr_policy", "oppurtunistic", set_eval_otr_policy, irc );
s = set_add( &irc->set, "password", NULL, set_eval_password, irc );
s->flags |= SET_NULL_OK;
s = set_add( &irc->set, "private", "true", set_eval_bool, irc );
@@ -202,15 +209,16 @@ irc_t *irc_new( int fd )
s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc );
s = set_add( &irc->set, "show_offline", "false", set_eval_bool, irc );
s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc );
- s = set_add( &irc->set, "status", NULL, set_eval_away_status, irc );
- s->flags |= SET_NULL_OK;
s = set_add( &irc->set, "strip_html", "true", NULL, irc );
s = set_add( &irc->set, "timezone", "local", set_eval_timezone, irc );
s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );
s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc );
+ s = set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc);
conf_loaddefaults( irc );
-
+
+ irc->otr = otr_new();
+
/* Evaluator sets the iconv/oconv structures. */
set_eval_charset( set_find( &irc->set, "charset" ), set_getstr( &irc->set, "charset" ) );
@@ -362,9 +370,11 @@ void irc_free( irc_t * irc )
g_free( irc->channel );
g_free( irc->last_target );
+
+ otr_free(irc->otr);
g_free( irc );
-
+
if( global.conf->runmode == RUNMODE_INETD ||
global.conf->runmode == RUNMODE_FORKDAEMON ||
( global.conf->runmode == RUNMODE_DAEMON &&
@@ -733,12 +743,45 @@ void irc_write_all( int now, char *format, ... )
return;
}
+const char *user_mode_prefix( irc_t *irc, user_t *u )
+{
+ static char op[] = "@";
+ static char halfop[] = "%";
+ static char voice[] = "+";
+ static char none[] = "";
+
+ int or = set_getbool(&irc->set, "op_root");
+ int ou = set_getbool(&irc->set, "op_user");
+ char *ob = set_getstr(&irc->set, "op_buddies");
+ char *hb = set_getstr(&irc->set, "halfop_buddies");
+ char *vb = set_getstr(&irc->set, "voice_buddies");
+
+ if( (!strcmp(u->nick, irc->mynick) && or) ||
+ (!strcmp(u->nick, irc->nick) && ou) ||
+ (!u->away && !strcmp(ob, "notaway")) ||
+ (u->encrypted && !strcmp(ob, "encrypted")) ||
+ (u->encrypted>1 && !strcmp(ob, "trusted"))
+ )
+ return op;
+ else if( (!u->away && !strcmp(hb, "notaway")) ||
+ (u->encrypted && !strcmp(hb, "encrypted")) ||
+ (u->encrypted>1 && !strcmp(hb, "trusted"))
+ )
+ return halfop;
+ else if( (!u->away && !strcmp(vb, "notaway")) ||
+ (u->encrypted && !strcmp(vb, "encrypted")) ||
+ (u->encrypted>1 && !strcmp(vb, "trusted"))
+ )
+ return voice;
+ else
+ return none;
+}
+
void irc_names( irc_t *irc, char *channel )
{
user_t *u;
char namelist[385] = "";
struct groupchat *c = NULL;
- char *ops = set_getstr( &irc->set, "ops" );
/* RFCs say there is no error reply allowed on NAMES, so when the
channel is invalid, just give an empty reply. */
@@ -753,12 +796,7 @@ void irc_names( irc_t *irc, char *channel )
*namelist = 0;
}
- if( u->ic && !u->away && set_getbool( &irc->set, "away_devoice" ) )
- strcat( namelist, "+" );
- else if( ( strcmp( u->nick, irc->mynick ) == 0 && ( strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) == 0 ) ) ||
- ( strcmp( u->nick, irc->nick ) == 0 && ( strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) == 0 ) ) )
- strcat( namelist, "@" );
-
+ strcat( namelist, user_mode_prefix(irc, u) );
strcat( namelist, u->nick );
strcat( namelist, " " );
}
@@ -769,8 +807,8 @@ void irc_names( irc_t *irc, char *channel )
/* root and the user aren't in the channel userlist but should
show up in /NAMES, so list them first: */
- sprintf( namelist, "%s%s %s%s ", strcmp( ops, "root" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->mynick,
- strcmp( ops, "user" ) == 0 || strcmp( ops, "both" ) ? "@" : "", irc->nick );
+ sprintf( namelist, "%s%s %s%s ", set_getbool(&irc->set, "op_root") ? "@" : "", irc->mynick,
+ set_getbool(&irc->set, "op_user") ? "@" : "", irc->nick );
for( l = c->in_room; l; l = l->next ) if( ( u = user_findhandle( c->ic, l->data ) ) )
{
@@ -780,6 +818,7 @@ void irc_names( irc_t *irc, char *channel )
*namelist = 0;
}
+ strcat( namelist, user_mode_prefix(irc, u) );
strcat( namelist, u->nick );
strcat( namelist, " " );
}
@@ -821,14 +860,13 @@ void irc_login( irc_t *irc )
irc_reply( irc, 2, ":Host %s is running BitlBee " BITLBEE_VERSION " " ARCH "/" CPU ".", irc->myhost );
irc_reply( irc, 3, ":%s", IRCD_INFO );
irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES );
- irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee "
+ irc_reply( irc, 5, "PREFIX=(ohv)@%%+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee "
"CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server",
CTYPES, CMODES, MAX_NICK_LENGTH - 1 );
irc_motd( irc );
irc->umode[0] = '\0';
irc_umode_set( irc, "+" UMODE, 1 );
-
- u = user_add( irc, irc->mynick );
+u = user_add( irc, irc->mynick );
u->host = g_strdup( irc->myhost );
u->realname = g_strdup( ROOT_FN );
u->online = 1;
@@ -850,12 +888,7 @@ void irc_login( irc_t *irc )
u->online = 1;
irc_spawn( irc, u );
- irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n"
- "If you've never used BitlBee before, please do read the help "
- "information using the \x02help\x02 command. Lots of FAQs are "
- "answered there.\n"
- "If you already have an account on this server, just use the "
- "\x02identify\x02 command to identify yourself." );
+ irc_welcome( irc );
if( global.conf->runmode == RUNMODE_FORKDAEMON || global.conf->runmode == RUNMODE_DAEMON )
ipc_to_master_str( "CLIENT %s %s :%s\r\n", irc->host, irc->nick, irc->realname );
@@ -873,6 +906,35 @@ void irc_login( irc_t *irc )
}
}
+static void irc_welcome( irc_t *irc )
+{
+ FILE *f;
+
+ f = fopen( global.conf->welcomefile, "r" );
+ if( !f )
+ {
+ irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\n"
+ "If you've never used BitlBee before, please do read the help "
+ "information using the \x02help\x02 command. Lots of FAQs are "
+ "answered there.\n"
+ "OTR users please note: Private key files are owned by the user "
+ "BitlBee is running as.\n"
+ "If you already have an account on this server, just use the "
+ "\x02identify\x02 command to identify yourself." );
+ }
+ else
+ {
+ char linebuf[380];
+
+ while( fgets( linebuf, 380, f ) )
+ {
+ irc_usermsg( irc, linebuf );
+ }
+
+ fclose( f );
+ }
+}
+
void irc_motd( irc_t *irc )
{
int fd;