修复了IP格式化导致的登录不了的Bug

master
ArgonarioD 2022-07-13 11:55:30 +08:00
parent cc39e36c33
commit f2f6bb8d8a
2 changed files with 7 additions and 2 deletions

View File

@ -16,7 +16,10 @@ public class IPAddress {
public static IPAddress of(String ip) { public static IPAddress of(String ip) {
long ipHex = 0; long ipHex = 0;
ip = ip.substring(0, ip.indexOf(':')); int portIndex = ip.indexOf(':');
if (portIndex != -1) {
ip = ip.substring(0, ip.indexOf(':'));
}
String[] split = ip.split("\\."); String[] split = ip.split("\\.");
for (String s : split) { for (String s : split) {
ipHex = (ipHex << 8) + Integer.parseInt(s); ipHex = (ipHex << 8) + Integer.parseInt(s);

View File

@ -22,7 +22,9 @@ public class SerializeTests {
@SneakyThrows @SneakyThrows
@Test @Test
public void serializeTime() { public void serializeTime() {
System.out.println(objectMapper.readValue("1657166400", LocalDateTime.class)); String timestamp = objectMapper.writeValueAsString(LocalDateTime.now());
System.out.println(timestamp);
System.out.println(objectMapper.readValue(timestamp, LocalDateTime.class));
} }
@SneakyThrows @SneakyThrows