mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-24 18:26:54 +00:00
Service validation fixes
This commit is contained in:
@@ -48,11 +48,26 @@ public abstract class AbstractServiceStore
|
||||
|
||||
@Override
|
||||
public void checkComplete() throws Throwable {
|
||||
// We do not require the host to be complete
|
||||
if (getHost() != null) {
|
||||
Validators.isType(getHost(), HostAddressStore.class);
|
||||
}
|
||||
Validators.nonNull(remotePort);
|
||||
Validators.nonNull(serviceProtocolType);
|
||||
if (getHost() == null) {
|
||||
Validators.nonNull(getAddress());
|
||||
}
|
||||
|
||||
if (serviceProtocolType.hasScheme()) {
|
||||
var addr = serviceProtocolType.formatAddress(getOpenTargetUrl());
|
||||
if (addr != null) {
|
||||
try {
|
||||
URI.create(addr);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ValidationException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getOpenTargetUrl() {
|
||||
@@ -95,6 +110,10 @@ public abstract class AbstractServiceStore
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getHost().getStore().isComplete()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getHost().getStore() instanceof HostAddressGatewayStore g
|
||||
&& !(getHost().getStore() instanceof NetworkTunnelStore)) {
|
||||
var gw = g.getTunnelGateway();
|
||||
@@ -127,6 +146,10 @@ public abstract class AbstractServiceStore
|
||||
}
|
||||
|
||||
if (getHost() != null) {
|
||||
if (!getHost().getStore().isComplete()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(getHost().getStore() instanceof NetworkTunnelStore)
|
||||
&& getHost().getStore() instanceof HostAddressGatewayStore g) {
|
||||
if (g.getTunnelGateway() == null
|
||||
|
||||
@@ -39,6 +39,10 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt
|
||||
}
|
||||
|
||||
if (abs.getHost() != null) {
|
||||
if (!abs.getHost().getStore().isComplete()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abs.getHost().getStore() instanceof HostAddressGatewayStore a) {
|
||||
if (a.getTunnelGateway() != null
|
||||
&& a.getTunnelGateway().getStore().requiresTunnel()
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.util.Locale;
|
||||
})
|
||||
public interface ServiceProtocolType {
|
||||
|
||||
boolean hasScheme();
|
||||
|
||||
String formatAddress(String base);
|
||||
|
||||
void open(String url) throws Exception;
|
||||
@@ -33,6 +35,11 @@ public interface ServiceProtocolType {
|
||||
@Builder
|
||||
class Undefined implements ServiceProtocolType {
|
||||
|
||||
@Override
|
||||
public boolean hasScheme() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatAddress(String base) {
|
||||
return base;
|
||||
@@ -55,6 +62,11 @@ public interface ServiceProtocolType {
|
||||
|
||||
String path;
|
||||
|
||||
@Override
|
||||
public boolean hasScheme() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatAddress(String base) {
|
||||
var url = "http://" + base;
|
||||
@@ -83,6 +95,11 @@ public interface ServiceProtocolType {
|
||||
|
||||
String path;
|
||||
|
||||
@Override
|
||||
public boolean hasScheme() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatAddress(String base) {
|
||||
var url = "https://" + base;
|
||||
@@ -111,6 +128,11 @@ public interface ServiceProtocolType {
|
||||
|
||||
String commandTemplate;
|
||||
|
||||
@Override
|
||||
public boolean hasScheme() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatAddress(String base) {
|
||||
return base;
|
||||
|
||||
Reference in New Issue
Block a user