int m_squit(user_t *cptr, int parc, char **parv) { user_t *sptr = find_client(strnull(parv[1])); if (sptr) switch (me.servtype) { case SERV_IRCNN: return del_server(sptr); case SERV_HYBRD: return del_server(sptr); } return 1; }
void add_linked_server(char *hub, char *leaf, char *comment) { user_t *server, *uplink; if ((server = find_client(leaf))) del_server(server); if (!(uplink = find_client(hub)) && !is_me(leaf)) return; server = add_user_to_list(); server->nick = leetstrdup(leaf); server->realname = leetstrdup(comment); server->server = uplink ? uplink : server; server->ts = time(NULL); server->privs = SERVER; me.servers++; }
static int add_server_default(void) { char buf[128]; server_generic_t *server; int ret, prev_family = AF_UNSPEC; struct addrinfo *ai, *ai_start, hints; memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_PASSIVE; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_family = PF_UNSPEC; #ifdef AI_ADDRCONFIG /* * Only look up addresses using address types for which a local * interface is configured. */ hints.ai_flags |= AI_ADDRCONFIG; #endif snprintf(buf, sizeof(buf), "%u", DEFAULT_MANAGER_PORT); ret = getaddrinfo(NULL, buf, &hints, &ai); if ( ret != 0 ) { requiem_log(REQUIEM_LOG_ERR, "error getting default machine address: %s.\n", (ret == EAI_SYSTEM) ? strerror(errno) : gai_strerror(ret)); return -1; } for ( ai_start = ai; ai != NULL; ai = ai->ai_next ) { if ( ! inet_ntop(ai->ai_family, requiem_sockaddr_get_inaddr(ai->ai_addr), buf, sizeof(buf)) ) { requiem_log(REQUIEM_LOG_ERR, "address to string translation failed: %s.\n", strerror(errno)); break; } server = add_server(); if ( ! server ) break; ret = server_generic_bind_numeric(server, ai->ai_addr, ai->ai_addrlen, DEFAULT_MANAGER_PORT); if ( ret < 0 ) { char buf[128]; /* * More information on this at: * http://lists.debian.org/debian-ipv6/2001/01/msg00031.html */ if ( requiem_error_get_code(ret) == REQUIEM_ERROR_EADDRINUSE && prev_family != AF_UNSPEC && ai->ai_family != prev_family ) { ret = 0; del_server(); continue; } inet_ntop(ai->ai_family, requiem_sockaddr_get_inaddr(ai->ai_addr), buf, sizeof(buf)); requiem_perror(ret, "error initializing server on %s:%u", buf, DEFAULT_MANAGER_PORT); break; } prev_family = ai->ai_family; } if ( config.nserver == 0 ) { requiem_log(REQUIEM_LOG_WARN, "could not find any address to listen on.\n"); return -1; } freeaddrinfo(ai_start); return ret; }