mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-17 13:30:01 -04:00
Added Local Node Unblocker
This commit is contained in:
parent
455178384e
commit
f02f8b0e74
4 changed files with 131 additions and 2 deletions
24
newrelic.js
Normal file
24
newrelic.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* New Relic agent configuration.
|
||||
*
|
||||
* See lib/config.defaults.js in the agent distribution for a more complete
|
||||
* description of configuration variables and their potential values.
|
||||
*/
|
||||
exports.config = {
|
||||
/**
|
||||
* Array of application names.
|
||||
*/
|
||||
app_name: ['Node Unblocker'],
|
||||
/**
|
||||
* Your New Relic license key.
|
||||
*/
|
||||
license_key: process.env.NEW_RELIC_LICENSE_KEY,
|
||||
logging: {
|
||||
/**
|
||||
* Level at which to log. 'trace' is most useful to New Relic when diagnosing
|
||||
* issues with the agent, 'info' and higher will impose the least overhead on
|
||||
* production applications.
|
||||
*/
|
||||
level: 'info'
|
||||
}
|
||||
};
|
79
nodeub.js
Normal file
79
nodeub.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
/***************
|
||||
* node-unblocker: Web Proxy for evading firewalls and content filters,
|
||||
* similar to CGIProxy or PHProxy
|
||||
*
|
||||
*
|
||||
* This project is hosted on github: https://github.com/nfriedly/nodeunblocker.com
|
||||
*
|
||||
* By Nathan Friedly - http://nfriedly.com
|
||||
* Released under the terms of the Affero GPL v3
|
||||
*/
|
||||
|
||||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
var express = require('express');
|
||||
var unblocker = require('unblocker');
|
||||
var Transform = require('stream').Transform;
|
||||
|
||||
var app = express();
|
||||
|
||||
var google_analytics_id = process.env.GA_ID || null;
|
||||
|
||||
function addGa(html) {
|
||||
if (google_analytics_id) {
|
||||
var ga = [
|
||||
"<script type=\"text/javascript\">",
|
||||
"var _gaq = []; // overwrite the existing one, if any",
|
||||
"_gaq.push(['_setAccount', '" + google_analytics_id + "']);",
|
||||
"_gaq.push(['_trackPageview']);",
|
||||
"(function() {",
|
||||
" var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;",
|
||||
" ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';",
|
||||
" var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);",
|
||||
"})();",
|
||||
"</script>"
|
||||
].join("\n");
|
||||
html = html.replace("</body>", ga + "\n\n</body>");
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
function googleAnalyticsMiddleware(data) {
|
||||
if (data.contentType == 'text/html') {
|
||||
|
||||
// https://nodejs.org/api/stream.html#stream_transform
|
||||
data.stream = data.stream.pipe(new Transform({
|
||||
decodeStrings: false,
|
||||
transform: function(chunk, encoding, next) {
|
||||
this.push(addGa(chunk.toString()));
|
||||
next();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
var unblockerConfig = {
|
||||
prefix: '/proxy/',
|
||||
responseMiddleware: [
|
||||
googleAnalyticsMiddleware
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
|
||||
// this line must appear before any express.static calls (or anything else that sends responses)
|
||||
app.use(unblocker(unblockerConfig));
|
||||
|
||||
// serve up static files *after* the proxy is run
|
||||
app.use('/', express.static(__dirname + '/public'));
|
||||
|
||||
// this is for users who's form actually submitted due to JS being disabled or whatever
|
||||
app.get("/no-js", function(req, res) {
|
||||
// grab the "url" parameter from the querystring
|
||||
var site = querystring.parse(url.parse(req.url).query).url;
|
||||
// and redirect the user to /proxy/url
|
||||
res.redirect(unblockerConfig.prefix + site);
|
||||
});
|
||||
|
||||
// for compatibility with gatlin and other servers, export the app rather than passing it directly to http.createServer
|
||||
module.exports = app;
|
|
@ -5,7 +5,7 @@
|
|||
"main": "app.js",
|
||||
"scripts": {
|
||||
"test": "test",
|
||||
"start": "node app.js auth.js"
|
||||
"start": "node app.js auth.js ./node_modules/gatling/gatling.js ./nodeub.js"
|
||||
},
|
||||
"keywords": [
|
||||
"proxy",
|
||||
|
@ -21,6 +21,10 @@
|
|||
"node-fetch": "^2.6.1",
|
||||
"sanitizer": "^0.1.3",
|
||||
"session": "^0.1.0",
|
||||
"cookies": "0.4"
|
||||
"cookies": "0.4",
|
||||
"gatling": "~1.2.0",
|
||||
"newrelic": "^1.20.2",
|
||||
"through": "^2.3.8",
|
||||
"unblocker": "*"
|
||||
}
|
||||
}
|
22
packagenode.json
Normal file
22
packagenode.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "nodeunblocker.com",
|
||||
"description": "Web proxy for evading internet censorship",
|
||||
"author": "Nathan Friedly - http://nfriedly.com",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"homepage": "https://github.com/nfriedly/nodeunblocker.com/",
|
||||
"dependencies": {
|
||||
"express": "^4.13.0",
|
||||
"gatling": "~1.2.0",
|
||||
"newrelic": "^1.20.2",
|
||||
"through": "^2.3.8",
|
||||
"unblocker": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node ./node_modules/gatling/gatling.js ./app.js"
|
||||
},
|
||||
"license": "AGPL-3.0"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue