Update things

This commit is contained in:
hiimgoodpack 2021-01-20 19:32:08 -05:00
parent 1a8a6c1ef8
commit 4c5a28ca84
Signed by: hiimgoodpack
GPG key ID: 4E0E62733C14AE69
5 changed files with 86 additions and 21 deletions

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "brainlet-lib"] [submodule "brainlet-lib"]
path = brainlet-lib path = brainlet-lib
url = https://git.hippoz.xyz/hiimgoodpack/brainlet-lib.git url = https://git.hippoz.xyz/hiimgoodpack/brainlet-lib.git
[submodule "ircd.js"]
path = ircd.js
url = https://github.com/TestingPlant/ircd.js.git

View file

@ -1,3 +1,10 @@
# brainlet-irc # brainlet-irc
Brainlet to IRC translation layer Brainlet to IRC translation layer
# Technical notes
This uses irc@0.5.0. See [this](https://github.com/martynsmith/node-irc/issues/495) for more information
This also uses a fork of ircdjs to add the NOTICE command. [This pull request](https://github.com/alexyoung/ircd.js/pull/99)
is trying to get it merged with the main repository, but I'm not sure how fast it'll get merged seeing the date of the last commit.

View file

@ -4,10 +4,30 @@ module.exports = {
name: "BrainletToIrcSpectator", name: "BrainletToIrcSpectator",
password: "Put a secure password here. See the README for more info" password: "Put a secure password here. See the README for more info"
}, },
motd: `A Brainlet to IRC translation layer.
SECURITY WARNING: The traffic to the Brainlet server is not encrypted motd: "A Brainlet to IRC translation layer.\n" +
"SECURITY WARNING: The traffic to the Brainlet server is not encrypted.\n" +
"Use \"/msg NickServ help\" to see how to use an account",
To sign up, use /nick YourName and then /msg NickServ REGISTER YourPassword YourEmail responses: {
To log in, use /msg NickServ IDENTIFY YourName YourPassword` NickServ: {
help: `NickServ allows you to use and create a Brainlet account from IRC.
You can use a command with "/msg NickServ <command> <arguments>"
Commands:
HELP - Shows this message
REGISTER <password> <email> - Creates an account, using your current nick as the username.
Note: The email is not directly used by IRC, but may be used by the Brainlet host.
IDENTIFY <name> <password> - Logs into an account.`,
// Sent on invalid command
invalid: "Invalid command. Use \"/msg NickServ help\" for help",
// Sent on an invalid entry.
// %s is replaced with how it's invalid.
invalidName: "Invalid username specified. %s",
invalidEmail: "Invalid email specified. %s",
invalidPassword: "Invalid password specified. %s"
}
}
} }

View file

@ -16,12 +16,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
const fs = require("fs"); const fs = require("fs");
const ircServer = require("ircdjs"); const ircServer = require("./ircd.js/lib/server.js");
const ircClient = require("irc"); const ircClient = require("irc");
const crypto = require("crypto"); const crypto = require("crypto");
// Set up IRC server // Set up IRC server
const translationConfig = require(`${__dirname}/config.js`) const config = require(`${__dirname}/config.js`)
const genPass = () => { const genPass = () => {
// This should give us a reasonably secure password // This should give us a reasonably secure password
@ -37,10 +37,10 @@ const ircConfig = {
network: "BrainletToIRC", network: "BrainletToIRC",
hostname: "localhost", hostname: "localhost",
serverDescription: "A brainlet to IRC translation layer", serverDescription: "A brainlet to IRC translation layer",
serverName: translationConfig.server, serverName: config.server,
port: 6667, port: 6667,
linkPort: 7777, linkPort: 7777,
motd: translationConfig.motd, motd: config.motd,
whoWasLimit: 10000, whoWasLimit: 10000,
token: 1, token: 1,
opers: systemUsers, opers: systemUsers,
@ -56,22 +56,56 @@ const ircConfig = {
pingTimeout: 120, pingTimeout: 120,
maxNickLength: 30 maxNickLength: 30
}; };
fs.writeFileSync(`${__dirname}/node_modules/ircdjs/config/config.json`, JSON.stringify(ircConfig)); fs.writeFileSync(`${__dirname}/ircd.js/config/config.json`, JSON.stringify(ircConfig));
ircServer.Server.boot(); ircServer.Server.boot();
// Set up system users // Set up system users
// TODO: Figure out why user is not joining
const ircServerAddress = ircConfig.links.server.host; const ircServerAddress = ircConfig.links.server.host;
const ircServerPort = ircConfig.links.server.port; const ircServerPort = ircConfig.links.server.port;
let NickServ = new ircClient.Client("127.0.0.1", "NickServ", {
userName: "NickServ", let NickServ = new ircClient.Client("localhost", "NickServ");
realName: "NickServ", console.log(NickServ)
port: ircServerPort,
channels: ["#foo"],
password: systemUsers.NickServ.password
});
NickServ.addListener("error", console.error); NickServ.addListener("error", console.error);
NickServ.addListener("join", () => { NickServ.addListener("message", (from, to, text, message) => {
console.log("Joined server"); // Make sure it's a private message to NickServ
}) if (to !== NickServ.opt.nick)
return;
const args = text.split(" ");
if (args.length == 0) {
NickServ.notice(from, config.responses.NickServ.invalid);
return;
}
switch (args[0].toLowerCase()) {
case "help": {
NickServ.notice(from, config.responses.NickServ.help);
break;
}
case "register": {
const password = args[1];
const email = args[2];
if (!password || !email) {
NickServ.notice(from, config.responses.NickServ.invalid);
return;
}
NickServ.notice(from, "Account registration is currently not implemented");
break;
}
case "identify": {
const name = args[1];
const password = args[2];
if (!name || !password) {
NickServ.notice(from, config.responses.NickServ.invalid);
return;
}
NickServ.notice(from, "Account login is currently not implemented");
break;
}
default: {
NickServ.notice(from, config.responses.NickServ.invalid);
break;
}
}
});

1
ircd.js Submodule

@ -0,0 +1 @@
Subproject commit 53e18a0032600abd092aced978e232f637221d1d