Titanium Networks main web proxy. Successor to Alloy.
- Corrosion
- Installation
- Public Deployment Example
- Advanced Configuration
- Middleware
- Contributing
- Todo
npm i corrosion
"in your js file:"
require("corrosion")
OR
git clone https://github.com/EnderKingJ/Simplified-Corrosion.git
cd Simplified-Corrosion
npm install
npm start
For implementing a Corrosion server into your production website, we recommend you follow the below configuration.
index.html
<!DOCTYPE html>
<html>
<head>
<style>
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #222;
color: white;
}
</style>
</head>
<body>
<form action="/service/gateway/" method="POST">
Corrosion<br><br>
<input name="url" placeholder="Search the web"><br>
<input type="submit" value="Go">
</form>
</body>
</html>
index.js
const http = require('http');
const fs = require('fs');
const path = require('path');
const Corrosion = require('corrosion');
const server = http.createServer();
const proxy = new Corrosion({
codec: 'xor', // apply basic xor encryption to url parameters in an effort to evade filters. Optional.
prefix: '/service/', // specify the endpoint (prefix). Optional.
requestMiddleware: [Corrosion.middleware.https()] // encode HTTPS:// protocol on urls, fixes Corrosion on Heroku and Repl.it
});
proxy.bundleScripts();
server.on('request', (request, response) => {
if (request.url.startsWith(proxy.prefix)) return proxy.request(request, response);
response.end(fs.readFileSync(__dirname + '/index.html', 'utf-8'));
}).on('upgrade', (clientRequest, clientSocket, clientHead) => proxy.upgrade(clientRequest, clientSocket, clientHead)).listen(8443); // port other than 443 if it is needed by other software.
Access a Website by going to https://your-url.com/service/gateway?url=https://url-to-proxify.com
{
'prefix': '/get/', // String - URL Prefix
'title': 'Woah Corrosion', // (Boolean / String) - Title used for HTML documents
'ws': true, // Boolean - WebSocket rewriting
'cookie': true, // Boolean - Request Cookies
'codec': 'base64', // String - URL encoding (base64, plain, xor).
'requestMiddleware': [Corrosion.middleware.address([0.0.0.0])] // Array - Array of [middleware](../README.md#middleware) functions for proxy request (Server).
'responseMiddleware': [myCustomMiddleware()] // Array - Array of [middleware](../README.md#middleware) functions for proxy response (Server).
'standardMiddleware': true // Boolean - Use the prebuilt [middleware](../README.md#middleware) used by default (Server).
}
Middleware are functions that will be executed either before request or after response. These can alter the way a request is made or response is sent.
function(ctx) {
ctx.body; // (Request / Response) Body (Will return null if none)
ctx.headers; // (Request / Response) Headers
ctx.url; // WHATWG URL
ctx.flags; // URL Flags
ctx.origin; // Request origin
ctx.method; // Request method
ctx.rewrite; // Corrosion object
ctx.statusCode; // Response status (Only available on response)
ctx.agent; // HTTP agent
ctx.address; // Address used to make remote request
ctx.clientSocket; // Node.js Server Socket (Only available on upgrade)
ctx.clientRequest; // Node.js Server Request
ctx.clientResponse; // Node.js Server Response
ctx.remoteResponse; // Node.js Remote Response (Only available on response)
};
-
Request
- requestHeaders
-
Response
- responseHeaders
- decompress
- rewriteBody
arr
Array of IP addresses to use in request.
const Corrosion = require('corrosion');
const proxy = new Corrosion({
requestMiddleware: [
Corrosion.middleware.address([
0.0.0.0,
0.0.0.0
]),
],
});
arr
Array of hostnames to block clients from seeing.page
Block page.
const Corrosion = require('corrosion');
const proxy = new Corrosion({
requestMiddleware: [
Corrosion.middleware.blacklist([
'example.org',
'example.com',
], 'Page is blocked'),
],
});
See something lacking in Corrosion that you can fix? Fork the repo, make some changes, and send in a pull request.
- Code readability/commenting
- Documentation (wiki)
- JS Rewriter
- Uniform error codes
- JS Rewriter: Inject header properties (due to import statements).