Commit ff9263f1 authored by CompileNix's avatar CompileNix

Fix write output error

parent f8b7cd63
*.txt
node_modules
*.html
*.log
*.log*
*.swp
......@@ -18,6 +18,8 @@ class FtpScanner {
this.outFileJson = outFileJson;
this.ipAddresses = ipAddresses;
this.ipAddressesCount = ipAddresses.length;
this.outputBuffer = "";
this.done = false;
}
/**
......@@ -36,7 +38,7 @@ class FtpScanner {
"<h3>\n<a href=\"//" + targetDomain + "/" + urlRelativeBasePath + "\">" + targetDomain + "/" + urlRelativeBasePath + "</a><br>\n</h3>\n" +
"<p>\n" +
"ftpscan archive: <a href=\"//" + targetDomain + "/" + urlRelativeBasePath + "/" + urlRelativeArchivePath + "\">" + targetDomain + "/" + urlRelativeBasePath + "/" + urlRelativeArchivePath + "/</a><br>\n" +
"</p>";
"</p>\n";
this.WriteHtmlToOutputFile(header);
this.UpdateStdOut(true);
......@@ -47,7 +49,8 @@ class FtpScanner {
if (this.ipAddresses.length > 0) {
(() => this.ProcessJob())();
} else {
} else if (!this.done) {
this.done = true;
process.stdout.write('\n');
}
}
......@@ -59,6 +62,8 @@ class FtpScanner {
if (force || (this.ipAddresses.length % 10 === 0)) {
this.ResetCursor();
readline.cursorTo(process.stdout, 0);
process.stdout.write(" ");
readline.cursorTo(process.stdout, 0);
process.stdout.write(this.ipAddresses.length.toString());
}
}
......@@ -71,20 +76,15 @@ class FtpScanner {
* @param {string} content
*/
AppendHtmlToOutputFile(content) {
fs.appendFileSync(this.outFileHtml, content, {
encoding: "utf8",
flag: fs.constants.O_APPEND
});
fs.appendFileSync(this.outFileHtml, content, { encoding: "utf8" });
//this.outputBuffer += content;
}
/**
* @param {string} content
*/
WriteHtmlToOutputFile(content) {
fs.writeFileSync(this.outFileHtml, content, {
encoding: "utf8",
flag: fs.constants.O_WRONLY
});
fs.appendFileSync(this.outFileHtml, content, { encoding: "utf8" });
}
/**
......@@ -117,6 +117,9 @@ class FtpScanner {
switch (error.code) {
case "ECONNREFUSED":
case "EHOSTUNREACH":
case "ECONNRESET":
case "ENOPROTOOPT":
break;
default:
console.log(error);
......
#!/bin/bash
targetPath="$1";
nodeExecutable=$(which node)
filePermissionUser="www";
filePermissionGroup="www";
filePermissionMode="0777";
mkdir -pv "${targetPath}/archive";
npm install;
while true
do
workingDir=$(pwd);
......@@ -16,7 +17,7 @@ do
currentDateTimeFormated=$(date +%Y-%m-%d_%H%M.%S);
echo "$currentDateTime";
node ftpscan.js;
npm start;
mv tmp.html "$targetPath/archive/${currentDateTimeFormated}.html";
#mv tmp.json "${targetPath}/${currentDateTimeFormated}.json";
......@@ -29,3 +30,4 @@ do
cd "$workingDir";
done
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment