diff --git a/config.example b/config.example index 16f587e..4389d99 100644 --- a/config.example +++ b/config.example @@ -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', ], diff --git a/doc/index.rst b/doc/index.rst index 0e5a522..0241681 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -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 ` 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: diff --git a/src/server/blacklist.ts b/src/server/blocklist.ts similarity index 66% rename from src/server/blacklist.ts rename to src/server/blocklist.ts index ed2d964..6cdaa03 100644 --- a/src/server/blacklist.ts +++ b/src/server/blocklist.ts @@ -7,17 +7,17 @@ function add(promise: Promise) { 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 { +export function getBlocklist(): Readonly { return [ ...list ]; } diff --git a/src/server/config.ts b/src/server/config.ts index 54e92ac..eb49ab0 100644 --- a/src/server/config.ts +++ b/src/server/config.ts @@ -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' diff --git a/src/server/device.ts b/src/server/device.ts index 0145553..956a29e 100644 --- a/src/server/device.ts +++ b/src/server/device.ts @@ -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'; @@ -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; } diff --git a/src/server/server.ts b/src/server/server.ts index e52ae39..08fc78f 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -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'; @@ -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 () => { diff --git a/src/server/web.ts b/src/server/web.ts index 059bbaa..b7a1492 100644 --- a/src/server/web.ts +++ b/src/server/web.ts @@ -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'; @@ -206,8 +206,8 @@ function makeServices(app: Application, config: Config, devices: Devic return { ...config.portsFind, }; - case 'blacklist': - return getBlacklist(); + case 'blocklist': + return getBlocklist(); case 'reload': if(!config.configReloadable) { return { @@ -501,8 +501,8 @@ export function makeWebserver(config: Config, devices: Devices, remotes: Remote[ const app = express(feathers()); 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(); } @@ -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; }