Go to the source code of this file.
Data Structures | |
struct | egg_proxy_t |
Functions | |
int | egg_net_init (void) |
int | egg_net_shutdown (void) |
int | egg_iprintf (int idx, const char *format,...) |
int | egg_server (const char *vip, int port, int *real_port) |
int | egg_client (int idx, const char *host, int port, const char *vip, int vport, int timeout) |
int | egg_listen (int port, int *real_port) |
int | egg_connect (const char *host, int port, int timeout) |
int | egg_reconnect (int idx, const char *host, int port, int timeout) |
int | egg_proxy_add (egg_proxy_t *proxy) |
int | egg_proxy_del (egg_proxy_t *proxy) |
egg_proxy_t * | egg_proxy_lookup (const char *name) |
int | egg_proxy_set_default (const char *name) |
const char * | egg_proxy_get_default () |
int egg_client | ( | int | idx, | |
const char * | host, | |||
int | port, | |||
const char * | vip, | |||
int | vport, | |||
int | timeout | |||
) |
Definition at line 106 of file net.c.
References attach(), connect_host_resolved(), connect_info::dns_id, egg_dns_lookup(), NULL, and sockbuf_new().
Referenced by egg_reconnect(), http_reconnect(), and socks5_reconnect().
00107 { 00108 connect_info_t *connect_info; 00109 00110 /* If they don't have their own idx (-1), create one. */ 00111 if (idx < 0) idx = sockbuf_new(); 00112 00113 /* Resolve the hostname. */ 00114 connect_info = attach(idx, host, port, timeout); 00115 connect_info->dns_id = egg_dns_lookup(host, -1, connect_host_resolved, connect_info, NULL); 00116 return(idx); 00117 }
int egg_connect | ( | const char * | host, | |
int | port, | |||
int | timeout | |||
) |
Definition at line 155 of file net.c.
References egg_reconnect(), and sockbuf_new().
Referenced by connect_to_next_server(), dcc_accept_send(), do_link(), egg_ident_lookup(), got_chat_request(), and script_net_open().
00156 { 00157 int idx; 00158 00159 idx = sockbuf_new(); 00160 egg_reconnect(idx, host, port, timeout); 00161 return(idx); 00162 }
int egg_iprintf | ( | int | idx, | |
const char * | format, | |||
... | ||||
) |
Definition at line 68 of file net.c.
References egg_mvsprintf(), and sockbuf_write().
Referenced by dcc_on_connect(), dcc_on_read(), do_ping(), got_join(), got_mode(), got_nlinked(), got_part(), got_passreq(), got_ping(), got_privmsg(), got_version(), got_who(), http_on_connect(), ident_on_connect(), idx_on_connect(), irc_greet(), irc_on_newclient(), irc_on_read(), oldbotnet_on_connect(), on_bcast(), on_botbroadcast(), on_botmsg(), on_chanmsg(), on_extension(), on_join(), on_link(), on_login(), on_lost_bot(), on_new_bot(), on_nick(), on_part(), on_privmsg(), on_quit(), on_unlink(), partyline_idx_chanmsg(), partyline_idx_join(), partyline_idx_nick(), partyline_idx_part(), partyline_idx_privmsg(), partyline_idx_quit(), process_results(), recving_login(), sending_login(), telnet_on_newclient(), and telnet_on_read().
00069 { 00070 char *ptr, buf[1024]; 00071 int len; 00072 va_list args; 00073 00074 va_start(args, format); 00075 ptr = egg_mvsprintf(buf, sizeof(buf), &len, format, args); 00076 va_end(args); 00077 sockbuf_write(idx, ptr, len); 00078 if (ptr != buf) free(ptr); 00079 return(len); 00080 }
int egg_listen | ( | int | port, | |
int * | real_port | |||
) |
Definition at line 121 of file net.c.
References egg_server(), and NULL.
Referenced by dcc_listen(), and script_net_listen().
00122 { 00123 int idx; 00124 00125 /* Proxy/firewall/vhost code goes here. */ 00126 idx = egg_server(NULL, port, real_port); 00127 return(idx); 00128 }
int egg_net_init | ( | void | ) |
Definition at line 53 of file net.c.
References egg_dns_init(), and sockbuf_init().
Referenced by eggdrop_init().
00054 { 00055 if (egg_dns_init() != 0) 00056 return (-1); 00057 return sockbuf_init(); 00058 }
int egg_net_shutdown | ( | void | ) |
Definition at line 60 of file net.c.
References egg_dns_shutdown(), and sockbuf_shutdown().
Referenced by eggdrop_shutdown().
00061 { 00062 if (egg_dns_shutdown() != 0) 00063 ; 00064 return sockbuf_shutdown(); 00065 }
int egg_proxy_add | ( | egg_proxy_t * | proxy | ) |
int egg_proxy_del | ( | egg_proxy_t * | proxy | ) |
Definition at line 287 of file net.c.
References nproxies.
00288 { 00289 int i; 00290 00291 for (i = 0; i < nproxies; i++) { 00292 if (proxies[i] == proxy) break; 00293 } 00294 if (i == nproxies) return(-1); 00295 memmove(proxies+i, proxies+i+1, (nproxies-i-1) * sizeof(*proxies)); 00296 nproxies--; 00297 return(0); 00298 }
const char* egg_proxy_get_default | ( | ) |
Definition at line 316 of file net.c.
References default_proxy_name.
00317 { 00318 return(default_proxy_name); 00319 }
egg_proxy_t* egg_proxy_lookup | ( | const char * | name | ) |
int egg_proxy_set_default | ( | const char * | name | ) |
Definition at line 310 of file net.c.
References default_proxy_name, and str_redup().
Referenced by on_proxy_set(), and proxy_init().
00311 { 00312 str_redup(&default_proxy_name, name); 00313 return(0); 00314 }
int egg_reconnect | ( | int | idx, | |
const char * | host, | |||
int | port, | |||
int | timeout | |||
) |
Definition at line 132 of file net.c.
References attach(), default_proxy_name, egg_client(), egg_proxy_lookup(), LOG_MISC, NULL, putlog(), and egg_proxy_t::reconnect.
Referenced by egg_connect(), and got_accept().
00133 { 00134 egg_proxy_t *proxy; 00135 00136 if (!default_proxy_name) return egg_client(idx, host, port, NULL, 0, timeout); 00137 00138 /* If there is a proxy configured, send this request to the right 00139 * handler. */ 00140 proxy = egg_proxy_lookup(default_proxy_name); 00141 if (!proxy) { 00142 putlog(LOG_MISC, "*", "Proxy '%s' selected but not loaded!", default_proxy_name); 00143 putlog(LOG_MISC, "*", "Trying to connect without proxy."); 00144 return egg_client(idx, host, port, NULL, 0, timeout); 00145 } 00146 00147 /* Ok, so we will connect through the selected proxy. But we still have 00148 * to set up the timeout handler (to avoid duplication of code in the 00149 * proxy handlers) if they want one. */ 00150 if (timeout > 0) attach(idx, host, port, timeout); 00151 proxy->reconnect(idx, host, port); 00152 return(0); 00153 }
int egg_server | ( | const char * | vip, | |
int | port, | |||
int * | real_port | |||
) |
Definition at line 83 of file net.c.
References NULL, sockbuf_new(), SOCKBUF_SERVER, sockbuf_set_sock(), socket_create(), socket_get_name(), SOCKET_NONBLOCK, SOCKET_SERVER, and SOCKET_TCP.
Referenced by bot_init(), egg_listen(), irc_init(), and telnet_init().
00084 { 00085 int idx, sock, ntries; 00086 00087 ntries = 0; 00088 do { 00089 sock = socket_create(NULL, 0, vip, port+ntries, SOCKET_SERVER|SOCKET_TCP|SOCKET_NONBLOCK); 00090 ntries++; 00091 } while (sock < 0 && ntries < 20 && port); 00092 00093 if (sock < 0) return(sock); 00094 00095 if (real_port) socket_get_name(sock, NULL, real_port); 00096 00097 idx = sockbuf_new(); 00098 sockbuf_set_sock(idx, sock, SOCKBUF_SERVER); 00099 00100 return(idx); 00101 }