browsed 0.2.9 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +28 -28
  3. data/browsed.gemspec +3 -4
  4. data/lib/browsed.rb +1 -1
  5. data/lib/browsed/chrome.rb +2 -2
  6. data/lib/browsed/client.rb +2 -2
  7. data/lib/browsed/firefox.rb +2 -2
  8. data/lib/browsed/version.rb +1 -1
  9. metadata +13 -166
  10. data/lib/browsed/proxies/proxy-chain-server/node_modules/.bin/portastic +0 -1
  11. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/LICENSE +0 -21
  12. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/README.md +0 -57
  13. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/changelog.md +0 -1
  14. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.js +0 -3824
  15. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.core.min.js +0 -31
  16. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.js +0 -5666
  17. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/browser/bluebird.min.js +0 -31
  18. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/any.js +0 -21
  19. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/assert.js +0 -55
  20. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/async.js +0 -165
  21. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bind.js +0 -67
  22. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/bluebird.js +0 -11
  23. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/call_get.js +0 -123
  24. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/cancel.js +0 -129
  25. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/catch_filter.js +0 -42
  26. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/context.js +0 -69
  27. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/debuggability.js +0 -934
  28. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/direct_resolve.js +0 -46
  29. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/each.js +0 -30
  30. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/errors.js +0 -116
  31. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/es5.js +0 -80
  32. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/filter.js +0 -12
  33. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/finally.js +0 -146
  34. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/generators.js +0 -223
  35. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/join.js +0 -168
  36. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/map.js +0 -168
  37. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/method.js +0 -55
  38. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeback.js +0 -51
  39. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/nodeify.js +0 -58
  40. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise.js +0 -789
  41. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promise_array.js +0 -185
  42. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/promisify.js +0 -314
  43. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/props.js +0 -118
  44. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/queue.js +0 -73
  45. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/race.js +0 -49
  46. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/reduce.js +0 -172
  47. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/schedule.js +0 -62
  48. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/settle.js +0 -43
  49. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/some.js +0 -148
  50. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/synchronous_inspection.js +0 -103
  51. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/thenables.js +0 -86
  52. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/timers.js +0 -93
  53. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/using.js +0 -226
  54. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/js/release/util.js +0 -389
  55. data/lib/browsed/proxies/proxy-chain-server/node_modules/bluebird/package.json +0 -102
  56. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/CHANGELOG.md +0 -408
  57. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/LICENSE +0 -22
  58. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/Readme.md +0 -428
  59. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/index.js +0 -1224
  60. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/package.json +0 -70
  61. data/lib/browsed/proxies/proxy-chain-server/node_modules/commander/typings/index.d.ts +0 -310
  62. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.coveralls.yml +0 -1
  63. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.eslintrc +0 -11
  64. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.npmignore +0 -9
  65. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/.travis.yml +0 -14
  66. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/CHANGELOG.md +0 -362
  67. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/LICENSE +0 -19
  68. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/Makefile +0 -50
  69. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/README.md +0 -312
  70. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/component.json +0 -19
  71. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/karma.conf.js +0 -70
  72. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/node.js +0 -1
  73. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/package.json +0 -88
  74. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/browser.js +0 -185
  75. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/debug.js +0 -202
  76. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/index.js +0 -10
  77. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/inspector-log.js +0 -15
  78. data/lib/browsed/proxies/proxy-chain-server/node_modules/debug/src/node.js +0 -248
  79. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/index.js +0 -152
  80. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/license.md +0 -21
  81. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/package.json +0 -69
  82. data/lib/browsed/proxies/proxy-chain-server/node_modules/ms/readme.md +0 -51
  83. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/LICENSE +0 -13
  84. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/README.md +0 -148
  85. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/bin/portastic +0 -65
  86. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/history.md +0 -7
  87. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/index.js +0 -4
  88. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/monitor.js +0 -59
  89. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/lib/portastic.js +0 -167
  90. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/LICENSE +0 -21
  91. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/README.md +0 -677
  92. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/changelog.md +0 -1730
  93. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.js +0 -4892
  94. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/browser/bluebird.min.js +0 -31
  95. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/any.js +0 -21
  96. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/assert.js +0 -55
  97. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/async.js +0 -150
  98. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bind.js +0 -72
  99. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/bluebird.js +0 -11
  100. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/call_get.js +0 -123
  101. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/cancel.js +0 -48
  102. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/captured_trace.js +0 -493
  103. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/catch_filter.js +0 -66
  104. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/context.js +0 -38
  105. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/debuggability.js +0 -162
  106. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/direct_resolve.js +0 -63
  107. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/each.js +0 -12
  108. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/errors.js +0 -111
  109. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/es5.js +0 -80
  110. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/filter.js +0 -12
  111. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/finally.js +0 -98
  112. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/generators.js +0 -136
  113. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/join.js +0 -107
  114. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/map.js +0 -133
  115. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/method.js +0 -44
  116. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/nodeify.js +0 -59
  117. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/progress.js +0 -76
  118. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise.js +0 -759
  119. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_array.js +0 -142
  120. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promise_resolver.js +0 -123
  121. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/promisify.js +0 -307
  122. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/props.js +0 -79
  123. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/queue.js +0 -90
  124. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/race.js +0 -47
  125. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/reduce.js +0 -148
  126. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/schedule.js +0 -35
  127. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/settle.js +0 -40
  128. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/some.js +0 -125
  129. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/synchronous_inspection.js +0 -94
  130. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/thenables.js +0 -84
  131. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/timers.js +0 -64
  132. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/using.js +0 -213
  133. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/js/main/util.js +0 -321
  134. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/node_modules/bluebird/package.json +0 -103
  135. data/lib/browsed/proxies/proxy-chain-server/node_modules/portastic/package.json +0 -69
  136. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/CHANGELOG.md +0 -109
  137. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/LICENSE +0 -201
  138. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/README.md +0 -278
  139. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/anonymize_proxy.js +0 -100
  140. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_base.js +0 -319
  141. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_custom_response.js +0 -96
  142. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_forward.js +0 -173
  143. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_chain.js +0 -132
  144. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_direct.js +0 -89
  145. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/handler_tunnel_tcp_chain.js +0 -271
  146. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/index.js +0 -26
  147. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/run_locally.js +0 -66
  148. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/server.js +0 -595
  149. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tcp_tunnel.js +0 -138
  150. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/testing_tcp_service.js +0 -37
  151. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/build/tools.js +0 -220
  152. data/lib/browsed/proxies/proxy-chain-server/node_modules/proxy-chain/package.json +0 -104
  153. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/LICENSE +0 -23
  154. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/README.md +0 -28
  155. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/package.json +0 -81
  156. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js +0 -5
  157. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore-min.js.map +0 -1
  158. data/lib/browsed/proxies/proxy-chain-server/node_modules/underscore/underscore.js +0 -1692
  159. data/lib/browsed/proxies/proxy-chain-server/package-lock.json +0 -63
  160. data/lib/browsed/proxies/proxy-chain-server/package.json +0 -15
  161. data/lib/browsed/proxies/proxy-chain-server/server.js +0 -25
  162. data/lib/browsed/proxies/proxy_chain.rb +0 -39
