More rework

This commit is contained in:
crschnick 2024-06-15 09:12:06 +00:00
parent 27a7df8402
commit 7cec691480
11 changed files with 32 additions and 53 deletions

View file

@ -36,7 +36,7 @@ public class AppBeaconServer {
private String localAuthSecret; private String localAuthSecret;
private String notFoundHtml; private String notFoundHtml;
private Map<String, String> resources = new HashMap<>(); private final Map<String, String> resources = new HashMap<>();
static { static {
int port; int port;

View file

@ -77,7 +77,8 @@ public class BeaconRequestHandler<T> implements HttpHandler {
} }
try { try {
if (response != null) { var emptyResponseClass = beaconInterface.getResponseClass().getDeclaredFields().length == 0;
if (!emptyResponseClass && response != null) {
TrackEvent.trace("Sending response:\n" + object); TrackEvent.trace("Sending response:\n" + object);
var tree = JacksonMapper.getDefault().valueToTree(response); var tree = JacksonMapper.getDefault().valueToTree(response);
TrackEvent.trace("Sending raw response:\n" + tree.toPrettyString()); TrackEvent.trace("Sending raw response:\n" + tree.toPrettyString());

View file

@ -310,6 +310,11 @@ public abstract class StoreEntryComp extends SimpleComp {
browse.setOnAction( browse.setOnAction(
event -> DesktopHelper.browsePathLocal(wrapper.getEntry().getDirectory())); event -> DesktopHelper.browsePathLocal(wrapper.getEntry().getDirectory()));
contextMenu.getItems().add(browse); contextMenu.getItems().add(browse);
var copyId = new MenuItem(AppI18n.get("copyId"), new FontIcon("mdi2c-content-copy"));
copyId.setOnAction(
event -> ClipboardHelper.copyText(wrapper.getEntry().getUuid().toString()));
contextMenu.getItems().add(copyId);
} }
if (DataStorage.get().isRootEntry(wrapper.getEntry())) { if (DataStorage.get().isRootEntry(wrapper.getEntry())) {

View file

@ -2,6 +2,7 @@ package io.xpipe.app.prefs;
import io.xpipe.app.comp.base.ButtonComp; import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.core.AppI18n; import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.storage.DataStorage; import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.util.DesktopHelper; import io.xpipe.app.util.DesktopHelper;
@ -19,8 +20,10 @@ public class SyncCategory extends AppPrefsCategory {
var builder = new OptionsBuilder(); var builder = new OptionsBuilder();
builder.addTitle("sync") builder.addTitle("sync")
.sub(new OptionsBuilder() .sub(new OptionsBuilder()
.nameAndDescription("enableGitStorage") .name("enableGitStorage")
.description(AppProperties.get().isStaging() ? "enableGitStoragePtbDisabled" : "enableGitStorage")
.addToggle(prefs.enableGitStorage) .addToggle(prefs.enableGitStorage)
.disable(AppProperties.get().isStaging())
.nameAndDescription("storageGitRemote") .nameAndDescription("storageGitRemote")
.addString(prefs.storageGitRemote, true) .addString(prefs.storageGitRemote, true)
.disable(prefs.enableGitStorage.not()) .disable(prefs.enableGitStorage.not())

View file

@ -1,13 +1,8 @@
package io.xpipe.app.storage; package io.xpipe.app.storage;
import io.xpipe.app.comp.store.StoreSortMode; import io.xpipe.app.comp.store.StoreSortMode;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.core.store.LocalStore; import io.xpipe.core.store.LocalStore;
import org.apache.commons.io.FileUtils;
import java.nio.file.Files;
import java.time.Instant; import java.time.Instant;
import java.util.UUID; import java.util.UUID;
@ -20,22 +15,17 @@ public class ImpersistentStorage extends DataStorage {
@Override @Override
public void load() { public void load() {
var storesDir = getStoresDir();
var categoriesDir = getCategoriesDir();
{ {
var cat = DataStoreCategory.createNew(null, ALL_CONNECTIONS_CATEGORY_UUID, "All connections"); var cat = DataStoreCategory.createNew(null, ALL_CONNECTIONS_CATEGORY_UUID, "All connections");
cat.setDirectory(categoriesDir.resolve(ALL_CONNECTIONS_CATEGORY_UUID.toString()));
storeCategories.add(cat); storeCategories.add(cat);
} }
{ {
var cat = DataStoreCategory.createNew(null, ALL_SCRIPTS_CATEGORY_UUID, "All scripts"); var cat = DataStoreCategory.createNew(null, ALL_SCRIPTS_CATEGORY_UUID, "All scripts");
cat.setDirectory(categoriesDir.resolve(ALL_SCRIPTS_CATEGORY_UUID.toString()));
storeCategories.add(cat); storeCategories.add(cat);
} }
{ {
var cat = new DataStoreCategory( var cat = new DataStoreCategory(
categoriesDir.resolve(DEFAULT_CATEGORY_UUID.toString()), null,
DEFAULT_CATEGORY_UUID, DEFAULT_CATEGORY_UUID,
"Default", "Default",
Instant.now(), Instant.now(),
@ -50,7 +40,6 @@ public class ImpersistentStorage extends DataStorage {
var e = DataStoreEntry.createNew( var e = DataStoreEntry.createNew(
LOCAL_ID, DataStorage.DEFAULT_CATEGORY_UUID, "Local Machine", new LocalStore()); LOCAL_ID, DataStorage.DEFAULT_CATEGORY_UUID, "Local Machine", new LocalStore());
e.setDirectory(getStoresDir().resolve(LOCAL_ID.toString()));
e.setConfiguration( e.setConfiguration(
StorageElement.Configuration.builder().deletable(false).build()); StorageElement.Configuration.builder().deletable(false).build());
storeEntries.put(e, e); storeEntries.put(e, e);
@ -58,18 +47,7 @@ public class ImpersistentStorage extends DataStorage {
} }
@Override @Override
public synchronized void save(boolean dispose) { public synchronized void save(boolean dispose) {}
var storesDir = getStoresDir();
TrackEvent.info("Storage persistence is disabled. Deleting storage contents ...");
try {
if (Files.exists(storesDir)) {
FileUtils.cleanDirectory(storesDir.toFile());
}
} catch (Exception ex) {
ErrorEvent.fromThrowable(ex).build().handle();
}
}
@Override @Override
public boolean supportsSharing() { public boolean supportsSharing() {

View file

@ -4,36 +4,27 @@
## XPipe Beacon ## XPipe Beacon
The XPipe beacon component is responsible for handling all communications between the XPipe daemon The XPipe beacon component is responsible for handling all communications between the XPipe daemon
and the various programming language APIs and the CLI. It provides an API that supports all kinds and the APIs and the CLI. It provides an API that supports all kinds
of different operations. of different operations.
### Inner Workings ### Inner Workings
- The underlying inter-process communication is realized through - The underlying communication is realized through an HTTP server on port `21721`
TCP sockets on port `21721` on Windows and `21723` on Linux/macOS.
- The data structures and exchange protocols are specified in the - The data structures and exchange protocols are specified in the
[io.xpipe.beacon.exchange package](src/main/java/io/xpipe/beacon/exchange). [io.xpipe.beacon.api package](src/main/java/io/xpipe/beacon/api).
- Every exchange is initiated from the outside by sending a request message to the XPipe daemon. - Every exchange is initiated from the outside by sending a request message to the XPipe daemon.
The daemon then always sends a response message. The daemon then always sends a response message.
- The header information of a message is formatted in the json format. - The body of a message is formatted in the json format.
As a result, all data structures exchanged must be serializable/deserializable with jackson. As a result, all data structures exchanged must be serializable/deserializable with jackson.
- Both the requests and responses can optionally include content in a body.
A body is initiated with two new lines (`\n`).
- The body is split into segments of max length `65536`.
Each segment is preceded by four bytes that specify the length of the next segment.
In case the next segment has a length of less than `65536` bytes, we know that the end of the body has been reached.
This way the socket communication can handle payloads of unknown length.
## Configuration ## Configuration
#### Custom port #### Custom port
The default port can be changed by passing the property `io.xpipe.beacon.port=<port>` to both the daemon and APIs. The default port can be changed by passing the property `io.xpipe.beacon.port=<port>` to the daemon or changing it in the settings menu.
Note that if both sides do not have the same port setting, they won't be able to reach each other. Note that if both sides do not have the same port setting, they won't be able to reach each other.
#### Custom launch command #### Custom launch command

View file

@ -88,7 +88,7 @@ project.ext {
arch = getArchName() arch = getArchName()
privateExtensions = file("$rootDir/private_extensions.txt").exists() ? file("$rootDir/private_extensions.txt").readLines() : [] privateExtensions = file("$rootDir/private_extensions.txt").exists() ? file("$rootDir/private_extensions.txt").readLines() : []
isFullRelease = System.getenv('RELEASE') != null && Boolean.parseBoolean(System.getenv('RELEASE')) isFullRelease = System.getenv('RELEASE') != null && Boolean.parseBoolean(System.getenv('RELEASE'))
isStage = System.getenv('STAGE') != null && Boolean.parseBoolean(System.getenv('STAGE')) isStage = true
rawVersion = file('version').text.trim() rawVersion = file('version').text.trim()
versionString = rawVersion + (isFullRelease || isStage ? '' : '-SNAPSHOT') versionString = rawVersion + (isFullRelease || isStage ? '' : '-SNAPSHOT')
versionReleaseNumber = rawVersion.split('-').length == 2 ? Integer.parseInt(rawVersion.split('-')[1]) : 1 versionReleaseNumber = rawVersion.split('-').length == 2 ? Integer.parseInt(rawVersion.split('-')[1]) : 1

View file

@ -22,7 +22,7 @@ public class XPipeInstallation {
.orElse(false); .orElse(false);
public static int getDefaultBeaconPort() { public static int getDefaultBeaconPort() {
var offset = isStaging() ? 1 : 0; var offset = isStaging() ? 2 : 0;
return 21721 + offset; return 21721 + offset;
} }

View file

@ -478,3 +478,4 @@ httpApi=HTTP API
isOnlySupportedLimit=is only supported with a professional license when having more than $COUNT$ connections isOnlySupportedLimit=is only supported with a professional license when having more than $COUNT$ connections
areOnlySupportedLimit=are only supported with a professional license when having more than $COUNT$ connections areOnlySupportedLimit=are only supported with a professional license when having more than $COUNT$ connections
enabled=Enabled enabled=Enabled
enableGitStoragePtbDisabled=Git synchronization is disabled for public test builds to prevent usage with regular release git repositories and to discourage using a PTB build as your daily driver.

View file

@ -26,7 +26,7 @@ externalDocs:
description: XPipe - Plans and pricing description: XPipe - Plans and pricing
url: https://xpipe.io/pricing url: https://xpipe.io/pricing
servers: servers:
- url: http://localhost:21721 - url: http://localhost:21723
description: XPipe Daemon API description: XPipe Daemon API
paths: paths:
/handshake: /handshake:

View file

@ -1 +1 @@
10.0 10.0-1