From 53b0d661a9e23e05b0ee95b7377e1249751c38a1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 9 Jan 2022 16:30:42 +0000 Subject: [PATCH] replace logging system ...I'm so picky --- package-lock.json | 500 -------------------- package.json | 2 - src/cli.mjs | 10 +- src/lib/agent/Agent.mjs | 8 +- src/lib/agent/Peer.mjs | 4 +- src/lib/agent/PeerServer.mjs | 11 +- src/lib/transport/Connection.mjs | 7 +- src/lib/transport/FramedTransport.mjs | 3 +- src/lib/transport/rekey.mjs | 3 +- src/subcommands/agent/agent.mjs | 12 +- src/subcommands/test-client/test-client.mjs | 12 +- src/subcommands/test-server/test-server.mjs | 8 +- 12 files changed, 45 insertions(+), 535 deletions(-) diff --git a/package-lock.json b/package-lock.json index f334d3f..1005b18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,6 @@ "@ltd/j-toml": "^1.24.0", "applause-cli": "^1.7.0", "jpake": "^1.0.1", - "log": "^6.3.1", - "log-node": "^8.0.3", "nexline": "^1.2.2", "p-queue": "^7.1.0", "p-retry": "^5.0.0", @@ -36,157 +34,21 @@ "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz", "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==" }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "engines": { - "node": ">=8" - } - }, "node_modules/applause-cli": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/applause-cli/-/applause-cli-1.7.0.tgz", "integrity": "sha512-zO/nBR9x37Iqlm3R2Glo0NyDIevwbDPrISprK61Z/M01Xvm5dFkL2FZAONxxHctT9QoF71fiY22sFRuq8Sqxug==" }, - "node_modules/cli-color": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.1.tgz", - "integrity": "sha512-eBbxZF6fqPUNnf7CLAFOersUnyYzv83tHFLSlts+OAHsNendaqv2tHCq+/MO+b3Y+9JeoUlIvobyxG/Z8GNeOg==", - "dependencies": { - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "es6-iterator": "^2.0.3", - "memoizee": "^0.4.15", - "timers-ext": "^0.1.7" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/cli-sprintf-format": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/cli-sprintf-format/-/cli-sprintf-format-1.1.1.tgz", - "integrity": "sha512-BbEjY9BEdA6wagVwTqPvmAwGB24U93rQPBFZUT8lNCDxXzre5LFHQUTJc70czjgUomVg8u8R5kW8oY9DYRFNeg==", - "dependencies": { - "cli-color": "^2.0.1", - "es5-ext": "^0.10.53", - "sprintf-kit": "^2.0.1", - "supports-color": "^6.1.0" - }, - "engines": { - "node": ">=6.0" - } - }, - "node_modules/cli-sprintf-format/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "engines": { - "node": ">=4" - } - }, - "node_modules/cli-sprintf-format/node_modules/supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/crypto-js": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz", "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" }, - "node_modules/d": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "dependencies": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - } - }, - "node_modules/d/node_modules/type": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" - }, - "node_modules/duration": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/duration/-/duration-0.2.2.tgz", - "integrity": "sha512-06kgtea+bGreF5eKYgI/36A6pLXggY7oR4p1pq4SmdFBn1ReOL5D8RhG64VrqfTTKNucqqtBAwEj8aB88mcqrg==", - "dependencies": { - "d": "1", - "es5-ext": "~0.10.46" - } - }, - "node_modules/es5-ext": { - "version": "0.10.53", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", - "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", - "dependencies": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.3", - "next-tick": "~1.0.0" - } - }, - "node_modules/es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "node_modules/es6-symbol": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", - "dependencies": { - "d": "^1.0.1", - "ext": "^1.1.2" - } - }, - "node_modules/es6-weak-map": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", - "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", - "dependencies": { - "d": "1", - "es5-ext": "^0.10.46", - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.1" - } - }, - "node_modules/event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "dependencies": { - "d": "1", - "es5-ext": "~0.10.14" - } - }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" }, - "node_modules/ext": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz", - "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", - "dependencies": { - "type": "^2.5.0" - } - }, "node_modules/fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -205,14 +67,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==" }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "engines": { - "node": ">=8" - } - }, "node_modules/iconv-lite": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.2.tgz", @@ -224,11 +78,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-promise": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", - "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" - }, "node_modules/jpake": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/jpake/-/jpake-1.0.1.tgz", @@ -247,69 +96,6 @@ "graceful-fs": "^4.1.6" } }, - "node_modules/log": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/log/-/log-6.3.1.tgz", - "integrity": "sha512-McG47rJEWOkXTDioZzQNydAVvZNeEkSyLJ1VWkFwfW+o1knW+QSi8D1KjPn/TnctV+q99lkvJNe1f0E1IjfY2A==", - "dependencies": { - "d": "^1.0.1", - "duration": "^0.2.2", - "es5-ext": "^0.10.53", - "event-emitter": "^0.3.5", - "sprintf-kit": "^2.0.1", - "type": "^2.5.0", - "uni-global": "^1.0.0" - } - }, - "node_modules/log-node": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/log-node/-/log-node-8.0.3.tgz", - "integrity": "sha512-1UBwzgYiCIDFs8A0rM2QdBFo8Wd8UQ0HrSTu/MNI+/2zN3NoHRj2fhplurAyuxTYUXu3Oohugq1jAn5s05u1MQ==", - "dependencies": { - "ansi-regex": "^5.0.1", - "cli-color": "^2.0.1", - "cli-sprintf-format": "^1.1.1", - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "sprintf-kit": "^2.0.1", - "supports-color": "^8.1.1", - "type": "^2.5.0" - }, - "engines": { - "node": ">=10.0" - }, - "peerDependencies": { - "log": "^6.0.0" - } - }, - "node_modules/lru-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", - "dependencies": { - "es5-ext": "~0.10.2" - } - }, - "node_modules/memoizee": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", - "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", - "dependencies": { - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "es6-weak-map": "^2.0.3", - "event-emitter": "^0.3.5", - "is-promise": "^2.2.2", - "lru-queue": "^0.1.0", - "next-tick": "^1.1.0", - "timers-ext": "^0.1.7" - } - }, - "node_modules/memoizee/node_modules/next-tick": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" - }, "node_modules/nexline": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/nexline/-/nexline-1.2.2.tgz", @@ -322,11 +108,6 @@ "node": ">= 8.0.0" } }, - "node_modules/next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" - }, "node_modules/noble-secp256k1": { "version": "1.2.10", "resolved": "https://registry.npmjs.org/noble-secp256k1/-/noble-secp256k1-1.2.10.tgz", @@ -386,28 +167,6 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "node_modules/sprintf-kit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/sprintf-kit/-/sprintf-kit-2.0.1.tgz", - "integrity": "sha512-2PNlcs3j5JflQKcg4wpdqpZ+AjhQJ2OZEo34NXDtlB0tIPG84xaaXhpA8XFacFiwjKA4m49UOYG83y3hbMn/gQ==", - "dependencies": { - "es5-ext": "^0.10.53" - } - }, - "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, "node_modules/systeminformation": { "version": "5.9.4", "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.9.4.tgz", @@ -432,33 +191,11 @@ "url": "https://www.buymeacoffee.com/systeminfo" } }, - "node_modules/timers-ext": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", - "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", - "dependencies": { - "es5-ext": "~0.10.46", - "next-tick": "1" - } - }, "node_modules/tweetnacl": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, - "node_modules/type": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.5.0.tgz", - "integrity": "sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw==" - }, - "node_modules/uni-global": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/uni-global/-/uni-global-1.0.0.tgz", - "integrity": "sha512-WWM3HP+siTxzIWPNUg7hZ4XO8clKi6NoCAJJWnuRL+BAqyFXF8gC03WNyTefGoUXYc47uYgXxpKLIEvo65PEHw==", - "dependencies": { - "type": "^2.5.0" - } - }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -484,146 +221,21 @@ "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.1.tgz", "integrity": "sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g==" }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" - }, "applause-cli": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/applause-cli/-/applause-cli-1.7.0.tgz", "integrity": "sha512-zO/nBR9x37Iqlm3R2Glo0NyDIevwbDPrISprK61Z/M01Xvm5dFkL2FZAONxxHctT9QoF71fiY22sFRuq8Sqxug==" }, - "cli-color": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.1.tgz", - "integrity": "sha512-eBbxZF6fqPUNnf7CLAFOersUnyYzv83tHFLSlts+OAHsNendaqv2tHCq+/MO+b3Y+9JeoUlIvobyxG/Z8GNeOg==", - "requires": { - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "es6-iterator": "^2.0.3", - "memoizee": "^0.4.15", - "timers-ext": "^0.1.7" - } - }, - "cli-sprintf-format": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/cli-sprintf-format/-/cli-sprintf-format-1.1.1.tgz", - "integrity": "sha512-BbEjY9BEdA6wagVwTqPvmAwGB24U93rQPBFZUT8lNCDxXzre5LFHQUTJc70czjgUomVg8u8R5kW8oY9DYRFNeg==", - "requires": { - "cli-color": "^2.0.1", - "es5-ext": "^0.10.53", - "sprintf-kit": "^2.0.1", - "supports-color": "^6.1.0" - }, - "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" - }, - "supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", - "requires": { - "has-flag": "^3.0.0" - } - } - } - }, "crypto-js": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz", "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" }, - "d": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz", - "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", - "requires": { - "es5-ext": "^0.10.50", - "type": "^1.0.1" - }, - "dependencies": { - "type": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", - "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" - } - } - }, - "duration": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/duration/-/duration-0.2.2.tgz", - "integrity": "sha512-06kgtea+bGreF5eKYgI/36A6pLXggY7oR4p1pq4SmdFBn1ReOL5D8RhG64VrqfTTKNucqqtBAwEj8aB88mcqrg==", - "requires": { - "d": "1", - "es5-ext": "~0.10.46" - } - }, - "es5-ext": { - "version": "0.10.53", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz", - "integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==", - "requires": { - "es6-iterator": "~2.0.3", - "es6-symbol": "~3.1.3", - "next-tick": "~1.0.0" - } - }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "requires": { - "d": "1", - "es5-ext": "^0.10.35", - "es6-symbol": "^3.1.1" - } - }, - "es6-symbol": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", - "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", - "requires": { - "d": "^1.0.1", - "ext": "^1.1.2" - } - }, - "es6-weak-map": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz", - "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", - "requires": { - "d": "1", - "es5-ext": "^0.10.46", - "es6-iterator": "^2.0.3", - "es6-symbol": "^3.1.1" - } - }, - "event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "requires": { - "d": "1", - "es5-ext": "~0.10.14" - } - }, "eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" }, - "ext": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz", - "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", - "requires": { - "type": "^2.5.0" - } - }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -639,11 +251,6 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==" }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, "iconv-lite": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.2.tgz", @@ -652,11 +259,6 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "is-promise": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", - "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" - }, "jpake": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/jpake/-/jpake-1.0.1.tgz", @@ -675,65 +277,6 @@ "graceful-fs": "^4.1.6" } }, - "log": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/log/-/log-6.3.1.tgz", - "integrity": "sha512-McG47rJEWOkXTDioZzQNydAVvZNeEkSyLJ1VWkFwfW+o1knW+QSi8D1KjPn/TnctV+q99lkvJNe1f0E1IjfY2A==", - "requires": { - "d": "^1.0.1", - "duration": "^0.2.2", - "es5-ext": "^0.10.53", - "event-emitter": "^0.3.5", - "sprintf-kit": "^2.0.1", - "type": "^2.5.0", - "uni-global": "^1.0.0" - } - }, - "log-node": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/log-node/-/log-node-8.0.3.tgz", - "integrity": "sha512-1UBwzgYiCIDFs8A0rM2QdBFo8Wd8UQ0HrSTu/MNI+/2zN3NoHRj2fhplurAyuxTYUXu3Oohugq1jAn5s05u1MQ==", - "requires": { - "ansi-regex": "^5.0.1", - "cli-color": "^2.0.1", - "cli-sprintf-format": "^1.1.1", - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "sprintf-kit": "^2.0.1", - "supports-color": "^8.1.1", - "type": "^2.5.0" - } - }, - "lru-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", - "requires": { - "es5-ext": "~0.10.2" - } - }, - "memoizee": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", - "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", - "requires": { - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "es6-weak-map": "^2.0.3", - "event-emitter": "^0.3.5", - "is-promise": "^2.2.2", - "lru-queue": "^0.1.0", - "next-tick": "^1.1.0", - "timers-ext": "^0.1.7" - }, - "dependencies": { - "next-tick": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", - "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" - } - } - }, "nexline": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/nexline/-/nexline-1.2.2.tgz", @@ -743,11 +286,6 @@ "iconv-lite": "^0.5.0" } }, - "next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=" - }, "noble-secp256k1": { "version": "1.2.10", "resolved": "https://registry.npmjs.org/noble-secp256k1/-/noble-secp256k1-1.2.10.tgz", @@ -786,54 +324,16 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "sprintf-kit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/sprintf-kit/-/sprintf-kit-2.0.1.tgz", - "integrity": "sha512-2PNlcs3j5JflQKcg4wpdqpZ+AjhQJ2OZEo34NXDtlB0tIPG84xaaXhpA8XFacFiwjKA4m49UOYG83y3hbMn/gQ==", - "requires": { - "es5-ext": "^0.10.53" - } - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "requires": { - "has-flag": "^4.0.0" - } - }, "systeminformation": { "version": "5.9.4", "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.9.4.tgz", "integrity": "sha512-FOsiTn0CyJZoj9kIhla11ndsMzbbwwuriul81wpqIBt9IpbxHZ6P/oZCphIFgJrwqjTnme0Qp1HDzIkUD9Xr/g==" }, - "timers-ext": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz", - "integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==", - "requires": { - "es5-ext": "~0.10.46", - "next-tick": "1" - } - }, "tweetnacl": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, - "type": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.5.0.tgz", - "integrity": "sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw==" - }, - "uni-global": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/uni-global/-/uni-global-1.0.0.tgz", - "integrity": "sha512-WWM3HP+siTxzIWPNUg7hZ4XO8clKi6NoCAJJWnuRL+BAqyFXF8gC03WNyTefGoUXYc47uYgXxpKLIEvo65PEHw==", - "requires": { - "type": "^2.5.0" - } - }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", diff --git a/package.json b/package.json index e1861bc..fa30454 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,6 @@ "@ltd/j-toml": "^1.24.0", "applause-cli": "^1.7.0", "jpake": "^1.0.1", - "log": "^6.3.1", - "log-node": "^8.0.3", "nexline": "^1.2.2", "p-queue": "^7.1.0", "p-retry": "^5.0.0", diff --git a/src/cli.mjs b/src/cli.mjs index bab7747..7133c5f 100644 --- a/src/cli.mjs +++ b/src/cli.mjs @@ -3,8 +3,9 @@ import path from 'path'; import fs from 'fs'; -import l from 'log'; -import ln from 'log-node'; ln(); +import log_core from './lib/io/Log.mjs'; +import { LOG_LEVELS} from './lib/io/Log.mjs'; +import log from './lib/io/NamespacedLog.mjs'; const l = log("core"); import CliParser from 'applause-cli'; @@ -22,7 +23,8 @@ async function load_subcommands(cli) { export default async function () { let settings = (await import("./settings.mjs")).default; let cli = new CliParser(path.resolve(__dirname, "../package.json")); - cli.argument("verbose", "Enable verbose debugging output", null, "boolean"); + cli.argument("verbose", "Enable verbose debugging output", null, "boolean") + .argument("log-level", "Set the logging level (possible values: debug, info [default], log, warn, error, none)", "info", "string"); await load_subcommands(cli); @@ -31,6 +33,8 @@ export default async function () { if(cli.current_subcommand == null) cli.write_help_exit(); + log_core.level = LOG_LEVELS[settings.cli.log_level.toUpperCase()]; + let subcommand_file = path.join( __dirname, "subcommands", diff --git a/src/lib/agent/Agent.mjs b/src/lib/agent/Agent.mjs index 75862d9..65e474f 100644 --- a/src/lib/agent/Agent.mjs +++ b/src/lib/agent/Agent.mjs @@ -4,7 +4,7 @@ import fs from 'fs'; import os from 'os'; import path from 'path'; -import log from 'log'; const l = log.get("agent"); +import log from '../io/NamespacedLog.mjs'; const l = log("agent"); import settings from '../../settings.mjs'; @@ -44,17 +44,17 @@ class Agent { ); this.server.retries = this.config.net.peer_retries; - l.notice(`Starting peer listener....`); + l.log(`Starting peer listener....`); await this.server.listen( this.config.net.port, this.config.net.bind_address ); - l.notice(`Listening on ${this.config.net.bind_address}:${this.config.net.port}`); + l.log(`Listening on ${this.config.net.bind_address}:${this.config.net.port}`); await this.server.add_peers(...this.config.peers.map( peer => parse_peer_name(peer) )); - l.notice(`Added ${this.config.peers.length} initial peers`); + l.log(`Added ${this.config.peers.length} initial peers`); if(this.config.peers.length < 1) l.warn(`No initial peers were specified! It's recommended that you specify at least 1 on every host.`); } diff --git a/src/lib/agent/Peer.mjs b/src/lib/agent/Peer.mjs index 779ec53..6237177 100644 --- a/src/lib/agent/Peer.mjs +++ b/src/lib/agent/Peer.mjs @@ -2,7 +2,7 @@ import { EventEmitter, once } from 'events'; -import log from 'log'; const l = log.get("peer"); +import log from '../io/NamespacedLog.mjs'; const l = log("peer"); import Connection from '../transport/Connection.mjs'; @@ -41,7 +41,7 @@ class Peer extends EventEmitter { this.known_peers = []; this.once("connect", () => { - l.notice(`${this.connection.address}:${this.connection.port} connected`); + l.log(`${this.connection.address}:${this.connection.port} connected`); }); } diff --git a/src/lib/agent/PeerServer.mjs b/src/lib/agent/PeerServer.mjs index d1dfcf4..6ed0088 100644 --- a/src/lib/agent/PeerServer.mjs +++ b/src/lib/agent/PeerServer.mjs @@ -4,7 +4,8 @@ import { EventEmitter, once } from 'events'; import net from 'net'; import p_retry from 'p-retry'; -import log from 'log'; const l = log.get("peerserver"); + +import log from '../io/NamespacedLog.mjs'; const l = log("peerserver"); import settings from '../../settings.mjs'; import Connection from '../transport/Connection.mjs'; @@ -176,16 +177,16 @@ class PeerServer extends EventEmitter { * @return {Promise} A Promise that resolves to the resulting Peer connection, or null if the connection wasn't attemped. */ async __add_peer(address, port) { - l.notice(`Attempting to connect to ${address}:${port}`); + l.log(`Attempting to connect to ${address}:${port}`); // If we're already connected, don't bother reconnecting again if(this.peers().some(el => el.address === address && el.port === port)) { - l.notice(`A connection is already open to ${address}:${port}, skipping`); + l.log(`A connection is already open to ${address}:${port}, skipping`); return; } // If we are attempting to connect to ourselves, then don't bother if(address == this.host && port == this.port) { - l.notice(`${address}:${port} is actually us, skipping`); + l.log(`${address}:${port} is actually us, skipping`); return; } @@ -206,7 +207,7 @@ class PeerServer extends EventEmitter { if(conn === null) return null; - l.notice(`Peer ${conn.id_short} from ${address}:${port} connected`) + l.log(`Peer ${conn.id_short} from ${address}:${port} connected`) this.emit(`peer`, conn); return conn; } diff --git a/src/lib/transport/Connection.mjs b/src/lib/transport/Connection.mjs index 9554639..4e95768 100644 --- a/src/lib/transport/Connection.mjs +++ b/src/lib/transport/Connection.mjs @@ -4,8 +4,7 @@ import crypto from 'crypto'; import net from 'net'; import { EventEmitter, once } from 'events'; -import log from 'log'; -const l = log.get("connection"); +import log from '../io/NamespacedLog.mjs'; const l = log("connection"); import settings from '../../settings.mjs'; import rekey from './rekey.mjs'; @@ -62,7 +61,7 @@ class Connection extends EventEmitter { address, port }); this.socket.once("end", () => { - l.notice(`${this.address}:${this.port} disconnected`); + l.log(`${this.address}:${this.port} disconnected`); }); await once(this.socket, "connect"); @@ -111,7 +110,7 @@ class Connection extends EventEmitter { } async destroy() { - l.notice(`Killing connection to ${this.address}:${this.port}`, new Error().stack); + l.log(`Killing connection to ${this.address}:${this.port}`, new Error().stack); if(this.framer instanceof FramedTransport) await this.framer.destroy(); else { diff --git a/src/lib/transport/FramedTransport.mjs b/src/lib/transport/FramedTransport.mjs index 5eb2a4f..573f33d 100644 --- a/src/lib/transport/FramedTransport.mjs +++ b/src/lib/transport/FramedTransport.mjs @@ -3,8 +3,7 @@ import os from 'os'; import { EventEmitter, once } from 'events'; -import log from 'log'; -const l = log.get("framedtransport"); +import log from '../io/NamespacedLog.mjs'; const l = log("framedtransport"); import PQueue from 'p-queue'; diff --git a/src/lib/transport/rekey.mjs b/src/lib/transport/rekey.mjs index a767ea5..973522f 100644 --- a/src/lib/transport/rekey.mjs +++ b/src/lib/transport/rekey.mjs @@ -2,8 +2,7 @@ import { once } from 'events'; -import log from 'log'; -const l = log.get("rekey"); +import log from '../io/NamespacedLog.mjs'; const l = log("rekey"); import jpake from 'jpake'; export default async function rekey(connection, secret_join) { diff --git a/src/subcommands/agent/agent.mjs b/src/subcommands/agent/agent.mjs index fc83f72..c65e209 100644 --- a/src/subcommands/agent/agent.mjs +++ b/src/subcommands/agent/agent.mjs @@ -3,6 +3,8 @@ import fs from 'fs'; import path from 'path'; +import log from '../../lib/io/NamespacedLog.mjs'; const l = log("agent"); + import settings from '../../settings.mjs'; import toml_settings_read from '../../lib/io/TomlSettings.mjs'; @@ -13,7 +15,15 @@ const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/")); export default async function () { if(!fs.existsSync(settings.cli.config)) - throw new Error(`Error: The config file at '${settings.cli.config}' doesn't appear to exist, or we don't have permission to access it.`); + throw new Error(`Error: The config file at '${settings.cli.config}' doesn't appear to exist, or we don't have permission to access it.`); + + l.log(` +███████ ██ ██ ███████ ████████ ███████ ███ ███ ██████ ██ ██ ███████ ██████ ██ ██ +██ ██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ +███████ ████ ███████ ██ █████ ██ ████ ██ ██ ██ ██ ██ █████ ██████ ████ + ██ ██ ██ ██ ██ ██ ██ ██ ██ ▄▄ ██ ██ ██ ██ ██ ██ ██ +███████ ██ ███████ ██ ███████ ██ ██ ██████ ██████ ███████ ██ ██ ██ + ▀▀`); let config = toml_settings_read( path.join(__dirname, "config.default.toml"), diff --git a/src/subcommands/test-client/test-client.mjs b/src/subcommands/test-client/test-client.mjs index 44972d6..b21a984 100644 --- a/src/subcommands/test-client/test-client.mjs +++ b/src/subcommands/test-client/test-client.mjs @@ -2,7 +2,7 @@ import net from 'net'; -import l from 'log'; +import log from '../../io/NamespacedLog.mjs'; const l = log("test-client"); import settings from '../../settings.mjs'; import sleep from '../../lib/async/sleep.mjs'; @@ -13,18 +13,18 @@ export default async function() { const test_key = "H7xKSxvJFoZoNjCKAfxn4E3qUzY3Y/4bjY+qIzxg+78="; const test_key_bytes = Buffer.from(test_key, "base64"); const test_data = "hello, world"; - l.notice(`TEST_DATA`, test_data); + l.log(`TEST_DATA`, test_data); const encrypted = encrypt_bytes(test_key_bytes, Buffer.from(test_data, "utf-8")); - l.notice(`ENCRYPTED`, encrypted); + l.log(`ENCRYPTED`, encrypted); const decrypted = decrypt_bytes(test_key_bytes, encrypted); - l.notice(`DECRYPTED`, decrypted); - l.notice(`DECRYPTED_TEXT`, decrypted.toString("utf-8")); + l.log(`DECRYPTED`, decrypted); + l.log(`DECRYPTED_TEXT`, decrypted.toString("utf-8")); const socket = await Connection.Create(test_key, "::1", settings.cli.port); socket.on("message", (_event, _msg) => { // noop - // l.notice(`<<< ${event}: ${JSON.stringify(msg)}`); + // l.log(`<<< ${event}: ${JSON.stringify(msg)}`); }); diff --git a/src/subcommands/test-server/test-server.mjs b/src/subcommands/test-server/test-server.mjs index 5c439a5..6956bca 100644 --- a/src/subcommands/test-server/test-server.mjs +++ b/src/subcommands/test-server/test-server.mjs @@ -2,7 +2,7 @@ import net from 'net'; -import l from 'log'; +import log from '../../io/NamespacedLog.mjs'; const l = log("test-server"); import settings from '../../settings.mjs'; import Connection from '../../lib/transport/Connection.mjs'; @@ -11,12 +11,12 @@ export default async function() { const test_key = "H7xKSxvJFoZoNjCKAfxn4E3qUzY3Y/4bjY+qIzxg+78="; const server = net.createServer(async (client) => { - l.notice("client connected"); + l.log("client connected"); const connection = await Connection.Wrap(test_key, client); connection.send("test-server", "hello\n"); connection.on("message", (_event, _msg) => { // noop - //l.notice(`<<< ${event}: ${JSON.stringify(msg)}`); + //l.log(`<<< ${event}: ${JSON.stringify(msg)}`); }); let id = setInterval(async () => { const rt = await connection.send("test-server", (new Date()).toString()); @@ -26,5 +26,5 @@ export default async function() { }); server.on("error", (error) => { throw error; }); - server.listen(settings.cli.port, () => l.notice(`Listening on port ${settings.cli.port}`)); + server.listen(settings.cli.port, () => l.log(`Listening on port ${settings.cli.port}`)); }