@@ -1,138 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
-
9
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
10
-
11
- exports.createTunnel = createTunnel;
12
- exports.closeTunnel = closeTunnel;
13
-
14
- var _bluebird = require('bluebird');
15
-
16
- var _bluebird2 = _interopRequireDefault(_bluebird);
17
-
18
- var _net = require('net');
19
-
20
- var _net2 = _interopRequireDefault(_net);
21
-
22
- var _handler_tunnel_tcp_chain = require('./handler_tunnel_tcp_chain');
23
-
24
- var _handler_tunnel_tcp_chain2 = _interopRequireDefault(_handler_tunnel_tcp_chain);
25
-
26
- var _tools = require('./tools');
27
-
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
- var runningServers = {};
31
-
32
- function createTunnel(proxyUrl, targetHost) {
33
- var providedOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
34
- var callback = arguments[3];
35
-
36
- // TODO: More and better validations - yeah, make sure targetHost is really a hostname
37
- var _targetHost$split = targetHost.split(':'),
38
- _targetHost$split2 = _slicedToArray(_targetHost$split, 2),
39
- trgHostname = _targetHost$split2[0],
40
- trgPort = _targetHost$split2[1];
41
-
42
- if (!trgHostname || !trgPort) throw new Error('target needs to include both hostname and port.');
43
-
44
- var parsedProxyUrl = (0, _tools.parseUrl)(proxyUrl);
45
- if (!parsedProxyUrl.hostname) throw new Error('proxyUrl needs to include atleast hostname');
46
- if (parsedProxyUrl.scheme !== 'http') throw new Error('Currently only "http" scheme is supported');
47
-
48
- var options = _extends({
49
- verbose: false,
50
- hostname: 'localhost',
51
- port: null
52
- }, providedOptions);
53
-
54
- return new _bluebird2.default(function (resolve, reject) {
55
- if (options.port) return resolve(options.port);
56
- (0, _tools.findFreePort)().then(resolve).catch(reject);
57
- }).then(function (port) {
58
- var server = _net2.default.createServer();
59
-
60
- var log = function log() {
61
- var _console;
62
-
63
- if (options.verbose) (_console = console).log.apply(_console, arguments);
64
- };
65
-
66
- server.on('connection', function (srcSocket) {
67
- runningServers[port].connections = srcSocket;
68
- var remoteAddress = srcSocket.remoteAddress + ':' + srcSocket.remotePort;
69
- log('new client connection from %s', remoteAddress);
70
-
71
- srcSocket.pause();
72
-
73
- var tunnel = new _handler_tunnel_tcp_chain2.default({
74
- srcSocket: srcSocket,
75
- upstreamProxyUrlParsed: parsedProxyUrl,
76
- trgParsed: {
77
- hostname: trgHostname,
78
- port: trgPort
79
- },
80
- log: log
81
- });
82
-
83
- tunnel.run();
84
-
85
- srcSocket.on('data', onConnData);
86
- srcSocket.once('close', onConnClose);
87
- srcSocket.on('error', onConnError);
88
-
89
- function onConnData(d) {
90
- log('connection data from %s: %j', remoteAddress, d);
91
- }
92
-
93
- function onConnClose() {
94
- log('connection from %s closed', remoteAddress);
95
- }
96
-
97
- function onConnError(err) {
98
- log('Connection %s error: %s', remoteAddress, err.message);
99
- }
100
- });
101
-
102
- return new _bluebird2.default(function (resolve) {
103
- server.listen(port, function (err) {
104
- if (err) return reject(err);
105
- log('server listening to ', server.address());
106
- runningServers[port] = { server: server, connections: [] };
107
- resolve(options.hostname + ':' + port);
108
- });
109
- });
110
- }).nodeify(callback);
111
- }
112
-
113
- function closeTunnel(serverPath, closeConnections, callback) {
114
- var _serverPath$split = serverPath.split(':'),
115
- _serverPath$split2 = _slicedToArray(_serverPath$split, 2),
116
- hostname = _serverPath$split2[0],
117
- port = _serverPath$split2[1];
118
-
119
- if (!hostname) throw new Error('serverPath must contain hostname');
120
- if (!port) throw new Error('serverPath must contain port');
121
-
122
- return new _bluebird2.default(function (resolve) {
123
- if (!runningServers[port]) return resolve(false);
124
- if (!closeConnections) return resolve();
125
- runningServers[port].connections.forEach(function (connection) {
126
- return connection.destroy();
127
- });
128
- resolve();
129
- }).then(function (serverExists) {
130
- return new _bluebird2.default(function (resolve) {
131
- if (!serverExists) return resolve(false);
132
- runningServers[port].close(function () {
133
- delete runningServers[port];
134
- resolve(true);
135
- });
136
- });
137
- }).nodeify(callback);
138
- }
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- var net = require('net');
4
-
5
- // TODO: please move this into ./test dir
6
-
7
- var server = net.createServer();
8
-
9
- server.on('connection', handleConnection);
10
-
11
- server.listen(9112, function () {
12
- console.log('server listening to %j', server.address());
13
- });
14
-
15
- function handleConnection(conn) {
16
- var remoteAddress = conn.remoteAddress + ':' + conn.remotePort;
17
- console.log('new client connection from %s', remoteAddress);
18
-
19
- conn.setEncoding('utf8');
20
-
21
- conn.on('data', onConnData);
22
- conn.once('close', onConnClose);
23
- conn.on('error', onConnError);
24
-
25
- function onConnData(d) {
26
- console.log('connection data from %s: %j', remoteAddress, d);
27
- conn.write(d);
28
- }
29
-
30
- function onConnClose() {
31
- console.log('connection from %s closed', remoteAddress);
32
- }
33
-
34
- function onConnError(err) {
35
- console.log('Connection %s error: %s', remoteAddress, err.message);
36
- }
37
- }
@@ -1,220 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.maybeAddProxyAuthorizationHeader = exports.findFreePort = exports.PORT_SELECTION_CONFIG = exports.addHeader = exports.parseProxyAuthorizationHeader = exports.redactParsedUrl = exports.redactUrl = exports.parseUrl = exports.isInvalidHeader = exports.isHopByHopHeader = exports.parseHostHeader = undefined;
7
-
8
- var _url = require('url');
9
-
10
- var _url2 = _interopRequireDefault(_url);
11
-
12
- var _http_common = require('_http_common');
13
-
14
- var _portastic = require('portastic');
15
-
16
- var _portastic2 = _interopRequireDefault(_portastic);
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- // import through from 'through';
21
-
22
-
23
- var HOST_HEADER_REGEX = /^((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]))(:([0-9]+))?$/;
24
-
25
- /**
26
- * Parsed the 'Host' HTTP header and returns an object with { host: String, port: Number }.
27
- * For example, for 'www.example.com:80' it returns { host: 'www.example.com', port: 80 }.
28
- * If port is not present, the function
29
- * If the header is invalid, returns null.
30
- * @param hostHeader
31
- * @return {*}
32
- */
33
- // eslint-disable-line
34
- var parseHostHeader = exports.parseHostHeader = function parseHostHeader(hostHeader) {
35
- var matches = HOST_HEADER_REGEX.exec(hostHeader || '');
36
- if (!matches) return null;
37
-
38
- var hostname = matches[1];
39
- if (hostname.length > 255) return null;
40
-
41
- var port = null;
42
- if (matches[5]) {
43
- port = parseInt(matches[6], 10);
44
- if (!(port > 0 && port <= 65535)) return null;
45
- }
46
-
47
- return { hostname: hostname, port: port };
48
- };
49
-
50
- var HOP_BY_HOP_HEADERS = ['Connection', 'Keep-Alive', 'Proxy-Authenticate', 'Proxy-Authorization', 'TE', 'Trailers', 'Transfer-Encoding', 'Upgrade'];
51
-
52
- var HOP_BY_HOP_HEADERS_REGEX = new RegExp('^(' + HOP_BY_HOP_HEADERS.join('|') + ')$', 'i');
53
-
54
- var isHopByHopHeader = exports.isHopByHopHeader = function isHopByHopHeader(header) {
55
- return HOP_BY_HOP_HEADERS_REGEX.test(header);
56
- };
57
-
58
- // This code is based on Node.js' validateHeader() function from _http_outgoing.js module
59
- // (see https://github.com/nodejs/node/blob/189d29f39e6de9ccf10682bfd1341819b4a2291f/lib/_http_outgoing.js#L485)
60
- var isInvalidHeader = exports.isInvalidHeader = function isInvalidHeader(name, value) {
61
- // NOTE: These are internal Node.js functions, they might stop working in the future!
62
- return typeof name !== 'string' || !name || !(0, _http_common._checkIsHttpToken)(name) || value === undefined || (0, _http_common._checkInvalidHeaderChar)(value);
63
- };
64
-
65
- /**
66
- * Sames are Node's url.parse() just adds the 'username', 'password' and 'scheme' fields.
67
- * Also this method makes sure "port" is a number rather than a string.
68
- * Note that `scheme` is always lower-cased (e.g. `ftp`).
69
- * @param url
70
- * @ignore
71
- */
72
- var parseUrl = exports.parseUrl = function parseUrl(url) {
73
- var parsed = _url2.default.parse(url);
74
-
75
- parsed.username = null;
76
- parsed.password = null;
77
- parsed.scheme = null;
78
-
79
- if (parsed.auth) {
80
- var matches = /^([^:]+)(:?)(.*)$/.exec(parsed.auth);
81
- if (matches && matches.length === 4) {
82
- parsed.username = matches[1];
83
- if (matches[2] === ':') parsed.password = matches[3];
84
- }
85
- }
86
-
87
- if (parsed.protocol) {
88
- var _matches = /^([a-z0-9]+):$/i.exec(parsed.protocol);
89
- if (_matches && _matches.length === 2) {
90
- parsed.scheme = _matches[1];
91
- }
92
- }
93
-
94
- if (parsed.port) {
95
- parsed.port = parseInt(parsed.port, 10);
96
- }
97
-
98
- return parsed;
99
- };
100
-
101
- /**
102
- * Redacts password from a URL, so that it can be shown in logs, results etc.
103
- * For example, converts URL such as
104
- * 'https://username:password@www.example.com/path#hash'
105
- * to 'https://username:<redacted>@www.example.com/path#hash'
106
- * @param url URL, it must contain at least protocol and hostname
107
- * @param passwordReplacement The string that replaces password, by default it is '<redacted>'
108
- * @returns {string}
109
- * @ignore
110
- */
111
- var redactUrl = exports.redactUrl = function redactUrl(url, passwordReplacement) {
112
- return redactParsedUrl(parseUrl(url), passwordReplacement);
113
- };
114
-
115
- var redactParsedUrl = exports.redactParsedUrl = function redactParsedUrl(parsedUrl) {
116
- var passwordReplacement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '<redacted>';
117
-
118
- var p = parsedUrl;
119
- var auth = null;
120
- if (p.username) {
121
- if (p.password) {
122
- auth = p.username + ':' + passwordReplacement;
123
- } else {
124
- auth = '' + p.username;
125
- }
126
- }
127
- return p.protocol + '//' + (auth || '') + (auth ? '@' : '') + p.host + (p.path || '') + (p.hash || '');
128
- };
129
-
130
- var PROXY_AUTH_HEADER_REGEX = /^([a-z0-9-]+) ([a-z0-9+/=]+)$/i;
131
-
132
- /**
133
- * Parses the content of the Proxy-Authorization HTTP header.
134
- * @param header
135
- * @returns {*} Object with fields { type: String, username: String, password: String }
136
- * or null if string parsing failed. Note that password and username might be empty strings.
137
- */
138
- var parseProxyAuthorizationHeader = exports.parseProxyAuthorizationHeader = function parseProxyAuthorizationHeader(header) {
139
- var matches = PROXY_AUTH_HEADER_REGEX.exec(header);
140
- if (!matches) return null;
141
-
142
- var auth = Buffer.from(matches[2], 'base64').toString();
143
- if (!auth) return null;
144
-
145
- var index = auth.indexOf(':');
146
- return {
147
- type: matches[1],
148
- username: index >= 0 ? auth.substr(0, index) : auth,
149
- password: index >= 0 ? auth.substr(index + 1) : ''
150
- };
151
- };
152
-
153
- /**
154
- * Works like Bash tee, but instead of passing output to file,
155
- * passes output to log
156
- *
157
- * @param {String} name identifier
158
- * @param {Boolean} initialOnly log only initial chunk of data
159
- * @return {through} duplex stream (pipe)
160
-
161
- export const tee = (name, initialOnly = true) => {
162
- console.log('tee');
163
- let maxChunks = 2;
164
- const duplex = through((chunk) => {
165
- if (maxChunks || !initialOnly) {
166
- // let msg = chunk.toString();
167
- // msg += '';
168
- maxChunks--;
169
- console.log(`pipe: ${JSON.stringify({
170
- context: name,
171
- chunkHead: chunk.toString().slice(0, 100),
172
- })}`);
173
- }
174
- duplex.queue(chunk);
175
- });
176
-
177
- return duplex;
178
- };
179
- */
180
-
181
- var addHeader = exports.addHeader = function addHeader(headers, name, value) {
182
- if (headers[name] === undefined) {
183
- headers[name] = value;
184
- } else if (Array.isArray(headers[name])) {
185
- headers[name].push(value);
186
- } else {
187
- headers[name] = [headers[name], value];
188
- }
189
- };
190
-
191
- var PORT_SELECTION_CONFIG = exports.PORT_SELECTION_CONFIG = {
192
- FROM: 20000,
193
- TO: 60000,
194
- RETRY_COUNT: 10
195
- };
196
-
197
- var findFreePort = exports.findFreePort = function findFreePort() {
198
- // Let 'min' be a random value in the first half of the PORT_FROM-PORT_TO range,
199
- // to reduce a chance of collision if other ProxyChain is started at the same time.
200
- var half = Math.floor((PORT_SELECTION_CONFIG.TO - PORT_SELECTION_CONFIG.FROM) / 2);
201
-
202
- var opts = {
203
- min: PORT_SELECTION_CONFIG.FROM + Math.floor(Math.random() * half),
204
- max: PORT_SELECTION_CONFIG.TO,
205
- retrieve: 1
206
- };
207
-
208
- return _portastic2.default.find(opts).then(function (ports) {
209
- if (ports.length < 1) throw new Error('There are no more free ports in range from ' + PORT_SELECTION_CONFIG.FROM + ' to ' + PORT_SELECTION_CONFIG.TO); // eslint-disable-line max-len
210
- return ports[0];
211
- });
212
- };
213
-
214
- var maybeAddProxyAuthorizationHeader = exports.maybeAddProxyAuthorizationHeader = function maybeAddProxyAuthorizationHeader(parsedUrl, headers) {
215
- if (parsedUrl && parsedUrl.username) {
216
- var auth = parsedUrl.username;
217
- if (parsedUrl.password || parsedUrl.password === '') auth += ':' + parsedUrl.password;
218
- headers['Proxy-Authorization'] = 'Basic ' + Buffer.from(auth).toString('base64');
219
- }
220
- };
@@ -1,104 +0,0 @@
1
- {
2
- "_from": "proxy-chain",
3
- "_id": "proxy-chain@0.2.7",
4
- "_inBundle": false,
5
- "_integrity": "sha512-e0s94WDfooeC3zQkvIJ/Eudiy/AywTQK4K6PMYbZdBE2m/eug54ThgCPdBE4txHvzi0A0gAVbX04Kt4RygTlRQ==",
6
- "_location": "/proxy-chain",
7
- "_phantomChildren": {},
8
- "_requested": {
9
- "type": "tag",
10
- "registry": true,
11
- "raw": "proxy-chain",
12
- "name": "proxy-chain",
13
- "escapedName": "proxy-chain",
14
- "rawSpec": "",
15
- "saveSpec": null,
16
- "fetchSpec": "latest"
17
- },
18
- "_requiredBy": [
19
- "#USER",
20
- "/"
21
- ],
22
- "_resolved": "https://registry.npmjs.org/proxy-chain/-/proxy-chain-0.2.7.tgz",
23
- "_shasum": "3c24d1a487e37838b0c9fe34317c276f3401e0ec",
24
- "_spec": "proxy-chain",
25
- "_where": "/Users/sebastianjohnsson/Programming/Javascript/proxy-chain-server",
26
- "author": {
27
- "name": "Apify",
28
- "email": "support@apify.com",
29
- "url": "https://www.apify.com"
30
- },
31
- "bugs": {
32
- "url": "https://github.com/apifytech/proxy-chain/issues"
33
- },
34
- "bundleDependencies": false,
35
- "contributors": [
36
- {
37
- "name": "Jan Curn",
38
- "email": "jan@apify.com"
39
- }
40
- ],
41
- "dependencies": {
42
- "bluebird": "^3.5.1",
43
- "portastic": "^1.0.1",
44
- "underscore": "^1.9.1"
45
- },
46
- "deprecated": false,
47
- "description": "Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.",
48
- "devDependencies": {
49
- "babel-cli": "^6.6.5",
50
- "babel-core": "^6.1.21",
51
- "babel-eslint": "^8.2.6",
52
- "babel-preset-es2015": "^6.1.18",
53
- "babel-preset-stage-0": "^6.1.18",
54
- "basic-auth": "^2.0.0",
55
- "body-parser": "^1.18.2",
56
- "chai": "^4.0.2",
57
- "eslint": "^3.19.0",
58
- "eslint-config-airbnb": "^15.0.1",
59
- "eslint-config-airbnb-base": "^11.1.0",
60
- "eslint-plugin-import": "^2.2.0",
61
- "eslint-plugin-jsx-a11y": "^5.0.3",
62
- "eslint-plugin-promise": "^3.4.2",
63
- "eslint-plugin-react": "^7.0.1",
64
- "express": "^4.16.2",
65
- "https-proxy-agent": "^2.1.0",
66
- "isparta": "^4.0.0",
67
- "mocha": "^3.2.0",
68
- "phantomjs-prebuilt": "^2.1.16",
69
- "proxy": "^0.2.4",
70
- "request": "^2.83.0",
71
- "sinon": "^6.1.4",
72
- "sinon-stub-promise": "^4.0.0",
73
- "through": "^2.3.8",
74
- "ws": "^6.0.0"
75
- },
76
- "files": [
77
- "build"
78
- ],
79
- "homepage": "https://blog.apify.com/how-to-make-headless-chrome-and-puppeteer-use-a-proxy-server-with-authentication-249a21a79212",
80
- "keywords": [
81
- "proxy",
82
- "squid",
83
- "apify",
84
- "tunnel"
85
- ],
86
- "license": "Apache-2.0",
87
- "main": "build/index.js",
88
- "name": "proxy-chain",
89
- "optionalDependencies": {},
90
- "repository": {
91
- "type": "git",
92
- "url": "git+https://github.com/apifytech/proxy-chain.git"
93
- },
94
- "scripts": {
95
- "build": "rm -rf ./build && babel src --out-dir build",
96
- "clean": "rm -rf build",
97
- "lint": "npm run build && eslint src",
98
- "local-proxy": "npm run build && node ./build/run_locally.js",
99
- "prepare": "npm run build",
100
- "prepublishOnly": "(test $RUNNING_FROM_SCRIPT || (echo \"You must use publish.sh instead of 'npm publish' directly!\"; exit 1)) && npm test && npm run lint",
101
- "test": "npm run build && mocha --compilers js:babel-core/register --recursive"
102
- },
103
- "version": "0.2.7"
104
- }