You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1 KiB

import * as radius from 'radius';
import * as gblConfig from '../config';
import { IPacket } from './types/PacketHandler';
export type PacketDecoder = (msg: Buffer) =>
| {
packet?: radius.RadiusPacket & IPacket;
secret: string;
}
| Promise<{
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 = gblConfig;
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;
}
}