Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 1x 1x 1x 3x 3x 3x 3x 1x 1x 1x 3x 3x 3x 1x 1x 1x 3x 3x 3x 3x 3x 3x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 9x 9x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 2x 2x 1x 1x 1x 1x 1x | "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Client = exports.AuthLevel = exports.Direction = exports.ConnectionMode = void 0;
const util_1 = require("util");
const crypto_1 = require("crypto");
const logger_1 = require("./logger");
class Action {
constructor() {
this.id = null;
this.subid = null;
this.is_strong = false;
this.valid_until = null;
this.func = null;
}
equals(other) {
return this.id === other.id && this.subid === other.subid;
}
}
class Challenge {
constructor() {
this.min = null;
this.max = null;
this.data = null;
this.proof = null;
this.nonce = null;
}
}
var ConnectionMode;
(function (ConnectionMode) {
ConnectionMode[ConnectionMode["Disconnected"] = 0] = "Disconnected";
ConnectionMode[ConnectionMode["Connecting"] = 1] = "Connecting";
ConnectionMode[ConnectionMode["Connected"] = 2] = "Connected";
ConnectionMode[ConnectionMode["Authenticated"] = 3] = "Authenticated";
})(ConnectionMode || (exports.ConnectionMode = ConnectionMode = {}));
var Direction;
(function (Direction) {
Direction[Direction["Unknown"] = 0] = "Unknown";
Direction[Direction["Inbound"] = 1] = "Inbound";
Direction[Direction["Outbound"] = 2] = "Outbound";
})(Direction || (exports.Direction = Direction = {}));
var AuthLevel;
(function (AuthLevel) {
AuthLevel[AuthLevel["NotAuthenticated"] = 0] = "NotAuthenticated";
AuthLevel[AuthLevel["SentChallenge"] = 1] = "SentChallenge";
AuthLevel[AuthLevel["ReceivedChallenge"] = 2] = "ReceivedChallenge";
AuthLevel[AuthLevel["SentId"] = 4] = "SentId";
AuthLevel[AuthLevel["ReceivedId"] = 8] = "ReceivedId";
AuthLevel[AuthLevel["Authenticated"] = 15] = "Authenticated";
})(AuthLevel || (exports.AuthLevel = AuthLevel = {}));
class Client {
constructor(uuid = null) {
// Unmapped
this.node = null;
// Connection
this.connMode = ConnectionMode.Disconnected;
this.connMsg = null;
// Direction
this.dirMode = Direction.Unknown;
// Auth
this.auth = AuthLevel.NotAuthenticated;
this.actions = [];
this.cash = null;
this.socket = null;
this.uuid = uuid || (0, crypto_1.randomUUID)();
this.challenge = new Challenge();
this._logger = logger_1.LoggerFactory.getInstance().createLogger('client');
this._logger.info((0, util_1.format)('constructor(%s)', this.uuid));
}
toString() {
return (0, util_1.format)('Client(%s,%s:%d,ID=%s)', this.uuid, this.address, this.port, this.id);
}
toJSON() {
this._logger.info((0, util_1.format)('toJSON(%s)', this.uuid));
return {
address: this.address,
port: this.port,
id: this.id,
seen_at: this.seenAt,
used_at: this.usedAt,
meetings: this.meetings,
is_bootstrap: this.isBootstrap,
is_trusted: this.isTrusted,
debug_add: this.debugAdd,
};
}
fromJSON(data, key) {
this._logger.info((0, util_1.format)('fromJSON(%s)', key));
const _mapped = data;
this.uuid = key;
this.address = _mapped.address;
this.port = _mapped.port;
this.id = _mapped.id;
this.seenAt = _mapped.seenAt;
this.usedAt = _mapped.usedAt;
this.meetings = _mapped.meetings;
this.isBootstrap = _mapped.isBootstrap;
this.isTrusted = _mapped.isTrusted;
this.debugAdd = _mapped.debugAdd;
}
equals(other) {
return this.uuid === other.uuid;
}
reset() {
this._logger.info((0, util_1.format)('reset(%s)', this.uuid));
this.connMode = ConnectionMode.Disconnected;
this.connMsg = null;
this.auth = AuthLevel.NotAuthenticated;
this.actions = [];
this.challenge = new Challenge();
this.cash = null;
}
hasContact() {
return this.address !== undefined && this.port !== undefined;
}
refreshSeenAt() {
this._logger.info((0, util_1.format)('refreshSeenAt(%s)', this.uuid));
this.seenAt = new Date();
}
refreshUsedAt() {
this._logger.info((0, util_1.format)('refreshUsedAt(%s)', this.uuid));
this.usedAt = new Date();
}
incMeetings() {
this._logger.info((0, util_1.format)('incMeetings(%s)', this.uuid));
this.meetings = (this.meetings || 0) + 1;
}
}
exports.Client = Client;
|