aboutsummaryrefslogtreecommitdiffstats
path: root/irc.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc.c')
-rw-r--r--irc.c91
1 files changed, 77 insertions, 14 deletions
diff --git a/irc.c b/irc.c
index 3a09f684..ae275216 100644
--- a/irc.c
+++ b/irc.c
@@ -27,8 +27,11 @@
#include "bitlbee.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;
@@ -101,20 +104,24 @@ 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 );
-
- set_add( &irc->set, "away_devoice", "true", set_eval_away_devoice, irc );
+
set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );
set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc );
set_add( &irc->set, "auto_reconnect_delay", "300", set_eval_int, irc );
set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc );
set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc );
set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc );
+ set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc );
set_add( &irc->set, "debug", "false", set_eval_bool, irc );
set_add( &irc->set, "default_target", "root", NULL, irc );
set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc );
set_add( &irc->set, "handle_unknown", "root", NULL, irc );
+ set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc );
set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc );
- set_add( &irc->set, "ops", "both", set_eval_ops, irc );
+ set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc );
+ set_add( &irc->set, "op_root", "true", set_eval_op_root, irc );
+ set_add( &irc->set, "op_user", "true", set_eval_op_user, irc );
+ set_add( &irc->set, "otr_policy", "opportunistic", set_eval_otr_policy, irc );
set_add( &irc->set, "password", NULL, passchange, irc );
set_add( &irc->set, "private", "true", set_eval_bool, irc );
set_add( &irc->set, "query_order", "lifo", NULL, irc );
@@ -123,8 +130,11 @@ irc_t *irc_new( int fd )
set_add( &irc->set, "strip_html", "true", NULL, irc );
set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );
set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc );
+ set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc );
conf_loaddefaults( irc );
+
+ irc->otr = otr_new();
return( irc );
}
@@ -264,6 +274,8 @@ void irc_free(irc_t * irc)
g_hash_table_foreach_remove(irc->watches, irc_free_hashkey, NULL);
g_hash_table_destroy(irc->watches);
+ otr_free(irc->otr);
+
g_free(irc);
if( global.conf->runmode == RUNMODE_INETD || global.conf->runmode == RUNMODE_FORKDAEMON )
@@ -619,12 +631,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. */
@@ -639,12 +684,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, " " );
}
@@ -655,8 +695,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 ) ) )
{
@@ -666,6 +706,7 @@ void irc_names( irc_t *irc, char *channel )
*namelist = 0;
}
+ strcat( namelist, user_mode_prefix(irc, u) );
strcat( namelist, u->nick );
strcat( namelist, " " );
}
@@ -707,7 +748,7 @@ 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=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 );
+ irc_reply( irc, 5, "PREFIX=(ohv)@%%+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 );
irc_motd( irc );
irc->umode[0] = '\0';
irc_umode_set( irc, "+" UMODE, 1 );
@@ -734,7 +775,7 @@ void irc_login( irc_t *irc )
u->online = 1;
irc_spawn( irc, u );
- irc_usermsg( irc, "Welcome to the BitlBee gateway!\n\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there." );
+ 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 );
@@ -742,6 +783,28 @@ void irc_login( irc_t *irc )
irc->status |= USTATUS_LOGGED_IN;
}
+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\nIf you've never used BitlBee before, please do read the help information using the \x02help\x02 command. Lots of FAQs are answered there.\n\nOTR users please note: Private key files are owned by the user BitlBee is running as." );
+ }
+ else
+ {
+ char linebuf[380];
+
+ while( fgets( linebuf, 380, f ) )
+ {
+ irc_usermsg( irc, linebuf );
+ }
+
+ fclose( f );
+ }
+}
+
void irc_motd( irc_t *irc )
{
int fd;