Hirdetés
- iPhone topik
- Samsung Galaxy S23 és S23+ - ami belül van, az számít igazán
- Apple iPhone 13 - hízott, de jól áll neki!
- A piac legerősebb kameráját ígéri a Xiaomi 17 Ultra
- Samsung Galaxy Watch6 Classic - tekerd!
- Xiaomi 14 - párátlanul jó lehetne
- Megérkezett a Google Pixel 7 és 7 Pro
- Honor Magic5 Pro - kamerák bűvöletében
- Fél perc csend, majd világra jön egy Magic8 Pro
- Külföldi prepaid SIM-ek itthon
-
Mobilarena

Ú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!
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- iPhone topik
- Kritikát kapott a Nintendo konzolgyilkos felhasználói szerződése
- Mini-ITX
- Kábel nélkül a Sapphire VGA-val
- PlayStation 5
- Samsung Galaxy S23 és S23+ - ami belül van, az számít igazán
- sziku69: Szólánc.
- Milyen asztali (teljes vagy fél-) gépet vegyek?
- sziku69: Fűzzük össze a szavakat :)
- További aktív témák...
- AZONNAL KÉSZLETRŐL! AMD Ryzen 7 9800X3D 64GB 6000MHz RAM 2TB Gen4 SSD RTX 5090 32GB GDDR7 1200W
- AZONNAL KÉSZLETRŐL! Intel Core i5 14600K 64GB 6000MHz RAM 2TB Gen4 SSD RTX 5060 8GB FSP 750W
- AZONNAL KÉSZLETRŐL! Intel Core i5 14600K 32GB 6000MHz RAM 2TB Gen4 SSD RTX 5060 8GB FSP 750W
- AZONNAL KÉSZLETRŐL! Intel Core i5 14600K 32GB 6000MHz RAM 1TB Gen4 SSD RTX 5060 8GB FSP 750W
- BESZÁMÍTÁS! GIGABYTE A520M R5 5500 16GB DDR4 256GB SSD 1TB HDD GTX 1060 6GB Zalman T3 Plus 400W
- Karácsonyi RAKTÁRSÖPRÉS!!! - Videókártyák, Monitorok, Notebookok, Stb. - Szaküzletből! Számlával!
- Akciós Windows 10 pro + Office 2019 professional plus csomag AZONNALI SZÁLLÍTÁS
- MacBook Pro 13, 14, 15, 16, MacBook Air M1, M2 M3 M4 bill magyarosítás lézerrel / sapkacserével
- Eredeti Lenovo 230W töltők - 4X20Z83995
- GYÖNYÖRŰ iPhone 14 128GB Midnight -1 ÉV GARANCIA - Kártyafüggetlen, MS4248,100% Akksi
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopszaki Kft.
Város: Budapest



