ssh-tunneling
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -1,32 +0,12 @@ | ||
declare const logger: { | ||
success(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
purple(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
cyan(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
error(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
info(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
warn(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
lightWhite(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
bgBlack(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
bgRed(content: any, options?: { | ||
newLine?: boolean; | ||
}): void; | ||
type LogType = 'success' | 'purple' | 'cyan' | 'error' | 'info' | 'warn' | 'bgBlack' | 'bgRed' | 'lightWhite'; | ||
type Logger = Record<LogType, (content: any, options?: { | ||
newLine?: boolean; | ||
}) => void> & { | ||
/** log one line */ | ||
line: (logs: { | ||
type?: LogType; | ||
content: any; | ||
}[]) => void; | ||
}; | ||
export declare function padRight(str: string, length: number, padStr?: string): string; | ||
export declare function padLeft(str: string, length: number, padStr?: string): string; | ||
declare const logger: Logger; | ||
export default logger; |
@@ -44,3 +44,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.padLeft = exports.padRight = void 0; | ||
function colorOutput(options) { | ||
@@ -57,80 +56,53 @@ const { fontColor, bgColor, newLine = true, content } = options; | ||
} | ||
const logger = { | ||
success(content, options) { | ||
// 46 | ||
colorOutput({ | ||
fontColor: 46, | ||
...options, | ||
content | ||
}); | ||
const config = { | ||
success: { | ||
fontColor: 46, | ||
}, | ||
purple(content, options) { | ||
// 57 | ||
colorOutput({ | ||
fontColor: 57, | ||
...options, | ||
content | ||
}); | ||
purple: { | ||
fontColor: 57, | ||
}, | ||
cyan(content, options) { | ||
// 87 | ||
colorOutput({ | ||
fontColor: 87, | ||
...options, | ||
content | ||
}); | ||
cyan: { | ||
fontColor: 87, | ||
}, | ||
error(content, options) { | ||
// 196 | ||
colorOutput({ | ||
fontColor: 196, | ||
...options, | ||
content | ||
}); | ||
error: { | ||
fontColor: 196, | ||
}, | ||
info(content, options) { | ||
// 15 | ||
colorOutput({ | ||
fontColor: 15, | ||
...options, | ||
content | ||
}); | ||
info: { | ||
fontColor: 15, | ||
}, | ||
warn(content, options) { | ||
colorOutput({ | ||
fontColor: 184, | ||
...options, | ||
content | ||
}); | ||
warn: { | ||
fontColor: 184, | ||
}, | ||
bgBlack: { | ||
fontColor: 255, | ||
bgColor: 232 | ||
}, | ||
bgRed: { | ||
fontColor: 255, | ||
bgColor: 196 | ||
}, | ||
lightWhite: {} | ||
}; | ||
const logger = { | ||
...Object.entries(config).reduce((pre, [type, config]) => { | ||
const { fontColor, bgColor } = config; | ||
pre[type] = (content, options) => { | ||
colorOutput({ | ||
fontColor, | ||
bgColor, | ||
...options, | ||
content | ||
}); | ||
}; | ||
return pre; | ||
}, {}), | ||
lightWhite(content, options) { | ||
console.log(`\x1b[2m$%s\x1b[0m`, content); | ||
}, | ||
bgBlack(content, options) { | ||
// 232 | ||
colorOutput({ | ||
fontColor: 255, | ||
bgColor: 232, | ||
...options, | ||
content | ||
line(logs) { | ||
logs.forEach((log, i) => { | ||
logger[log.type || 'info'](log.content, { newLine: i === logs.length - 1 }); | ||
}); | ||
}, | ||
bgRed(content, options) { | ||
// 196 | ||
colorOutput({ | ||
fontColor: 255, | ||
bgColor: 196, | ||
...options, | ||
content | ||
}); | ||
}, | ||
} | ||
}; | ||
function padRight(str, length, padStr) { | ||
return `${str}${(padStr || ' ').repeat(length - str.length)}`; | ||
} | ||
exports.padRight = padRight; | ||
function padLeft(str, length, padStr) { | ||
return `${(padStr || ' ').repeat(length - str.length)}${str}`; | ||
} | ||
exports.padLeft = padLeft; | ||
// logger.bgRed({a:1}, { newLine: false }); | ||
@@ -141,2 +113,24 @@ // logger.success({a:2,d:{f:{a:1}}}); | ||
// logger.info(padRight('', 50)); | ||
// logger.line([ | ||
// { | ||
// type: 'bgBlack', | ||
// content: 'bgBlack' | ||
// }, | ||
// { | ||
// type: 'bgRed', | ||
// content: 'bgRed' | ||
// }, | ||
// { | ||
// type: 'cyan', | ||
// content: 'cyan' | ||
// }, | ||
// { | ||
// type: 'error', | ||
// content: 'error' | ||
// }, | ||
// { | ||
// type: 'purple', | ||
// content: 'purple' | ||
// } | ||
// ]); | ||
exports.default = logger; |
export declare const checkPortAvailable: (port: number) => Promise<unknown>; | ||
export declare const getAvailablePort: (port: number) => any; | ||
export declare function padRight(str: string, length: number, padStr?: string): string; | ||
export declare function padLeft(str: string, length: number, padStr?: string): string; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAvailablePort = exports.checkPortAvailable = void 0; | ||
exports.padLeft = exports.padRight = exports.getAvailablePort = exports.checkPortAvailable = void 0; | ||
const net_1 = __importDefault(require("net")); | ||
@@ -36,1 +36,15 @@ const checkPortAvailable = (port) => { | ||
exports.getAvailablePort = getAvailablePort; | ||
function padRight(str, length, padStr) { | ||
if (isNaN(str.length) || length - str.length < 0) { | ||
return str; | ||
} | ||
return `${str}${(padStr || ' ').repeat(length - str.length)}`; | ||
} | ||
exports.padRight = padRight; | ||
function padLeft(str, length, padStr) { | ||
if (isNaN(str.length) || length - str.length < 0) { | ||
return str; | ||
} | ||
return `${(padStr || ' ').repeat(length - str.length)}${str}`; | ||
} | ||
exports.padLeft = padLeft; |
{ | ||
"private": false, | ||
"name": "ssh-tunneling", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "a ssh-tunneling client for nodejs", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -24,6 +24,7 @@ # Ssh tunneling for nodejs | ||
- host: [**required**] ssh ip | ||
- port: [**required**] ssh port | ||
- username: [**required**] ssh user name | ||
- privateKey: [**required**] ssh private key | ||
- host: <**required**> ssh ip | ||
- port: <**required**> ssh port | ||
- username: <**required**> ssh user name | ||
- privateKey: [**optional**] ssh private key | ||
- password: [**optional**] ssh password | ||
- hoppingServer: [**optional**] Currently it just supports the socks4 or socks5 server,such as 'socks5://180.80.80.80:1080' or 'socks4://180.80.80.80:1080' | ||
@@ -30,0 +31,0 @@ |
269
36584
708