Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tcproxy

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcproxy - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

14

lib/proxy.js

@@ -34,2 +34,9 @@ /* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */

/**
* @ 设置代理请求头
*/
this._setProxyHeader = function (client) {
return '';
};
/**
* @ 协议解析函数

@@ -70,2 +77,3 @@ */

var socket = net.createConnection(R, function () {
this.write(_that._setProxyHeader.call(_that, client));
this.write(H);

@@ -94,2 +102,8 @@ client.pipe(this);

ProxyServer.prototype.setProxyHeader = function (handle) {
if ('function' === (typeof handle)) {
this._setProxyHeader = handle;
}
};
ProxyServer.prototype.listen = function () {

@@ -96,0 +110,0 @@ this.server.listen.apply(this.server, arguments);

4

package.json

@@ -5,3 +5,3 @@ {

"keywords": [ "tcp proxy" ],
"version": "0.0.3",
"version": "0.0.4",
"author": "Aleafs Zhang (zhangxc83@gmail.com)",

@@ -18,3 +18,3 @@ "repository": {

"engines": {
"node": ">=0.8.14"
"node": ">=0.10.21"
},

@@ -21,0 +21,0 @@ "devDependencies": {

@@ -135,3 +135,35 @@ /* vim: set expandtab tabstop=2 shiftwidth=2 foldmethod=marker: */

it('should_set_proxy_header_works_fine', function (done) {
var proxy = sproxy.createServer();
proxy.whenProxyError(function (error, client) {
client.end(error.stack);
});
proxy.use(function (buffer, socket) {
return {
'path' : fdfiles[1],
};
});
proxy.setProxyHeader(function (client) {
return ['{' + client.remoteAddress, client.remotePort + '}'].join(':');
});
proxy.listen(0, function (err) {
should.ok(!err);
net.createConnection({
'host' : '127.0.0.1',
'port' : this.address().port,
}, function (err) {
this.write('hello');
this.on('data', function (data) {
String(data).should.eql('[WORLD]{127.0.0.1:' + this.localPort + '}hello');
proxy.close();
done();
});
});
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc