Compare commits

..

3 Commits

Author SHA1 Message Date
kirill.labutin c1d68c0bfa hotfix as fetch failure 2026-03-06 14:19:31 +03:00
kirillius 8672d74174 Merge pull request 'hotfix TDNS time parsing' (#2) from hotfix/tdns-time-parsing into master
Reviewed-on: #2
2026-03-06 11:08:47 +00:00
kirill.labutin 256c70571a hotfix TDNS time parsing 2026-03-06 12:30:00 +03:00
7 changed files with 18 additions and 51 deletions

View File

@ -43,8 +43,7 @@ public class HEInfoProvider implements ASInfoProvider {
return getIPv4Subnets(inputStream);
}
} else {
SystemLogger.error("Unable to get info about AS" + as, CTX);
return Collections.emptyList();
throw new RuntimeException("Unable to get info about AS" + as);
}
}
}

View File

@ -39,8 +39,7 @@ public class RIPEInfoProvider implements ASInfoProvider {
return getIPv4Subnets(inputStream);
}
} else {
SystemLogger.error("Unable to get info about AS" + as, CTX);
return Collections.emptyList();
throw new RuntimeException("Unable to get info about AS" + as);
}
}
}

View File

@ -15,6 +15,7 @@ import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.util.*;
/**
@ -93,7 +94,7 @@ public class TDNSAPI implements Closeable {
private long soaSerial;
@JSONProperty(required = false)
@Getter
private Date expiry;
private Instant expiry;
@JSONProperty(required = false)
@Getter
private boolean isExpired;
@ -105,7 +106,7 @@ public class TDNSAPI implements Closeable {
private boolean disabled;
@JSONProperty
@Getter
private Date lastModified;
private Instant lastModified;
}
/**

View File

@ -2,7 +2,6 @@ package ru.kirillius.pf.sdn.web.RPC;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
import ru.kirillius.json.DefaultPropertySerializer;
import ru.kirillius.json.JSONUtility;
import ru.kirillius.json.rpc.Annotations.JRPCArgument;
@ -89,8 +88,7 @@ public class SubscriptionManager implements RPC {
@JRPCArgument(name = "subnets") JSONArray subnets,
@JRPCArgument(name = "addresses") JSONArray addresses,
@JRPCArgument(name = "storage") String storage,
@JRPCArgument(name = "subscribe") boolean subscribe,
@JRPCArgument(name = "append") boolean append) throws IOException {
@JRPCArgument(name = "subscribe") boolean subscribe) throws IOException {
var repositoryConfig = findLocalRepo(storage);
var directory = new File(repositoryConfig.getSource());
if (!directory.exists()) {
@ -98,43 +96,25 @@ public class SubscriptionManager implements RPC {
}
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(targetFile)))) {
try (var writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(directory, name + ".json"))))) {
var merged = JSONUtility.deserializeCollection(subnets, IPv4Subnet.class, null).collect(Collectors.toList());
addresses.forEach(address -> {
merged.add(new IPv4Subnet(address.toString(), 32));
});
//noinspection rawtypes
@SuppressWarnings("unchecked")
var asnList = (List<Integer>) JSONUtility.deserializeCollection(ASN, Integer.class, (Class) DefaultPropertySerializer.class).toList();
bundle.add(NetworkResourceBundle.builder()
writer.write(JSONUtility.serializeStructure(
NetworkResourceBundle.builder()
.ASN(asnList)
.subnets(merged)
.domains(domainList)
.description(description)
.build());
writer.write(JSONUtility.serializeStructure(bundle).toString(2));
.build()
).toString(2));
}
if (subscribe) {
var subscribedResources = context.getConfig().getSubscribedResources();

View File

@ -92,7 +92,7 @@
<dependency>
<groupId>ru.kirillius</groupId>
<artifactId>json-rpc-servlet</artifactId>
<version>2.1.4.0</version>
<version>2.1.5.0</version>
</dependency>
</dependencies>

View File

@ -53,12 +53,6 @@ function renderSubscriptionList() {
}).join('');
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>
<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>
@ -69,11 +63,6 @@ function renderSubscriptionList() {
}
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 () {
const $btn = $(this);
const $message = $('#subscription-status-message');

View File

@ -308,8 +308,7 @@ function handleAdd() {
selectedSubnets,
selectedAddresses,
storage,
true,
false
true
).then(() => {
setStatus('Ресурсы успешно добавлены.', 'success');
}).catch(error => {