forked from Qortal/qortal
Added gatewayLoopbackEnabled setting (default false) to allow serving gateway requests via localhost.
Useful for testing, but not recommended for production environments.
This commit is contained in:
parent
eb569304ba
commit
8ddcae249c
@ -56,7 +56,7 @@ public abstract class Security {
|
|||||||
public static void disallowLoopbackRequests(HttpServletRequest request) {
|
public static void disallowLoopbackRequests(HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
InetAddress remoteAddr = InetAddress.getByName(request.getRemoteAddr());
|
InetAddress remoteAddr = InetAddress.getByName(request.getRemoteAddr());
|
||||||
if (remoteAddr.isLoopbackAddress()) {
|
if (remoteAddr.isLoopbackAddress() && !Settings.getInstance().isGatewayLoopbackEnabled()) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createCustomException(request, ApiError.UNAUTHORIZED, "Local requests not allowed");
|
throw ApiExceptionFactory.INSTANCE.createCustomException(request, ApiError.UNAUTHORIZED, "Local requests not allowed");
|
||||||
}
|
}
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
|
@ -104,6 +104,7 @@ public class Settings {
|
|||||||
private Integer gatewayPort;
|
private Integer gatewayPort;
|
||||||
private boolean gatewayEnabled = false;
|
private boolean gatewayEnabled = false;
|
||||||
private boolean gatewayLoggingEnabled = false;
|
private boolean gatewayLoggingEnabled = false;
|
||||||
|
private boolean gatewayLoopbackEnabled = false;
|
||||||
|
|
||||||
// Specific to this node
|
// Specific to this node
|
||||||
private boolean wipeUnconfirmedOnStart = false;
|
private boolean wipeUnconfirmedOnStart = false;
|
||||||
@ -633,6 +634,10 @@ public class Settings {
|
|||||||
return this.gatewayLoggingEnabled;
|
return this.gatewayLoggingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGatewayLoopbackEnabled() {
|
||||||
|
return this.gatewayLoopbackEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean getWipeUnconfirmedOnStart() {
|
public boolean getWipeUnconfirmedOnStart() {
|
||||||
return this.wipeUnconfirmedOnStart;
|
return this.wipeUnconfirmedOnStart;
|
||||||
|
Loading…
Reference in New Issue
Block a user