mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-13 04:51:03 +00:00
Various fixes
This commit is contained in:
@@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user