static void set_hostname(char *host) { const struct iflist *ifl = iface_find(host); if (ifl == NULL) { yell("no such hostname [%s]!", host); } else if (local_host_name && !strcmp(local_host_name, ifl->ifi_host)) { bitchsay("%s is already my hostname, yo.", local_host_name); } else { sa_addr_t *addr; sa_rc_t ret; malloc_strcpy(&local_host_name, ifl->ifi_host); sa_addr_create(&addr); ret = sa_addr_s2a(addr, ifl->ifi_addr, ifl->ifi_len); if (ret != SA_OK) { sa_addr_destroy(addr); bitchsay("couldn't set local hostname: %s", sa_error(ret)); } else { bitchsay("local host name is now %s", local_host_name); if (local_host_addr) sa_addr_destroy(local_host_addr); local_host_addr = addr; t_parse_command("RECONNECT", NULL); } } }
void identd_read(int s) { char buffer[100]; char *bufptr; unsigned int lport = 0, rport = 0; *buffer = 0; bufptr = buffer; if (recv(s, buffer, sizeof(buffer)-1, 0) <=0) { bitchsay("ERROR in identd request"); close_socketread(s); return; } if (sscanf(bufptr, "%d , %d", &lport, &rport) == 2) { if (lport < 1 || rport < 1 || lport > 32767 || rport > 32767) { close_socketread(s); bitchsay("ERROR port for identd bad [%d:%d]", lport, rport); return; } sprintf(buffer, "%hu , %hu : USERID : UNIX : %s", lport, rport, get_dllstring_var("identd_user")); dcc_printf(s, "%s\r\n", buffer); bitchsay("Sent IDENTD request %s", buffer); set_socketflags(identd, now); } close_socketread(s); }
static void print_id3_tag(FILE *fp, char *buf) { struct id3tag { char tag[3]; char title[30]; char artist[30]; char album[30]; char year[4]; char comment[30]; unsigned char genre; }; struct idxtag { char tag[3]; char title[90]; char artist[50]; char album[50]; char comment[50]; }; struct id3tag *tag = (struct id3tag *) buf; struct idxtag *xtag = (struct idxtag *) buf; char title[121]="\0"; char artist[81]="\0"; char album[81]="\0"; char year[5]="\0"; char comment[81]="\0"; strncpy(title,tag->title,30); strncpy(artist,tag->artist,30); strncpy(album,tag->album,30); strncpy(year,tag->year,4); strncpy(comment,tag->comment,30); strunpad(title); strunpad(artist); strunpad(album); strunpad(comment); if ((fseek(fp, 384, SEEK_END) != -1) && (fread(buf, 256, 1, fp) == 1)) { if (!strncmp(buf, "TXG", 3)) { strncat(title, xtag->title, 90); strncat(artist, xtag->artist, 50); strncat(album, xtag->album, 50); strncat(comment, xtag->comment, 50); strunpad(title); strunpad(artist); strunpad(album); strunpad(comment); } } if (!do_hook(MODULE_LIST, "AMP ID3 \"%s\" \"%s\" \"%s\" %s %d %s", title, artist, album, year, tag->genre, comment)) { bitchsay("Title : %.120s Artist: %s",title, artist); bitchsay("Album : %.80s Year: %4s, Genre: %d",album, year, (int)tag->genre); bitchsay("Comment: %.80s",comment); } }
void add_to_a_list(char *thestring, int thetype, char *nick, char *channels, char *reason, int shitlevel) { ShitList *sremove = NULL; int scount = 0; switch(thetype) { case SHITLIST_ADD: { if (!(sremove = nickinshit(nick, thestring))) { shit_count++; sremove = (ShitList *) new_malloc(sizeof(ShitList)); sremove->level = shitlevel; sremove->reason = m_strdup(reason); sremove->channels = m_strdup(channels); sremove->filter = m_sprintf("%s!%s", nick, thestring); add_to_list((List **)&shitlist_list, (List *)sremove); sync_whowas_addshit(sremove); sync_shitlist(sremove, 1); if (shitlevel == PERM_IGNORE) ignore_nickname(sremove->filter, IGNORE_ALL, 0); bitchsay("Adding %s!%s to Shitlist", nick, thestring); } else bitchsay ("%s!%s already on my Shitlist", nick, thestring); break; } case SHITLIST_REMOVE: { char *s_str; s_str = m_sprintf("%s!%s", nick, thestring); while ((sremove = (ShitList *)removewild_from_list((List **)&shitlist_list, s_str))) { shit_count--; scount++; if (sremove->level == PERM_IGNORE) ignore_nickname(sremove->filter, IGNORE_ALL, IGNORE_REMOVE); sync_whowas_unshit(sremove); sync_shitlist(sremove, 0); new_free(&sremove->filter); new_free(&sremove->reason); new_free(&sremove->channels); new_free((char **)&sremove); bitchsay("Deleting %s!%s from Shitlist", nick, thestring); } if (!scount) bitchsay("Didnt find %s!%s on the Shitlist", nick, thestring); new_free(&s_str); break; } } }
int Wavplay_Init(IrcCommandDll **intp, Function_ptr *global_table) { initialize_module("wavplay"); add_module_proc(COMMAND_PROC, "Wavplay", "wavplay", NULL, 0, 0, wav_play, NULL); bitchsay("Wavplay Module loaded. /wavplay <filename>"); return 0; }
void join_last_invite(char dumb, char *dumber) { if (invite_channel) send_to_server(SERVER(from_server), "JOIN %s", invite_channel); else bitchsay("You haven't been invited to a channel yet"); }
void prepare_addshit(UserhostItem *stuff, char *nick, char *args) { char *uh; char *channels, *reason; char listbuf[BIG_BUFFER_SIZE+1]; int thetype = 0, shit = 0; if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) { bitchsay("No such nick [%s] found", nick); return; } thetype = my_atol(args); next_arg(args, &args); shit = my_atol(args); next_arg(args, &args); channels = next_arg(args, &args); reason = args; uh = clear_server_flags(stuff->user); while (strlen(uh) > 7) uh++; sprintf(listbuf, "*%s@%s", uh, stuff->host); add_to_a_list(listbuf, thetype, "*", channels, reason, shit); }
char *get_help_topic(char *args, int helpfunc) { char *new_comm = NULL; int found = 0, i; char *others = NULL; new_comm = LOCAL_COPY(args); for (i = 0; helpfunc ? script_help[i] : help_index[i]; i++) { if (!my_strnicmp(helpfunc?script_help[i]->title:help_index[i]->title, new_comm, strlen(new_comm))) { int j; char *text = NULL; if (found++) { m_s3cat(&others, " , ", helpfunc?script_help[i]->title:help_index[i]->title); continue; } if (args && *args && do_hook(HELPTOPIC_LIST, "%s", args)) put_it("%s",convert_output_format("$G \002$0\002: Help on Topic: \002$1\002", version, args)); for (j = 0; ; j++) { if (helpfunc && (script_help[i] && script_help[i]->contents[j])) text = script_help[i]->contents[j]; else if (!helpfunc && (help_index[i] && help_index[i]->contents[j])) text = help_index[i]->contents[j]; else break; if (text && do_hook(HELPSUBJECT_LIST, "%s %s", new_comm, text)) { in_chelp++; put_it("%s", convert_output_format(text, NULL)); in_chelp--; } } text = helpfunc ?script_help[i]->relates:help_index[i]->relates; if (text && do_hook(HELPTOPIC_LIST, "%s", text)) put_it("%s", convert_output_format(text, NULL)); } else if (found) break; } if (!found) { if (do_hook(HELPTOPIC_LIST, "%s", args)) bitchsay("No help on %s", args); } if (others && found) { if (do_hook(HELPTOPIC_LIST, "%d %s", found, others)) put_it("Other %d subjects: %s", found - 1, others); } new_free(&others); if (helpfunc) return m_strdup(empty_string); return NULL; }
int handle_socks(int fd, struct sockaddr_in addr, char *host, int portnum) { struct sockaddr_in proxy; struct hostent *hp; memset(&proxy, 0, sizeof(proxy)); if (!(hp = gethostbyname(host))) { bitchsay("Unable to resolve SOCKS proxy host address: %s", host); return -1; } bcopy(hp->h_addr, (char *)&proxy.sin_addr, hp->h_length); proxy.sin_family = AF_INET; proxy.sin_port = htons(portnum); alarm(get_int_var(CONNECT_TIMEOUT_VAR)); if (connect(fd, (struct sockaddr *)&proxy, sizeof(proxy)) < 0) { alarm(0); bitchsay("Unable to connect to SOCKS5 proxy: %s", strerror(errno)); close(fd); return -1; } alarm(0); if (!socks5_connect(fd, portnum, &addr)) { close(fd); if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { bitchsay("Unable to get socket: %s", strerror(errno)); return -1; } alarm(get_int_var(CONNECT_TIMEOUT_VAR)); if (connect(fd, (struct sockaddr *)&proxy, sizeof(proxy)) < 0) { alarm(0); bitchsay("Unable to connect to SOCKS4 proxy: %s", strerror(errno)); return -1; } alarm(0); if (!socks4_connect(fd, portnum, &addr)) { close(fd); return -1; } } return fd; }
void add_numeric_fset(char *name, int remove, char *args, int verbose) { FsetNumber *tmp = numeric_fset, *last = NULL; int num = my_atol(name); for (tmp = numeric_fset; tmp; tmp = tmp->next) { if (num == tmp->numeric) { if (remove) { if (last) last->next = tmp->next; else numeric_fset = tmp->next; new_free(&tmp->format); new_free(&tmp); return; } else { if (args && *args) malloc_strcpy(&tmp->format, args); if (verbose) bitchsay("Numeric %d is %s", num, tmp->format); return; } } last = tmp; } if (!args || !*args) { if (verbose) bitchsay("No such Numeric Fset %d", num); return; } tmp = (FsetNumber *) new_malloc(sizeof(FsetNumber)); tmp->numeric = num; tmp->format = m_strdup(args); add_to_list_ext((List **)&numeric_fset, (List *)tmp, compare_number); if (verbose) bitchsay("Added Numeric %d as %s", num, tmp->format); }
/* * try to negotiate a SOCKS4 connection. * */ int socks4_connect(int s, int portnum, struct sockaddr_in *server) { struct _sock_connect { char version; char type; unsigned short port; unsigned long address; char username[NAME_LEN+1]; } sock4_connect; char socksreq[10]; char *p; int red; memset(&sock4_connect, 0, sizeof(sock4_connect)); sock4_connect.version = SOCKS4_VERSION; sock4_connect.type = SOCKS_CONNECT; sock4_connect.port = server->sin_port; strncpy(sock4_connect.username, socks_user? socks_user: getenv("USER") ? getenv("USER") : username, NAME_LEN); p = inet_ntoa(server->sin_addr); sock4_connect.address = inet_addr(p); if ((red = write(s, &sock4_connect, 8 + strlen(sock4_connect.username) + 1)) == -1) { bitchsay("Cannot write to socks proxy: %s", strerror(errno)); return 0; } alarm(get_int_var(CONNECT_TIMEOUT_VAR)); if ((red = read(s, socksreq, 8)) == -1) { alarm(0); bitchsay("Cannot read from socks proxy: %s", strerror(errno)); return 0; } alarm(0); if (socksreq[1] != 90) { bitchsay("Cannot connect to SOCKS4 proxy: %s", socks4_error(socksreq[1])); return 0; } return 1; }
void get_nat_address(UserhostItem *stuff, char *nick, char *args) { char *h; if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN")) return; if (isdigit((unsigned char)*stuff->host)) h = stuff->host; else h = host_to_ip(stuff->host); nat_address.s_addr = inet_addr(h); bitchsay("using NAT address for DCC"); }
void log_channel(CSetArray *var, CSetList *cs) { ChannelList *chan; if (!cs->channel_log_file) { bitchsay("Try setting a channel log file first"); set_cset_int_var(cs, CHANNEL_LOG_CSET, 0); return; } if ((chan = lookup_channel(cs->channel, from_server, 0))) do_log(cs->channel_log, cs->channel_log_file, &chan->msglog_fp); }
int save_formats(FILE *outfile) { char thefile[BIG_BUFFER_SIZE+1]; char *p; int i; int count = 0; FsetNumber *tmp; #if defined(__EMX__) || defined(WINNT) sprintf(thefile, "%s/%s.fmt", get_string_var(CTOOLZ_DIR_VAR), version); #else sprintf(thefile, "%s/%s.formats", get_string_var(CTOOLZ_DIR_VAR), version); #endif p = expand_twiddle(thefile); outfile = fopen(p, "w"); if (!outfile) { bitchsay("Cannot open file %s for saving!", thefile); new_free(&p); return 1; } for (i = 0; i < NUMBER_OF_FSET; i++) { if (fset_array[i].string) fprintf(outfile, "FSET %s %s\n", fset_array[i].name, fset_array[i].string); else fprintf(outfile, "FSET -%s\n", fset_array[i].name); } count = NUMBER_OF_FSET; for (tmp = numeric_fset; tmp; tmp = tmp->next) { fprintf(outfile, "FSET %d %s\n", tmp->numeric, tmp->format); count++; } fclose(outfile); bitchsay("Saved %d formats to %s", count, thefile); new_free(&p); return 0; }
void check_hack(char *nick, ChannelList *channel, NickList *ThisNick, char *from) { #ifdef WANT_USERLIST UserList *userptr = NULL; ShitList *shitptr = NULL; #endif WhowasList *check_op = NULL; int flag; if (from && *from && !strchr(from, '.')) return; if (!channel || !are_you_opped(channel->channel) || !nick || !ThisNick || wild_match(nick, get_server_nickname(from_server))) return; if (!(flag = get_cset_int_var(channel->csets, HACKING_CSET))) return; if ((ThisNick->sent_deop) && (now - ThisNick->sent_deop_time < 10)) return; #ifdef WANT_USERLIST userptr = ThisNick->userlist; shitptr = ThisNick->shitlist; #endif check_op = check_whosplitin_buffer(nick, ThisNick->host, channel->channel, 0); if (check_op && check_op->has_ops) return; #ifdef WANT_USERLIST if ( !userptr || (userptr && !check_channel_match(userptr->channels, channel->channel)) || (shitptr && check_channel_match(shitptr->channels, channel->channel))) #endif { switch(flag) { case 1: case 3: if (is_chanop(channel->channel, nick)) add_mode(channel, "o", 0, nick, NULL, get_int_var(NUM_OPMODES_VAR)); ThisNick->sent_deop++; ThisNick->sent_deop_time = now; case 2: if (flag != 1) bitchsay("NetHack detected on %s by %s!%s", channel->channel, nick, ThisNick->host); case 0: default: break; } } }
void do_log(int flag, char *logfile, FILE **fp) { #ifdef PUBLIC_ACCESS bitchsay("This command has been disabled on a public access system"); return; #else time_t t = now; if (flag) { if (*fp) say("Logging is already on"); else { if (!logfile) return; if (!(logfile = expand_twiddle(logfile))) { say("SET LOGFILE: No such user"); return; } if ((*fp = fopen(logfile, get_int_var(APPEND_LOG_VAR)?"a":"w")) != NULL) { say("Starting logfile %s", logfile); chmod(logfile, S_IREAD | S_IWRITE); fprintf(*fp, "IRC log started %.24s\n", ctime(&t)); fflush(*fp); } else { say("Couldn't open logfile %s: %s", logfile, strerror(errno)); *fp = NULL; } new_free(&logfile); } } else { if (*fp) { fprintf(*fp, "IRC log ended %.24s\n", ctime(&t)); fflush(*fp); fclose(*fp); *fp = NULL; say("Logfile ended"); } } #endif }
int Amp_Init(IrcCommandDll **intp, Function_ptr *global_table) { initialize_module("amp"); initialise_decoder(); /* initialise decoder */ A_QUIET = TRUE; AUDIO_BUFFER_SIZE=300*1024; A_SHOW_CNT=FALSE; A_SET_VOLUME=-1; A_SHOW_TIME=0; A_AUDIO_PLAY=TRUE; A_DOWNMIX=FALSE; add_module_proc(COMMAND_PROC, "Amp", "mp3", NULL, 0, 0, mp3_play, NULL); add_module_proc(COMMAND_PROC, "Amp", "mp3vol", NULL, 0, 0, mp3_volume, NULL); add_module_proc(ALIAS_PROC, "Amp", "TIMEDECODE", NULL, 0, 0, func_convert_time, NULL); bitchsay("Amp Module loaded. /mp3 <filename> /mp3vol <L> <R> $timedecode(seconds)"); return 0; }
void get_help_topic(const char *args, int helpfunc) { int found = 0, i; char *others = NULL; struct chelp_index *index = helpfunc ? &script_help : &bitchx_help; size_t arglen = strlen(args); for (i = 0; i < index->size; i++) { if (!my_strnicmp(index->entries[i].title, args, arglen)) { int j; char *text = NULL; if (found++) { m_s3cat(&others, " , ", index->entries[i].title); continue; } if (do_hook(HELPTOPIC_LIST, "%s", index->entries[i].title)) put_it("%s", convert_output_format("$G \002$0\002: Help on Topic: \002$1-\002", "%s %s", version, index->entries[i].title)); for (j = 0; (text = index->entries[i].contents[j]) != NULL; j++) { if (do_hook(HELPSUBJECT_LIST, "%s , %s", index->entries[i].title, text)) { in_chelp++; put_it("%s", convert_output_format(text, NULL)); in_chelp--; } } text = index->entries[i].relates; if (text && do_hook(HELPTOPIC_LIST, "%s", text)) put_it("%s", convert_output_format(text, NULL)); } else if (found) break; } if (!found) { if (do_hook(HELPTOPIC_LIST, "%s", args)) bitchsay("No help on %s", args); } if (others && found) { if (do_hook(HELPTOPIC_LIST, "%d %s", found, others)) put_it("Other %d subjects: %s", found - 1, others); } new_free(&others); }
void check_auto_invite(char *nick, char *userhost) { #ifdef WANT_USERLIST ChannelList *chan = NULL; UserList *tmp = NULL; for (chan = get_server_channels(from_server); chan; chan = chan->next) { if ((tmp = lookup_userlevelc("*", userhost, chan->channel, NULL))) { NickList *n = NULL; n = find_nicklist_in_channellist(nick, chan, 0); if (!n && chan->have_op && get_cset_int_var(chan->csets, AINV_CSET) && (tmp->flags & ADD_INVITE) && get_cset_int_var(chan->csets, AINV_CSET)) { bitchsay("Auto-inviting %s to %s", nick, chan->channel); send_to_server("NOTICE %s :Auto-invite from %s", nick, get_server_nickname(from_server)); send_to_server("INVITE %s %s%s%s", nick, chan->channel, chan->key?space:empty_string, chan->key?chan->key:empty_string); } } tmp = NULL; } #endif }
int BX_flood_prot (char *nick, char *userhost, char *type, int ctcp_type, int ignoretime, char *channel) { ChannelList *chan; NickList *Nick; char tmp[BIG_BUFFER_SIZE+1]; char *uh; int old_window_display; int kick_on_flood = 1; if ((ctcp_type == CDCC_FLOOD || ctcp_type == CTCP_FLOOD || ctcp_type == CTCP_ACTION_FLOOD) && !get_int_var(CTCP_FLOOD_PROTECTION_VAR)) return 0; else if (!get_int_var(FLOOD_PROTECTION_VAR)) return 0; else if (!my_stricmp(nick, get_server_nickname(from_server))) return 0; switch (ctcp_type) { case WALL_FLOOD: case MSG_FLOOD: break; case NOTICE_FLOOD: break; case PUBLIC_FLOOD: if (channel) { if ((chan = lookup_channel(channel, from_server, 0))) { kick_on_flood = get_cset_int_var(chan->csets, PUBFLOOD_CSET); if (kick_on_flood && (Nick = find_nicklist_in_channellist(nick, chan, 0))) { if (chan->have_op && (!Nick->userlist || (Nick->userlist && !(Nick->userlist->flags & ADD_FLOOD)))) if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET)) send_to_server("KICK %s %s :\002%s\002 flooder", chan->channel, nick, type); } } } break; case CTCP_FLOOD: case CTCP_ACTION_FLOOD: check_ctcp_ban_flood(channel, nick); default: if (get_int_var(FLOOD_KICK_VAR) && kick_on_flood && channel) { for (chan = get_server_channels(from_server); chan; chan = chan->next) { if (chan->have_op && (Nick = find_nicklist_in_channellist(nick, chan, 0))) { if ((!Nick->userlist || (Nick->userlist && !(Nick->userlist->flags & ADD_FLOOD)))) if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET)) send_to_server("KICK %s %s :\002%s\002 flooder", chan->channel, nick, type); } } } } if (!ignoretime) return 0; uh = clear_server_flags(userhost); sprintf(tmp, "*!*%s", uh); old_window_display = window_display; window_display = 0; ignore_nickname(tmp, ignore_type(type, strlen(type)), 0); window_display = old_window_display; sprintf(tmp, "%d ^IGNORE *!*%s NONE", ignoretime, uh); timercmd("TIMER", tmp, NULL, NULL); bitchsay("Auto-ignoring %s for %d minutes [\002%s\002 flood]", nick, ignoretime/60, type); return 1; }
void userhost_ban(UserhostItem *stuff, char *nick1, char *args) { char *temp; char *str= NULL; char *channel; ChannelList *c = NULL; NickList *n = NULL; char *ob = "-o+b"; char *b = "+b"; char *host = NULL, *nick = NULL, *user = NULL, *chan = NULL; WhowasList *whowas = NULL; int f**k = 0; int set_ignore = 0; channel = next_arg(args, &args); temp = next_arg(args, &args); f**k = !my_stricmp("F**K", args); set_ignore = !my_stricmp("BKI", args); if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) { if (nick1 && channel && (whowas = check_whowas_nick_buffer(nick1, channel, 0))) { nick = whowas->nicklist->nick; user = m_strdup(clear_server_flags(whowas->nicklist->host)); host = strchr(user, '@'); *host++ = 0; bitchsay("Using WhoWas info for ban of %s ", nick1); n = whowas->nicklist; } else if (nick1) { bitchsay("No match for the %s of %s on %s", f**k ? "F**k":"Ban", nick1, channel); return; } } else { nick = stuff->nick; user = m_strdup(clear_server_flags(stuff->user)); host = stuff->host; } if (!(my_stricmp(nick, get_server_nickname(from_server)))) { bitchsay("Try to kick yourself again!!"); new_free(&user); return; } if (is_on_channel(channel, from_server, nick)) chan = channel; c = lookup_channel(channel, from_server, 0); if (c && !n) n = find_nicklist_in_channellist(nick, c, 0); send_to_server("MODE %s %s %s %s", channel, chan ? ob : b, chan?nick:empty_string, ban_it(nick, user, host, (n && n->ip)?n->ip:NULL)); if (f**k) { malloc_sprintf(&str, "%s!*%s@%s %s 3 Auto-Shit", nick, user, host, channel); #ifdef WANT_USERLIST add_shit(NULL, str, NULL, NULL); #endif new_free(&str); } else if (set_ignore) ignore_nickname(ban_it("*", user, host, NULL) , IGNORE_ALL, 0); new_free(&user); }
void userhost_unban(UserhostItem *stuff, char *nick1, char *args) { char *tmp; ChannelList *chan; char *channel = NULL; BanList *bans; char *host = NULL; char *ip_str = NULL; WhowasList *whowas = NULL; NickList *n = NULL; int count = 0; int old_server = from_server; if (!stuff || !stuff->nick || !nick1 || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick1)) { if (nick1 && (whowas = check_whowas_nick_buffer(nick1, args, 0))) { malloc_sprintf(&host, "%s!%s", whowas->nicklist->nick, whowas->nicklist->host); bitchsay("Using WhoWas info for unban of %s ", nick1); n = whowas->nicklist; } else if (nick1) { bitchsay("No match for the unban of %s on %s", nick1, args); return; } if (!nick1) return; } else { tmp = clear_server_flags(stuff->user); malloc_sprintf(&host, "%s!%s@%s",stuff->nick, tmp, stuff->host); } channel = next_arg(args, &args); if (args && *args) from_server = atoi(args); if (!(chan = prepare_command(&from_server, channel, NEED_OP))) { new_free(&host); return; } if (!n) n = find_nicklist_in_channellist(stuff->nick, chan, 0); if (n && n->ip) { size_t len = strlen(n->nick)+strlen(n->host)+strlen(n->ip)+10; ip_str = alloca(len); *ip_str = 0; strmopencat(ip_str, len, stuff->nick, "!", stuff->user, "@", n->ip, NULL); } for (bans = chan->bans; bans; bans = bans->next) { if (!bans->sent_unban && (wild_match(bans->ban, host) || (ip_str && wild_match(bans->ban, ip_str))) ) { add_mode(chan, "b", 0, bans->ban, NULL, get_int_var(NUM_BANMODES_VAR)); bans->sent_unban++; count++; } } flush_mode_all(chan); if (!count) bitchsay("No match for Unban of %s on %s", nick1, args); new_free(&host); from_server = old_server; }
/* * TODO: add some kind of error reporting here */ void play(char *inFileStr) { char *f; long totalframes = 0; long tseconds = 0; struct AUDIO_HEADER header; int bitrate, fs, g, cnt = 0; while ((f = new_next_arg(inFileStr, &inFileStr))) { if (!f || !*f) return; if ((in_file=fopen(f,"r"))==NULL) { if (!do_hook(MODULE_LIST, "AMP ERROR open %s", f)) put_it("Could not open file: %s\n", f); continue; } filesize = file_size(f); initialise_globals(); if ((g=gethdr(&header))!=0) { report_header_error(g); continue; } if (header.protection_bit==0) getcrc(); if (setup_audio(&header)!=0) { yell("Cannot set up audio. Exiting"); continue; } filesize -= sizeof(header); switch (header.layer) { case 1: { if (layer3_frame(&header,cnt)) { yell(" error. blip."); continue; } break; } case 2: { if (layer2_frame(&header,cnt)) { yell(" error. blip."); continue; } break; } default: continue; } bitrate=t_bitrate[header.ID][3-header.layer][header.bitrate_index]; fs=t_sampling_frequency[header.ID][header.sampling_frequency]; if (header.ID) framesize=144000*bitrate/fs; else framesize=72000*bitrate/fs; totalframes = (filesize / (framesize + 1)) - 1; tseconds = (totalframes * 1152/ t_sampling_frequency[header.ID][header.sampling_frequency]); if (A_AUDIO_PLAY) { char *p = strrchr(f, '/'); if (!p) p = f; else p++; if (!do_hook(MODULE_LIST, "AMP PLAY %lu %lu %s", tseconds, filesize, p)) bitchsay("Playing: %s\n", p); } /* * */ if (!(fseek(in_file, 0, SEEK_END))) { char id3_tag[256]; if (!fseek(in_file, -128, SEEK_END) && (fread(id3_tag,128, 1, in_file) == 1)) { if (!strncmp(id3_tag, "TAG", 3)) print_id3_tag(in_file, id3_tag); } fseek(in_file,0,SEEK_SET); } decodeMPEG(&header); do_hook(MODULE_LIST, "AMP CLOSE %s", f); close_audio(); fclose(in_file); } }
/* * try to negotiate a SOCKS5 connection. (with the socket/username, to the server) */ int socks5_connect(int s, int portnum, struct sockaddr_in *server) { struct _sock_connect { char version; char type; char authtype; char addrtype; unsigned long address; unsigned short port; char username[NAME_LEN+1]; } sock5_connect; char tmpbuf[25], *p; struct in_addr tmpAddr; unsigned short tmpI; int red; /* propose any authentication */ memset(&sock5_connect, 0, sizeof(sock5_connect)); sock5_connect.version = SOCKS5_VERSION; sock5_connect.type = SOCKS_CONNECT; sock5_connect.authtype = AUTH_NONE; /* AUTH_PASSWD, AUTH_GSSAPI, AUTH_CHAP */ if ((red = write(s, &sock5_connect, 4)) == -1) { bitchsay("Cannot write to proxy: %s", strerror(errno)); return 0; } memset(tmpbuf, 0, sizeof(tmpbuf)); alarm(get_int_var(CONNECT_TIMEOUT_VAR)); if ((red = read(s, tmpbuf, sizeof(tmpbuf)-1)) == -1) { alarm(0); bitchsay("Cannot use SOCKS5 proxy, read failed during auth: %s", strerror(errno)); return 0; } alarm(0); /* report server desired authentication (if not none) */ if (tmpbuf[1] != AUTH_NONE) { bitchsay("Cannot use SOCKS5 proxy, server wants type %x authentication.", tmpbuf[1]); return 0; } /* try to bounce to target */ memset(&sock5_connect, 0, sizeof(sock5_connect)); sock5_connect.version = SOCKS5_VERSION; sock5_connect.type = SOCKS_CONNECT; sock5_connect.addrtype = SOCKS5_IPV4ADDR; p = inet_ntoa(server->sin_addr); sock5_connect.address = inet_addr(p); sock5_connect.port = server->sin_port; if ((red = write(s, &sock5_connect, 10)) == -1) { bitchsay("Cannot write to the proxy: %s", strerror(errno)); return 0; } memset(tmpbuf, 0, sizeof(tmpbuf)-1); alarm(get_int_var(CONNECT_TIMEOUT_VAR)); if ((red = read(s, tmpbuf, sizeof(tmpbuf)-1)) == -1) { alarm(0); bitchsay("Cannot use SOCKS5 proxy, read failed during bounce: %s. Attempting SOCKS4", strerror(errno)); return 0; } alarm(0); if (tmpbuf[0] != SOCKS5_VERSION) { bitchsay("This is not a SOCKS5 proxy."); return 0; } if (tmpbuf[1] != SOCKS5_NOERR) { bitchsay("Cannot use SOCKS5 proxy, server failed: %s", socks5_error(tmpbuf[1])); return 0; } /* * read the rest of the response (depending on what type of address they use) */ alarm(get_int_var(CONNECT_TIMEOUT_VAR)); switch (tmpbuf[3]) { case 1: read(s, tmpbuf, 4); memcpy(&tmpAddr.s_addr, tmpbuf, 4); read(s, tmpbuf, 2); tmpbuf[3] = '\0'; tmpI = atoi(tmpbuf); bitchsay("SOCKS5 bounce successful, your address will be: %s:%d", inet_ntoa(tmpAddr), ntohs(tmpI)); break; case 3: { char buffer[256]; read(s, tmpbuf, 1); tmpbuf[1] = '\0'; tmpI = atoi(tmpbuf); read(s, tmpbuf, tmpI); tmpbuf[tmpI] = '\0'; strncpy(buffer, tmpbuf, sizeof(buffer)); read(s, tmpbuf, 2); tmpbuf[3] = '\0'; tmpI = atoi(tmpbuf); bitchsay("SOCKS5 bounce successful, your address will be: %s:%d", buffer, ntohs(tmpI)); break; } case 4: read(s, tmpbuf, 18); /* don't report address of ipv6 addresses. */ bitchsay("SOCKS5 bounce successful. [ipv6]"); break; default: bitchsay("error tmpbuf[3]: %x", tmpbuf[3]); alarm(0); return 0; } alarm(0); return 1; }
void prepare_adduser(UserhostItem *stuff, char *nick, char *args) { int thetype = 0; unsigned long flags = 0; int ppp = 0; UserList *uptr = NULL; char *channels = NULL, *passwd = NULL, *p = NULL, *uh, *e_host, *host; if (!stuff || !stuff->nick || !nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick)) { bitchsay("No such nick [%s] found", nick); return; } thetype = my_atol(args); next_arg(args, &args); ppp = my_atol(args); next_arg(args, &args); channels = next_arg(args, &args); p = next_arg(args, &args); flags = convert_str_to_flags(p); passwd = next_arg(args, &args); uh = clear_server_flags(stuff->user); if (*stuff->user == '~' || *stuff->user == '^') { while ((strlen(uh) > 8)) uh++; host = m_sprintf("*%s@%s", uh, ppp ? cluster(stuff->host) : stuff->host); } else host = m_sprintf("%s@%s", uh, ppp ? cluster(stuff->host) : stuff->host); e_host = m_sprintf("%s@%s", stuff->user, stuff->host); if (thetype == USERLIST_ADD) { char *e_pass = NULL; if (passwd) e_pass = cryptit(passwd); if (!(uptr = lookup_userlevelc(stuff->nick, e_host, channels, NULL))) { add_userhost_to_userlist(stuff->nick, host, channels, e_pass, flags); send_to_server("NOTICE %s :You have been added to my Userlist as *!%s with [%s]", nick, host, convert_flags_to_str(flags)); send_to_server("NOTICE %s :You are allowed on channels [%s]", nick, channels); if (passwd) send_to_server("NOTICE %s :Your password is [%s]", nick, passwd); put_it("%s", convert_output_format("$G Added [*!$0] on $1. Password is [$2] and flags are [$3-]", "%s %s %s %s", host, channels, passwd?passwd:"None", convert_flags_to_str(flags))); } else if (passwd) { send_to_server("NOTICE %s :Your password is %s[%s]", nick, uptr->password ? "changed to " : "", passwd); malloc_strcpy(&uptr->password, e_pass); } } else { if (!(remove_userhost_from_userlist(host, channels))) bitchsay("User not found on the userlist"); else put_it("%s", convert_output_format("$G Removed [$0] on $1 from userlist", "%s %s", host, channels)); } new_free(&e_host); new_free(&host); }
void fake(void) { bitchsay("--- Fake Message recieved!!! ---"); return; }