File src/dinoex_irc.c

* by Dirk Meyer (dinoex) * Copyright (C) 2004-2011 Dirk Meyer * * By using this file, you agree to the terms and conditions set * forth in the GNU General Public License. More information is * available in the LICENSE file. * * If you received this file without documentation, it can be * downloaded from http://iroffer.dinoex.net/ * * $Id: dinoex_irc.c,v 1.82 2012/08/24 08:54:13 cvs Exp $ *


Included Files

include the headers


Preprocessor definitions

#define _LONGLONG 1

#define MAX_IRCMSG_PARTS 6


Typedef ir_parseline_t

typedef struct {...} ir_parseline_t
struct  
   {  
      char* line;  
      char* part[6];  
   }  

Local Variables

irc_resolved_errormsg
static const char* irc_resolved_errormsg[]
Used in: irc_resolved()  

Global Function bind_irc_vhost()

limit connection to the configured interface

unsigned int bind_irc_vhost ( int family, int clientsocket )

Prototyped in: src/dinoex_irc.h
Calls: get_local_vhost() src/dinoex_irc.c
  outerror() src/iroffer_utilities.c
  __inet_pton(), bind(), bzero()
Called by: connectirc2() src/dinoex_irc.c
  l_establishcon() src/iroffer_upload.c
  setupdccchat() src/iroffer_dccchat.c
  t_passive() src/dinoex_transfer.c

Global Function check_ignore()

count actions for ignore list

unsigned int check_ignore ( const char* nick, const char* hostmask )

Prototyped in: src/dinoex_irc.h
Calls: get_ignore() src/dinoex_irc.c
  ioutput() src/iroffer_utilities.c
  notice() src/iroffer_utilities.c
  verifyshell() src/dinoex_utilities.c
  write_statefile() src/iroffer_statefile.c
Called by: botonly_parse() src/dinoex_user.c
  check_trigger() src/dinoex_user.c
  do_atfind() src/dinoex_user.c
  privmsgparse2() src/dinoex_user.c
References Variables: gdata src/dinoex_main.c

Global Function child_resolver()

the DNS resolution as a separate process

void child_resolver ( int family )

Prototyped in: src/dinoex_irc.h
Calls: __h_errno(), _exit(), close(), freeaddrinfo(), getaddrinfo(), memcpy(), memset(), snprintf(), write()
Called by: connectirc() src/iroffer_misc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Global Function get_config_nick()

get the configured nick of the bot for the current network

char* get_config_nick ( void )

Prototyped in: src/dinoex_irc.h
Called by: a_rehash_cleanup() src/dinoex_jobs.c
  get_user_nick() src/dinoex_irc.c
  initirc() src/iroffer_misc.c
  ir_parseline2() src/dinoex_irc.c
  mainloop() src/iroffer_main.c
  u_botinfo() src/iroffer_admin.c
  xdcc_save_xml() src/dinoex_jobs.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Global Function get_ignore()

update or create an entry in the ignore list

igninfo* get_ignore ( const char* hostmask )

Prototyped in: src/dinoex_irc.h
Calls: irlist_add2() src/iroffer_utilities.c
  irlist_get_head() src/iroffer_utilities.c
  irlist_get_next() src/iroffer_utilities.c
  mystrdup2() src/dinoex_utilities.c
  fnmatch()
Called by: a_ignore() src/dinoex_admin.c
  check_ignore() src/dinoex_irc.c
  reset_ignore() src/dinoex_user.c
  t_check_duplicateip() src/dinoex_transfer.c
  t_checkminspeed() src/iroffer_transfer.c
References Variables: gdata src/dinoex_main.c

Global Function get_local_vhost()

get the local vhost for the current network

char* get_local_vhost ( void )

Prototyped in: src/dinoex_irc.h
Called by: a_rehash_needtojump() src/dinoex_jobs.c
  bind_irc_vhost() src/dinoex_irc.c
  connectirc() src/iroffer_misc.c
  t_setup_dcc() src/dinoex_transfer.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Global Function get_user_nick()

