xud
Version:
Exchange Union Daemon
164 lines • 7.58 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorCodes = void 0;
const errorCodesPrefix_1 = __importDefault(require("../constants/errorCodesPrefix"));
const addressUtils_1 = __importDefault(require("../utils/addressUtils"));
const codesPrefix = errorCodesPrefix_1.default.P2P;
const errorCodes = {
NODE_ALREADY_CONNECTED: codesPrefix.concat('.1'),
NOT_CONNECTED: codesPrefix.concat('.2'),
UNEXPECTED_NODE_PUB_KEY: codesPrefix.concat('.3'),
ATTEMPTED_CONNECTION_TO_SELF: codesPrefix.concat('.4'),
EXTERNAL_IP_UNRETRIEVABLE: codesPrefix.concat('.5'),
CONNECTION_RETRIES_MAX_PERIOD_EXCEEDED: codesPrefix.concat('.6'),
CONNECTION_RETRIES_REVOKED: codesPrefix.concat('.7'),
COULD_NOT_CONNECT: codesPrefix.concat('.7'),
NODE_UNKNOWN: codesPrefix.concat('.8'),
NODE_ALREADY_BANNED: codesPrefix.concat('.9'),
NODE_NOT_BANNED: codesPrefix.concat('.10'),
NODE_IS_BANNED: codesPrefix.concat('.11'),
ALREADY_CONNECTING: codesPrefix.concat('.12'),
RESPONSE_TIMEOUT: codesPrefix.concat('.13'),
AUTH_FAILURE_INVALID_TARGET: codesPrefix.concat('.14'),
AUTH_FAILURE_INVALID_SIGNATURE: codesPrefix.concat('.15'),
PARSER_INVALID_PACKET: codesPrefix.concat('.16'),
PARSER_UNKNOWN_PACKET_TYPE: codesPrefix.concat('.17'),
PARSER_DATA_INTEGRITY_ERR: codesPrefix.concat('.18'),
PARSER_MAX_BUFFER_SIZE_EXCEEDED: codesPrefix.concat('.19'),
FRAMER_MSG_NOT_ENCRYPTED: codesPrefix.concat('.`20'),
FRAMER_INVALID_NETWORK_MAGIC_VALUE: codesPrefix.concat('.21'),
FRAMER_INCOMPATIBLE_MSG_ORIGIN_NETWORK: codesPrefix.concat('.22'),
FRAMER_INVALID_MSG_LENGTH: codesPrefix.concat('.23'),
POOL_CLOSED: codesPrefix.concat('.24'),
NODE_TOR_ADDRESS: codesPrefix.concat('.25'),
ALIAS_CONFLICT: codesPrefix.concat('.26'),
UNKNOWN_ALIAS: codesPrefix.concat('.27'),
};
exports.errorCodes = errorCodes;
const errors = {
NODE_ALREADY_CONNECTED: (nodePubKey, address) => ({
message: `node ${nodePubKey} at ${addressUtils_1.default.toString(address)} already connected`,
code: errorCodes.NODE_ALREADY_CONNECTED,
}),
NOT_CONNECTED: (nodePubKey) => ({
message: `node ${nodePubKey} is not connected`,
code: errorCodes.NOT_CONNECTED,
}),
NODE_TOR_ADDRESS: (nodePubKey, address) => ({
message: `can't connect to node ${nodePubKey} at tor address ${addressUtils_1.default.toString(address)} because tor is disabled`,
code: errorCodes.NODE_TOR_ADDRESS,
}),
UNEXPECTED_NODE_PUB_KEY: (nodePubKey, expectedNodePubKey, address) => ({
message: `node at ${address} sent pub key ${nodePubKey}, expected ${expectedNodePubKey}`,
code: errorCodes.UNEXPECTED_NODE_PUB_KEY,
}),
MALFORMED_VERSION: (address, peerVersion) => ({
message: `node at ${address} has version ${peerVersion}, which is malformed, should be in semantic format`,
code: errorCodes.UNEXPECTED_NODE_PUB_KEY,
}),
INCOMPATIBLE_VERSION: (address, minCompatibleVersion, peerVersion) => ({
message: `node at ${address} has version ${peerVersion}, expected minimum ${minCompatibleVersion}`,
code: errorCodes.UNEXPECTED_NODE_PUB_KEY,
}),
ATTEMPTED_CONNECTION_TO_SELF: {
message: 'cannot attempt connection to self',
code: errorCodes.ATTEMPTED_CONNECTION_TO_SELF,
},
EXTERNAL_IP_UNRETRIEVABLE: (err) => ({
message: `could not retrieve external IP: ${err.message}`,
code: errorCodes.EXTERNAL_IP_UNRETRIEVABLE,
}),
CONNECTION_RETRIES_MAX_PERIOD_EXCEEDED: {
message: 'Connection retry attempts to peer exceeded maximum time allotment',
code: errorCodes.CONNECTION_RETRIES_MAX_PERIOD_EXCEEDED,
},
CONNECTION_RETRIES_REVOKED: {
message: 'Connection retry attempts to peer were revoked',
code: errorCodes.CONNECTION_RETRIES_REVOKED,
},
COULD_NOT_CONNECT: (address, err) => ({
message: `could not connect to peer at ${addressUtils_1.default.toString(address)}: ${err.message}`,
code: errorCodes.COULD_NOT_CONNECT,
}),
NODE_NOT_FOUND: (nodePubKey) => ({
message: `node with pub key ${nodePubKey} not found`,
code: errorCodes.NODE_UNKNOWN,
}),
NODE_ALREADY_BANNED: (nodePubKey) => ({
message: `node ${nodePubKey} has already been banned`,
code: errorCodes.NODE_ALREADY_BANNED,
}),
NODE_NOT_BANNED: (nodePubKey) => ({
message: `node ${nodePubKey} has not been banned`,
code: errorCodes.NODE_NOT_BANNED,
}),
NODE_IS_BANNED: (nodePubKey) => ({
message: `could not connect to node ${nodePubKey} because it is banned`,
code: errorCodes.NODE_IS_BANNED,
}),
ALREADY_CONNECTING: (nodePubKey) => ({
message: `there is already an existing connection attempt to node ${nodePubKey}`,
code: errorCodes.ALREADY_CONNECTING,
}),
RESPONSE_TIMEOUT: (request) => ({
message: `response timeout (${request}) `,
code: errorCodes.RESPONSE_TIMEOUT,
}),
AUTH_FAILURE_INVALID_TARGET: (nodePubKey, target) => ({
message: `could not authenticate peer ${nodePubKey}: invalid target (${target})`,
code: errorCodes.AUTH_FAILURE_INVALID_TARGET,
}),
AUTH_FAILURE_INVALID_SIGNATURE: (nodePubKey) => ({
message: `could not authenticate peer ${nodePubKey}: invalid signature`,
code: errorCodes.AUTH_FAILURE_INVALID_SIGNATURE,
}),
PARSER_INVALID_PACKET: (packet) => ({
message: `parser: invalid packet: ${packet}`,
code: errorCodes.PARSER_INVALID_PACKET,
}),
PARSER_UNKNOWN_PACKET_TYPE: (packetType) => ({
message: `parser: unknown packet type: ${packetType}`,
code: errorCodes.PARSER_UNKNOWN_PACKET_TYPE,
}),
PARSER_DATA_INTEGRITY_ERR: (packet) => ({
message: `parser: packet data integrity error: ${packet}`,
code: errorCodes.PARSER_DATA_INTEGRITY_ERR,
}),
PARSER_MAX_BUFFER_SIZE_EXCEEDED: (size) => ({
message: `parser: max buffer size exceeded: ${size.toString()}`,
code: errorCodes.PARSER_MAX_BUFFER_SIZE_EXCEEDED,
}),
FRAMER_MSG_NOT_ENCRYPTED: {
message: 'framer: msg is not encrypted',
code: errorCodes.FRAMER_MSG_NOT_ENCRYPTED,
},
FRAMER_INVALID_NETWORK_MAGIC_VALUE: {
message: 'framer: msg has an invalid network magic value (might be encrypted)',
code: errorCodes.FRAMER_INVALID_NETWORK_MAGIC_VALUE,
},
FRAMER_INCOMPATIBLE_MSG_ORIGIN_NETWORK: (expected, found) => ({
message: `framer: incompatible msg origin network (expected: ${expected}, found: ${found})`,
code: errorCodes.FRAMER_INCOMPATIBLE_MSG_ORIGIN_NETWORK,
}),
FRAMER_INVALID_MSG_LENGTH: (expected, found) => ({
message: `framer: invalid msg length (expected: ${expected}, found: ${found})`,
code: errorCodes.FRAMER_INVALID_MSG_LENGTH,
}),
POOL_CLOSED: {
message: 'p2p pool is closed and not accepting new peers',
code: errorCodes.POOL_CLOSED,
},
ALIAS_CONFLICT: (alias) => ({
message: `alias ${alias} refers to more than one node`,
code: errorCodes.ALIAS_CONFLICT,
}),
ALIAS_NOT_FOUND: (alias) => ({
message: `node with alias ${alias} not found`,
code: errorCodes.UNKNOWN_ALIAS,
}),
};
exports.default = errors;
//# sourceMappingURL=errors.js.map