Compare commits
2 Commits
master
...
feature/lo
| Author | SHA1 | Date |
|---|---|---|
|
|
c9ae84c721 | |
|
|
47b8620013 |
|
|
@ -43,7 +43,8 @@ public class HEInfoProvider implements ASInfoProvider {
|
||||||
return getIPv4Subnets(inputStream);
|
return getIPv4Subnets(inputStream);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unable to get info about AS" + as);
|
SystemLogger.error("Unable to get info about AS" + as, CTX);
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ public class RIPEInfoProvider implements ASInfoProvider {
|
||||||
return getIPv4Subnets(inputStream);
|
return getIPv4Subnets(inputStream);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unable to get info about AS" + as);
|
SystemLogger.error("Unable to get info about AS" + as, CTX);
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -94,7 +93,7 @@ public class TDNSAPI implements Closeable {
|
||||||
private long soaSerial;
|
private long soaSerial;
|
||||||
@JSONProperty(required = false)
|
@JSONProperty(required = false)
|
||||||
@Getter
|
@Getter
|
||||||
private Instant expiry;
|
private Date expiry;
|
||||||
@JSONProperty(required = false)
|
@JSONProperty(required = false)
|
||||||
@Getter
|
@Getter
|
||||||
private boolean isExpired;
|
private boolean isExpired;
|
||||||
|
|
@ -106,7 +105,7 @@ public class TDNSAPI implements Closeable {
|
||||||
private boolean disabled;
|
private boolean disabled;
|
||||||
@JSONProperty
|
@JSONProperty
|
||||||
@Getter
|
@Getter
|
||||||
private Instant lastModified;
|
private Date lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package ru.kirillius.pf.sdn.web.RPC;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.json.JSONTokener;
|
||||||
import ru.kirillius.json.DefaultPropertySerializer;
|
import ru.kirillius.json.DefaultPropertySerializer;
|
||||||
import ru.kirillius.json.JSONUtility;
|
import ru.kirillius.json.JSONUtility;
|
||||||
import ru.kirillius.json.rpc.Annotations.JRPCArgument;
|
import ru.kirillius.json.rpc.Annotations.JRPCArgument;
|
||||||
|
|
@ -88,7 +89,8 @@ public class SubscriptionManager implements RPC {
|
||||||
@JRPCArgument(name = "subnets") JSONArray subnets,
|
@JRPCArgument(name = "subnets") JSONArray subnets,
|
||||||
@JRPCArgument(name = "addresses") JSONArray addresses,
|
@JRPCArgument(name = "addresses") JSONArray addresses,
|
||||||
@JRPCArgument(name = "storage") String storage,
|
@JRPCArgument(name = "storage") String storage,
|
||||||
@JRPCArgument(name = "subscribe") boolean subscribe) throws IOException {
|
@JRPCArgument(name = "subscribe") boolean subscribe,
|
||||||
|
@JRPCArgument(name = "append") boolean append) throws IOException {
|
||||||
var repositoryConfig = findLocalRepo(storage);
|
var repositoryConfig = findLocalRepo(storage);
|
||||||
var directory = new File(repositoryConfig.getSource());
|
var directory = new File(repositoryConfig.getSource());
|
||||||
if (!directory.exists()) {
|
if (!directory.exists()) {
|
||||||
|
|
@ -96,25 +98,43 @@ public class SubscriptionManager implements RPC {
|
||||||
}
|
}
|
||||||
|
|
||||||
var domainList = new ArrayList<String>();
|
var domainList = new ArrayList<String>();
|
||||||
|
var targetFile = new File(directory, name + ".json");
|
||||||
|
var bundle = new NetworkResourceBundle();
|
||||||
|
|
||||||
|
if (append) {
|
||||||
|
if (targetFile.exists()) {
|
||||||
|
try (var stream = new FileInputStream(targetFile)) {
|
||||||
|
var json = new JSONObject(new JSONTokener(stream));
|
||||||
|
bundle.add(
|
||||||
|
JSONUtility.deserializeStructure(json, NetworkResourceBundle.class)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
domains.forEach(d -> domainList.add(d.toString()));
|
domains.forEach(d -> domainList.add(d.toString()));
|
||||||
|
|
||||||
try (var writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(directory, name + ".json"))))) {
|
|
||||||
|
try (var writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(targetFile)))) {
|
||||||
var merged = JSONUtility.deserializeCollection(subnets, IPv4Subnet.class, null).collect(Collectors.toList());
|
var merged = JSONUtility.deserializeCollection(subnets, IPv4Subnet.class, null).collect(Collectors.toList());
|
||||||
addresses.forEach(address -> {
|
addresses.forEach(address -> {
|
||||||
merged.add(new IPv4Subnet(address.toString(), 32));
|
merged.add(new IPv4Subnet(address.toString(), 32));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//noinspection rawtypes
|
//noinspection rawtypes
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
var asnList = (List<Integer>) JSONUtility.deserializeCollection(ASN, Integer.class, (Class) DefaultPropertySerializer.class).toList();
|
var asnList = (List<Integer>) JSONUtility.deserializeCollection(ASN, Integer.class, (Class) DefaultPropertySerializer.class).toList();
|
||||||
writer.write(JSONUtility.serializeStructure(
|
|
||||||
NetworkResourceBundle.builder()
|
bundle.add(NetworkResourceBundle.builder()
|
||||||
.ASN(asnList)
|
.ASN(asnList)
|
||||||
.subnets(merged)
|
.subnets(merged)
|
||||||
.domains(domainList)
|
.domains(domainList)
|
||||||
.description(description)
|
.description(description)
|
||||||
.build()
|
.build());
|
||||||
).toString(2));
|
|
||||||
|
|
||||||
|
writer.write(JSONUtility.serializeStructure(bundle).toString(2));
|
||||||
}
|
}
|
||||||
if (subscribe) {
|
if (subscribe) {
|
||||||
var subscribedResources = context.getConfig().getSubscribedResources();
|
var subscribedResources = context.getConfig().getSubscribedResources();
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -92,7 +92,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ru.kirillius</groupId>
|
<groupId>ru.kirillius</groupId>
|
||||||
<artifactId>json-rpc-servlet</artifactId>
|
<artifactId>json-rpc-servlet</artifactId>
|
||||||
<version>2.1.5.0</version>
|
<version>2.1.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,12 @@ function renderSubscriptionList() {
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
const html = `
|
const html = `
|
||||||
|
<div class="select-all-container" style="margin-bottom: 10px;">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="select-all-checkbox">
|
||||||
|
Выделить все
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<ul class="subscription-list">${listHtml}</ul>
|
<ul class="subscription-list">${listHtml}</ul>
|
||||||
<button id="save-subscriptions-btn" class="btn-primary" style="width: 250px; margin-top: 30px;">Сохранить</button>
|
<button id="save-subscriptions-btn" class="btn-primary" style="width: 250px; margin-top: 30px;">Сохранить</button>
|
||||||
<div id="subscription-status-message" class="error-message" style="display: none;"></div>
|
<div id="subscription-status-message" class="error-message" style="display: none;"></div>
|
||||||
|
|
@ -63,6 +69,11 @@ function renderSubscriptionList() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function attachEventHandlers() {
|
function attachEventHandlers() {
|
||||||
|
$('#select-all-checkbox').on('change', function() {
|
||||||
|
const isChecked = $(this).is(':checked');
|
||||||
|
$('.subscription-checkbox').prop('checked', isChecked);
|
||||||
|
});
|
||||||
|
|
||||||
$('#save-subscriptions-btn').on('click', async function () {
|
$('#save-subscriptions-btn').on('click', async function () {
|
||||||
const $btn = $(this);
|
const $btn = $(this);
|
||||||
const $message = $('#subscription-status-message');
|
const $message = $('#subscription-status-message');
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,8 @@ function handleAdd() {
|
||||||
selectedSubnets,
|
selectedSubnets,
|
||||||
selectedAddresses,
|
selectedAddresses,
|
||||||
storage,
|
storage,
|
||||||
true
|
true,
|
||||||
|
false
|
||||||
).then(() => {
|
).then(() => {
|
||||||
setStatus('Ресурсы успешно добавлены.', 'success');
|
setStatus('Ресурсы успешно добавлены.', 'success');
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue