Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.example
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ config = {
jenkinsUrl: 'http://...',

// Optional. List of hostnames/IP addresses to block from connecting.
blacklist: [
blocklist: [
'google.com',
'8.8.8.8',
],
Expand Down
4 changes: 2 additions & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ How to handle the files stored on the server when a user shares their terminal s
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If Jenkins is :ref:`integrated <jenkins>` with Serial Bridge, this is the root URL of the Jenkins installation.

:field-optional:`blacklist`
:field-optional:`blocklist`
^^^^^^^^^^^^^^^^^^^^^^^^^^^
An array of hostnames and IP addresses to block from connecting to the web interface and node telnet ports. Serial Bridge will attempt to convert hostnames to IPs and the reverse on startup, but after that the blacklist is fixed. Best practice is to list exactly the string you see in the console output when the target host tries to connect.
An array of hostnames and IP addresses to block from connecting to the web interface and node telnet ports. Serial Bridge will attempt to convert hostnames to IPs and the reverse on startup, but after that the blocklist is fixed. Best practice is to list exactly the string you see in the console output when the target host tries to connect.

.. _users:

Expand Down
8 changes: 4 additions & 4 deletions src/server/blacklist.ts → src/server/blocklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ function add(promise: Promise<string[]>) {
promise.then(names => names.forEach(name => list.add(name))).catch(err => {});
}

export function blacklist(host: string) {
console.log('blacklist', host);
export function blocklist(host: string) {
console.log('blocklist', host);
list.add(host);
add(resolver.resolve(host));
add(resolver.reverse(host));
}

export function isBlacklisted(host: string): boolean {
export function isBlocklisted(host: string): boolean {
return list.has(host);
}

export function getBlacklist(): Readonly<string[]> {
export function getBlocklist(): Readonly<string[]> {
return [ ...list ];
}
2 changes: 1 addition & 1 deletion src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const configJoi = joi.object({
commands: joi.array().items(commandJoi),
jenkinsUrl: joi.string(),
notice: joi.string(),
blacklist: joi.array().items(joi.string()).default([]),
blocklist: joi.array().items(joi.string()).default([]),
}).required();

// Serial Bridge 1's config file had keys with spaces in it, so for backwards compatibility, convert 'foo bar' to 'fooBar'
Expand Down
8 changes: 4 additions & 4 deletions src/server/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import slugify from 'slugify';
import ioClient from 'socket.io-client';

import { ClientServices as Services } from '@/services';
import { isBlacklisted } from './blacklist';
import { isBlocklisted } from './blocklist';
import { Config } from './config';
import Connections, { Connection } from './connections';
import IdGenerator from './id-generator';
Expand Down Expand Up @@ -243,9 +243,9 @@ export abstract class Node extends EventEmitter {

private onTcpConnect(socket: net.Socket) {
const address = socket.remoteAddress!;
if(isBlacklisted(address)) {
this.log(`${address} rejected -- blacklisted`);
socket.write("Blacklisted\r\n");
if(isBlocklisted(address)) {
this.log(`${address} rejected -- blocklisted`);
socket.write("Blocklisted\r\n");
socket.destroy();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import net from 'net';
import ora from 'ora';

import banner from 'raw-loader!./banner.txt';
import { blacklist } from './blacklist';
import { blocklist } from './blocklist';
import { loadConfig, Config } from './config';
import { Devices, Remote } from './device';
import { configureUserFactory } from './connections';
Expand Down Expand Up @@ -51,7 +51,7 @@ function makeHttpxServer(httpServer: http.Server, httpsServer: https.Server) {
console.log(`${banner}\n${BUILD_VERSION}${BUILD_ID ? ` (build ${BUILD_ID})` : ''} (${BUILD_FILE_HASH ?? 'no file hash'})\nBuilt ${BUILD_DATE}\n`);
const config = await spinner("Load configuration", loadConfig);
configureUserFactory(config.users ? config.users.identify as any : undefined);
config.blacklist.forEach(blacklist);
config.blocklist.forEach(blocklist);
const devices: Devices = await spinner("Load device information", async () => Devices.fromConfig(config.devices));
if(config.configReloadable) {
process.on('SIGUSR2', async () => {
Expand Down
12 changes: 6 additions & 6 deletions src/server/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import pathlib from 'path';
import slugify from 'slugify';

import { ServerServices as Services, ServiceDefinitions, DeviceJson } from '@/services';
import { isBlacklisted, getBlacklist } from './blacklist';
import { isBlocklisted, getBlocklist } from './blocklist';
import { Config, gitPull, hasGitDir, loadConfig } from './config';
import Device, { Node, Remote, EphemeralDevice, RemoteIONode, Devices, DevicesConfigReloadSpec } from './device';
import { getUser, setUserInfo } from './connections';
Expand Down Expand Up @@ -206,8 +206,8 @@ function makeServices(app: Application<Services>, config: Config, devices: Devic
return {
...config.portsFind,
};
case 'blacklist':
return getBlacklist();
case 'blocklist':
return getBlocklist();
case 'reload':
if(!config.configReloadable) {
return {
Expand Down Expand Up @@ -501,8 +501,8 @@ export function makeWebserver(config: Config, devices: Devices, remotes: Remote[
const app = express(feathers<Services>());

app.use((req, res, next) => {
if(isBlacklisted(req.ip)) {
res.status(403).send('Blacklisted');
if(isBlocklisted(req.ip)) {
res.status(403).send('Blocklisted');
} else {
next();
}
Expand Down Expand Up @@ -610,7 +610,7 @@ export function makeWebserver(config: Config, devices: Devices, remotes: Remote[

app.configure(socketioServer(io => {
io.on('connection', socket => {
if(isBlacklisted(socket.conn.remoteAddress)) {
if(isBlocklisted(socket.conn.remoteAddress)) {
socket.disconnect();
return;
}
Expand Down