static int do_chghost(struct Client *source_p, struct Client *target_p, const char *newhost, int is_encap) { if (!clean_host(newhost)) { sendto_realops_snomask(SNO_GENERAL, is_encap ? L_ALL : L_NETWIDE, "%s attempted to change hostname for %s to %s (invalid)", IsServer(source_p) ? source_p->name : get_oper_name(source_p), target_p->name, newhost); /* sending this remotely may disclose important * routing information -- jilles */ if (is_encap ? MyClient(target_p) : !ConfigServerHide.flatten_links) sendto_one_notice(target_p, ":*** Notice -- %s attempted to change your hostname to %s (invalid)", source_p->name, newhost); return 0; } change_nick_user_host(target_p, target_p->name, target_p->username, newhost, 0, "Changing host"); if (irccmp(target_p->host, target_p->orighost)) { SetDynSpoof(target_p); if (MyClient(target_p)) sendto_one_numeric(target_p, RPL_HOSTHIDDEN, "%s :is now your hidden host (set by %s)", target_p->host, source_p->name); } else { ClearDynSpoof(target_p); if (MyClient(target_p)) sendto_one_numeric(target_p, RPL_HOSTHIDDEN, "%s :hostname reset by %s", target_p->host, source_p->name); } if (MyClient(source_p)) sendto_one_notice(source_p, ":Changed hostname for %s to %s", target_p->name, target_p->host); if (!IsServer(source_p) && !IsService(source_p)) sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s changed hostname for %s to %s", get_oper_name(source_p), target_p->name, target_p->host); return 1; }
/* * me_realhost * parv[1] = real host * * Yes this contains a little race condition if someone does a whois * in between the UID and REALHOST and use_whois_actually is enabled. * I don't think that's a big problem as the whole thing is a * race condition. */ static int me_realhost(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { if (!IsPerson(source_p)) return 0; del_from_hostname_hash(source_p->orighost, source_p); rb_strlcpy(source_p->orighost, parv[1], sizeof source_p->orighost); if (irccmp(source_p->host, source_p->orighost)) SetDynSpoof(source_p); else ClearDynSpoof(source_p); add_to_hostname_hash(source_p->orighost, source_p); return 0; }
static void distribute_hostchange(struct Client *client) { if (irccmp(client->host, client->orighost)) sendto_one_numeric(client, RPL_HOSTHIDDEN, "%s :is now your hidden host", client->host); else sendto_one_numeric(client, RPL_HOSTHIDDEN, "%s :hostname reset", client->host); sendto_server(NULL, NULL, CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s", use_id(&me), use_id(client), client->host); sendto_server(NULL, NULL, CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s", use_id(&me), use_id(client), client->host); sendto_server(NULL, NULL, NOCAPS, CAP_TS6, ":%s ENCAP * CHGHOST %s :%s", me.name, client->name, client->host); if (irccmp(client->host, client->orighost)) SetDynSpoof(client); else ClearDynSpoof(client); }
static void check_new_user(void *vdata) { struct Client *source_p = (void *)vdata; if (IsIPSpoof(source_p)) { source_p->umodes &= ~user_modes['h']; return; } source_p->localClient->mangledhost = MyMalloc(HOSTLEN); if (!irccmp(source_p->orighost, source_p->sockhost)) do_host_cloak(source_p->orighost, source_p->localClient->mangledhost, 1); else do_host_cloak(source_p->orighost, source_p->localClient->mangledhost, 0); if (IsDynSpoof(source_p)) source_p->umodes &= ~user_modes['h']; if (source_p->umodes & user_modes['h']) { strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host)); if (irccmp(source_p->host, source_p->orighost)) SetDynSpoof(source_p); } }