Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
6 README.markdown
@@ -71,6 +71,12 @@ disable that behavior with `opts.autoCreate`.
If `opts.checkout` is true, create and expected checked-out repos instead of
bare repos.
+If `opts.httpsOptions` is defined, create an https server instead. These options
+are a passthru to the options passed to node core
+[`https.createServer`](http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener).
+To use a self-signed cert or to ignore CA verification, you need to set `GIT_SSL_NO_VERIFY=1`
+in the shell where the `git push` will occur.
+
repos.handle(req, res, next)
----------------------------
View
16 example/https/https.js
@@ -0,0 +1,16 @@
+var fs = require('fs');
+var pushover = require('pushover');
+var options = {
+ httpsOptions: {
+ key: fs.readFileSync(__dirname + '/server.key'),
+ cert: fs.readFileSync(__dirname + '/server.crt')
+ }
+};
+
+var repos = pushover(__dirname + '/repos', options);
+
+repos.on('push', function (repo) {
+ console.log('received a push to ' + repo);
+});
+
+repos.listen(7000);
View
13 example/https/server.crt
@@ -0,0 +1,13 @@
+-----BEGIN CERTIFICATE-----
+MIIB4TCCAUoCCQCLuqR3TcdMVjANBgkqhkiG9w0BAQUFADA1MQswCQYDVQQGEwJV
+UzETMBEGA1UECBMKU29tZS1TdGF0ZTERMA8GA1UEChMIcHVzaG92ZXIwHhcNMTIw
+MzI4MTYxOTQyWhcNMTMwMzI4MTYxOTQyWjA1MQswCQYDVQQGEwJVUzETMBEGA1UE
+CBMKU29tZS1TdGF0ZTERMA8GA1UEChMIcHVzaG92ZXIwgZ8wDQYJKoZIhvcNAQEB
+BQADgY0AMIGJAoGBAMEHGZwaL8tPh/2gxHThdszzaDeYQZHb1rDTl6/Cy31hHbZk
+z0UWM+UsI5YlBS2F60J4AOU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8hfSoQ616T4X5mifY6bsrgZas
+sy0yJqqpishOiWK6JQJBAKSZ3x1Db/hwCre+U9UfY2haCHzDRQV0mBuGkB2VJBf3
+Dtx/IrCOZtNbgB+KtjnIwHwpYCHJzCkqMUnwKvlA3vM=
+-----END RSA PRIVATE KEY-----
View
11 index.js
@@ -3,6 +3,7 @@ var url = require('url');
var qs = require('querystring');
var path = require('path');
var http = require('http');
+var https = require('https');
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
@@ -18,14 +19,16 @@ function Git (repoDir, opts) {
this.repoDir = repoDir;
this.autoCreate = opts.autoCreate === false ? false : true;
this.checkout = opts.checkout;
+ this.httpsOptions = opts.httpsOptions;
}
Git.prototype = new EventEmitter;
Git.prototype.listen = function () {
var self = this;
- var server = http.createServer(this.handle.bind(this));
+ var server = this.createServer();
server.on('listening', function () {
+ console.log('listening')
var args = Array.prototype.slice.call(arguments);
args.unshift('listening');
self.emit.apply(self, args);
@@ -34,6 +37,12 @@ Git.prototype.listen = function () {
return server;
};
+Git.prototype.createServer = function () {
+ return typeof this.httpsOptions === 'object'
+ ? https.createServer(this.httpsOptions, this.handle.bind(this))
+ : http.createServer(this.handle.bind(this));
+}
+
Git.prototype.list = function (cb) {
fs.readdir(this.repoDir, cb);
};
View
111 test/https.js
@@ -0,0 +1,111 @@
+var test = require('tap').test;
+var pushover = require('../');
+
+var fs = require('fs');
+var path = require('path');
+var spawn = require('child_process').spawn;
+
+var seq = require('seq');
+
+var sslKey = new Buffer("-----BEGIN RSA PRIVATE KEY-----\n\
+MIICXAIBAAKBgQDBBxmcGi/LT4f9oMR04XbM82g3mEGR29aw05evwst9YR22ZM9F\n\
+FjPlLCOWJQUthetCeADlLbOIJpXUxCD65YaNhLDa7yNsG88PLWxkq2alCwBT7LLy\n\
+nbbVRfwafGCg2n2xsDJBw0TcuRK/kzqlq2/+MlUOhiiumSaP3gCwPhAusQIDAQAB\n\
+AoGAMSbNrqI8aVjnF/5ICDshNS8F6qIqkCmakYxPo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ho2EsNrvI2wbzw8tbGSrZqULAFPs\n\
+svKdttVF/Bp8YKDafbGwMkHDRNy5Er+TOqWrb/4yVQ6GKK6ZJo/eALA+EC6xAgMB\n\
+AAEwDQYJKoZIhvcNAQEFBQADgYEAEmaoBMJXk71S9q+Jpr9C8lU7F360xW9cArc3\n\
+iYZwTmF3TlzQURs43kSKY9Ue0ICza8apCyLyKWC1KYTMdDLw3q3Yk29zU7RMNoV6\n\
+agzKLGikSwyvcviTjotbHESbZjFpI8tYkbhAYy+rRlMr50Rw7BoC457CocsmHz9T\n\
+DBk9d8Q=\n\
+-----END CERTIFICATE-----");
+
+test('create, push to, and clone a repo over https', function (t) {
+ t.plan(2);
+
+ var repoDir = '/tmp/' + Math.floor(Math.random() * (1<<30)).toString(16);
+ var srcDir = '/tmp/' + Math.floor(Math.random() * (1<<30)).toString(16);
+ var dstDir = '/tmp/' + Math.floor(Math.random() * (1<<30)).toString(16);
+
+ fs.mkdirSync(repoDir, 0700);
+ fs.mkdirSync(srcDir, 0700);
+ fs.mkdirSync(dstDir, 0700);
+
+ var httpsOptions = {
+ key: sslKey,
+ cert: sslCert
+ };
+ var repos = pushover(repoDir, { autoCreate : false, httpsOptions: httpsOptions });
+ var port = Math.floor(Math.random() * ((1<<16) - 1e4)) + 1e4;
+ var server = repos.listen(port);
+
+ process.chdir(srcDir);
+ seq()
+ .seq(function () { repos.create('doom', this) })
+ .seq(function () {
+ var ps = spawn('git', [ 'init' ]);
+ ps.stderr.pipe(process.stderr, { end : false });
+ ps.on('exit', this.ok);
+ })
+ .seq(function () {
+ fs.writeFile(srcDir + '/a.txt', 'abcd', this);
+ })
+ .seq(function () {
+ spawn('git', [ 'add', 'a.txt' ]).on('exit', this.ok)
+ })
+ .seq(function () {
+ spawn('git', [ 'commit', '-am', 'a!!' ]).on('exit', this.ok)
+ })
+ .seq(function () {
+ var ps = spawn('git', [
+ 'push', 'https://localhost:' + port + '/doom', 'master'
+ ], {
+ env: {
+ 'GIT_SSL_NO_VERIFY': '1'
+ }
+ });
+ ps.stderr.pipe(process.stderr, { end : false });
+ ps.on('exit', this.ok);
+ })
+ .seq(function () {
+ process.chdir(dstDir);
+ spawn('git', [ 'clone', 'https://localhost:' + port + '/doom' ], {
+ env: {
+ 'GIT_SSL_NO_VERIFY': '1'
+ }
+ }).on('exit', this.ok)
+ })
+ .seq_(function (next) {
+ path.exists(dstDir + '/doom/a.txt', function (ex) {
+ t.ok(ex, 'a.txt exists');
+ next();
+ })
+ })
+ .seq(function () {
+ server.close();
+ t.end();
+ })
+ .catch(t.fail)
+ ;
+
+ repos.on('push', function (repo) {
+ t.equal(repo, 'doom');
+ });
+});

No commit comments for this range

Something went wrong with that request. Please try again.