Allow packetDecoder to return promise
This commit is contained in:
parent
16dba70123
commit
d494db0b29
@ -1,14 +1,19 @@
|
|||||||
import * as radius from 'radius';
|
import * as radius from 'radius';
|
||||||
import * as gblConfig from '../config';
|
import * as gblConfig from '../config';
|
||||||
import { IPacket } from './types/PacketHandler';
|
import { IPacket } from './types/PacketHandler';
|
||||||
import {Authentication} from "./auth";
|
import { Authentication } from './auth';
|
||||||
import {UDPServer} from "./server/UDPServer";
|
import { UDPServer } from './server/UDPServer';
|
||||||
import {RadiusService} from "./radius/RadiusService";
|
import { RadiusService } from './radius/RadiusService';
|
||||||
|
|
||||||
export type PacketDecoder = (msg: Buffer) => {
|
export type PacketDecoder = (msg: Buffer) =>
|
||||||
packet?: radius.RadiusPacket & IPacket;
|
| {
|
||||||
secret: string;
|
packet?: radius.RadiusPacket & IPacket;
|
||||||
};
|
secret: string;
|
||||||
|
}
|
||||||
|
| Promise<{
|
||||||
|
packet?: radius.RadiusPacket & IPacket;
|
||||||
|
secret: string;
|
||||||
|
}>;
|
||||||
|
|
||||||
export default class PackageInterface {
|
export default class PackageInterface {
|
||||||
private static _instance?: PackageInterface;
|
private static _instance?: PackageInterface;
|
||||||
|
@ -27,7 +27,7 @@ export class RadiusService {
|
|||||||
msg: Buffer
|
msg: Buffer
|
||||||
): Promise<{ data: Buffer; expectAcknowledgment?: boolean } | undefined> {
|
): Promise<{ data: Buffer; expectAcknowledgment?: boolean } | undefined> {
|
||||||
const { packet, secret } = packageInterface.packetDecoder
|
const { packet, secret } = packageInterface.packetDecoder
|
||||||
? packageInterface.packetDecoder(msg)
|
? await packageInterface.packetDecoder(msg)
|
||||||
: this.defaultDecoder(msg);
|
: this.defaultDecoder(msg);
|
||||||
|
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
|
Loading…
Reference in New Issue
Block a user