Refuse a bind the server cannot record as it refuses one authenticate turns down
Mirror / push (push) Successful in 6s
Test / lint (pull_request) Successful in 24s
Test / test (18) (pull_request) Successful in 38s
Test / test (20) (pull_request) Successful in 32s
Test / test (22) (pull_request) Successful in 32s
Test / test (24) (pull_request) Successful in 34s
Test / test (26) (pull_request) Successful in 32s

This commit is contained in:
2026-09-28 04:05:07 +02:00
parent 2ac72fb3f4
commit 9a07f75bdf
3 changed files with 14 additions and 20 deletions
+2 -3
View File
@@ -36,9 +36,8 @@ shape is the same, connect, send, listen for delivery reports, with callbacks re
Write `alert_on_message_delivery` and `broadcast_area_identifier`, the names they read back Write `alert_on_message_delivery` and `broadcast_area_identifier`, the names they read back
under, for `alert_on_msg_delivery` and `failed_broadcast_area_identifier`, which are gone from under, for `alert_on_msg_delivery` and `failed_broadcast_area_identifier`, which are gone from
`tlvs` too. `tlvs` too.
- **`session.loggedIn` is gone**: read `session.boundAs !== undefined`. `boundAs` and - **`session.loggedIn` is gone**: read `session.boundAs !== undefined`. A session you construct
`peerInterfaceVersion` are read-only; a session you construct yourself records a bind with yourself records a bind with `session.bound()`.
`session.bound()`.
- **The `error` event is `sessionError`**, and `serverError` on the server handle. - **The `error` event is `sessionError`**, and `serverError` on the server handle.
- **`log`** takes any object with `debug`, `error`, `info`, `verbose` and `warn` methods instead of - **`log`** takes any object with `debug`, `error`, `info`, `verbose` and `warn` methods instead of
a `larvitutils` one, and is silent by default: [README](README.md#logging). a `larvitutils` one, and is silent by default: [README](README.md#logging).
+10 -13
View File
@@ -170,18 +170,6 @@ function bindRespTlvs(session: Session, options: ServerOptions): TlvInputs | und
}; };
} }
async function acceptBind(
session: Session,
pduObj: PduObject,
bindType: BindType,
options: ServerOptions,
identity: Record<string, string>,
): Promise<void> {
const recorded = session.bound(bindType, pduObj.params.interface_version);
await session.sendReturn(pduObj, recorded.err ? 'ESME_RBINDFAIL' : 'ESME_ROK', identity, bindRespTlvs(session, options));
}
async function onBind( async function onBind(
session: Session, session: Session,
pduObj: PduObject, pduObj: PduObject,
@@ -198,7 +186,16 @@ async function onBind(
return; return;
} }
await acceptBind(session, pduObj, bindType, options, identity); const recorded = session.bound(bindType, pduObj.params.interface_version);
if (recorded.err) {
session.log.info('server - bind refused', { message: recorded.err.message, systemId });
await session.sendReturn(pduObj, 'ESME_RBINDFAIL', identity);
return;
}
await session.sendReturn(pduObj, 'ESME_ROK', identity, bindRespTlvs(session, options));
session.log.verbose('server - bound', { systemId }); session.log.verbose('server - bound', { systemId });
} }
+2 -4
View File
@@ -123,16 +123,14 @@ export const undeclaredInterfaceVersion = 0x00;
export type SessionBind = { as: BindType; peerVersion: number }; export type SessionBind = { as: BindType; peerVersion: number };
const bindTypes: readonly string[] = ['receiver', 'transceiver', 'transmitter'];
function isBindType(value: unknown): value is BindType { function isBindType(value: unknown): value is BindType {
return typeof value === 'string' && bindTypes.includes(value); return typeof value === 'string' && bindTypeFromCommand(`bind_${value}`) !== undefined;
} }
/** A bind as `Session.bound()` records it: undefined declares no version, which is pre-3.4. */ /** A bind as `Session.bound()` records it: undefined declares no version, which is pre-3.4. */
export function checkedBind(bindType: unknown, declaredVersion: unknown): Result<{ bind: SessionBind }> { export function checkedBind(bindType: unknown, declaredVersion: unknown): Result<{ bind: SessionBind }> {
if (!isBindType(bindType)) { if (!isBindType(bindType)) {
return { err: new Error(`bindType must be ${bindTypes.join(', ')}, got ${namedValue(bindType)}`) }; return { err: new Error(`bindType must be receiver, transceiver or transmitter, got ${namedValue(bindType)}`) };
} }
if (declaredVersion === undefined) return { bind: { as: bindType, peerVersion: undeclaredInterfaceVersion } }; if (declaredVersion === undefined) return { bind: { as: bindType, peerVersion: undeclaredInterfaceVersion } };