Index: seeborg-irc.cpp =================================================================== --- seeborg-irc.cpp (revision 21) +++ seeborg-irc.cpp (working copy) @@ -76,6 +76,14 @@ autosaveperiod = 600; tokenizer = tokenizer_init(); + + //Added by SchAmane 08.09.2007 + registernickname = false; + registerpassword = L""; + registerservice = L"NickServ"; + + //Added by SchAmane 31.10.2007 + localaddress = L""; } botsettings_s::~botsettings_s() { tokenizer_free(tokenizer); @@ -319,6 +327,16 @@ } +void RegisterNickName(BN_PInfo I,wstring service,wstring password) +{ + char* utf8service = utf8_wstringtombs(service); + char* utf8password = utf8_wstringtombs(password); + + see_printstring(stdout,L"Auth NickName\n"); + BN_SendPrivateMessage(I, utf8service, utf8password); +} + + // BotNet callback functions // --------------------------------------------------------------------------- void ProcOnError(BN_PInfo I, int errnum) { @@ -343,6 +361,10 @@ void ProcOnRegistered(BN_PInfo I) { see_printstring(stdout, L"Registered...\n"); + //Added by SchAmane 08.09.2007 + if(botsettings.registernickname) + RegisterNickName(I, botsettings.registerservice, botsettings.registerpassword); + vector::iterator it = botsettings.channels.begin(); for (; it != botsettings.channels.end(); ++it) { char* utf8channel = utf8_wstringtombs(*it); @@ -556,6 +578,17 @@ safe_free(utf8line); } } + vector::iterator it = botsettings.autovoicechannels.begin(); + for (; it != botsettings.autovoicechannels.end(); ++it) { + char* utf8channel = utf8_wstringtombs(*it); + if(strcmp(utf8channel, Chan)==0) + { + see_printstring(stdout, L"Give autovoice to %s on channel %ls...\n", tempnick, (*it).c_str()); + BN_SendVoiceMessage(I,Chan,tempnick); + } + safe_free(utf8channel); + } + } @@ -901,6 +934,16 @@ initialized = true; char* utf8server = utf8_wstringtombs(botsettings.server); + //Added by SchAmane 31.10.2007 + if(botsettings.localaddress != L"") + { + char* utf8localaddress = utf8_wstringtombs(botsettings.localaddress); + Info.LocalAddr = strdup(utf8localaddress); + Info.SetLocalAddr = true; + see_printstring(stdout, L"try to bind socket to %s for connection.\n",Info.LocalAddr); + } + else + Info.SetLocalAddr = false; while(BN_Connect(&Info, utf8server, botsettings.serverport, 0) != true) { see_printstring(stdout, L"Disconnected.\n"); #ifdef __unix__ Index: seeborg-irc.h =================================================================== --- seeborg-irc.h (revision 21) +++ seeborg-irc.h (working copy) @@ -86,6 +86,14 @@ wstring quitmessage; wstring ctcpversionstring; + //Added by SchAmane 31.10.2007 + wstring localaddress; + + //Added by SchAmane 8.09.2007 + int registernickname; + wstring registerservice; + wstring registerpassword; + // Other settings float replyrate; int32_t learning; @@ -107,6 +115,8 @@ tokenizer_t* tokenizer; + vector autovoicechannels; + } botsettings_t; extern botsettings_t botsettings; @@ -127,6 +137,9 @@ static const configsetting_t configsettings[] = { {L"server", L"Address of IRC server", &botsettings.server, NULL, NULL, NULL}, {L"serverport", L"Server port", NULL, NULL, &botsettings.serverport, NULL}, + + //Added by SchAmane 31.10.2007 + {L"localaddress", L"Bot's local IP to bind, if your host have more then one network interfaces", &botsettings.localaddress, NULL, NULL, NULL}, {L"nickname", L"Bot's nickname, most servers allow English only", &botsettings.nickname, NULL, NULL, NULL}, {L"username", L"Bot's username (will show as ~@your.host.com), most servers allow English only", &botsettings.username, NULL, NULL, NULL}, @@ -135,7 +148,13 @@ {L"ctcpversion", L"Bot's CTCP version string (if stealth is enabled)", &botsettings.ctcpversionstring, NULL, NULL, NULL}, {NULL, NULL, NULL, NULL, NULL}, // Newline in cfg + //Added by SchAmane 08.09.2007 + {L"registernickname", L"If bot have to register own nickname with IRC services (boolean)", NULL, NULL, &botsettings.registernickname, NULL}, + {L"registerservice", L"NickServ or Nickname of Bot with Services (if registernickname is enabled)", &botsettings.registerservice, NULL, NULL, NULL}, + {L"registerpassword", L"Bot nickname password (if registernickname is enabled)", &botsettings.registerpassword, NULL, NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL}, // Newline in cfg + {L"replyrate", L"Reply rate to all messages (in percent)", NULL, &botsettings.replyrate, NULL, NULL}, {L"replynick", L"Reply rate to messages containing bot's nickname (in percent)", NULL, &botsettings.replyrate_mynick, NULL, NULL}, {L"replymagic", L"Reply rate to messages containing magic words (in percent)", NULL, &botsettings.replyrate_magic, NULL, NULL}, @@ -159,7 +178,12 @@ {L"censorlist", L"Censor word list (will prevent bot from speaking those words)", NULL, NULL, NULL, &botsettings.censored}, {L"ignorelist", L"Ignore word list (will prevent bot from reacting to those words)", NULL, NULL, NULL, &botsettings.ignorelist}, + {NULL, NULL, NULL, NULL, NULL}, + + {L"autovoicechannels", L"Autovoice channel list", NULL, NULL, NULL, &botsettings.autovoicechannels}, + {NULL, NULL, NULL, NULL, NULL} + }; static const int numconfigsettings = sizeof(configsettings) / sizeof(configsettings[0]) - 1; Index: botnet/botnet.h =================================================================== --- botnet/botnet.h (revision 21) +++ botnet/botnet.h (working copy) @@ -274,6 +274,10 @@ void *User; int Flags; char *Server; + //Added by SchAmane on 31.10.2007 + char *LocalAddr; + bool SetLocalAddr; + //end int Port; time_t Stamps[BN_STAMPSIZE]; int StampPos,NbStamps,StampLen[BN_STAMPSIZE]; @@ -344,6 +348,15 @@ /* Join a channel (with key if needed)*/ void BN_SendJoinMessage(BN_PInfo,const char*,const char *); +//added by SchAmane 16.03.06 +/* Voice a nickname o specified channel */ +void BN_SendVoiceMessage(BN_PInfo,const char *,const char *); + +//added by SchAmane 16.03.06 +/* DeVoice a nickname on specified channel */ +void BN_SendDeVoiceMessage(BN_PInfo,const char *,const char *); + + /* Part a channel (with reason)*/ void BN_SendPartMessage(BN_PInfo,const char*,const char *); Index: botnet/output.c =================================================================== --- botnet/output.c (revision 21) +++ botnet/output.c (working copy) @@ -255,6 +255,25 @@ BN_SendMessage(I,BN_MakeMessage(NULL,"JOIN",buf),BN_HIGH_PRIORITY); } +//added by SchAmane 16.03.06 +void BN_SendVoiceMessage(BN_PInfo I,const char *Channel,const char *Nick) +{ + char buf[1024]; + + snprintf(buf,sizeof(buf),"%s +v %s",Channel,Nick); + BN_SendMessage(I,BN_MakeMessage(NULL,"MODE",buf),BN_LOW_PRIORITY); +} + +//aded by SchAmane 16.03.06 +void BN_SendDeVoiceMessage(BN_PInfo I,const char *Channel,const char *Nick) +{ + char buf[1024]; + + snprintf(buf,sizeof(buf),"%s -v %s",Channel,Nick); + BN_SendMessage(I,BN_MakeMessage(NULL,"MODE",buf),BN_LOW_PRIORITY); +} + + void BN_SendPartMessage(BN_PInfo I,const char *Channel,const char *Reason) { char buf[1024]; Index: botnet/botnet.c =================================================================== --- botnet/botnet.c (revision 21) +++ botnet/botnet.c (working copy) @@ -172,8 +172,10 @@ void *ThreadProc_Connect(void *Info) #endif { - struct sockaddr_in SAddr; - struct hostent *HostAddr; + //Added by SchAmane on 31.10.2007 + //Added LAddr to specify local adress + struct sockaddr_in SAddr, LAddr; + struct hostent *HostAddr, *LocalAddr; BN_PMessage Msg; BN_PInfo I; @@ -233,16 +235,42 @@ } memcpy((void *)&SAddr.sin_addr, HostAddr->h_addr, HostAddr->h_length); } + //Added by SchAmane on 31.10.2007 + //Select IP to bind client connection + if(I->SetLocalAddr) + { + memset(&LAddr, 0, sizeof(LAddr)); + LAddr.sin_port = htons(0); + LAddr.sin_family = AF_INET; + + LocalAddr = (struct hostent *)gethostbyname(I->LocalAddr); + if(LocalAddr == NULL) + { + if(I->CB.OnError != NULL) + I->CB.OnError(I,99); + if((I->Flags & PROCESS_NEW_PROCESS) == PROCESS_NEW_PROCESS) + EXIT_PROCESS_FUNC(1); + else if((I->Flags & PROCESS_NEW_THREAD) == PROCESS_NEW_THREAD) + EXIT_THREAD_FUNC 1); + else + return false; + } + memcpy((void *)&LAddr.sin_addr, LocalAddr->h_addr, LocalAddr->h_length); + if(bind(I->Socket,(struct sockaddr *)&LAddr, sizeof(LAddr))==-1) + { + if(I->CB.OnError != NULL) + I->CB.OnError(I,errno); + if((I->Flags & PROCESS_NEW_PROCESS) == PROCESS_NEW_PROCESS) + EXIT_PROCESS_FUNC(1); + else if((I->Flags & PROCESS_NEW_THREAD) == PROCESS_NEW_THREAD) + EXIT_THREAD_FUNC 1); + else + return false; + } + } + //End bind interface patch if(connect(I->Socket, (struct sockaddr *)&SAddr, sizeof(SAddr)) == -1) { - if(I->CB.OnError != NULL) - I->CB.OnError(I,errno); - if((I->Flags & PROCESS_NEW_PROCESS) == PROCESS_NEW_PROCESS) - EXIT_PROCESS_FUNC(1); - else if((I->Flags & PROCESS_NEW_THREAD) == PROCESS_NEW_THREAD) - EXIT_THREAD_FUNC 1); - else - return false; } if(I->CB.OnConnected != NULL) I->CB.OnConnected(I,I->Server); Index: Makefile =================================================================== --- Makefile (revision 21) +++ Makefile (working copy) @@ -14,7 +14,7 @@ ## If you're getting link errors on any unix, try uncommeting this line below CFUSER = -pthread -CFCPU = -march=pentium +CFCPU = -march=athlon64 CFOPT = -O3 -fomit-frame-pointer -fforce-addr -finline -funroll-loops -fexpensive-optimizations #CFDEBUG = -g3