get the active nick of the bot for the current network

char* get_user_nick ( void )

Prototyped in: src/dinoex_irc.h
Calls: get_config_nick() src/dinoex_irc.c
Called by: a_announce_msg() src/dinoex_admin.c
  addtoidlequeue() src/dinoex_queue.c
  cie_mynick() src/dinoex_ruby.c
  noticeresults() src/dinoex_user.c
  notifybandwidth() src/iroffer_misc.c
  send_help() src/dinoex_user.c
  setup_chat_banner() src/iroffer_dccchat.c
  setupdccchat() src/iroffer_dccchat.c
  t_remind() src/iroffer_transfer.c
  u_botinfo() src/iroffer_admin.c
  u_xdl_head() src/iroffer_admin.c
  xdcc_save_xml() src/dinoex_jobs.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Global Function has_closed_servers()

check if all networks are disconnected

unsigned int has_closed_servers ( void )

Prototyped in: src/dinoex_irc.h
Called by: mainloop() src/iroffer_main.c
  shutdowniroffer() src/iroffer_misc.c
References Variables: gdata src/dinoex_main.c

Global Function identify_needed()

try to identify at Nickserv

void identify_needed ( unsigned int force )

Prototyped in: src/dinoex_irc.h
Calls: get_nickserv_pass() src/dinoex_misc.c
  ioutput() src/iroffer_utilities.c
  save_nick() src/dinoex_utilities.c
  writeserver() src/iroffer_misc.c
Called by: a_identify() src/dinoex_admin.c
  identify_check() src/dinoex_irc.c
  ir_parseline2() src/dinoex_irc.c
  irc_001() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Global Function ir_setsockopt()

set all options for a transfer connection

void ir_setsockopt ( int clientsocket )

Prototyped in: src/dinoex_irc.h
Calls: ir_setsockopt2() src/dinoex_irc.c
  outerror() src/iroffer_utilities.c
  set_socket_nonblocking() src/iroffer_utilities.c
  updatecontext_f() src/iroffer_utilities.c
  setsockopt()
Called by: l_establishcon() src/iroffer_upload.c
  l_setup_accept() src/dinoex_upload.c
  t_setup_send() src/iroffer_transfer.c
References Variables: gdata src/dinoex_main.c

Global Function irc_open_listen()

find a free port and open a new socket for an incoming connection

unsigned int irc_open_listen ( ir_connection_t* con )

Prototyped in: src/dinoex_irc.h
Calls: get_port() src/dinoex_utilities.c
  open_listen() src/dinoex_irc.c
Called by: l_setup_listen() src/dinoex_upload.c
  setupdccchatout() src/iroffer_dccchat.c
  t_setuplisten() src/iroffer_transfer.c
References Variables: gdata src/dinoex_main.c

Global Function irc_perform()

handle irc server connectipn

void irc_perform ( int changesec )

Prototyped in: src/dinoex_irc.h
Calls: close_server() src/dinoex_ssl.c
  connectirc2() src/dinoex_irc.c
  handshake_ssl() src/dinoex_ssl.c
  ioutput() src/iroffer_utilities.c
  ir_parseline() src/dinoex_irc.c
  irc_server_is_timeout() src/dinoex_irc.c
  irc_server_timeout() src/dinoex_irc.c
  irlist_get_head() src/iroffer_utilities.c
  my_getnameinfo() src/dinoex_irc.c
  mydelete2() src/iroffer_utilities.c
  mymalloc2() src/iroffer_utilities.c
  outerror() src/iroffer_utilities.c
  readserver_ssl() src/dinoex_ssl.c
  start_sends() src/dinoex_queue.c
  switchserver() src/iroffer_misc.c
  updatecontext_f() src/iroffer_utilities.c
  __bswap32(), __error(), bzero(), getsockname(), getsockopt(), kill(), memset(), read(), strerror(), strlen()
Called by: mainloop() src/iroffer_main.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Global Function irc_resolved()

