diff --git a/conf/springboot.yml b/conf/springboot.yml
index 332ef09..70f792f 100644
--- a/conf/springboot.yml
+++ b/conf/springboot.yml
@@ -1,5 +1,5 @@
ssh-server:
- port: 22
+ port: 2022
private-key:
location: "conf/private.key"
hash-replies:
diff --git a/pom.xml b/pom.xml
index 4076472..1d66410 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.example.sshd
echo-sshd-server
- 1.4.5
+ 1.4.6
ECHO SSH SERVER
Learning Apache Mina SSHD library
diff --git a/src/main/java/com/example/sshd/config/AppConfig.java b/src/main/java/com/example/sshd/config/AppConfig.java
index be18a88..0ed9afb 100644
--- a/src/main/java/com/example/sshd/config/AppConfig.java
+++ b/src/main/java/com/example/sshd/config/AppConfig.java
@@ -5,6 +5,8 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
+import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.reactor.IOReactorConfig;
import org.apache.sshd.common.Session;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@@ -34,4 +36,9 @@ public class AppConfig {
client.start();
return client;
}
+
+ @Bean
+ public CloseableHttpClient httpClient() {
+ return HttpClients.createDefault();
+ }
}
diff --git a/src/main/java/com/example/sshd/service/GeoIpLocator.java b/src/main/java/com/example/sshd/service/GeoIpLocator.java
index b3afcae..a8976dd 100644
--- a/src/main/java/com/example/sshd/service/GeoIpLocator.java
+++ b/src/main/java/com/example/sshd/service/GeoIpLocator.java
@@ -51,14 +51,18 @@ public class GeoIpLocator {
@Override
public String handleResponse(ClassicHttpResponse result) throws HttpException, IOException {
String body = new String(result.getEntity().getContent().readAllBytes(), StandardCharsets.UTF_8);
- logger.info("[{}] asyncClient.execute completed, response code: {}, body: {}", remoteIpAddress,
+ logger.info("[{}] httpClient.execute completed, response code: {}, body: {}", remoteIpAddress,
result.getCode(), body);
+ ipInfoMapping.put(remoteIpAddress, body);
+ int inserted = jdbcService.insertRemoteIpInfo(remoteIpAddress, body);
+ ipInfoLogger.info("[{}] {}, inserted = {}", remoteIpAddress, ipInfoMapping.get(remoteIpAddress),
+ inserted);
return body;
}
});
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("[getIpLocationInfo] IO Exception has occurred!", e);
return null;
}
}