Improve tunneling ability check

This commit is contained in:
crschnick
2025-09-15 16:07:34 +00:00
parent 30acedd540
commit 7813680541
21 changed files with 51 additions and 22 deletions
@@ -4,6 +4,7 @@ import io.xpipe.app.process.ShellControl;
import io.xpipe.app.process.ShellStoreState;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.xpipe.app.storage.DataStoreEntryRef;
import lombok.Value;
@JsonTypeName("local")
@@ -30,7 +31,7 @@ public class LocalStore implements NetworkTunnelStore, ShellStore, StatefulDataS
}
@Override
public DataStore getNetworkParent() {
public DataStoreEntryRef<?> getNetworkParent() {
return null;
}
@@ -1,8 +1,25 @@
package io.xpipe.app.ext;
public interface NetworkTunnelStore extends DataStore {
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.storage.DataStorage;
import io.xpipe.app.storage.DataStoreEntryRef;
DataStore getNetworkParent();
import java.util.Optional;
public interface NetworkTunnelStore extends DataStore, SelfReferentialStore {
static void checkTunneable(DataStoreEntryRef<?> ref) throws ValidationException {
if (!(ref.getStore() instanceof NetworkTunnelStore t)) {
throw new ValidationException(AppI18n.get("parentHostDoesNotSupportTunneling", ref.get().getName()));
}
var unsupported = t.getUnsupportedParent();
if (unsupported.isPresent()) {
throw new ValidationException(AppI18n.get("parentHostDoesNotSupportTunneling", unsupported.get().get().getName()));
}
}
DataStoreEntryRef<?> getNetworkParent();
default boolean requiresTunnel() {
return getNetworkParent() != null;
@@ -12,21 +29,25 @@ public interface NetworkTunnelStore extends DataStore {
return null;
}
default boolean isLocallyTunnelable() {
NetworkTunnelStore current = this;
default Optional<DataStoreEntryRef<NetworkTunnelStore>> getUnsupportedParent() {
DataStoreEntryRef<NetworkTunnelStore> current = getSelfEntry().ref();
while (true) {
var p = current.getNetworkParent();
var p = current.getStore().getNetworkParent();
if (p == null) {
return true;
return Optional.empty();
}
if (p instanceof NetworkTunnelStore t) {
current = t;
if (p.getStore() instanceof NetworkTunnelStore) {
current = p.asNeeded();
} else {
return false;
return Optional.of(current);
}
}
}
default boolean isLocallyTunnelable() {
return getUnsupportedParent().isEmpty();
}
NetworkTunnelSession createTunnelSession(int localPort, int remotePort, String address) throws Exception;
}
@@ -38,7 +38,6 @@ public class StoreCreationModel {
Property<Validator> validator = new SimpleObjectProperty<>(new SimpleValidator());
BooleanProperty finished = new SimpleBooleanProperty();
ObservableValue<DataStoreEntry> entry;
BooleanProperty changedSinceError = new SimpleBooleanProperty();
BooleanProperty skippable = new SimpleBooleanProperty();
BooleanProperty connectable = new SimpleBooleanProperty();
StringProperty name;
@@ -61,12 +60,6 @@ public class StoreCreationModel {
this.existingEntry = existingEntry;
this.staticDisplay = staticDisplay;
this.consumer = consumer;
this.store.addListener((c, o, n) -> {
changedSinceError.setValue(true);
});
this.name.addListener((c, o, n) -> {
changedSinceError.setValue(true);
});
this.provider.addListener((c, o, n) -> {
store.unbind();
@@ -212,12 +205,11 @@ public class StoreCreationModel {
.getFirst()
.getText();
ErrorEventFactory.fromMessage(msg).expected().handle();
changedSinceError.setValue(false);
return;
}
// We didn't change anything
if (!wasChanged()) {
if (store.getValue().isComplete() && !wasChanged()) {
commit(false);
return;
}
@@ -248,8 +240,6 @@ public class StoreCreationModel {
ErrorEventFactory.expected(ex);
}
changedSinceError.setValue(false);
ErrorEventFactory.fromThrowable(ex).handle();
} finally {
if (DataStorage.get() != null) {
@@ -34,7 +34,7 @@ public abstract class AbstractServiceStore implements SingletonSessionStore<Netw
@Override
public void checkComplete() throws Throwable {
Validators.nonNull(getHost());
Validators.isType(getHost(), NetworkTunnelStore.class);
NetworkTunnelStore.checkTunneable(getHost());
Validators.nonNull(remotePort);
Validators.nonNull(serviceProtocolType);
}
+1
View File
@@ -1604,3 +1604,4 @@ replaceFileDescription=Erstattet den eksisterende fil med denne
renameFile=Omdøb fil
renameFileDescription=Giv denne fil et andet navn for at synkronisere
newFileName=Nyt filnavn
parentHostDoesNotSupportTunneling=Parent host $NAME$ understøtter ikke tunneling
+1
View File
@@ -1594,3 +1594,4 @@ replaceFileDescription=Ersetze die bestehende Datei durch diese
renameFile=Datei umbenennen
renameFileDescription=Gib dieser Datei einen anderen Namen, um sie zu synchronisieren
newFileName=Neuer Dateiname
parentHostDoesNotSupportTunneling=Der übergeordnete Host $NAME$ unterstützt kein Tunneling
+1
View File
@@ -1633,3 +1633,4 @@ replaceFileDescription=Replaced the existing file with this one
renameFile=Rename file
renameFileDescription=Give this file a different name to sync
newFileName=New filename
parentHostDoesNotSupportTunneling=Parent host $NAME$ does not support tunneling
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Sustituye el archivo existente por éste
renameFile=Renombrar archivo
renameFileDescription=Dale a este archivo un nombre diferente para sincronizarlo
newFileName=Nuevo nombre de archivo
parentHostDoesNotSupportTunneling=El host principal $NAME$ no admite túneles
+1
View File
@@ -1603,3 +1603,4 @@ replaceFileDescription=Remplace le fichier existant par celui-ci
renameFile=Renommer un fichier
renameFileDescription=Donne à ce fichier un nom différent pour le synchroniser
newFileName=Nouveau nom de fichier
parentHostDoesNotSupportTunneling=L'hôte parent $NAME$ ne prend pas en charge le tunneling
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Mengganti file yang ada dengan file ini
renameFile=Mengganti nama file
renameFileDescription=Berikan nama yang berbeda pada file ini untuk disinkronkan
newFileName=Nama file baru
parentHostDoesNotSupportTunneling=Host induk $NAME$ tidak mendukung tunneling
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Ho sostituito il file esistente con questo
renameFile=Rinominare un file
renameFileDescription=Dai a questo file un nome diverso per sincronizzarlo
newFileName=Nuovo nome di file
parentHostDoesNotSupportTunneling=L'host principale $NAME$ non supporta il tunneling
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=既存のファイルをこのファイルに置き換え
renameFile=ファイル名を変更する
renameFileDescription=このファイルに別の名前を付けて同期する
newFileName=新しいファイル名
parentHostDoesNotSupportTunneling=親ホスト$NAME$ はトンネリングをサポートしていない
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=기존 파일을 이 파일로 바꿨습니다
renameFile=파일 이름 바꾸기
renameFileDescription=이 파일에 다른 이름을 지정하여 동기화
newFileName=새 파일 이름
parentHostDoesNotSupportTunneling=상위 호스트 $NAME$ 는 터널링을 지원하지 않습니다
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Het bestaande bestand vervangen door dit bestand
renameFile=Bestand hernoemen
renameFileDescription=Geef dit bestand een andere naam om te synchroniseren
newFileName=Nieuwe bestandsnaam
parentHostDoesNotSupportTunneling=Moederhost $NAME$ ondersteunt geen tunneling
+1
View File
@@ -1561,3 +1561,4 @@ replaceFileDescription=Zastąp istniejący plik tym
renameFile=Zmień nazwę pliku
renameFileDescription=Nadaj temu plikowi inną nazwę do synchronizacji
newFileName=Nowa nazwa pliku
parentHostDoesNotSupportTunneling=Host nadrzędny $NAME$ nie obsługuje tunelowania
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Substitui o ficheiro existente por este
renameFile=Mudar o nome do ficheiro
renameFileDescription=Dá a este ficheiro um nome diferente para sincronizar
newFileName=Novo nome de ficheiro
parentHostDoesNotSupportTunneling=O host pai $NAME$ não suporta tunelamento
+1
View File
@@ -1674,3 +1674,4 @@ replaceFileDescription=Замените существующий файл на
renameFile=Переименовать файл
renameFileDescription=Дайте этому файлу другое имя для синхронизации
newFileName=Новое имя файла
parentHostDoesNotSupportTunneling=Родительский хост $NAME$ не поддерживает туннелирование
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Ersatte den befintliga filen med den här
renameFile=Byt namn på fil
renameFileDescription=Ge den här filen ett annat namn för att synkronisera
newFileName=Nytt filnamn
parentHostDoesNotSupportTunneling=Överordnad värd $NAME$ stöder inte tunnling
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Mevcut dosyayı bununla değiştirdim
renameFile=Dosyayı yeniden adlandır
renameFileDescription=Senkronize etmek için bu dosyaya farklı bir ad verin
newFileName=Yeni dosya adı
parentHostDoesNotSupportTunneling=Ana bilgisayar $NAME$ tünellemeyi desteklemiyor
+1
View File
@@ -1560,3 +1560,4 @@ replaceFileDescription=Đã thay thế tệp hiện có bằng tệp này
renameFile=Đổi tên tệp
renameFileDescription=Đổi tên tệp này để đồng bộ hóa
newFileName=Tên tệp mới
parentHostDoesNotSupportTunneling=Máy chủ cha $NAME$ không hỗ trợ tunneling
+1
View File
@@ -2197,3 +2197,4 @@ replaceFileDescription=用这个文件替换现有文件
renameFile=重命名文件
renameFileDescription=为该文件取一个不同的名称,以便同步
newFileName=新文件名
parentHostDoesNotSupportTunneling=父主机$NAME$ 不支持隧道传输