Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/server/node_modules/findhit-proxywrap/test/specific/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /* related to issue https://github.com/findhit/proxywrap/issues/15 */
var http = require('http')
var assert = require('assert')
var net = require('net')
var exec = require('child_process').exec
var child
var proxyWrap = require('../..')
function findCloseWaitConnections(port, callback) {
var child = exec('netstat -tonp | grep 8000 | grep CLOSE_WAIT', function(
err,
stdout,
stderr
) {
if (err) {
return callback(err)
}
return callback(null, stdout)
})
}
function reproduce(proxyWrapConf, callback) {
var socket, server, port, proxiedHttp
if (!callback) {
callback = proxyWrapConf
proxyWrapConf = null
}
proxiedHttp = proxyWrap.proxy(http, proxyWrapConf)
server = proxiedHttp
.createServer(function handler(req, res) {
throw new Error('For this test socket should not call #write()')
})
.listen(function(err) {
if (err) {
return done(err)
}
port = this.address().port
socket = net.connect(
{
port: port
},
function() {
socket.end()
}
)
socket.on('end', function() {
return callback(null, server)
})
})
}
describe('Sockets closed before any write #15', function() {
describe('On strict mode', function() {
var port, server
before(function(done) {
reproduce(function(err, _server) {
server = _server
port = server.address().port
done()
})
})
after(function() {
server.close()
})
it('should be restored', function(done) {
findCloseWaitConnections(port, function(err, stdout) {
assert(!stdout)
done()
})
})
})
describe('On non-strict mode', function() {
var port, server
before(function(done) {
reproduce(
{
strict: false
},
function(err, _server) {
server = _server
port = server.address().port
done()
}
)
})
after(function() {
server.close()
})
it('should be restored', function(done) {
findCloseWaitConnections(port, function(err, stdout) {
assert(!stdout)
done()
})
})
})
})
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0065 ]-- |