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
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:
+2
-3
@@ -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
|
||||
under, for `alert_on_msg_delivery` and `failed_broadcast_area_identifier`, which are gone from
|
||||
`tlvs` too.
|
||||
- **`session.loggedIn` is gone**: read `session.boundAs !== undefined`. `boundAs` and
|
||||
`peerInterfaceVersion` are read-only; a session you construct yourself records a bind with
|
||||
`session.bound()`.
|
||||
- **`session.loggedIn` is gone**: read `session.boundAs !== undefined`. A session you construct
|
||||
yourself records a bind with `session.bound()`.
|
||||
- **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
|
||||
a `larvitutils` one, and is silent by default: [README](README.md#logging).
|
||||
|
||||
+10
-13
@@ -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(
|
||||
session: Session,
|
||||
pduObj: PduObject,
|
||||
@@ -198,7 +186,16 @@ async function onBind(
|
||||
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 });
|
||||
}
|
||||
|
||||
|
||||
@@ -123,16 +123,14 @@ export const undeclaredInterfaceVersion = 0x00;
|
||||
|
||||
export type SessionBind = { as: BindType; peerVersion: number };
|
||||
|
||||
const bindTypes: readonly string[] = ['receiver', 'transceiver', 'transmitter'];
|
||||
|
||||
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. */
|
||||
export function checkedBind(bindType: unknown, declaredVersion: unknown): Result<{ bind: SessionBind }> {
|
||||
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 } };
|
||||
|
||||
Reference in New Issue
Block a user