fprintf(stderr, "\n");
return processPacket(client, source, command, argc, args);
}
+static void cont_webirc(struct client_data *client, int res) {
+ if (!(client->umode & UMODE_SECURE) || res != 0) {
+ free(client->webircpeername);
+ client->webircpeername = 0;
+ err_passwdmismatch(client), sendbuf(client);
+ } else {
+ free(client->peername);
+ client->peername = client->webircpeername;
+ client->webircpeername = 0;
+ if (client->webircwait == 2) {
+ // NOTE: this relies on the job system being FIFO
+ client->umode &= ~UMODE_SECURE;
+ }
+ client->webircwait = 0;
+ newUser(client);
+ }
+}
static void cont_oper(struct client_data *client, int res) {
if (!(client->umode & UMODE_SECURE) || res != 0) {
err_passwdmismatch(client), sendbuf(client);
client->pass_reg = mystrdup(args[0]);
memset(args[0], 0, strlen(args[0]));
if (!client->pass_reg) abort();
+ } else if(strcmp(command, "WEBIRC") == 0) {
+ if (is_registered(client))
+ return err_alreadyregistered(client), sendbuf(client), 0;
+ if (argc < 4)
+ return err_needmoreparams(client, command), sendbuf(client), 0;
+ if (!client->webircwait) {
+ client->webircpeername = mystrdup(args[3]);
+ if (argc > 4 && (!strncmp(args[4], "secure", 6) || strstr(args[4], " secure")))
+ client->webircwait = 1;
+ else
+ client->webircwait = 2;
+ job_password_check(client, args[1], args[0], getdatafile("webirc.txt"), cont_webirc);
+ memset(args[0], 0, strlen(args[0]));
+ }
} else if(strcmp(command, "OPER") == 0) {
if (!is_registered(client))
return err_notregistered(client), sendbuf(client), 0;
}
void newUser(struct client_data *client) {
- if (client->regstate == REG_CAPLS || !client->nick_reg || !client->username || client->passwait)
+ if (client->regstate == REG_CAPLS || !client->nick_reg || !client->username || client->passwait || client->webircwait)
return;
if (client->saslbuf || client->saslusername) {
copy_strf(&databuf, ":%s 906 * :SASL auhtentication aborted\r\n", hostname), sendbuf(client);
net_nonblock(newSocket);
int is_onion = 0;
+ int is_webirc = 0;
{
struct sockaddr_storage sockname;
socklen_t socknamelen = sizeof(sockname);
// onion if connecting to 127.0.0.2
if (ntohl(ia->s_addr) == 0x7F000002)
is_onion = 1;
+ // webirc if connecting to 127.0.0.3
+ if (ntohl(ia->s_addr) == 0x7F000003)
+ is_webirc = 1;
}
}
cl->umode |= UMODE_SECURE;
extern const char *hostname;
if (is_local) {
- cl->hostname = mystrdup(is_onion ? "onion" : "localhost");
+ cl->hostname = mystrdup(is_webirc ? "webirc" : is_onion ? "onion" : "localhost");
cl->umode |= UMODE_SECURE;
} else {
cl->hostname = mystrdup(hostname);