| | |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | | import com.fasterxml.jackson.databind.DeserializationFeature; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import kr.wisestone.owl.constant.MsgConstants; |
| | | import kr.wisestone.owl.constant.Regular; |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.vo.CompanyFieldVo; |
| | | import kr.wisestone.owl.vo.IspFieldVo; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | |
| | | */ |
| | | public static long ipToLong(String ipAddress) { |
| | | long result = 0; |
| | | String reg = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + |
| | | ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; |
| | | if (!StringUtils.isEmpty(ipAddress) && !Pattern.matches(reg, ipAddress)) { |
| | | |
| | | if (!StringUtils.isEmpty(ipAddress) && !Pattern.matches(Regular.IP, ipAddress)) { |
| | | return result; |
| | | } else { |
| | | String[] ipAddressArr = ipAddress.split("\\."); |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 콤마로 구분된 문자열을 IP 배열로 변환 |
| | | * @param ipAddressList 콤마로 구분된 IP 문자열 |
| | | * @return 정수로 변환한 배열 |
| | | */ |
| | | public static List<Long> ipToLongs(String ipAddressList) { |
| | | if (!StringUtils.isEmpty(ipAddressList)) { |
| | | String[] split = ipAddressList.split(CommonUtil.COMMA); |
| | | List<Long> longs = Lists.newArrayList(); |
| | | for (String str : split) { |
| | | longs.add(ipToLong(str)); |
| | | } |
| | | return longs; |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | } |