Permalink
Browse files

0.9.50

  • Loading branch information...
1 parent c30426b commit 1f75f6b1f25b8c36c5348a5dacdac51c3f30cb4d @asafhola asafhola committed Jan 3, 2017
Showing with 97 additions and 11 deletions.
  1. +3 −0 CHANGELOG.md
  2. +2 −0 README.md
  3. +7 −4 lib/luminati.js
  4. +1 −1 lib/manager.js
  5. +5 −1 lib/swagger.json
  6. +23 −4 lib/username.js
  7. +1 −1 package.json
  8. +55 −0 test.js
View
@@ -1,5 +1,8 @@
# Luminati Proxy manager - Change Log
+## 0.9.50:
+- :sparkles: Support short_username for shorter credentials headers
+
## 0.9.49:
- :sparkles: Improve db handling
- :sparkles: Remove unnecesary warnings
View
@@ -90,6 +90,8 @@ Options:
[number] [default: 1]
--secure_proxy Use SSL when accessing super proxy
[boolean] [default: false]
+ --short_username Use Shorthand username for super proxy credentials
+ [boolean] [default: false]
--proxy_switch Automatically switch super proxy on failure
[number] [default: 5]
--insecure Enable SSL connection/sniffing to insecure hosts
View
@@ -49,8 +49,8 @@ E.default = {
sticky_ip: false,
insecure: false,
secure_proxy: false,
+ short_username: false,
ssl: false,
- dropin: false,
};
let write_http_reply = (_stream, res, headers)=>{
@@ -248,7 +248,8 @@ E.prototype.calculate_username = function(opt){
const opt_usr = _.omit(opt, qw`request_timeout password`);
if (opt.request_timeout)
opt_usr.timeout = opt.request_timeout;
- return {username: username.calc(opt_usr), password: opt.password};
+ return {username: username.calc(opt_usr, this.opt.short_username),
+ password: opt.password};
};
E.prototype._handler = etask._fn(
@@ -718,13 +719,15 @@ E.prototype.is_session_expired = function(session){
};
E.prototype._request_session = etask._fn(
-function*request_session(_this, req, auth_header, only){
+function*_request_session(_this, req, auth_header, only){
if (only)
return;
- const authorization = _this.opt.allow_proxy_auth &&
+ let authorization = _this.opt.allow_proxy_auth &&
username.parse(auth_header);
if (authorization)
{
+ if (authorization.timeout)
+ authorization.request_timeout = authorization.timeout;
_this._log.debug('Using request authorization', authorization);
return {authorization};
}
View
@@ -68,8 +68,8 @@ E.default = assign({}, Luminati.default, {
'.luminati.json'.substr(is_win ? 1 : 0)),
database: path.resolve(os.homedir(),
'.luminati.sqlite3'.substr(is_win ? 1 : 0)),
- history: false,
mode: 'root',
+ dropin: false,
debug: 'none',
});
const default_port = 22225;
View
@@ -1,7 +1,7 @@
{
"swagger": "2.0",
"info": {
- "version": "0.9.49",
+ "version": "0.9.50",
"title": "Luminati Proxy Manager",
"license": {
"name": "MIT",
@@ -401,6 +401,10 @@
"type": "boolean",
"description": "Use SSL when accessing super proxy"
},
+ "short_username": {
+ "type": "boolean",
+ "description": "Use Shorthand username for super proxy credentials"
+ },
"proxy_switch": {
"type": "integer",
"description": "Automatically switch super proxy on failure"
View
@@ -1,10 +1,24 @@
// LICENSE_CODE ZON ISC
'use strict'; /*jslint node:true, esnext:true*/
+const _ = require('lodash');
const boolean_part = {
raw: true,
direct: true,
};
+const abbr = {
+ cu: 'customer',
+ z: 'zone',
+ k: 'key',
+ d: 'direct',
+ s: 'session',
+ to: 'timeout',
+ dbg: 'debug',
+ cy: 'country',
+ st: 'state',
+ ct: 'city',
+};
+const short = _.fromPairs(_.toPairs(abbr).map(x=>[x[1], x[0]]));
const parse = header=>{
if (!header)
@@ -21,20 +35,25 @@ const parse = header=>{
let key = parts.shift();
if (key=='lum')
continue;
+ if (abbr[key])
+ key = abbr[key];
auth[key] = boolean_part[key] || parts.shift();
}
auth.password = cred[1];
return auth;
};
-const calc = opt=>{
+const calc = (opt, make_short)=>{
const parts = ['lum'];
for(let key in opt) {
- if (!opt[key])
+ let val = opt[key], bool = boolean_part[key];
+ if (!val)
continue;
+ if (make_short && short[key])
+ key = short[key];
parts.push(key);
- if (!boolean_part[key])
- parts.push(opt[key]);
+ if (!bool)
+ parts.push(val);
}
return parts.join('-');
};
View
@@ -1,6 +1,6 @@
{
"name": "luminati-proxy",
- "version": "0.9.49",
+ "version": "0.9.50",
"description": "A configurable local proxy for luminati.io",
"homepage": "https://luminati.io/",
"main": "index.js",
View
@@ -395,6 +395,61 @@ describe('proxy', ()=>{
assert.equal(res.body.auth.zone, 'zzz');
}));
});
+ describe('short_username', ()=>{
+ const t = (name, user, short, expected)=>it(name, ()=>etask(
+ function*(){
+ l = yield lum({
+ allow_proxy_auth: true,
+ short_username: short,
+ });
+ const res = yield l.test({headers: {
+ 'proxy-authorization': 'Basic '+
+ (new Buffer(user+':pass'))
+ .toString('base64'),
+ }});
+ let m = res.body.headers['proxy-authorization']
+ .match(/^Basic (.*)/);
+ let h = new Buffer(m[1], 'base64').toString('ascii');
+ let parts = h.split(':');
+ assert_has(res.body.auth, expected);
+ if (short)
+ assert.ok(parts[0].length <= user.length);
+ else
+ assert.ok(parts[0].length >= user.length);
+ }));
+ t(
+ 'short notation',
+ 'lum-cu-ttt-z-zzz-d-s-sss-to-5-dbg-full-cy-us-st-fl-ct-miami',
+ true,
+ {
+ customer: 'ttt',
+ zone: 'zzz',
+ direct: true,
+ session: 'sss',
+ timeout: '5',
+ debug: 'full',
+ country: 'us',
+ state: 'fl',
+ city: 'miami',
+ }
+ );
+ t(
+ 'long notation',
+ 'lum-cu-ttt-z-zzz-d-s-sss-to-5-dbg-full-cy-us-st-fl-ct-miami',
+ false,
+ {
+ customer: 'ttt',
+ zone: 'zzz',
+ direct: true,
+ session: 'sss',
+ timeout: '5',
+ debug: 'full',
+ country: 'us',
+ state: 'fl',
+ city: 'miami',
+ }
+ );
+ });
describe('pool', ()=>{
describe('pool_size', ()=>{
const t = pool_size=>it(''+pool_size, ()=>etask(function*(){

0 comments on commit 1f75f6b

Please sign in to comment.