diff --git a/src/main/java/page/clab/api/domain/login/domain/GeoIpInfo.java b/src/main/java/page/clab/api/domain/login/domain/GeoIpInfo.java deleted file mode 100644 index dd9d92ca5..000000000 --- a/src/main/java/page/clab/api/domain/login/domain/GeoIpInfo.java +++ /dev/null @@ -1,50 +0,0 @@ -package page.clab.api.domain.login.domain; - -import com.maxmind.geoip2.record.City; -import com.maxmind.geoip2.record.Country; -import com.maxmind.geoip2.record.Location; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@Builder -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@AllArgsConstructor(access = AccessLevel.PRIVATE) -public class GeoIpInfo { - - private String location; - - private String city; - - private String country; - - private Double latitude; - - private Double longitude; - - public static GeoIpInfo create(City city, Country country, Location location) { - return GeoIpInfo.builder() - .location(city.getName() + " " + country.getName()) - .city(city.getName()) - .country(country.getName()) - .latitude(location.getLatitude()) - .longitude(location.getLongitude()) - .build(); - } - - public static GeoIpInfo createUnknown() { - return GeoIpInfo.builder() - .location("Unknown") - .city(null) - .country(null) - .latitude(null) - .longitude(null) - .build(); - } - -} diff --git a/src/main/java/page/clab/api/global/util/GeoIpUtil.java b/src/main/java/page/clab/api/global/util/GeoIpUtil.java deleted file mode 100644 index d9927a0d5..000000000 --- a/src/main/java/page/clab/api/global/util/GeoIpUtil.java +++ /dev/null @@ -1,42 +0,0 @@ -package page.clab.api.global.util; - -import com.maxmind.geoip2.DatabaseReader; -import com.maxmind.geoip2.exception.GeoIp2Exception; -import com.maxmind.geoip2.model.CityResponse; -import com.maxmind.geoip2.record.City; -import com.maxmind.geoip2.record.Country; -import com.maxmind.geoip2.record.Location; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.io.ResourceLoader; -import page.clab.api.domain.login.domain.GeoIpInfo; - -import java.io.IOException; -import java.io.InputStream; -import java.net.InetAddress; - -public class GeoIpUtil { - - private static DatabaseReader databaseReader; - - public GeoIpUtil(ResourceLoader resourceLoader, @Value("${geoip2.database.path}") String databasePath) throws IOException { - try (InputStream inputStream = resourceLoader.getResource(databasePath).getInputStream()) { - databaseReader = new DatabaseReader.Builder(inputStream).build(); - } catch (IOException e) { - throw new RuntimeException("Error initializing GeoIpUtil", e); - } - } - - public static GeoIpInfo getInfoByIp(String ipAddress) { - try { - InetAddress ip = InetAddress.getByName(ipAddress); - CityResponse response = databaseReader.city(ip); - City city = response.getCity(); - Country country = response.getCountry(); - Location location = response.getLocation(); - return GeoIpInfo.create(city, country, location); - } catch (NullPointerException | IOException | GeoIp2Exception e) { - return GeoIpInfo.createUnknown(); - } - } - -} \ No newline at end of file diff --git a/src/main/resources/GeoLite2-City.mmdb b/src/main/resources/GeoLite2-City.mmdb deleted file mode 100644 index 2bc1a2bfb..000000000 Binary files a/src/main/resources/GeoLite2-City.mmdb and /dev/null differ