Various fixes

This commit is contained in:
crschnick
2024-06-21 18:20:35 +00:00
parent 2d67443f22
commit 4f3f2bbfd2
16 changed files with 41 additions and 84 deletions
@@ -2,6 +2,7 @@ package io.xpipe.ext.base.service;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.util.HostHelper;
import io.xpipe.app.util.LicenseProvider;
import io.xpipe.app.util.Validators;
import io.xpipe.core.store.*;
import io.xpipe.core.util.JacksonizedValue;
@@ -32,7 +33,7 @@ public abstract class AbstractServiceStore extends JacksonizedValue
@Override
public NetworkTunnelSession newSession() throws Exception {
ServiceLicenseCheck.check();
LicenseProvider.get().getFeature("services").throwIfUnsupported();
var l = localPort != null ? localPort : HostHelper.findRandomOpenPortOnAllLocalInterfaces();
return getHost().getStore().sessionChain(l, remotePort);
}
@@ -1,35 +0,0 @@
package io.xpipe.ext.base.service;
import io.xpipe.app.util.LicenseConnectionLimit;
import io.xpipe.app.util.LicenseProvider;
import io.xpipe.app.util.LicensedFeature;
import io.xpipe.core.store.DataStore;
public class ServiceLicenseCheck {
public static LicensedFeature getFeature() {
return LicenseProvider.get().getFeature("services");
}
public static void check() {
if (getFeature().isSupported()) {
return;
}
var limit = getConnectionLimit();
limit.checkLimit();
}
public static LicenseConnectionLimit getConnectionLimit() {
// We check before starting a new service
return new LicenseConnectionLimit(0, getFeature()) {
@Override
protected boolean matches(DataStore store) {
return store instanceof AbstractServiceStore abstractServiceStore
&& abstractServiceStore.requiresTunnel()
&& abstractServiceStore.isSessionRunning();
}
};
}
}