Commit 2093196b authored by pokkst's avatar pokkst

Upload

parent d2fb7fa1
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.fxmisc.easybind:easybind:1.0.2" level="project" />
<orderEntry type="library" name="Maven: de.jensd:fontawesomefx:8.0.0" level="project" />
<orderEntry type="library" name="Maven: net.glxn:qrgen:1.3" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:javase:2.0" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:core:2.0" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
<orderEntry type="library" name="Maven: com.lambdaworks:scrypt:1.4.0" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna:4.2.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-jdk14:1.7.7" level="project" />
<orderEntry type="library" name="Maven: org.controlsfx:controlsfx:8.40.10" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp:okhttp:2.7.2" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.6.0" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" name="Maven: com.madgag.spongycastle:core:1.51.0.0" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.5.0" level="project" />
<orderEntry type="module-library">
<library name="Maven: org.bitcoinj:bitcoinj-core:0.15-SNAPSHOT">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/bitcoinj-core-0.15-SNAPSHOT-bundled.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/lib" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="bitcoinj-core-0.15-SNAPSHOT-bundled" level="project" />
<orderEntry type="library" name="Maven: org.fxmisc.easybind:easybind:1.0.2" level="project" />
<orderEntry type="library" name="Maven: de.jensd:fontawesomefx:8.0.0" level="project" />
<orderEntry type="library" name="Maven: net.glxn:qrgen:1.3" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:javase:2.0" level="project" />
<orderEntry type="library" name="Maven: com.google.zxing:core:2.0" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
<orderEntry type="library" name="Maven: com.lambdaworks:scrypt:1.4.0" level="project" />
<orderEntry type="library" name="Maven: net.java.dev.jna:jna:4.2.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-jdk14:1.7.7" level="project" />
<orderEntry type="library" name="Maven: org.controlsfx:controlsfx:8.40.10" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okhttp:okhttp:2.7.2" level="project" />
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.6.0" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" name="Maven: com.madgag.spongycastle:core:1.51.0.0" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.5.0" level="project" />
<orderEntry type="module-library">
<library name="Maven: org.bitcoinj:bitcoinj-core:0.15-SNAPSHOT">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/bitcoinj-core-0.15-SNAPSHOT-bundled.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.duudl3</groupId>
<artifactId>orion</artifactId>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<!-- Create the bundled JAR, it's easier for some people -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>false</minimizeJar>
<filters>
<filter>
<!-- exclude signatures, the bundling process breaks them for some reason -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>bundled</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>xyz.duudl3.orion.Main</mainClass>
</transformer>
</transformers>
<outputFile>target/Orion.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<izpack.version>5.0.6</izpack.version>
<izpack.staging>${project.build.directory}/staging</izpack.staging>
<installer-output-filename>cate-${project.version}-installer.jar</installer-output-filename>
</properties>
<dependencies>
<dependency>
<groupId>org.fxmisc.easybind</groupId>
<artifactId>easybind</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>com.lambdaworks</groupId>
<artifactId>scrypt</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>8.40.10</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
</dependency>
<dependency>
<groupId>com.madgag.spongycastle</groupId>
<artifactId>core</artifactId>
<version>1.51.0.0</version>
</dependency>
<dependency>
<groupId>com.madgag.spongycastle</groupId>
<artifactId>core</artifactId>
<version>1.51.0.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-core</artifactId>
<version>0.15-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/bitcoinj-core-0.15-SNAPSHOT-bundled.jar</systemPath>
</dependency>
</dependencies>
</project>
This diff is collapsed.
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package xyz.duudl3.orion;
import javafx.beans.binding.Bindings;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.TextFieldListCell;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.FileChooser;
import javafx.util.StringConverter;
import xyz.duudl3.orion.network.ConnectionHandler;
import xyz.duudl3.orion.utils.UIModel;
import javax.xml.bind.DatatypeConverter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
/**
* Gets created auto-magically by FXMLLoader via reflection. The widget fields are set to the GUI controls they're named
* after. This class handles all the updates and event handling for the main UI.
*/
public class ConnectController {
public TextField ip;
// Called by FXMLLoader.
public void initialize() {
}
public void connectToNode(ActionEvent actionEvent) {
if(ip.getText() != null && !ip.getText().equals("")) {
Main.connHandler = new ConnectionHandler();
try {
Main.connHandler.initialize(ip.getText());
} catch (IOException e) {
e.printStackTrace();
}
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("main.fxml"));
AnchorPane pane = null;
try {
pane = loader.<AnchorPane>load();
} catch (IOException e) {
e.printStackTrace();
}
Main.instance.controller = loader.getController();
Main.instance.mainWindow.setTitle(Main.APP_NAME);
Scene scene = new Scene(pane);
scene.getStylesheets().add(getClass().getResource("styles.css").toString());
Main.instance.mainWindow.setScene(scene);
Main.instance.mainWindow.setResizable(false);
Main.instance.mainWindow.setMaxWidth(800);
Main.instance.mainWindow.setMaxHeight(451);
Main.instance.mainWindow.show();
if (Main.connHandler.getClient().getClientConnection().isConnected())
Main.instance.controller.onServerConnected();
}
}
}
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package xyz.duudl3.orion;
import javafx.application.Platform;
import javafx.scene.image.Image;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.core.listeners.DownloadProgressTracker;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.MainNetParams;
import org.bitcoinj.params.TestNet3Params;
import org.bitcoinj.utils.Threading;
import org.bitcoinj.wallet.DeterministicSeed;
import org.bitcoinj.wallet.Wallet;
import xyz.duudl3.orion.network.ConnectionHandler;
import xyz.duudl3.orion.utils.GuiUtils;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import static xyz.duudl3.orion.utils.GuiUtils.*;
public class Main extends Application {
public static NetworkParameters params = null;
public static final String APP_NAME = "Orion";
private static String WALLET_FILE_NAME = "orion_wallet";
public static WalletAppKit walletAppKit;
public static Main instance;
private StackPane uiStack;
private Pane mainUI;
public MainController controller;
public ConnectController connectController;
public WalletController walletController;
public Stage mainWindow;
public static ConnectionHandler connHandler;
public static String masterPass = "00000000000000";
public static void main(String[] args) throws IOException {
//Variable is never actually used, we just mkdir each time just in case it doesn't exist.
boolean client_dir = new File("./client_dl/").mkdir();
params = MainNetParams.get();
launch(args);
}
@Override
public void start(Stage mainWindow) throws Exception {
try {
loadWindow(mainWindow);
} catch (Throwable e) {
GuiUtils.crashAlert(e);
throw e;
}
}
private void loadWindow(Stage mainWindow) throws IOException {
this.mainWindow = mainWindow;
instance = this;
FXMLLoader loader2 = new FXMLLoader();
loader2.setLocation(getClass().getResource("connect.fxml"));
AnchorPane pane2 = loader2.<AnchorPane>load();
connectController = loader2.getController();
Scene scene2 = new Scene(pane2);
scene2.getStylesheets().add(getClass().getResource("styles.css").toString());
mainWindow.setScene(scene2);
mainWindow.setResizable(false);
mainWindow.setMaxWidth(800);
mainWindow.setMaxHeight(451);
mainWindow.getIcons().add(new Image("https://duudl3.xyz/img/orion_client.png"));
Threading.USER_THREAD = Platform::runLater;
setupWalletKit(null);
if (walletAppKit.isChainFileLocked()) {
informationalAlert("Orion Notification", "Orion is already running and cannot be started twice.");
Platform.exit();
return;
}
mainWindow.show();
}
public void setupWalletKit(DeterministicSeed seed) {
// If seed is non-null it means we are restoring from backup.
walletAppKit = new WalletAppKit(params, new File("."), WALLET_FILE_NAME)
{
@Override
protected void onSetupCompleted() {
walletAppKit.wallet().allowSpendingUnconfirmedTransactions();
}
};
walletAppKit.setDownloadListener(new DownloadProgressTracker() {
@Override
protected void progress(double pct, int blocksSoFar, Date date) {
super.progress(pct, blocksSoFar, date);
int percentage = (int) pct;
}
@Override
protected void doneDownload() {
super.doneDownload();
//watchingWallet = Wallet.fromWatchingKey(parameters, DeterministicKey.deserializeB58(null, serialized, parameters));
}
});
walletAppKit.setBlockingStartup(false).setUserAgent(APP_NAME, "1.0");
if (seed != null)
walletAppKit.restoreWalletFromSeed(seed);
walletAppKit.startAsync();
}
private Node stopClickPane = new Pane();
public class OverlayUI<T>
{
public Node ui;
public T controller;
public OverlayUI(Node ui, T controller)
{
this.ui = ui;
this.controller = controller;
}
public void show()
{
checkGuiThread();
if (currentOverlay == null)
{
uiStack.getChildren().add(stopClickPane);
uiStack.getChildren().add(ui);
blurOut(mainUI);
fadeIn(ui);
zoomIn(ui);
}
else
{
explodeOut(currentOverlay.ui);
fadeOutAndRemove(uiStack, currentOverlay.ui);
uiStack.getChildren().add(ui);
ui.setOpacity(0.0);
fadeIn(ui, 100);
zoomIn(ui, 100);
}
currentOverlay = this;
}
public void done() {
checkGuiThread();
if (ui == null) return; // In the middle of being dismissed and got an extra click.
explodeOut(ui);
fadeOutAndRemove(uiStack, ui, stopClickPane);
blurIn(mainUI);
this.ui = null;
this.controller = null;
currentOverlay = null;
}
}
private OverlayUI currentOverlay;
//loads given .fxml file and displays it onto the Scene.
public <T> OverlayUI<T> overlayUI(String name)
{
try
{
checkGuiThread();
URL location = GuiUtils.getResource(name);
FXMLLoader loader = new FXMLLoader(location);
Pane ui = loader.load();
T controller = loader.getController();
OverlayUI<T> pair = new OverlayUI<T>(ui, controller);
try
{
if (controller != null)
controller.getClass().getField("overlayUI").set(controller, pair);
}
catch (IllegalAccessException | NoSuchFieldException ignored)
{
//my program is fucking flawless so i wont need this shit tbh
ignored.printStackTrace();
}
pair.show();
return pair;
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
@Override
public void stop() throws Exception {
walletAppKit.stopAsync();
walletAppKit.awaitTerminated();
System.exit(0);
}
}
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package xyz.duudl3.orion;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.TextFieldListCell;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.FileChooser;
import javafx.util.StringConverter;
import xyz.duudl3.orion.utils.UIModel;
import javax.xml.bind.DatatypeConverter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
/**
* Gets created auto-magically by FXMLLoader via reflection. The widget fields are set to the GUI controls they're named
* after. This class handles all the updates and event handling for the main UI.
*/
public class MainController {
public ListView fileList;
public static UIModel model = new UIModel();
public static int fileSelected;
public TextField filePath;
public TextField decryptionKey;
public TextField directDownloadFileName;
public TextField uploadedFileHash;
public Button btnUpload;
public ProgressBar progressBar;
public Button btnDownload;
public Label maxSizeWarning;
public Button btnWallet;
private String filePathAbsolute;
// Called by FXMLLoader.
public void initialize() {
Bindings.bindContent(fileList.getItems(), model.getFiles());
}
public void onServerConnected()
{
Bindings.bindContent(fileList.getItems(), model.getFiles());
}
public void downloadFile(MouseEvent mouseEvent) {
if(fileList.getSelectionModel().getSelectedItem() != null && !decryptionKey.getText().equals("") && decryptionKey.getText() != null) {
new Thread() {
@Override
public void run() {
Main.masterPass = decryptionKey.getText();
btnUpload.setDisable(true);
btnDownload.setDisable(true);
progressBar.setVisible(true);
fileSelected = fileList.getSelectionModel().getSelectedIndex();
String file = Main.connHandler.getClient().files.get(fileSelected);
try {
Main.connHandler.getClient().getFile(file);
} catch (IOException e) {
e.printStackTrace();
}
btnUpload.setDisable(false);
btnDownload.setDisable(false);
progressBar.setVisible(false);
}
}.start();
}