Skip to content

Commit

Permalink
0.9.36
Browse files Browse the repository at this point in the history
  • Loading branch information
ishay-hola committed Dec 18, 2016
1 parent 18ed321 commit c791f73
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 76 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
@@ -1,8 +1,11 @@
# Luminati Proxy manager - Change Log

- NEXT-VERSION:
- :star: refresh_sessions for sequential pools will only refresh the used
session, and not all
- 0.9.35:
- :sparkles: Proxy settings dialog will not prevent port conflicts when
saving proxy
- :sparkles: Proxy settings dialog will prevent port conflicts when saving
proxy
- 0.9.34:
- :bug: refresh_sessions now refresh sticky_ip sessions properly
- :sparkles: export history to CSV
Expand Down
45 changes: 31 additions & 14 deletions lib/luminati.js
Expand Up @@ -68,7 +68,7 @@ let write_http_reply = (stream, res, headers)=>{
function Luminati(opt){
events.EventEmitter.call(this);
this._refresh_sessions_emitter = new events.EventEmitter();
this._refresh_sessions_emitter.setMaxListeners(2*opt.pool_size||10);
this._refresh_sessions_emitter.setMaxListeners(Number.MAX_SAFE_INTEGER);
this.http = opt.secure_proxy ? https : http;
this.protocol = {
http: new http.Agent({keepAlive: true, keepAliveMsecs: 5000}),
Expand Down Expand Up @@ -102,7 +102,6 @@ function Luminati(opt){
this.throttle_queue = [];
this.session_id = 1;
this.sticky_sessions = {};
this.sticky_session_id = 1;
this.keep_alive = opt.keep_alive && opt.keep_alive*1000;
this.session_init_timeout = opt.session_init_timeout*1000;
this.seed = opt.seed||
Expand Down Expand Up @@ -293,14 +292,29 @@ E.prototype.refresh_sessions = etask._fn(
function*refresh_sessions(_this){
_this._log.info('Refreshing all sessions');
_this._refresh_sessions_emitter.emit('refresh_sessions');
// XXX marka/lee: set flag for other instncies of current session that can
// be in use (in _pool_fetch)
if (_this.sessions)
_this.sessions.canceled = true;
_this.sessions = [];
_this.sticky_sessions = {};
_this.sticky_session_id++;
yield _this._pool(_this.opt.pool_size);
if (_this.opt.pool_size)
{
if (_this.pool_type==E.pool_types.sequential && _this.sessions
&& _this.sessions.length)
{
_this.sessions.shift();
yield _this._pool_fetch();
}
else
{
// XXX marka/lee: set flag for other instncies of current session
// that can be in use (in _pool_fetch)
if (_this.sessions)
_this.sessions.canceled = true;
_this.sessions = [];
yield _this._pool(_this.opt.pool_size);
}
}
if (_this.opt.sticky_ip)
{
_this.sticky_sessions = {};
_this.session_id++;
}
});

E.prototype.error_handler = function error_handler(source, err){
Expand Down Expand Up @@ -732,7 +746,7 @@ E.prototype._request_session = etask._fn(function*request_session(_this, req, au
const ip = (req.connection.remoteAddress||'').replace(/\./g, '_');
if (!_this.sticky_sessions[ip])
{
let id = _this.sticky_session_id;
let id = _this.session_id;
_this.sticky_sessions[ip] = {
proxy: _this.hosts[0],
session: `${_this.port}_${ip}_${_this.seed}_${id}`,
Expand Down Expand Up @@ -908,17 +922,20 @@ E.prototype._request = etask._fn(function*_request(_this, req, res, head){
_this._log.error('Request socket error',
{error: err, proxy});
_this._log.silly(err, err.stack);
_this._refresh_sessions_emitter.removeListener('refresh_sessions', end_socket);
_this._refresh_sessions_emitter
.removeListener('refresh_sessions', end_socket);
}).on('end', ()=>{
if (timeline.end==undefined)
{
timeline.end = Date.now()-timeline.start;
_this.emit('response', response);
}
_this._refresh_sessions_emitter.removeListener('refresh_sessions', end_socket);
_this._refresh_sessions_emitter
.removeListener('refresh_sessions', end_socket);
this.return();
});
_this._refresh_sessions_emitter.on('refresh_sessions', end_socket);
_this._refresh_sessions_emitter
.on('refresh_sessions', end_socket);
}
catch(e){ this.throw(e); }
}).on('error', err=>{
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "luminati-proxy",
"version": "0.9.35",
"version": "0.9.36",
"description": "A configurable local proxy for luminati.io",
"homepage": "https://luminati.io/",
"main": "index.js",
Expand Down

0 comments on commit c791f73

Please sign in to comment.