X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FDomain.java;h=55ed0f591f61a8769d85cd61cf6ad14aa116de71;hb=6700c089da23a9f38171fceddb3480ce502f224d;hp=78ebc9bbf78ff3f96edee4b8ef27a3888925f183;hpb=9c05ed99bc13cd875e16f1f8c72376ed29f57498;p=gigi.git diff --git a/src/org/cacert/gigi/dbObjects/Domain.java b/src/org/cacert/gigi/dbObjects/Domain.java index 78ebc9bb..55ed0f59 100644 --- a/src/org/cacert/gigi/dbObjects/Domain.java +++ b/src/org/cacert/gigi/dbObjects/Domain.java @@ -73,6 +73,12 @@ public class Domain implements IdCachable, Verifyable { if ( !s.equals(publicSuffix)) { throw new GigiApiException("You may only register a domain with exactly one lable before the public suffix."); } + if (("." + s).matches("(\\.[0-9]*)*")) { + // This is not reached because we currently have no TLD that is + // numbers only. But who knows.. + // Better safe than sorry. + throw new GigiApiException("IP Addresses are not allowed"); + } checkPunycode(parts[0], s.substring(parts[0].length() + 1)); } @@ -171,7 +177,7 @@ public class Domain implements IdCachable, Verifyable { LinkedList configs = this.configs; if (configs == null) { configs = new LinkedList<>(); - try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT id FROM pingconfig WHERE domainid=?")) { + try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT id FROM pingconfig WHERE domainid=? AND `deleted` IS NULL")) { ps.setInt(1, id); GigiResultSet rs = ps.executeQuery(); while (rs.next()) { @@ -194,6 +200,14 @@ public class Domain implements IdCachable, Verifyable { configs = null; } + public void clearPings() throws GigiApiException { + try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `pingconfig` SET `deleted`=CURRENT_TIMESTAMP WHERE `deleted` is NULL AND `domainid`=?")) { + ps.setInt(1, id); + ps.execute(); + } + configs = null; + } + public synchronized void verify(String hash) throws GigiApiException { try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `domainPinglog` SET `state`='success' WHERE `challenge`=? AND `state`='open' AND `configId` IN (SELECT `id` FROM `pingconfig` WHERE `domainid`=? AND `type`='email')")) { ps.setString(1, hash);