44 lines
975 B
JavaScript
44 lines
975 B
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 检查IP和DNS ===\n');
|
|
|
|
conn.exec('curl -s ifconfig.me', (err, stream) => {
|
|
if (err) {
|
|
console.log('获取公网IP失败:', err.message);
|
|
} else {
|
|
stream.on('data', (data) => {
|
|
console.log('公网IP:', data.toString());
|
|
});
|
|
}
|
|
|
|
stream.on('close', () => {
|
|
conn.exec('nslookup hs.yifenbao.cn', (err, stream2) => {
|
|
if (err) {
|
|
console.log('DNS解析失败:', err.message);
|
|
} else {
|
|
stream2.on('data', (data2) => {
|
|
console.log('\nDNS解析:', data2.toString());
|
|
});
|
|
}
|
|
|
|
stream2.on('close', () => {
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |