allproxy
Version:
AllProxy: MITM HTTP Debugging Tool.
70 lines • 2.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
class Paths {
static getDataDir() {
return this.dataDir;
}
static configJson() {
return Paths.platform(`${Paths.dataDir}config.json`);
}
static sslCaDir() {
return Paths.platform(`${Paths.dataDir}.http-mitm-proxy`);
}
static certsDirAndSlash() {
return Paths.platform(`${Paths.sslCaDir()}/certs/`);
}
static keysDirAndSlash() {
return Paths.platform(`${Paths.sslCaDir()}/keys/`);
}
static copyCaPemToRoot() {
const src = Paths.platform(Paths.platform(Paths.dataDir + '.http-mitm-proxy/certs/ca.pem'));
const dst = Paths.platform(Paths.dataDir + 'ca.pem');
try {
fs_1.default.copyFileSync(src, dst);
}
catch (e) { } // Already exists
}
static setupInterceptDir() {
// Installed from NPM?
if (process.env.ALLPROXY_DATA_DIR) {
const target = Paths.platform(`${Paths.interceptDir()}/InterceptResponse.js`);
const path = Paths.platform(Paths.platform(`${Paths.baseDir}intercept/InterceptResponse.js`));
if (!fs_1.default.existsSync(target)) {
fs_1.default.copyFileSync(path, target);
fs_1.default.renameSync(path, Paths.platform(path + '.bak'));
}
try {
fs_1.default.symlinkSync(target, path);
}
catch (e) { } // Already exists
}
}
static clientDir() {
return Paths.platform(`${Paths.baseDir}client`);
}
static protoDir() {
return Paths.platform(`${Paths.dataDir}proto`);
}
static interceptDir() {
return Paths.platform(`${Paths.dataDir}intercept`);
}
static sep() {
return /*process.env.SHELL?.indexOf('bash') !== -1 ? '/' :*/ path_1.default.sep;
}
static platform(dir) {
return dir.replace(/\//g, Paths.sep());
}
}
exports.default = Paths;
Paths.baseDir = process.env.NODE_ENV === 'production'
? `${__dirname + ''}/../../../`
: `${__dirname + ''}/../../`;
Paths.dataDir = process.env.ALLPROXY_DATA_DIR
? `${process.env.ALLPROXY_DATA_DIR}/`
: Paths.baseDir;
//# sourceMappingURL=Paths.js.map