Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TorBot GUI #152

Merged
merged 37 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d69ade6
Adding front-end architecture
KingAkeem Nov 11, 2018
cfdb4c3
fixing titles
KingAkeem Nov 11, 2018
e055ab1
Adding eslint to hound
KingAkeem Nov 11, 2018
d43521a
Fixing syntax
KingAkeem Nov 11, 2018
81a3316
Removing buildJ
KingAkeem Nov 11, 2018
6d54348
Remvoing build and setting title
KingAkeem Nov 11, 2018
e119490
Setting up WS Server for front end
KingAkeem Nov 12, 2018
d52b5a6
Adding input and button
KingAkeem Nov 12, 2018
30b82d7
Successful WSMessages!
KingAkeem Nov 12, 2018
d725b11
Adding ability to use Onion links as well
KingAkeem Nov 12, 2018
06ef3be
Code cleanup
KingAkeem Nov 12, 2018
36f0f86
Adding support for onion
KingAkeem Nov 12, 2018
941e8fe
Adding onion button
KingAkeem Nov 12, 2018
66b1376
More styling, fixing WS latency issue
KingAkeem Nov 12, 2018
2a08689
Rendering links from TorBot
KingAkeem Nov 12, 2018
dc5636b
Removing useless enumeration
KingAkeem Nov 12, 2018
540e68e
Adding home button
KingAkeem Nov 12, 2018
a143d36
Merge branch 'dev' into front_end
KingAkeem Nov 16, 2018
9bbe784
Sending node links, updating function to class attribute
KingAkeem Nov 16, 2018
0c14198
Adding documentation
KingAkeem Nov 17, 2018
d8c42f8
Adding error checking for incorrect URLs
KingAkeem Nov 17, 2018
f994c3c
Returning after error, no need to render page
KingAkeem Nov 17, 2018
31ba103
Organizing file structure
KingAkeem Nov 17, 2018
f5a3b14
Async urls for websocket, results in better performance and smoother …
KingAkeem Nov 17, 2018
9b1ff79
Adding proxy head and actually displaying status of link
KingAkeem Nov 18, 2018
200917d
Cleaning up code
KingAkeem Nov 18, 2018
85cc2aa
Moving WebSocket to links
KingAkeem Nov 18, 2018
9265007
Adding documentation
KingAkeem Nov 18, 2018
aa70a9a
Disabling jshint
KingAkeem Nov 18, 2018
43dd359
Adding documentation
KingAkeem Nov 18, 2018
1989da5
Minor refactor
KingAkeem Nov 18, 2018
622a931
pylint and hound
KingAkeem Nov 18, 2018
54515e9
Renaming file
KingAkeem Nov 18, 2018
71594bf
Getting paste event to capture initial paste
KingAkeem Nov 18, 2018
e9032c7
Adding radio buttons for action selection
KingAkeem Nov 18, 2018
e33e272
Beginning work on get_info feature
KingAkeem Nov 18, 2018
fcf739d
Adding loading screen and renaming folder
KingAkeem Nov 24, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ modules/.pytest_cache
modules/.ropeproject/
modules/lib/*.so

# JS Ignores
node_modules
build

# Tests Ignores
tests/.pytest_cache
tests/*.pyc
Expand Down
5 changes: 4 additions & 1 deletion .hound.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
flake8:
enabled: true
enabled: true
eslint:
enbaled: true
config_file: ./ui/.eslintrc.json
12 changes: 12 additions & 0 deletions modules/wsserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import asyncio
import websockets

async def handle_msg(websocket, path):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 0

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 2 blank lines, found 1

msg = await websocket.recv()
print(path)
print(msg)

def startWSServer():
start_server = websockets.serve(handle_msg, 'localhost', '8080')
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pyinstaller==3.4.0
ete3==3.1.1
PyQt5==5.11.3
validators==0.12.2
websockets==7.0.0
8 changes: 7 additions & 1 deletion torBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from modules.updater import updateTor
from modules.savefile import saveJson
from modules.info import execute_all
from modules.wsserver import startWSServer

# GLOBAL CONSTS
LOCALHOST = "127.0.0.1"
Expand Down Expand Up @@ -118,6 +119,8 @@ def get_args():
help="Visualizes tree of data gathered.")
parser.add_argument("-d", "--download", action="store_true",
help="Downloads tree of data gathered.")
parser.add_argument("-g", "--gui", action="store_true",
help="Display GUI for TorBot.")
return parser.parse_args()


Expand All @@ -126,7 +129,8 @@ def main():
TorBot's Core
"""
args = get_args()
connect(args.ip, args.port)
if not args.gui:
connect(args.ip, args.port)
try:
node = LinkNode(args.url, tld=args.extension)
except (ValueError, HTTPError, ConnectionError) as err:
Expand Down Expand Up @@ -164,6 +168,8 @@ def main():
tree = LinkTree(node, tld=node.tld)
file_name = str(input("File Name (.pdf/.png/.svg): "))
tree.save(file_name)
elif args.gui:
startWSServer()
else:
LinkIO.display_children(node)
if args.save:
Expand Down
33 changes: 33 additions & 0 deletions ui/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"env": {
"node": true,
"browser": true,
"commonjs": true,
"es6": true
},
"extends": ["plugin:react/recommended","eslint:recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
Binary file added ui/images/tor-onion.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "torbot",
"version": "0.1.0",
"private": true,
"dependencies": {
"electron-reload-webpack-plugin": "^2.0.4",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-scripts": "2.0.5"
},
"scripts": {
"start": "webpack --mode development --watch",
"build": "webpack --mode production",
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron": "electron ."
},
"homepage": "./",
"main": "src/electron-main.js",
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"@babel/preset-env": "^7.1.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"css-loader": "^1.0.1",
"electron": "^3.0.8",
"electron-connect": "^0.6.3",
"electron-reload": "^1.2.5",
"eslint": "^5.9.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-react": "^7.11.1",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.4.4",
"prettier": "^1.15.2",
"webpack-cli": "^3.1.2"
}
}
Empty file added ui/src/app.css
Empty file.
11 changes: 11 additions & 0 deletions ui/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'import' is only available in ES6 (use 'esversion: 6').

import Home from './components/home';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'import' is only available in ES6 (use 'esversion: 6').

import './app.css';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'import' is only available in ES6 (use 'esversion: 6').


class App extends React.Component {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'class' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

render() {
return <Home/>;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw '<'.
Expected an identifier and instead saw '>'.
Missing semicolon.

}
}

export default App;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'export' is only available in ES6 (use 'esversion: 6').

Empty file added ui/src/components/home.css
Empty file.
37 changes: 37 additions & 0 deletions ui/src/components/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';


class Home extends React.Component {

constructor(props) {
super(props);
this.state = {url: ''};
this.onSubmit = this.onSubmit.bind(this);
this.onUrlChange = this.onUrlChange.bind(this);
}

onUrlChange(event) {
if (event.key === 'Enter') this.onSubmit();
this.setState({url: event.target.value});
}

onSubmit(event) {
let scope = this;
let ws = new WebSocket('ws://localhost:8080')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Missing semicolon.

ws.onopen = function() {
ws.send(scope.state.url);
};
}

render() {
return (
<React.Fragment>
<h1 align='center'>TorBot</h1>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclosed regular expression.
Unrecoverable syntax error. (76% scanned).

<input onKeyDown={this.onUrlChange} type='text'/>
<button onClick={this.onSubmit}></button>
</React.Fragment>
);
}
}

export default Home;
60 changes: 60 additions & 0 deletions ui/src/electron-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require('electron');
KingAkeem marked this conversation as resolved.
Show resolved Hide resolved

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
KingAkeem marked this conversation as resolved.
Show resolved Hide resolved

// Used in configuring path to load html from React
const path = require('path');
KingAkeem marked this conversation as resolved.
Show resolved Hide resolved
const url = require('url');
KingAkeem marked this conversation as resolved.
Show resolved Hide resolved

function createWindow () {
let browserOptions = {width: 800, height: 600};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

// Create the browser window.
mainWindow = new BrowserWindow(browserOptions);

// Configuring locaiton for HTML outputted after React
const startURL = url.format({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

pathname: path.join(__dirname, '../build/index.html'),
protocol: 'file:',
slashes: true
});

// Loads html
mainWindow.loadURL(startURL);

// Open the DevTools
mainWindow.webContents.openDevTools();

// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);


// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
14 changes: 14 additions & 0 deletions ui/src/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
15 changes: 15 additions & 0 deletions ui/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>TorBot</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
</body>
</html>
8 changes: 8 additions & 0 deletions ui/src/renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'import' is only available in ES6 (use 'esversion: 6').

import ReactDOM from 'react-dom';
PSNAppz marked this conversation as resolved.
Show resolved Hide resolved
import './global.css';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'import' is only available in ES6 (use 'esversion: 6').

import App from './app';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'import' is only available in ES6 (use 'esversion: 6').



ReactDOM.render(<App/>, document.getElementById('root'));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected ')' and instead saw 'App'.
Expected an assignment or function call and instead saw an expression.
Expected an identifier and instead saw ')'.
Expected an identifier and instead saw '<'.
Expected an identifier and instead saw '>'.
Missing semicolon.


73 changes: 73 additions & 0 deletions ui/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const MiniCssExtractTextPlugin = require('mini-css-extract-plugin');
const createElectronReloadWebpackPlugin = require('electron-reload-webpack-plugin');
KingAkeem marked this conversation as resolved.
Show resolved Hide resolved
const ElectronReloadWebpackPlugin = createElectronReloadWebpackPlugin({
KingAkeem marked this conversation as resolved.
Show resolved Hide resolved
path: './',
logLevel: 0
});
const HtmlWebpackPlugin = require('html-webpack-plugin');
KingAkeem marked this conversation as resolved.
Show resolved Hide resolved

const path = require('path');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

module.exports = {

watch: true,

target: 'electron-main',

entry: ['./src/renderer.js'],

output: {
path: __dirname + '/build',
filename: 'bundle.js'
},

module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
options: {
presets: ['@babel/react']
}
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractTextPlugin.loader
},
'css-loader'
]
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
query: {
name: '[name].[ext]?[hash]'
}
}
]
},

resolve: {
alias: {
images: path.resolve(__dirname, 'images')
}
},

plugins: [
new MiniCssExtractTextPlugin({
filename: 'bundle.css',
}),
new ElectronReloadWebpackPlugin(),
new HtmlWebpackPlugin({
title: 'TorBot',
template: 'src/index.html'

})
],

resolve: {
extensions: ['.js', '.json', '.jsx']
}

};