2021-12-05 17:44:13 -05:00
|
|
|
import { readFileSync } from "fs";
|
|
|
|
import { connect } from "tls";
|
|
|
|
|
2022-03-29 18:23:20 -04:00
|
|
|
const config = JSON.parse(readFileSync(process.argv[2]));
|
2021-12-05 17:44:13 -05:00
|
|
|
|
|
|
|
const client = connect({
|
|
|
|
host: 'localhost',
|
|
|
|
port: config["port"],
|
|
|
|
rejectUnauthorized: false
|
|
|
|
}, () => {
|
2022-03-29 16:10:59 -04:00
|
|
|
client.write("CAP LS 302\r\n");
|
2022-03-29 18:23:20 -04:00
|
|
|
client.write("CAP REQ :account-tag batch draft/channel-rename echo-message reflectionircd.chat/edit-message reflectionircd.chat/extended-invite extended-join invite-notify labeled-response message-tags sasl server-time\r\n");
|
2022-03-29 16:10:59 -04:00
|
|
|
const saslPassword = Buffer.from(`\0user\0${config.SASLPassword}`).toString('base64');
|
|
|
|
client.write(`AUTHENTICATE ${saslPassword}\r\n`)
|
|
|
|
client.write("CAP END\r\n")
|
2021-12-05 17:44:13 -05:00
|
|
|
process.stdin.pipe(client);
|
|
|
|
process.stdin.resume();
|
|
|
|
})
|
|
|
|
|
|
|
|
client.setEncoding('utf8');
|
|
|
|
client.on('data', (data) => {
|
|
|
|
const dataArray = data.toString().split('\r\n');
|
|
|
|
dataArray.forEach(m => {
|
|
|
|
const trimmedMsg = m.replace('\r', '').replace('\n', '');
|
|
|
|
if (trimmedMsg !== '') {
|
|
|
|
console.log(`--> ${trimmedMsg}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
client.on('end', () => {
|
|
|
|
console.log('server ends connection');
|
|
|
|
});
|