collect the the DNS resolution from the child process

void irc_resolved ( void )

Prototyped in: src/dinoex_irc.h
Calls: event_close() src/dinoex_kqueue.c
  ioutput() src/iroffer_utilities.c
  waitpid()
Called by: mainloop() src/iroffer_main.c
References Variables: gdata src/dinoex_main.c
  irc_resolved_errormsg src/dinoex_irc.c

Global Function irc_select()

register active connections for select()

int irc_select ( int highests )

Prototyped in: src/dinoex_irc.h
Called by: mainloop() src/iroffer_main.c
References Variables: gdata src/dinoex_main.c

Global Function my_dcc_ip_show()

returns a text with the external IP address of the bot

const char* my_dcc_ip_show ( char* buffer, size_t len, ir_sockaddr_union_t* sa, unsigned int net )

Prototyped in: src/dinoex_irc.h
Calls: __bswap32(), __inet_ntop()
Called by: u_botinfo() src/iroffer_admin.c
References Variables: gdata src/dinoex_main.c

Global Function my_getnameinfo()

writes IP address and port as text into the buffer

int my_getnameinfo ( char* buffer, size_t len, const struct sockaddr* sa )

Prototyped in: src/dinoex_irc.h
Calls: getnameinfo(), snprintf()
Called by: connectirc2() src/dinoex_irc.c
  dump_config_list() src/dinoex_config.c
  h_accept() src/dinoex_http.c
  h_open_listen() src/dinoex_http.c
  irc_perform() src/dinoex_irc.c
  l_setup_accept() src/dinoex_upload.c
  l_setup_listen() src/dinoex_upload.c
  setupdccchat() src/iroffer_dccchat.c
  setupdccchataccept() src/iroffer_dccchat.c
  setupdccchatout() src/iroffer_dccchat.c
  t_passive() src/dinoex_transfer.c
  t_setup_send() src/iroffer_transfer.c
  telnet_accept() src/dinoex_telnet.c
  telnet_open_listen() src/dinoex_telnet.c

Global Function open_listen()

find a free port and open a new socket for an incoming connection

unsigned int open_listen ( int family, ir_sockaddr_union_t* listenaddr, int* listen_socket, unsigned int port, unsigned int reuse, unsigned int search, const char* vhost )

Prototyped in: src/dinoex_irc.h
Calls: bind_vhost() src/dinoex_irc.c
  ir_bind_listen_socket() src/iroffer_utilities.c
  my_get_upnp_data() src/dinoex_irc.c
  outerror() src/iroffer_utilities.c
  shutdown_close() src/dinoex_kqueue.c
  updatecontext_f() src/iroffer_utilities.c
  __bswap16(), __error(), bind(), bzero(), listen(), setsockopt(), socket(), strchr(), strerror()
Called by: h_open_listen() src/dinoex_http.c
  irc_open_listen() src/dinoex_irc.c
  telnet_open_listen() src/dinoex_telnet.c
References Variables: gdata src/dinoex_main.c

Global Function setup_dcc_local()

returns the external IP address and port the bot as DCC argsments

char* setup_dcc_local ( ir_sockaddr_union_t* listenaddr )

Prototyped in: src/dinoex_irc.h
Calls: my_dcc_ip_port() src/dinoex_irc.c
  mymalloc2() src/iroffer_utilities.c
Called by: l_setup_listen() src/dinoex_upload.c
  setupdccchatout() src/iroffer_dccchat.c
  t_start_dcc_send() src/dinoex_transfer.c
References Variables: gnetwork src/dinoex_main.c

Global Function update_natip()

check that the given text is an IP address or hostname and store it as external DCC IP

void update_natip ( const char* var )

Prototyped in: src/dinoex_irc.h
Calls: ioutput() src/iroffer_utilities.c
  mydelete2() src/iroffer_utilities.c
  mystrdup2() src/dinoex_utilities.c
  outerror() src/iroffer_utilities.c
  update_getip_net() src/dinoex_irc.c
  updatecontext_f() src/iroffer_utilities.c
  __bswap32(), __h_errno(), __inet_aton(), __inet_ntoa(), bzero(), gethostbyname(), hstrerror(), memcpy()
