Added the +rules command.

Also added the +motd command to see the message of the day, which is sent while connecting.
This commit is contained in:
Jan Vidar Krey
2010-01-19 23:20:19 +01:00
parent 80c6ad9d76
commit e45511827f
6 changed files with 68 additions and 2 deletions

View File

@@ -361,14 +361,27 @@ void hub_send_handshake(struct hub_info* hub, struct hub_user* u)
}
}
void hub_send_motd(struct hub_info* hub, struct hub_user* u)
int hub_send_motd(struct hub_info* hub, struct hub_user* u)
{
if (hub->command_motd)
{
route_to_user(hub, u, hub->command_motd);
return 1;
}
return 0;
}
int hub_send_rules(struct hub_info* hub, struct hub_user* u)
{
if (hub->command_rules)
{
route_to_user(hub, u, hub->command_rules);
return 1;
}
return 0;
}
void hub_send_password_challenge(struct hub_info* hub, struct hub_user* u)
{
struct adc_message* igpa;
@@ -669,6 +682,22 @@ void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
close(fd);
}
hub->command_rules = 0;
fd = (hub->config->file_rules && *hub->config->file_rules) ? open(hub->config->file_rules, 0) : -1;
if (fd != -1)
{
ret = read(fd, buf, MAX_RECV_BUF);
if (ret > 0)
{
buf[ret] = 0;
tmp = adc_msg_escape(buf);
hub->command_rules = adc_msg_construct(ADC_CMD_IMSG, 6 + strlen(tmp));
adc_msg_add_argument(hub->command_rules, tmp);
hub_free(tmp);
}
close(fd);
}
hub->command_support = adc_msg_construct(ADC_CMD_ISUP, 6 + strlen(ADC_PROTO_SUPPORT));
if (hub->command_support)
{
@@ -697,6 +726,9 @@ void hub_free_variables(struct hub_info* hub)
if (hub->command_motd)
adc_msg_free(hub->command_motd);
if (hub->command_rules)
adc_msg_free(hub->command_rules);
adc_msg_free(hub->command_support);
}