Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zapek committed Sep 28, 2021
0 parents commit a4051ad
Show file tree
Hide file tree
Showing 486 changed files with 57,467 additions and 0 deletions.
672 changes: 672 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/data/
/data-ui/
/data2/
/.idea/
/.gradle/
./jpb/
/out/
/build/
.xeres.lock
12 changes: 12 additions & 0 deletions .jpb/persistence-units.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PersistenceUnitSettings">
<persistence-units>
<persistence-unit name="Default">
<packages>
<package value="io.xeres.app"/>
</packages>
</persistence-unit>
</persistence-units>
</component>
</project>
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Xeres

This is an attempted reimplementation of [Retroshare](https://retroshare.cc) in Java.

## Supported platforms

- Windows (x86_64)
- Linux (x86_64)
- MacOS (x86_64) _untested_

## Build requirements

- Java 17

## Features

- [AES-NI](https://en.wikipedia.org/wiki/AES_instruction_set) support
- [JavaFX](https://openjfx.io/) UI
- Web UI
- High concurrency

## Download

https://xeres.io

## How to run

##### IntelliJ IDEA Ultimate

It is recommended to run the _XeresApplication_ Spring Boot configuration which is the most convenient and fastest way.
Just make sure to configure it in the following way:

Select _Edit Configurations..._ of the _XeresApplication_ Spring Boot configuration.

Put the following _VM options_:

-ea -Djava.net.preferIPv4Stack=true

And the following _Active profiles_:

dev

Optionally, for faster build/test turnarounds you can add in the _program arguments_:

--fast-shutdown

Then just run the _XeresApplication_ Spring Boot configuration.

##### IntelliJ Community Edition

Run the Gradle ``bootRun`` target. It's in the top right _Gradle_ panel, Tasks / application. It's already preconfigured.

(This way also works with IntelliJ IDEA Ultimate but you'll miss some extras like colored debug output and faster launch)

##### Command line

###### Windows

gradlew.bat

###### Linux

./gradlew

To pass Xeres arguments, just use the args feature, ie.

./gradlew bootRun --args="--no-gui --fast-shutdown"

(Use ``--help`` to know all arguments)

## How to setup the WebUI

_Note: the webui is currently nonfunctional._

Run the gradle tasks ``installAngular`` (if you don't already have Angular installed) then ``buildAngular``. The later will create the needed files that will be served by Xeres on ``localhost:1066``.

## Database debugging

With IntelliJ Ultimate, create the following Database connection with the built-in Datagrip client (aka the _Database_ tool window)

- Connection type: Embedded
- Driver: H2
- Path: select ``./data/userdata.mv.db``. If the file is not there, run Xeres once.
- Authentication: User & Password
- User: ``sa``
- There's no password

## Misc

The project was started on 2019-10-30.

##### How to write proper git commit messages

https://chris.beams.io/posts/git-commit/

##### Branching model

The current plan is to use *master* for everything. Use a feature branch to work on a feature (ie. feature/165 if there's a ticket). Once it's ready, have someone review it then merge to master.

Releases will use tags and release branches if further fixes are needed.

https://reallifeprogramming.com/git-process-that-works-say-no-to-gitflow-50bf2038ccf7

## Useful tasks

##### Cleaning the build directory

run the ``clean`` task

##### Cleaning the Angular generated directory

run the ``cleanAngular`` task

##### Upgrading Gradle

- change the version in _build.gradle_ in the _wrapper_ section
- run the ``wrapper`` task
2 changes: 2 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build/
/out/
130 changes: 130 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright (c) 2019-2021 by David Gerber - https://zapek.com
*
* This file is part of Xeres.
*
* Xeres is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xeres is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xeres. If not, see <http://www.gnu.org/licenses/>.
*/

plugins {
id 'org.springframework.boot'
id 'org.flywaydb.flyway'
id 'jacoco'
id 'org.panteleyev.jpackageplugin'
}

flyway {
url = "jdbc:h2:file:${project.rootDir}/data/userdata"
user = 'sa'
}

bootJar {
manifest {
attributes 'Implementation-Version': "${project.version}"
attributes 'Implementation-Title': "${project.name}"
}
}

bootRun {
bootRun.jvmArgs "-ea", "-Djava.net.preferIPv4Stack=true", "-Dfile.encoding=UTF-8"
bootRun.systemProperty 'spring.profiles.active', 'dev'
}

springBoot {
buildInfo {
properties {
time = null // make the build repeatable
name = rootProject.name
}
}
}

editorconfig {
includes = ['src/**']
excludes = ['src/test/resources/upnp/**', 'src/main/webapp/dist/**', 'src/main/webapp/node_modules/**']
}

test {
useJUnitPlatform()
test.jvmArgs "-ea", "-Djava.net.preferIPv4Stack=true", "-Dfile.encoding=UTF-8"
}

// XXX: hack to make IntelliJ actually build properly. Maybe report to JetBrains
processResources {
dependsOn ":ui:processResources"
dependsOn ":webui:processResources"
}

task copyInstaller(type: Copy) {
from "${parent.rootDir}/installer"
include "*"
into "${project.buildDir}/${project.libsDirName}"
}

bootBuildImage {
imageName = "zapek/${rootProject.name.toLowerCase()}:${project.version}"
}

jpackage {
dependsOn "bootJar"
dependsOn "copyInstaller"
appName = parent.project.name
vendor = "David Gerber"
copyright = "Copyright 2019-2021 All Rights Reserved"
appDescription = "Xeres P2P Software"
input = "${project.buildDir}/${project.libsDirName}"
destination = "${project.buildDir}/dist"
mainClass = "org.springframework.boot.loader.JarLauncher"
mainJar = "app-${project.version}.jar"
icon = "${parent.rootDir}/icon.ico"
licenseFile = "${parent.rootDir}/LICENSE"
javaOptions = ['-Djava.net.preferIPv4Stack=true', '-Dfile.encoding=UTF-8', '-splash:$APPDIR/startup.jpg']
windows {
winMenu = true
winPerUserInstall = true
winDirChooser = true
winMenuGroup = "Xeres"
}
linux {
linuxShortcut = true
}
}

dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
implementation project(':common')
implementation project(':ui')
implementation project(':webui')
implementation 'org.springframework.boot:spring-boot-starter-json'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
runtimeOnly 'com.h2database:h2:1.4.200'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-webflux' // to bring in netty
implementation "org.flywaydb:flyway-core:$flywayVersion"
implementation "org.bouncycastle:bcpg-jdk15on:$bouncycastleVersion"
implementation "org.bouncycastle:bcpkix-jdk15on:$bouncycastleVersion"
implementation 'org.jsoup:jsoup:1.14.2'
implementation 'com.github.peter-gergely-horvath:windpapi4j:1.0'
implementation 'net.harawata:appdirs:1.2.1'
implementation 'com.github.atomashpolskiy:bt-dht:1.9'
implementation "org.apache.commons:commons-lang3:$apacheCommonsLangVersion"
implementation "org.apache.commons:commons-collections4:$apacheCommonsCollectionsVersion"
implementation "org.springdoc:springdoc-openapi-ui:$springOpenApi"
implementation 'io.netty:netty-tcnative-boringssl-static:2.0.43.Final'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
59 changes: 59 additions & 0 deletions app/src/main/java/io/xeres/app/XeresApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2019-2021 by David Gerber - https://zapek.com
*
* This file is part of Xeres.
*
* Xeres is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Xeres is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Xeres. If not, see <http://www.gnu.org/licenses/>.
*/

package io.xeres.app;

import io.xeres.app.application.environment.CommandArgument;
import io.xeres.app.application.environment.HostVariable;
import io.xeres.common.properties.StartupProperties;
import io.xeres.ui.UiStarter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import static io.xeres.app.application.environment.Cloud.isRunningOnCloud;

@SpringBootApplication(scanBasePackageClasses = {io.xeres.app.XeresApplication.class, io.xeres.ui.UiStarter.class})
public class XeresApplication
{
private static final Logger log = LoggerFactory.getLogger(XeresApplication.class);

public static void main(String[] args)
{
HostVariable.parse();
CommandArgument.parse(args);

if (isRunningOnCloud() || !StartupProperties.getBoolean(StartupProperties.Property.UI, true))
{
log.info("no gui mode");
SpringApplication.run(XeresApplication.class, args);
}
else
{
log.info("gui mode");
UiStarter.start(XeresApplication.class, args); // this starts spring as well
}
}

public static boolean isRemoteUiClient()
{
return "none".equals(System.getProperty("spring.main.web-application-type"));
}
}
Loading

0 comments on commit a4051ad

Please sign in to comment.