Called by: c_usenatip() src/dinoex_config.c
  global_defaults() src/dinoex_misc.c
  update_server_welcome() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Local Function bind_vhost()

static unsigned int bind_vhost ( ir_sockaddr_union_t* listenaddr, int family, const char* vhost )
Calls: outerror() src/iroffer_utilities.c
  __inet_pton()
Called by: open_listen() src/dinoex_irc.c

Local Function connectirc2()

complete the connection to the IRC server

static unsigned int connectirc2 ( res_addrinfo_t* remote )

Calls: bind_irc_vhost() src/dinoex_irc.c
  event_close() src/dinoex_kqueue.c
  ioutput() src/iroffer_utilities.c
  my_getnameinfo() src/dinoex_irc.c
  mydelete2() src/iroffer_utilities.c
  mymalloc2() src/iroffer_utilities.c
  outerror() src/iroffer_utilities.c
  set_socket_nonblocking() src/iroffer_utilities.c
  __error(), alarm(), connect(), socket(), strerror()
Called by: irc_perform() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Local Function identify_check()

check line from server to see if the bots need to identify again

static void identify_check ( const char* line )

Calls: get_nickserv_pass() src/dinoex_misc.c
  identify_needed() src/dinoex_irc.c
  strcasestr(), strstr()
Called by: ir_parseline2() src/dinoex_irc.c

Local Function ir_get_nickarg()

static char* ir_get_nickarg ( const char* line )
Calls: mymalloc2() src/iroffer_utilities.c
  strlen()
Called by: ir_parseline2() src/dinoex_irc.c

Local Function ir_parseline()

handle message from irc server

static void ir_parseline ( char* line )

Calls: do_myruby_server() src/dinoex_ruby.c
  get_argv2() src/dinoex_utilities.c
  ioutput() src/iroffer_utilities.c
  ir_parseline2() src/dinoex_irc.c
  mydelete2() src/iroffer_utilities.c
  removenonprintable() src/dinoex_utilities.c
  updatecontext_f() src/iroffer_utilities.c
  bzero()
Called by: irc_perform() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Local Function ir_parseline2()

static void ir_parseline2 ( ir_parseline_t* ipl )
Calls: addtomemberlist() src/iroffer_utilities.c
  caps() src/dinoex_utilities.c
  changeinmemberlist_mode() src/iroffer_utilities.c
  changeinmemberlist_nick() src/iroffer_utilities.c
  clean_send_buffers() src/dinoex_jobs.c
  clearmemberlist() src/iroffer_utilities.c
  close_server() src/dinoex_ssl.c
  do_myruby_notice() src/dinoex_ruby.c
  do_myruby_privmsg() src/dinoex_ruby.c
  get_config_nick() src/dinoex_irc.c
  getpart2() src/dinoex_utilities.c
  identify_check() src/dinoex_irc.c
  identify_needed() src/dinoex_irc.c
  ioutput() src/iroffer_utilities.c
  ir_get_nickarg() src/dinoex_irc.c
  ir_unknown_channel() src/dinoex_irc.c
  irc_001() src/dinoex_irc.c
  irc_005() src/dinoex_irc.c
  irlist_get_head() src/iroffer_utilities.c
  irlist_get_next() src/iroffer_utilities.c
  joinchannel() src/iroffer_misc.c
  lag_message() src/dinoex_jobs.c
  lost_nick() src/dinoex_user.c
  mydelete2() src/iroffer_utilities.c
  mystrdup2() src/dinoex_utilities.c
  outerror() src/iroffer_utilities.c
  privmsgparse() src/dinoex_user.c
  removefrommemberlist() src/iroffer_utilities.c
  reverify_restrictsend() src/iroffer_misc.c
  start_sends() src/dinoex_queue.c
  test_fish_message() src/dinoex_jobs.c
  user_changed_nick() src/iroffer_misc.c
  writeserver() src/iroffer_misc.c
  strcasecmp(), strcmp(), strlen(), strncmp(), strstr()
