Skip to content

Commit

Permalink
Done some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
StupidRepo committed Jul 16, 2023
1 parent e50283e commit 56ff736
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Changes
All notable changes to this project will be documented in `CHANGELOG.md`.
## Added
None
* You can now configure how many threads you use upon starting MCScanner.
<img alt="Image of thread menu" height="75%" src="images/1_11-threadmenu.png" width="75%"/>

## Modified
* Fixed the GitHub Workflow.
* Updated `README.md`
* Includes link to the `CHANGELOG.md` file.
* Includes notice that says macOS users can just double-click on the `.jar` file.
* Updated the requirements.

## Removed
None
Nothing has been removed.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
Now re-made in Java, and not Python!

## Requirements
* [`Java 17`][adopt17]
* [`JDK 17`][adopt17]
* MongoDB database (required for storing IPs)
* Stable internet connection
* A good computer (with a good CPU)

## Run
### macOS + Linux + Windows
1. Download the latest `.jar` file from the [releases page][releases].
2. Run the `.jar` file with `java -jar /path/to/MCScanner.jar` from Command Prompt or Terminal.
Note: If you're on macOS, you can just double-click on the `.jar` file.

## Build
### macOS + Linux + Windows
Expand All @@ -18,10 +20,15 @@ Now re-made in Java, and not Python!
3. Build the project with `Build > Build Project`.
4. Run the project with `Run > Run 'MCScanner [run]'`.

## Changelogs
All notable changes to this project will be documented in [`CHANGELOG.md`][changes].

# Warning
### **This program was made for educational purposes only, and is not meant to be used in malicious ways**.
Do not DDOS the IPs or do *anything* malicious with the IPs. The only thing this program is supposed to be used for is finding random Minecraft servers and joining them!
Oh, and **don't use this program for griefing**. Please.

[adopt17]: https://adoptium.net/en-GB/download/
[releases]: https://github.com/StupidRepo/MCScanner/releases

[releases]: https://github.com/StupidRepo/MCScanner/releases
[changes]: https://github.com/StupidRepo/MCScanner/blob/main/CHANGELOG.md
Binary file added images/1_11-threadmenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 54 additions & 6 deletions src/com/stupidrepo/mcscanner/MCScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.xml.crypto.Data;

public class MCScanner {
public static void main(String[] var0) {
int threads = 1024;
AtomicInteger threads = new AtomicInteger(1024);
int timeout = 1000;
int minimumRange = 1;
int maxRange = 255;
Expand All @@ -25,10 +23,60 @@ public static void main(String[] var0) {
// TODO: Optimize all of this code.
Logger logger = Logger.getLogger("com.stupidrepo.mcscanner");

float version = 1.10f;
float version = 1.11f;

DatabaseHandler databaseHandler = new DatabaseHandler("mongodb://localhost:27017");

// Make a window with an input box to input amount of threads
JFrame threadFrame = new JFrame("MCScanner v" + version);
threadFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
threadFrame.setSize(500, 125);
threadFrame.setLayout(new BorderLayout());

JLabel threadLabel = new JLabel("Threads to use (default is 1024, recommended is 1024-2048):");
threadLabel.setHorizontalAlignment(0);

threadFrame.add(threadLabel, "North");

JTextField threadField = new JTextField("1024");
threadField.setHorizontalAlignment(0);

threadFrame.add(threadField, "Center");

JButton threadButton = new JButton("OK");
threadFrame.add(threadButton, "East");

JButton quitButton = new JButton("Quit");
threadFrame.add(quitButton, "South");

threadButton.addActionListener(e -> {
try {
Integer.parseInt(threadField.getText());
} catch (NumberFormatException exception) {
JOptionPane.showMessageDialog(null, "Invalid number.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
threads.set(Integer.parseInt(threadField.getText()));
threadFrame.setVisible(false);
threadFrame.dispatchEvent(new WindowEvent(threadFrame, 201));
});

quitButton.addActionListener(e -> {
threadFrame.setVisible(false);
threadFrame.dispatchEvent(new WindowEvent(threadFrame, 201));
System.exit(0);
});

threadFrame.setVisible(true);

while(threadFrame.isVisible()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

logger.log(Level.INFO, "Scanning IPs...");

JFrame frame = new JFrame("MCScanner v" + version);
Expand Down Expand Up @@ -59,7 +107,7 @@ public static void main(String[] var0) {
threadList.add(scanThread);
scanThread.start();

if (threadList.size() >= threads) {
if (threadList.size() >= threads.get()) {
for (Thread nextThread: threadList) {
try {
nextThread.join();
Expand Down

0 comments on commit 56ff736

Please sign in to comment.