Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1var http = require('http'),2 https = require('https'),3 common = require('../common');4 5/*!6 * Array of passes.7 *8 * A `pass` is just a function that is executed on `req, socket, options`9 * so that you can easily add new checks while still keeping the base10 * flexible.11 */12 13/*14 * Websockets Passes15 *16 */17 18 19module.exports = {20 /**21 * WebSocket requests must have the `GET` method and22 * the `upgrade:websocket` header23 *24 * @param {ClientRequest} Req Request object25 * @param {Socket} Websocket26 *27 * @api private28 */29 30 checkMethodAndHeader : function checkMethodAndHeader(req, socket) {31 if (req.method !== 'GET' || !req.headers.upgrade) {32 socket.destroy();33 return true;34 }35 36 if (req.headers.upgrade.toLowerCase() !== 'websocket') {37 socket.destroy();38 return true;39 }40 },41 42 /**43 * Sets `x-forwarded-*` headers if specified in config.44 *45 * @param {ClientRequest} Req Request object46 * @param {Socket} Websocket47 * @param {Object} Options Config object passed to the proxy48 *49 * @api private50 */51 52 XHeaders : function XHeaders(req, socket, options) {53 if(!options.xfwd) return;54 55 var values = {56 for : req.connection.remoteAddress || req.socket.remoteAddress,57 port : common.getPort(req),58 proto: common.hasEncryptedConnection(req) ? 'wss' : 'ws'59 };60 61 ['for', 'port', 'proto'].forEach(function(header) {62 req.headers['x-forwarded-' + header] =63 (req.headers['x-forwarded-' + header] || '') +64 (req.headers['x-forwarded-' + header] ? ',' : '') +65 values[header];66 });67 },68 69 /**70 * Does the actual proxying. Make the request and upgrade it71 * send the Switching Protocols request and pipe the sockets.72 *73 * @param {ClientRequest} Req Request object74 * @param {Socket} Websocket75 * @param {Object} Options Config object passed to the proxy76 *77 * @api private78 */79 stream : function stream(req, socket, options, head, server, clb) {80 81 var createHttpHeader = function(line, headers) {82 return Object.keys(headers).reduce(function (head, key) {83 var value = headers[key];84 85 if (!Array.isArray(value)) {86 head.push(key + ': ' + value);87 return head;88 }89 90 for (var i = 0; i < value.length; i++) {91 head.push(key + ': ' + value[i]);92 }93 return head;94 }, [line])95 .join('\r\n') + '\r\n\r\n';96 }97 98 common.setupSocket(socket);99 100 if (head && head.length) socket.unshift(head);101 102 103 var proxyReq = (common.isSSL.test(options.target.protocol) ? https : http).request(104 common.setupOutgoing(options.ssl || {}, options, req)105 );106 107 // Enable developers to modify the proxyReq before headers are sent108 if (server) { server.emit('proxyReqWs', proxyReq, req, socket, options, head); }109 110 // Error Handler111 proxyReq.on('error', onOutgoingError);112 proxyReq.on('response', function (res) {113 // if upgrade event isn't going to happen, close the socket114 if (!res.upgrade) {115 socket.write(createHttpHeader('HTTP/' + res.httpVersion + ' ' + res.statusCode + ' ' + res.statusMessage, res.headers));116 res.pipe(socket);117 }118 });119 120 proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {121 proxySocket.on('error', onOutgoingError);122 123 // Allow us to listen when the websocket has completed124 proxySocket.on('end', function () {125 server.emit('close', proxyRes, proxySocket, proxyHead);126 });127 128 // The pipe below will end proxySocket if socket closes cleanly, but not129 // if it errors (eg, vanishes from the net and starts returning130 // EHOSTUNREACH). We need to do that explicitly.131 socket.on('error', function () {132 proxySocket.end();133 });134 135 common.setupSocket(proxySocket);136 137 if (proxyHead && proxyHead.length) proxySocket.unshift(proxyHead);138 139 //140 // Remark: Handle writing the headers to the socket when switching protocols141 // Also handles when a header is an array142 //143 socket.write(createHttpHeader('HTTP/1.1 101 Switching Protocols', proxyRes.headers));144 145 proxySocket.pipe(socket).pipe(proxySocket);146 147 server.emit('open', proxySocket);148 server.emit('proxySocket', proxySocket); //DEPRECATED.149 });150 151 return proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT152 153 function onOutgoingError(err) {154 if (clb) {155 clb(err, req, socket);156 } else {157 server.emit('error', err, req, socket);158 }159 socket.end();160 }161 }162};163 