- Akciókamerák
- Milyen TV-t vegyek?
- Kezdő fotósok digitális fényképei
- Amlogic S905, S912 processzoros készülékek
- Vezeték nélküli fülhallgatók
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Nem a Microsoft árazta be az Xbox kézikonzolokat
- Samsung Galaxy Tab S6 Lite 10.4 - az, ami
- Milyen széket vegyek?
- OLED TV topic
-
PROHARDVER!
Új hozzászólás Aktív témák
-
moli.hu
őstag
válasz
moli.hu #7979 üzenetére
Megirtam az elso nodejs kodomat, kerem, aki ert hozza, nezze at, hogy
--biztonsagos? nem csinaltam marhasagot?
--az async jol van irva, nem elozi be valamelyik sor amit nem kene?
--stilusos, igy kell-e kodolni nodejs-t?
--a timeoutok jo helyre vannak irva? (20 process, 10 transfer, 30 egyutt)
--a "httpd stopped" szoveg miert nem jon soha?http_createserver = require("http").createServer;
crypto_randombytes = require("crypto").pseudoRandomBytes;
url_parse = require("url").parse;
child_process_exec = require("child_process").exec;
os_hostname = require("os").hostname;
console.info (new Date().toISOString() + "\thttpd started");
var server = http_createserver (
function (IncomingMessage, ServerResponse) {
crypto_randombytes (16,
function (exception, buffer) {
if (exception) throw exception;
uniqueid = buffer.toString ("hex");
console.info (uniqueid + "\tdate: " + new Date().toISOString());
console.info (uniqueid + "\tremoteaddr: " + IncomingMessage.connection.remoteAddress);
ServerResponse.on ("close",
function () {
console.info (uniqueid + "\taborted");
}
);
ServerResponse.on ("finish",
function () {
console.info (uniqueid + "\tsent");
}
);
var querystring = url_parse(IncomingMessage.url, true).query;
if ("secret" && querystring.auth != "secret") {
ServerResponse.writeHead (404);
ServerResponse.end ();
console.info (uniqueid + "\tnoauth: " + IncomingMessage.url);
} else {
label = uniqueid + "\tgenerated";
if (querystring.hostname) console.info (uniqueid + "\thostname: " + querystring.hostname);
console.time (label);
child_process_exec ("rrd.sh graph '" + (querystring.hostname ? querystring.hostname : "") + "'", { encoding: "binary", maxBuffer: 10000000, timeout: 20000 },
function (error, stdout, stderr) {
console.timeEnd (label);
if (error !== null) {
ServerResponse.writeHead (500);
ServerResponse.end (error + stderr);
console.info (uniqueid + "\tnoexec: " + error.toString().replace (/[\r\n\t]+/gm, " "));
} else {
ServerResponse.setTimeout (10000);
ServerResponse.writeHead (200, { "content-type": "image/png", "content-length": stdout.length, "content-disposition": "inline; filename=\"" + (querystring.hostname ? querystring.hostname : os_hostname ()) + ".png\"" } );
ServerResponse.end (stdout, "binary");
console.info (uniqueid + "\tlength: " + stdout.length);
}
}
);
}
}
);
}
).listen (8000);
server.setTimeout (30000);
server.on ("close",
function () {
console.info (new Date().toISOString() + "\thttpd stopped");
}
);--ha nem irnek az elejere kulon sorba require-t, hanem a require-ket bele irnam a kod kozepebe, akkor az at jelentene, hogy ahanyszor odaer a kod, behuz egy ujabb instance-t a library-bol?
--a http 404 helyett tudok valahogy manualis timeout-ra futtatast csinalni vagy valami olyan valaszt szimulalni, mintha nem lenne ott a szerver?
--ugy olvastam, hogy az encoding binary deprecated, ezert mar bufferrel csinaltam meg a crypto-reszt, de mikor az exec-bol atadom a response-nak, azt a reszt hogy lehet atirni?
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
- Akciókamerák
- Suzuki topik
- One otthoni szolgáltatások (TV, internet, telefon)
- Spórolós topik
- Milyen TV-t vegyek?
- Hitelkártyák használata, hitelkártya visszatérítés
- Xbox Series X|S
- „Új mérce az Android világában” – Kezünkben a Vivo X300 és X300 Pro
- Okos Otthon / Smart Home
- Kezdő fotósok digitális fényképei
- További aktív témák...
- Apple Watch Ultra eladó
- BMW 325xi 3.0L sor6 218LE 2008
- ASRock Phantom Gaming RX 6950 XT 16 GB GDDR6 Kiváló állapot, garanciás (2026.04.29)
- Klipsch R-120SW aktív Mélynyomó / Subwoofer - 1,5 év garanciával
- Lenovo X13 Thinkpad Gen2 WUXGA IPS i5-1145G7 16GB RAM 256GB SSD Intel Iris XE Win11 Pro Garancia
- Lenovo ThinkCentre M920q/ Dell OptiPlex 3070/ Hp EliteDesk 800 G4-G5 mini, micro PC-Számla/garancia
- GYÖNYÖRŰ iPhone 13 mini 256GB Midnight -1 ÉV GARANCIA -Kártyafüggetlen, MS3622, 94% Akkumulátor
- HIBÁTLAN iPhone 15 Pro Max 256GB White Titanium -1 ÉV GARANCIA - Kártyafüggetlen, MS3661, 100% Akkum
- Eredeti Lenovo 135W töltők (sárga téglalap)
- Samsung Galaxy S22 Ultra / 12/256GB / Kártyafüggetlen / 12Hó Garancia
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Promenade Publishing House Kft.
Város: Budapest