Titanium Networks main web proxy. Successor to Alloy
npm i corrosion
const Corrosion = require('corrosion');
const proxy = new Corrosion();
const http = require('http')
http.createServer((req, res) =>
proxy.request(req, res) // Request Proxy
).on('upgrade', (req, socket, head) =>
proxy.upgrade(req, socket, head) // WebSocket Proxy
).listen(80);
Access a website by going to /prefix/gateway?url=URL
Much more in depth one is in the demo folder.
config
prefix
String - URL Prefixtitle
(Boolean / String) - Title used for HTML documentsws
Boolean - WebSocket rewritingcookie
Boolean - Request Cookiescodec
String - URL encoding (base64, plain, xor).requestMiddleware
Array - Array of middleware functions for proxy request (Server).responseMiddleware
Array - Array of middleware functions for proxy response (Server).standardMiddleware
Boolean - Use the prebuilt middleware used by default (Server).
request
Requestresponse
Response
request
Requestsocket
Sockethead
Head
Bundles scripts for client injection. Important when updating proxy.
val
Stringconfig
Configurationbase
WHATWG URLorigin
Location origin - Adds a location origin before the proxy urlflags
Array - ['xhr'] => /service/xhr_/https%3A%2F%2Fexample.org/
val
Stringconfig
Configurationorigin
Location origin - Required if a location origin starts before the proxy urlflags
Boolean - Returns with both the URL and flags found { value: 'https://example.org', flags: ['xhr'], })leftovers
Boolean - Use any leftovers if any after the encoded proxy url
-
regex
Regex used to determine to rewrite the URL or not. -
prefix
URL Prefix -
codec
(base64, plain, xor)
source
JS scripturl
URL for heading
ast
JS ASTCallback
Handler initated on AST node
url
URL for heading
callee
Acorn.js Nodeargs
Array
elements
Array
name
Identifier namepreventRewrite
Prevent further rewrites
value
Literal value
source
CSSconfig
Configurationbase
WHATWG URLorigin
Location origincontext
CSS-Tree context
source
HTML Sourceconfig
Configurationdocument
Determines of its a document or fragment for parsingbase
WHATWG URLorigin
Location origin
processed
Rewritten HTMLconfig
Configurationdocument
Determines of its a document or fragment for parsing
map
Map for attribute rewriting
input
New (Cookie / Cookies)config
Configurationurl
WHATWG URLdomain
Cookie Domainsecure
Cookie Secure
store
Encoded Cookiesconfig
Configurationurl
WHATWG URL
str
String
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) {r
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 seeingpage
Block page
const Corrosion = require('corrosion');
const proxy = new Corrosion({
requestMiddleware: [
Corrosion.middleware.blacklist([
'example.org',
'example.com',
], 'Page is blocked'),
],
});
- Inject header much more property in JS rewriter (because of import statements)