Called by: ir_parseline() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Local Function ir_setsockopt2()

static void ir_setsockopt2 ( int clientsocket, int optint, const char* optname, int val )
Calls: ioutput() src/iroffer_utilities.c
  getsockopt(), setsockopt()
Called by: ir_setsockopt() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c

Local Function ir_unknown_channel()

static void ir_unknown_channel ( const char* chname )
Calls: ioutput() src/iroffer_utilities.c
Called by: ir_parseline2() src/dinoex_irc.c
References Variables: gnetwork src/dinoex_main.c

Local Function irc_001()

static void irc_001 ( ir_parseline_t* ipl )
Calls: caps() src/dinoex_utilities.c
  get_user_modes() src/dinoex_misc.c
  getpart2() src/dinoex_utilities.c
  identify_needed() src/dinoex_irc.c
  ioutput() src/iroffer_utilities.c
  irlist_get_head() src/iroffer_utilities.c
  irlist_get_next() src/iroffer_utilities.c
  mydelete2() src/iroffer_utilities.c
  mystrdup2() src/dinoex_utilities.c
  update_server_welcome() src/dinoex_irc.c
  writeserver() src/iroffer_misc.c
Called by: ir_parseline2() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Local Function irc_005()

static void irc_005 ( ir_parseline_t* ipl )
Calls: getpart2() src/dinoex_utilities.c
  initprefixes() src/iroffer_misc.c
  mydelete2() src/iroffer_utilities.c
  outerror() src/iroffer_utilities.c
  memset(), strncmp()
Called by: ir_parseline2() src/dinoex_irc.c
References Variables: gnetwork src/dinoex_main.c

Local Function irc_server_is_timeout()

static int irc_server_is_timeout ( void )
Called by: irc_perform() src/dinoex_irc.c
  irc_server_timeout() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Local Function irc_server_timeout()

static void irc_server_timeout ( void )
Calls: close_server() src/dinoex_ssl.c
  ioutput() src/iroffer_utilities.c
  irc_server_is_timeout() src/dinoex_irc.c
Called by: irc_perform() src/dinoex_irc.c
References Variables: gnetwork src/dinoex_main.c

Local Function my_dcc_ip_port()

static int my_dcc_ip_port ( char* buffer, size_t len, ir_sockaddr_union_t* sa )
Calls: __bswap16(), __bswap32(), getnameinfo(), snprintf()
Called by: setup_dcc_local() src/dinoex_irc.c
References Variables: gnetwork src/dinoex_main.c

Local Function my_get_upnp_data()

static void my_get_upnp_data ( const struct sockaddr* sa )
Calls: outerror() src/iroffer_utilities.c
  updatecontext_f() src/iroffer_utilities.c
  upnp_add_redir() src/upnp.c
  getnameinfo()
Called by: open_listen() src/dinoex_irc.c

Local Function update_getip_net()

static void update_getip_net ( unsigned int net, ir_uint32 ourip )
Calls: ioutput() src/iroffer_utilities.c
  mydelete2() src/iroffer_utilities.c
  mystrdup2() src/dinoex_utilities.c
  __bswap32(), __inet_ntoa()
Called by: update_natip() src/dinoex_irc.c
  update_server_welcome() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c

Local Function update_server_welcome()

check the welcome message from the server for an IP address or hostname to set external DCC IP

static void update_server_welcome ( char* line )

Calls: ioutput() src/iroffer_utilities.c
  update_getip_net() src/dinoex_irc.c
  update_natip() src/dinoex_irc.c
  updatecontext_f() src/iroffer_utilities.c
  upnp_get_dccip() src/upnp.c
  strchr()
Called by: irc_001() src/dinoex_irc.c
References Variables: gdata src/dinoex_main.c
  gnetwork src/dinoex_main.c