forked from holy-unblocker/rammerhead
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure package to be used as cli tool
- Loading branch information
Showing
5 changed files
with
137 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ cache-js/* | |
|
||
# ignore any custom configurations | ||
/config.js | ||
|
||
# for any builders | ||
*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
// hack to catch any possible exceptions! | ||
// this package isn't a cli tool, the cli being installed is just for convenience | ||
process.chdir(__dirname); | ||
|
||
require('./src/server.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
const cookie = require('cookie'); | ||
|
||
module.exports = { | ||
//// HOSTING CONFIGURATION //// | ||
|
||
bindingAddress: '127.0.0.1', | ||
port: process.env.PORT, | ||
crossDomainPort: null, | ||
publicDir: null, | ||
|
||
ssl: null, | ||
|
||
// this function's return object will determine how the client url rewriting will work. | ||
// set them differently from bindingAddress and port if rammerhead is being served | ||
// from a reverse proxy. | ||
getServerInfo: (req) => { | ||
const { origin_proxy } = cookie.parse(req.headers.cookie || ''); | ||
|
||
let origin; | ||
|
||
try { | ||
origin = new URL(origin_proxy); | ||
} catch (error) { | ||
console.log(error, req.headers.cookie); | ||
origin = new URL(`${req.socket.encrypted ? 'https:' : 'http:'}//${req.headers.host}`); | ||
} | ||
|
||
const { hostname, port, protocol } = origin; | ||
|
||
return { | ||
hostname, | ||
port, | ||
crossDomainPort: port, | ||
protocol | ||
}; | ||
}, | ||
|
||
password: null, | ||
|
||
// disable or enable localStorage sync (turn off if clients send over huge localStorage data, resulting in huge memory usages) | ||
disableLocalStorageSync: false, | ||
|
||
// restrict sessions to be only used per IP | ||
restrictSessionToIP: true, | ||
|
||
//// REWRITE HEADER CONFIGURATION //// | ||
|
||
stripClientHeaders: [ | ||
'cf-ipcountry', | ||
'cf-ray', | ||
'x-forwarded-proto', | ||
'cf-visitor', | ||
'cf-connecting-ip', | ||
'cdn-loop', | ||
'x-forwarded-for' | ||
], | ||
rewriteServerHeaders: { | ||
// you can also specify a function to modify/add the header using the original value (undefined if adding the header) | ||
// 'x-frame-options': (originalHeaderValue) => '', | ||
'x-frame-options': null // set to null to tell rammerhead that you want to delete it | ||
}, | ||
|
||
//// LOGGING CONFIGURATION //// | ||
|
||
// valid values: 'disabled', 'debug', 'traffic', 'info', 'warn', 'error' | ||
generatePrefix: (level) => `[${new Date().toISOString()}] [${level.toUpperCase()}] `, | ||
|
||
// logger depends on this value | ||
getIP: (req) => (req.headers['x-forwarded-for'] || req.connection.remoteAddress || '').split(',')[0].trim() | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,55 @@ | ||
{ | ||
"name": "rammerhead", | ||
"version": "1.2.3", | ||
"description": "User friendly web proxy powered by testcafe-hammerhead", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions", | ||
"start": "node src/server.js", | ||
"build": "node src/build.js", | ||
"bstart": "npm run build && npm run start", | ||
"test": "npm run format && npm run lint && npm run build", | ||
"lint": "eslint -c .eslintrc.json --ext .js src", | ||
"format": "prettier --write 'src/**/*.js'", | ||
"clientes5": "es-check es5 src/client/*.js public/**/*.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/binary-person/rammerhead.git" | ||
}, | ||
"author": "Simon Cheng <[email protected]> (https://github.com/binary-person)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/binary-person/rammerhead/issues" | ||
}, | ||
"homepage": "https://github.com/binary-person/rammerhead#readme", | ||
"dependencies": { | ||
"cookie": "^0.5.0", | ||
"async-exit-hook": "^2.0.1", | ||
"keyv-lru-files": "github:binary-person/keyv-lru-files#patch-1", | ||
"mime": "^2.5.2", | ||
"sticky-session-custom": "^1.2.0", | ||
"testcafe-hammerhead": "24.5.18", | ||
"uglify-js": "^3.15.3", | ||
"uuid": "^8.3.2", | ||
"ws": "^8.2.0", | ||
"babel-eslint": "^10.1.0", | ||
"dotenv-flow": "^3.2.0", | ||
"eslint": "^7.32.0", | ||
"npm-force-resolutions": "0.0.10", | ||
"prettier": "^2.3.2" | ||
}, | ||
"resolutions": { | ||
"tmp": "0.2.1" | ||
}, | ||
"files": [ | ||
"src/*", | ||
"CHANGELOG.md", | ||
"package.json", | ||
"README.md" | ||
] | ||
"name": "rammerhead", | ||
"version": "1.2.3", | ||
"description": "User friendly web proxy powered by testcafe-hammerhead", | ||
"bin": "bin.js", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions", | ||
"start": "node src/server.js", | ||
"build": "node src/build.js", | ||
"bstart": "npm run build && npm run start", | ||
"test": "npm run format && npm run lint && npm run build", | ||
"lint": "eslint -c .eslintrc.json --ext .js src", | ||
"format": "prettier --write 'src/**/*.js'", | ||
"clientes5": "es-check es5 src/client/*.js public/**/*.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/binary-person/rammerhead.git" | ||
}, | ||
"author": "Simon Cheng <[email protected]> (https://github.com/binary-person)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/binary-person/rammerhead/issues" | ||
}, | ||
"homepage": "https://github.com/binary-person/rammerhead#readme", | ||
"dependencies": { | ||
"cookie": "^0.5.0", | ||
"async-exit-hook": "^2.0.1", | ||
"keyv-lru-files": "github:binary-person/keyv-lru-files#patch-1", | ||
"mime": "^2.5.2", | ||
"sticky-session-custom": "^1.2.0", | ||
"testcafe-hammerhead": "24.5.18", | ||
"uglify-js": "^3.15.3", | ||
"uuid": "^8.3.2", | ||
"ws": "^8.2.0", | ||
"babel-eslint": "^10.1.0", | ||
"dotenv-flow": "^3.2.0", | ||
"eslint": "^7.32.0", | ||
"npm-force-resolutions": "0.0.10", | ||
"prettier": "^2.3.2" | ||
}, | ||
"resolutions": { | ||
"tmp": "0.2.1" | ||
}, | ||
"files": [ | ||
"src/*", | ||
"holy-config.js", | ||
"CHANGELOG.md", | ||
"package.json", | ||
"README.md", | ||
"sessions/.gitkeep", | ||
"cache-js/.gitkeep" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters