- iPhone topik
- Amazfit Active 2 NFC - jó kör
- Újabb hét, újabb Galaxy S26 képek
- Samsung Galaxy S24 Ultra - ha működik, ne változtass!
- Milyen okostelefont vegyek?
- A lapkakészlet és az akku különbözteti meg a Motorola Edge 60 és Edge 60 Pro-t
- Poco X3 Pro - hardverfrissítés
- Samsung Galaxy S23 Ultra - non plus ultra
- Samsung Galaxy Z Fold7 - ezt vártuk, de…
- Redmi Note 15 Pro+ - több plusz, mint mínusz
-
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!
- pfSense - Avagy az okosított házirouter
- WoW avagy World of Warcraft -=MMORPG=-
- Kerékpárosok, bringások ide!
- Napelem
- Projektor topic
- gban: Ingyen kellene, de tegnapra
- Motorolaj, hajtóműolaj, hűtőfolyadék, adalékok és szűrők topikja
- Robotporszívók
- Házi hangfal építés
- Elektromos autók - motorok
- További aktív témák...
- Legion 5 GAMING Notebook! 16" OLED / RTX 5070 / Ultra 9 275HX / 32GB DDR5 / 1TB NVMe! BeszámítOK
- 229 - Lenovo LOQ (15IRX10) - Intel Core i7-13700HX, RTX 5060
- 228 - Lenovo LOQ (15IRX10) - Intel Core i7-13650HX, RTX 5060
- Extreme-Summit-X440- - 48 port router - Több db - 136 Gbps - 2,7Milió Ft volt az új ára
- 227 - Lenovo LOQ (15IRX10) - Intel Core i7-13650HX, RTX 5060
- BESZÁMÍTÁS! LENOVO ThinkPad P15 Gen2 munkaállomás - i7 11800H 64GB DDR4 1TB SSD RTX A2000 4GB W
- Telefon felvásárlás!! Apple Watch Series 6/Apple Watch Series 7/Apple Watch Series 8
- MacBook Air 15" (M3, 8 GB RAM, 512 GB SSD)
- GYÖNYÖRŰ iPhone 13 mini 128GB Green -1 ÉV GARANCIA - Kártyafüggetlen, MS3837
- ÁRGARANCIA!Épített KomPhone i5 12400F 16/32/64GB RAM RTX 5060 Ti 16GB GAMER PC termékbeszámítással
Állásajánlatok
Cég: Central PC számítógép és laptop szerviz - Pécs
Város: Pécs
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest



