proxy.py/proxy.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

/*
proxy.py
~~~~~~~~
Fast, Lightweight, Programmable Proxy Server in a single Python file.
:copyright: (c) 2013-present by Abhinav Singh and contributors.
:license: BSD, see LICENSE for more details.
*/
Chrome Devtool Integration first steps (#109) * Initialize skeleton electron app * Attempt to open devtools * Electron free * Initialize public/devtools * Add basic support for static file serving and chrome devtools. 1. No cache header management for static file serving yet. 2. No chunked encoded responses for static files yet. 3. Chrome Devtool initialization. * Fix static serving with query params * profile using py-spy * Complete websocket client loop * lint check * Add support for building websocket frames * Remove redundant CDT params * Lint check * Refactor web server base plugin name * Devtools integrated, need more polish * Add START_TIME global var * lint fix * Remove outdated chrome rdp * Add FAQs * Add FAQs * socket_connection decorator + context manager * Defer SSL handshake and plugin initialize until protocol handler thread has started. This is a follow up to this PR https://github.com/abhinavsingh/proxy.py/pull/111 * Add tests for new_socket_connection and its friend socket_connection * Address an issue which came back after being fixed in https://github.com/abhinavsingh/proxy.py/pull/92 * Lint fixes * uff ye str and bytes * Remove explicit flushes outside of write ready descriptor handlers * add links to import proxy * Only try websocket upgrade if a route is registered * Add plugin_examples.WebServerPlugin and use precision logging for levelname * Remove redundant comments * Add --devtools-ws-path flag * Add on_websocket_open and on_websocket_close callbacks * Add empty stubs for incomplete CDT responses * Ensure client is ready before final flush * Shutdown on write side of socket, may be client is still reading * Since client.closed can be set, explicitly call client.connection.closed * Add ModifyPostDataPlugin example. Was first asked and referenced here https://github.com/abhinavsingh/proxy.py/issues/115 * Start adding TestHttpProxyPlugin * Fixes #116
2019-10-10 05:36:47 +00:00
const path = require('path');
const fs = require('fs');
const ncp = require('ncp').ncp;
ncp.limit = 16;
const publicFolderPath = path.join(__dirname, 'public');
const destinationFolderPath = path.join(publicFolderPath, 'devtools');
const publicFolderExists = fs.existsSync(publicFolderPath);
if (!publicFolderExists) {
console.error(publicFolderPath + ' folder doesn\'t exist, make sure you are in the right directory.');
process.exit(1);
}
const destinationFolderExists = fs.existsSync(destinationFolderPath);
if (!destinationFolderExists) {
console.error(destinationFolderPath + ' folder doesn\'t exist, make sure you are in the right directory.');
process.exit(1);
}
const chromeDevTools = path.dirname(require.resolve('chrome-devtools-frontend/front_end/inspector.html'));
console.log(chromeDevTools + ' ---> ' + destinationFolderPath);
ncp(chromeDevTools, destinationFolderPath, (err) => {
if (err) {
return console.error(err);
}
console.log('Copy successful!!!');
});