parent
1149fc054a
commit
78c57d7747
@ -0,0 +1,39 @@
|
||||
@coreid/node-radius-server - CoreID maintained fork
|
||||
Copyright (C) 2021 Simon Tretter, Garrett Mills
|
||||
|
||||
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/>.
|
||||
|
||||
--
|
||||
|
||||
Note: this is a fork of Simon Tretter's node-radius-server package
|
||||
modified for use in Starship CoreID. Per the terms of GPLv3, the
|
||||
modifications made are documented below:
|
||||
|
||||
- Introduced the PackageInterface helper class
|
||||
- enables integrating the library into code rather than as a
|
||||
standalone CLI app
|
||||
|
||||
- Modified existing code to use configuration on the PackageInterface
|
||||
class instead of global imports
|
||||
|
||||
- Modified existing code to log through PackageInterface.logger
|
||||
|
||||
- Modified existing code to introduce a credentialMiddleware method
|
||||
to IPacket, which allows external code to customize the credentials
|
||||
before they are sent
|
||||
|
||||
- Modified RadiusService to allow specifying a custom packet decoder
|
||||
method on PackageInterface.
|
||||
|
||||
- Modified UDPServer class to expose a stop() method
|
@ -0,0 +1,47 @@
|
||||
import * as radius from 'radius';
|
||||
import * as config from '../config';
|
||||
import { IPacket } from './types/PacketHandler';
|
||||
|
||||
export type PacketDecoder = (msg: Buffer) => {
|
||||
packet?: radius.RadiusPacket & IPacket;
|
||||
secret: string;
|
||||
};
|
||||
|
||||
export default class PackageInterface {
|
||||
private static _instance?: PackageInterface;
|
||||
|
||||
public static get(): PackageInterface {
|
||||
if (!this._instance) {
|
||||
this._instance = new PackageInterface();
|
||||
}
|
||||
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
public packetDecoder?: PacketDecoder;
|
||||
|
||||
public start = true;
|
||||
|
||||
public cacheTTL = 60000;
|
||||
|
||||
public cacheSuccessTTL = 86400;
|
||||
|
||||
public cacheFailTTL = 60;
|
||||
|
||||
public logger: (...any: unknown[]) => unknown = console.log; // eslint-disable-line no-console
|
||||
|
||||
private config: any = config;
|
||||
|
||||
public log(...any: unknown[]): void {
|
||||
this.logger(...any);
|
||||
}
|
||||
|
||||
public getConfig(): any {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public setConfig(inConfig: any) {
|
||||
this.config = inConfig;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue