Remove netfinger client code and repurpose /FINGER command to send a CTCP FINGER instead

No-one runs fingerd servers anymore so this code was entirely obsolete.
This commit is contained in:
Kevin Easton
2017-04-11 01:19:32 +10:00
parent eace841366
commit bad8c2fa02
4 changed files with 25 additions and 123 deletions

View File

@@ -3594,127 +3594,6 @@ SocketList *BX_get_socket(int s)
return NULL;
}
extern int dgets_errno;
void read_netfinger(int s)
{
char tmpstr[BIG_BUFFER_SIZE+1];
char *p = tmpstr;
*tmpstr = 0;
switch(dgets(tmpstr, s, 0, BIG_BUFFER_SIZE, NULL))
{
case 0:
break;
case -1:
if (do_hook(SOCKET_LIST, "%d %d %s Remote closed connection", s, sock_manager.sockets[s].port, sock_manager.sockets[s].server))
{
if (dgets_errno == -1)
bitchsay("Remote closed connection");
}
close_socketread(s);
break;
default:
{
chop(tmpstr, 1);
while (*p)
{
switch(*p)
{
case '\210':
case '\211':
case '\212':
case '\214':
*p &= 0x7f;
break;
case '\x9b':
case '\t':
break;
case '\n':
case '\r':
*p = '\0';
break;
default:
if (!isprint((unsigned char)*p))
*p = (*p & 0x7f) | 0x40;
break;
}
p++;
}
if (do_hook(SOCKET_LIST, "%d %d %s %s", s, sock_manager.sockets[s].port, sock_manager.sockets[s].server, tmpstr))
put_it("%s", tmpstr);
}
}
}
void netfinger (char *name)
{
char *host = NULL;
unsigned short port = 79;
int s;
if (name)
{
if ((host = strrchr(name, '@')))
*host++ = 0;
else
host = name;
}
if (!host || !*host)
{
say("Invalid @host or user@host.");
return;
}
if (name && *name)
{
if ((s = connect_by_number(host, &port, SERVICE_CLIENT, PROTOCOL_TCP, 1)) < 0)
{
bitchsay("Finger connect error on %s@%s", name?name:empty_string, host);
return;
}
if ((add_socketread(s, port, 0, name, read_netfinger, NULL)) > -1)
{
write_sockets(s, name, strlen(name), 1);
add_sockettimeout(s, 120, NULL);
} else
close_socketread(s);
}
return;
}
void start_finger (UserhostItem *stuff, char *nick, char *args)
{
char *finger_userhost = NULL;
char *str;
if (!stuff || !stuff->nick || !strcmp(stuff->user, "<UNKNOWN>") || my_stricmp(stuff->nick, nick))
{
say("No information for %s", nick);
return;
}
finger_userhost = m_opendup(stuff->user, "@", stuff->host, NULL);
str = finger_userhost;
str = clear_server_flags(finger_userhost);
say("Launching finger for %s (%s)", nick, finger_userhost);
netfinger(str);
new_free(&finger_userhost);
}
BUILT_IN_COMMAND(finger)
{
char *userhost;
if ((userhost = next_arg(args, &args)))
{
if (!strchr(userhost, '@'))
{
userhostbase(userhost, start_finger, 1, "%s", userhost);
return;
}
netfinger(userhost);
}
}
static void handle_socket_connect(int rc)
{
struct servent *serv;