Initial commit
This commit is contained in:
parent
e42d3d6e43
commit
1a8a6c1ef8
5 changed files with 113 additions and 0 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "brainlet-lib"]
|
||||||
|
path = brainlet-lib
|
||||||
|
url = https://git.hippoz.xyz/hiimgoodpack/brainlet-lib.git
|
1
brainlet-lib
Submodule
1
brainlet-lib
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit b3d9f220b0941c088060c867135ff804d10fad77
|
13
config.js
Normal file
13
config.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module.exports = {
|
||||||
|
server: "127.0.0.1:3005",
|
||||||
|
spectator: {
|
||||||
|
name: "BrainletToIrcSpectator",
|
||||||
|
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
|
||||||
|
|
||||||
|
To sign up, use /nick YourName and then /msg NickServ REGISTER YourPassword YourEmail
|
||||||
|
To log in, use /msg NickServ IDENTIFY YourName YourPassword`
|
||||||
|
}
|
77
index.js
Normal file
77
index.js
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
Software to convert the Brainlet protocol to the IRC protocol
|
||||||
|
Copyright (C) 2021 hiimgoodpack
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
const fs = require("fs");
|
||||||
|
const ircServer = require("ircdjs");
|
||||||
|
const ircClient = require("irc");
|
||||||
|
const crypto = require("crypto");
|
||||||
|
|
||||||
|
// Set up IRC server
|
||||||
|
const translationConfig = require(`${__dirname}/config.js`)
|
||||||
|
|
||||||
|
const genPass = () => {
|
||||||
|
// This should give us a reasonably secure password
|
||||||
|
return crypto.randomBytes(66).toString("base64");
|
||||||
|
}
|
||||||
|
|
||||||
|
let systemUsers = {
|
||||||
|
NickServ: {
|
||||||
|
password: genPass()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const ircConfig = {
|
||||||
|
network: "BrainletToIRC",
|
||||||
|
hostname: "localhost",
|
||||||
|
serverDescription: "A brainlet to IRC translation layer",
|
||||||
|
serverName: translationConfig.server,
|
||||||
|
port: 6667,
|
||||||
|
linkPort: 7777,
|
||||||
|
motd: translationConfig.motd,
|
||||||
|
whoWasLimit: 10000,
|
||||||
|
token: 1,
|
||||||
|
opers: systemUsers,
|
||||||
|
channels: {},
|
||||||
|
links: {
|
||||||
|
server: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
password: genPass(),
|
||||||
|
port: 7778,
|
||||||
|
token: 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pingTimeout: 120,
|
||||||
|
maxNickLength: 30
|
||||||
|
};
|
||||||
|
fs.writeFileSync(`${__dirname}/node_modules/ircdjs/config/config.json`, JSON.stringify(ircConfig));
|
||||||
|
|
||||||
|
ircServer.Server.boot();
|
||||||
|
|
||||||
|
// Set up system users
|
||||||
|
// TODO: Figure out why user is not joining
|
||||||
|
const ircServerAddress = ircConfig.links.server.host;
|
||||||
|
const ircServerPort = ircConfig.links.server.port;
|
||||||
|
let NickServ = new ircClient.Client("127.0.0.1", "NickServ", {
|
||||||
|
userName: "NickServ",
|
||||||
|
realName: "NickServ",
|
||||||
|
port: ircServerPort,
|
||||||
|
channels: ["#foo"],
|
||||||
|
password: systemUsers.NickServ.password
|
||||||
|
});
|
||||||
|
NickServ.addListener("error", console.error);
|
||||||
|
NickServ.addListener("join", () => {
|
||||||
|
console.log("Joined server");
|
||||||
|
})
|
19
package.json
Normal file
19
package.json
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "brainlet-irc",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Brainlet to IRC translation layer",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.hippoz.xyz/hiimgoodpack/brainlet-irc.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "GPL-3.0-or-later",
|
||||||
|
"dependencies": {
|
||||||
|
"irc": "^0.5.2",
|
||||||
|
"ircdjs": "0.0.17"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue