Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ed0172a
Add support for sending event requests via proxy
ndmanvar Sep 11, 2017
b0bb3cb
add maxReqQueueCount in case sentry server is down
FennZheng Nov 5, 2015
d5a538e
Add test for maxReqQueueCount
kamilogorek Sep 8, 2017
beb40bf
feat: Make private key in DSN optional
kamilogorek Sep 18, 2017
28b7624
docs: Add Loopback integration docs
kamilogorek Sep 19, 2017
d1da947
fix: Pull Error's name from constructor, not Error itself
kamilogorek Sep 13, 2017
abdfb71
Add test for maxReqQueueCount
kamilogorek Sep 8, 2017
4f89ae2
docs: Fix syntax error for Loopback integration
kamilogorek Sep 20, 2017
3849f33
ref: Use local json-stringify-save package
kamilogorek Sep 21, 2017
2e971be
feat: Add Errors serialization to json-stringify-safe
kamilogorek Sep 21, 2017
9eebf71
docs: Mention git-rev usage in release config attribute
kamilogorek Sep 25, 2017
e5e5b22
docs: Add Sails.js integration docs
kamilogorek Sep 25, 2017
6c146b2
ci: Trigger build only once and cache deps
kamilogorek Sep 25, 2017
01e6de7
docs: Add name config description and optional ENV vars
kamilogorek Sep 22, 2017
b13ca83
feat(transport): enable keep-alives and limit number of sockets
mattrobenolt Mar 5, 2017
f5d3c08
feat(transport): retrieve socket name from http/s agents and add tests
kamilogorek Sep 12, 2017
41c10c4
feat: Fall back to NODE_ENV for Sentry Environment
kamilogorek Sep 26, 2017
ae75498
feat: Preserve some non-enumerable properties from request
kamilogorek Sep 22, 2017
f2801db
Rewrote tests and simplified implementation
kamilogorek Sep 26, 2017
588ac67
docs: Include information about fatalError install callback
kamilogorek Sep 22, 2017
443ea3a
2.2.0
kamilogorek Oct 2, 2017
151b6b5
Remove memwatch-next dependency
kamilogorek Oct 2, 2017
6d24403
fix: attach remaining non-enumerables to req
kamilogorek Oct 5, 2017
3f3d719
feat: Allow to configure stacktrace for captureMessage calls
kamilogorek Oct 5, 2017
ebcb270
docs: Add more clarification to req/request object
kamilogorek Oct 6, 2017
3b1c6e7
Fix typo in docs/config.rst
jorrit Oct 14, 2017
bf9dbab
Use tunnel-agent for proxying https request
ndmanvar Nov 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions lib/transports.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var timeoutReq = require('timed-out');

var http = require('http');
var https = require('https');
var Tls = require('tls');

function Transport() {}
util.inherits(Transport, events.EventEmitter);
Expand All @@ -17,6 +18,7 @@ function HTTPTransport(options) {
}
util.inherits(HTTPTransport, Transport);
HTTPTransport.prototype.send = function(client, message, headers, eventId, cb) {

var options = {
hostname: client.dsn.host,
path: client.dsn.path + 'api/' + client.dsn.project_id + '/store/',
Expand All @@ -25,6 +27,17 @@ HTTPTransport.prototype.send = function(client, message, headers, eventId, cb) {
port: client.dsn.port || this.defaultPort,
ca: client.ca
};

// set path apprpriately when using proxy
if (this.options.hasOwnProperty('host')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndmanvar I think you're missing setting the Host header to be set to client.dsn.host in case of proxy.
Without it the host header would keep the proxy host which cause the HTTP request to be rejected by the sentry.io server

if (client.dsn.protocol === 'http') {
options.path = 'http://' + client.dsn.host + ':' + client.dsn.port + client.dsn.path + 'api/' + client.dsn.project_id + '/store/'
} else {
options.path = client.dsn.host + ':' + client.dsn.port;
}
delete options.hostname; // only 'host' should be set when using proxy
}

for (var key in this.options) {
if (this.options.hasOwnProperty(key)) {
options[key] = this.options[key];
Expand Down Expand Up @@ -64,6 +77,22 @@ HTTPTransport.prototype.send = function(client, message, headers, eventId, cb) {
cbFired = true;
}
});

// TLS connection for proxying to HTTPS endpoint
/* req.on('connect', function (res, socket, head) {
var cts = Tls.connect({
host: client.dsn.host,
socket: socket
}, function () {
cts.write('GET /welcome HTTP/1.1rnHost: sentry.iornrn');
});

cts.on('data', function (data) {
// console.log(data.toString());
});
});
req.end(); */

req.end(message);
};

Expand All @@ -72,10 +101,37 @@ function HTTPSTransport(options) {
this.transport = https;
this.options = options || {};
}

function HTTPProxyTransport(options) {
// this.defaultPort = 80;
this.transport = http;
this.options = options || {};

// set host and port for proxy
this.options.host = options.proxyHost;
this.options.port = options.proxyPort;
}

function HTTPSProxyTransport(options) {
// Not working yet ):
this.defaultPort = 443;
this.transport = http;
this.options = options || {};

this.options.host = options.proxyHost;
this.options.port = options.proxyPort;
this.options.method = 'CONNECT';
}

util.inherits(HTTPSTransport, HTTPTransport);
util.inherits(HTTPProxyTransport, HTTPTransport);
util.inherits(HTTPSProxyTransport, HTTPTransport);

module.exports.http = new HTTPTransport();
module.exports.https = new HTTPSTransport();
module.exports.Transport = Transport;
module.exports.HTTPTransport = HTTPTransport;
module.exports.HTTPSTransport = HTTPSTransport;

module.exports.HTTPProxyTransport = HTTPProxyTransport;
module.exports.HTTPSProxyTransport = HTTPSProxyTransport;