Skip to content

Commit

Permalink
Colors
Browse files Browse the repository at this point in the history
  • Loading branch information
LuKks committed Oct 21, 2024
1 parent a6b2507 commit b281495
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const Protomux = require('protomux')
const HypercoreId = require('hypercore-id-encoding')
const crypto = require('hypercore-crypto')
const safetyCatch = require('safety-catch')
const crayon = require('tiny-crayon')
const { ShellServer, ShellClient } = require('./lib/protocols/shell.js')
const Copy = require('./lib/protocols/copy.js')
const Tunnel = require('./lib/protocols/tunnel.js')
Expand Down Expand Up @@ -137,7 +138,7 @@ class Server {
this._connections.add(socket)

if (this.verbose) {
console.log('Connection opened', HypercoreId.encode(socket.remotePublicKey))
console.log(crayon.green('Connection opened'), HypercoreId.encode(socket.remotePublicKey), '(' + this._connections.size + ')')
}

socket.setKeepAlive(5000)
Expand All @@ -148,7 +149,7 @@ class Server {
this._connections.delete(socket)

if (this.verbose) {
console.log('Connection closed', HypercoreId.encode(socket.remotePublicKey))
console.log(crayon.gray('Connection closed'), HypercoreId.encode(socket.remotePublicKey), '(' + this._connections.size + ')')
}
})

Expand All @@ -167,7 +168,7 @@ class Server {
for (const [publicKey] of this.invites) {
if (remotePublicKey.equals(Buffer.from(publicKey, 'hex'))) {
if (this.verbose) {
console.log('Invite accepted:', HypercoreId.encode(remotePublicKey))
console.log(crayon.cyan('Invite accepted'), HypercoreId.encode(remotePublicKey))
}

this.invites.delete(publicKey)
Expand All @@ -183,7 +184,7 @@ class Server {
}

if (this.verbose) {
console.log('Firewall denied:', HypercoreId.encode(remotePublicKey))
console.log(crayon.red('Connection denied'), HypercoreId.encode(remotePublicKey))
}

return true
Expand Down
3 changes: 2 additions & 1 deletion lib/bin/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs')
const path = require('path')
const crypto = require('hypercore-crypto')
const z32 = require('z32')
const crayon = require('tiny-crayon')
const constants = require('../constants.js')
const keygen = require('./keygen.js')
const Hypershell = require('../../index.js')
Expand Down Expand Up @@ -29,7 +30,7 @@ module.exports = async function login (keyOrName, opts = {}) {

const invite = await admin.createInvite()

console.log('One time invite:', z32.encode(invite))
console.log('One time invite:', crayon.cyan(z32.encode(invite)))

await admin.close()
await hs.destroy()
Expand Down
2 changes: 1 addition & 1 deletion lib/bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = async function server (opts = {}) {

if (server.protocols.includes('shell')) {
console.log('To connect to this shell, on another computer run:')
console.log('hypershell login ' + HypercoreId.encode(server.publicKey))
console.log(crayon.cyan('hypershell login ' + HypercoreId.encode(server.publicKey)))
} else {
console.log('Running server with restricted protocols:', server.protocols.join(', '))
console.log('Server key: ' + HypercoreId.encode(server.publicKey))
Expand Down

0 comments on commit b281495

Please sign in to comment.