Skip to content

Commit

Permalink
Added database version check
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Nov 1, 2020
1 parent 11499a0 commit 7a8e62d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/burp/Multiplayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ private void initalizeHistory() {
while (dbLoaded < dbCount) {

Result<MultiplayerRequestResponse> result = http()
.orderBy().optArg("index", r.asc("time"))
.skip(dbLoaded)
.limit(step)
.run(dbConn, MultiplayerRequestResponse.class);
.orderBy().optArg("index", r.asc("time"))
.skip(dbLoaded)
.limit(step)
.run(dbConn, MultiplayerRequestResponse.class);

while (result.hasNext()) {
MultiplayerRequestResponse entry = result.next();
logger.debug("Got entry %d of %d: %s", dbLoaded, dbCount, entry);
Expand Down Expand Up @@ -548,10 +548,10 @@ private Table version() {
return r.db(dbName).table(VersionTable);
}

private MultiplayerSemanticVersion getDatabaseSemVer() {
public MultiplayerSemanticVersion getDatabaseSemanticVerion() {
Result<MultiplayerSemanticVersion> result = version()
.limit(1)
.run(dbConn, MultiplayerSemanticVersion.class);
.limit(1)
.run(dbConn, MultiplayerSemanticVersion.class);
return result.single();
}

Expand Down
11 changes: 6 additions & 5 deletions src/burp/gui/ConnectionPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import burp.IBurpExtenderCallbacks;
import burp.Multiplayer;
import burp.MultiplayerLogger;
import burp.version.MultiplayerSemanticVersion;
import burp.version.MultiplayerVersion;
import java.awt.Desktop;
import java.io.IOException;
Expand Down Expand Up @@ -227,13 +228,13 @@ private void hostnameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {/

private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectButtonActionPerformed

this.connectButton.setEnabled(false);
connectButton.setEnabled(false);

String hostname = this.hostnameTextField.getText();
Integer port = Integer.parseInt(this.portNumberTextField.getText());
String hostname = hostnameTextField.getText();
Integer port = Integer.parseInt(portNumberTextField.getText());

try {
Boolean connected = this.multiplayer.connect(hostname, port);
Boolean connected = multiplayer.connect(hostname, port);
if (connected) {

if (saveSettingsCheckBox.isSelected()) {
Expand All @@ -249,7 +250,7 @@ private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN
String.format("Failed to connect.\n%s", err),
"Conncection Error",
JOptionPane.ERROR_MESSAGE);
this.connectButton.setEnabled(true);
connectButton.setEnabled(true);
}
}//GEN-LAST:event_connectButtonActionPerformed

Expand Down
27 changes: 25 additions & 2 deletions src/burp/gui/SelectProjectPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import burp.IBurpExtenderCallbacks;
import burp.Multiplayer;
import burp.MultiplayerLogger;
import burp.version.MultiplayerSemanticVersion;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultListModel;
Expand Down Expand Up @@ -134,12 +135,28 @@ private void selectProjectButtonActionPerformed(java.awt.event.ActionEvent evt)
String project = projectsJList.getSelectedValue();
if (project != null && !project.isBlank() && !project.isEmpty()) {
multiplayer.setProject(project);

logger.debug("Version check ...");
MultiplayerSemanticVersion mySemVer = MultiplayerSemanticVersion.mySemanticVerion();
MultiplayerSemanticVersion dbSemVer = multiplayer.getDatabaseSemanticVerion();

if (dbSemVer == null || !mySemVer.isCompatible(dbSemVer)) {
JOptionPane.showMessageDialog(this,
"The project database contains a different version than your extension. ",
"Compatability Warning",
JOptionPane.WARNING_MESSAGE);
}

triggerOnProjectSelection();
}
}//GEN-LAST:event_selectProjectButtonActionPerformed

private void createProjectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createProjectButtonActionPerformed
String projectName = JOptionPane.showInputDialog(null, "New project name:", "Create Project", JOptionPane.QUESTION_MESSAGE);
String projectName = JOptionPane.showInputDialog(null,
"New project name:",
"Create Project",
JOptionPane.QUESTION_MESSAGE);

if (projectName != null && !projectName.isBlank() && !projectName.isEmpty()) {
multiplayer.setProject(projectName);
triggerOnProjectSelection();
Expand All @@ -150,7 +167,13 @@ private void deleteProjectButtonActionPerformed(java.awt.event.ActionEvent evt)
String project = projectsJList.getSelectedValue();
if (project != null && !project.isBlank() && !project.isEmpty()) {
String message = String.format("Delete project '%s'?", project);
int confirmation = JOptionPane.showConfirmDialog(null, message, "Delete Project", JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);

int confirmation = JOptionPane.showConfirmDialog(null,
message,
"Delete Project",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE);

logger.debug("Confirmation: %d", confirmation);
if (confirmation == 0) {
multiplayer.deleteProject(project);
Expand Down

0 comments on commit 7a8e62d

Please sign in to comment.