Skip to content

Commit

Permalink
Added project selection menu
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Oct 30, 2020
1 parent 27b0d7f commit 96650f0
Show file tree
Hide file tree
Showing 12 changed files with 441 additions and 129 deletions.
43 changes: 28 additions & 15 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import burp.gui.ConnectionPanel;
import burp.gui.LoadingPanel;
import burp.gui.MainPanel;
import burp.gui.SelectProjectPanel;
import java.awt.Component;
import javax.swing.JPanel;

Expand Down Expand Up @@ -54,31 +55,43 @@ public void main() {
if (BurpExtender.rootPanel == null) {
BurpExtender.rootPanel = new MultiplayerRootPanel();
}
// ConnectionPanel

// Initialize all panels
ConnectionPanel connectionPanel = new ConnectionPanel(multiplayer, logger);
LoadingPanel loadingPanel = new LoadingPanel(multiplayer, logger);
SelectProjectPanel selectProjectPanel = new SelectProjectPanel(multiplayer, logger);

// ConnectionPanel
BurpExtender.rootPanel.add(connectionPanel);

connectionPanel.onConnection(() -> {
logger.debug("onConnection()");
BurpExtender.rootPanel.remove(connectionPanel);

BurpExtender.rootPanel.add(loadingPanel);
// Select Project Panel
selectProjectPanel.initProjectList();
BurpExtender.rootPanel.add(selectProjectPanel);
BurpExtender.rootPanel.repaint();
BurpExtender.rootPanel.revalidate();
loadingPanel.initialize();
loadingPanel.registerOnCompleteCallback(() -> {
BurpExtender.rootPanel.remove(loadingPanel);
BurpExtender.mainPanel = new MainPanel(multiplayer, logger);
BurpExtender.rootPanel.add(mainPanel);

// HTTP Listener
BurpExtender.callbacks.registerHttpListener(multiplayer);
selectProjectPanel.onProjectSelection(() -> {
BurpExtender.rootPanel.remove(selectProjectPanel);

// Loading Panel
BurpExtender.rootPanel.add(loadingPanel);
BurpExtender.rootPanel.repaint();
BurpExtender.rootPanel.revalidate();
});
BurpExtender.rootPanel.revalidate();
loadingPanel.initialize();
loadingPanel.registerOnCompleteCallback(() -> {
BurpExtender.rootPanel.remove(loadingPanel);

// Main Panel
BurpExtender.mainPanel = new MainPanel(multiplayer, logger);
BurpExtender.rootPanel.add(mainPanel);
BurpExtender.callbacks.registerHttpListener(multiplayer);
BurpExtender.rootPanel.repaint();
BurpExtender.rootPanel.revalidate();
});


});
});

BurpExtender.rootPanel.repaint();
Expand Down
38 changes: 26 additions & 12 deletions src/burp/Multiplayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public Multiplayer(BurpExtender extension, MultiplayerLogger logger) {
}

// Database = Project Name
public Boolean connect(String hostname, Integer port, String database) {
logger.info("Connecting to '%s:%d/%s' ...", hostname, port, database);
public Boolean connect(String hostname, Integer port) {
logger.info("Connecting to '%s:%d' ...", hostname, port);
dbHostname = hostname;
dbPort = port;
try {
Expand All @@ -98,14 +98,6 @@ public Boolean connect(String hostname, Integer port, String database) {
}
if (dbConn.isOpen()) {
logger.debug("Successfully connected: %s", dbConn);
dbName = database;

Result<Object> result = r.dbList().run(dbConn);
ArrayList<String> dbList = (ArrayList<String>) result.single();
if (!dbList.contains(dbName)) {
createDatabase();
}
logger.debug("Connected!");
return true;
} else {
return false;
Expand Down Expand Up @@ -134,6 +126,28 @@ public void startChangefeed() {
}
});
}

public List<String> getProjects() {
if (isConnected()) {
Result<Object> result = r.dbList().run(dbConn);
return (ArrayList<String>) result.single();
}
return new ArrayList<>();
}

public void setProject(String projectName) {
dbName = projectName;
logger.debug("Database/project name: %s", projectName);
Result<Object> result = r.dbList().run(dbConn);
ArrayList<String> dbList = (ArrayList<String>) result.single();
if (!dbList.contains(dbName)) {
createDatabase();
}
}

public void deleteProject(String projectName) {
r.dbDrop(projectName).run(dbConn);
}

private void createDatabase() {
logger.info("Database '%s' does not exist, initializing ...", dbName);
Expand All @@ -159,7 +173,7 @@ private void initalizeHistory() {

try {
Result<Integer> countCursor = http().count().run(dbConnect(), Integer.class);
dbCount = countCursor.next();
dbCount = countCursor.single();
logger.debug("Expect %d results ...", dbCount);
dbLoaded = 0;

Expand All @@ -170,7 +184,7 @@ private void initalizeHistory() {

while (dbLoaded < dbCount) {
Result<MultiplayerRequestResponse> result = http().skip(dbLoaded).limit(1).run(dbConn, MultiplayerRequestResponse.class);
MultiplayerRequestResponse entry = result.next();
MultiplayerRequestResponse entry = result.single();
logger.debug("Got entry %d of %d: %s", dbLoaded, dbCount, entry);
history.add(entry);
dbLoaded++;
Expand Down
67 changes: 37 additions & 30 deletions src/burp/gui/ConnectionPanel.form
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace pref="400" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="saveSettingsCheckBox" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
<Component id="titleLabel" min="-2" pref="223" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="projectNameLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="projectNameTextField" max="32767" attributes="0"/>
</Group>
<Group type="103" alignment="1" groupAlignment="1" max="-2" attributes="0">
<Component id="connectButton" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
Expand All @@ -43,20 +38,27 @@
</Group>
</Group>
</Group>
<EmptySpace pref="401" max="32767" attributes="0"/>
<EmptySpace pref="400" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="setupHelpButton" max="32767" attributes="0"/>
<Component id="githubButton" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Component id="setupHelpButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="githubButton" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="122" max="-2" attributes="0"/>
<Component id="titleLabel" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="projectNameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="projectNameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="hostnameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
Expand All @@ -71,7 +73,7 @@
<Component id="saveSettingsCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Component id="connectButton" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="320" max="32767" attributes="0"/>
<EmptySpace pref="323" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
Expand Down Expand Up @@ -102,22 +104,11 @@
<Property name="text" type="java.lang.String" value="28015"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="projectNameLabel">
<Properties>
<Property name="text" type="java.lang.String" value="Project Name"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="projectNameTextField">
<Properties>
<Property name="columns" type="int" value="10"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="projectNameTextFieldActionPerformed"/>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="projectNameTextFieldKeyReleased"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="titleLabel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name=".SF NS Text" size="13" style="1"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="RethinkDB Connection"/>
</Properties>
Expand All @@ -140,5 +131,21 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="saveSettingsCheckBoxActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="setupHelpButton">
<Properties>
<Property name="text" type="java.lang.String" value="Setup Help"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="setupHelpButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="githubButton">
<Properties>
<Property name="label" type="java.lang.String" value="GitHub"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="githubButtonActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

0 comments on commit 96650f0

Please sign in to comment.