mirror of
				https://git.coolaj86.com/coolaj86/telebit.js.git
				synced 2025-11-04 10:42:45 +00:00 
			
		
		
		
	ws
This commit is contained in:
		
							parent
							
								
									3a6df4db63
								
							
						
					
					
						commit
						9239153681
					
				@ -142,40 +142,40 @@ module.exports.assign = function (state, tun, cb) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function invokeHandler(conf, tlsSocket, tun, id) {
 | 
					  function invokeHandler(conf, tlsSocket, tun, id) {
 | 
				
			||||||
          if (parseInt(conf.handler, 10)) {
 | 
					    if (parseInt(conf.handler, 10)) {
 | 
				
			||||||
            // TODO http-proxy with proper headers and ws support
 | 
					      // TODO http-proxy with proper headers and ws support
 | 
				
			||||||
            var conn = getNetConn(conf.handler);
 | 
					      var conn = getNetConn(conf.handler);
 | 
				
			||||||
            console.info("Port-Forwarding '" + (tun.name || tun.serviceport) + "' to '" + conf.handler + "'");
 | 
					      console.info("Port-Forwarding '" + (tun.name || tun.serviceport) + "' to '" + conf.handler + "'");
 | 
				
			||||||
            conn.pipe(tlsSocket);
 | 
					      conn.pipe(tlsSocket);
 | 
				
			||||||
            tlsSocket.pipe(conn);
 | 
					      tlsSocket.pipe(conn);
 | 
				
			||||||
            return;
 | 
					      return;
 | 
				
			||||||
          }
 | 
					    }
 | 
				
			||||||
          var handle = tun.name || tun.port;
 | 
					    var handle = tun.name || tun.port;
 | 
				
			||||||
          var handler;
 | 
					    var handler;
 | 
				
			||||||
          var path = require('path');
 | 
					    var path = require('path');
 | 
				
			||||||
          var homedir = require('os').homedir();
 | 
					    var homedir = require('os').homedir();
 | 
				
			||||||
          var localshare = path.join(homedir, '.local/share/telebit/apps');
 | 
					    var localshare = path.join(homedir, '.local/share/telebit/apps');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (/^~/.test(conf.handler)) {
 | 
					    if (/^~/.test(conf.handler)) {
 | 
				
			||||||
            conf.handler = require('path').join(require('os').homedir(), conf.handler.replace(/^~(\/?)/, ''));
 | 
					      conf.handler = require('path').join(require('os').homedir(), conf.handler.replace(/^~(\/?)/, ''));
 | 
				
			||||||
          }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          try {
 | 
					    try {
 | 
				
			||||||
            handler = require(conf.handler);
 | 
					      handler = require(conf.handler);
 | 
				
			||||||
            console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'");
 | 
					      console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'");
 | 
				
			||||||
            handler(tlsSocket, tun, id);
 | 
					      handler(tlsSocket, tun, id);
 | 
				
			||||||
          } catch(e1) {
 | 
					    } catch(e1) {
 | 
				
			||||||
            try {
 | 
					      try {
 | 
				
			||||||
              handler = require(path.join(localshare, conf.handler));
 | 
					        handler = require(path.join(localshare, conf.handler));
 | 
				
			||||||
              console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'");
 | 
					        console.info("Handling '" + handle + ":" + id + "' with '" + conf.handler + "'");
 | 
				
			||||||
              handler(tlsSocket, tun, id);
 | 
					        handler(tlsSocket, tun, id);
 | 
				
			||||||
            } catch(e2) {
 | 
					      } catch(e2) {
 | 
				
			||||||
              console.error("Failed to load '" + conf.handler + "':", e1.message);
 | 
					        console.error("Failed to load '" + conf.handler + "':", e1.message);
 | 
				
			||||||
              console.error("Failed to load '" + path.join(localshare, conf.handler) + "':", e2.message);
 | 
					        console.error("Failed to load '" + path.join(localshare, conf.handler) + "':", e2.message);
 | 
				
			||||||
              console.warn("Using default handler for '" + handle + ":" + id + "'");
 | 
					        console.warn("Using default handler for '" + handle + ":" + id + "'");
 | 
				
			||||||
              handlers.https(tlsSocket, tun, id);
 | 
					        handlers.https(tlsSocket, tun, id);
 | 
				
			||||||
            }
 | 
					      }
 | 
				
			||||||
          }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function terminateTls(tun, cb) {
 | 
					  function terminateTls(tun, cb) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user