@@ -23,6 +23,12 @@ public class IP2Proxy {
23
23
private static final Pattern Pattern7 = Pattern .compile ("^([0-9]+\\ .){1,2}[0-9]+$" );
24
24
private static final BigInteger MAX_IPV4_RANGE = new BigInteger ("4294967295" );
25
25
private static final BigInteger MAX_IPV6_RANGE = new BigInteger ("340282366920938463463374607431768211455" );
26
+ private static final BigInteger FROM_6TO4 = new BigInteger ("42545680458834377588178886921629466624" );
27
+ private static final BigInteger TO_6TO4 = new BigInteger ("42550872755692912415807417417958686719" );
28
+ private static final BigInteger FROM_TEREDO = new BigInteger ("42540488161975842760550356425300246528" );
29
+ private static final BigInteger TO_TEREDO = new BigInteger ("42540488241204005274814694018844196863" );
30
+ private static final BigInteger LAST_32BITS = new BigInteger ("4294967295" );
31
+
26
32
private static final String MSG_NOT_SUPPORTED = "NOT SUPPORTED" ;
27
33
private static final String MSG_INVALID_IP = "INVALID IP ADDRESS" ;
28
34
private static final String MSG_MISSING_FILE = "MISSING FILE" ;
@@ -108,7 +114,7 @@ private enum Modes {
108
114
private boolean AS_ENABLED ;
109
115
private boolean LASTSEEN_ENABLED ;
110
116
111
- private static final String _ModuleVersion = "2.0 .0" ;
117
+ private static final String _ModuleVersion = "2.1 .0" ;
112
118
113
119
public IP2Proxy () {
114
120
@@ -1112,8 +1118,21 @@ else if (Pattern2.matcher(IP).matches() || Pattern3.matcher(IP).matches() || Pat
1112
1118
else if (IA instanceof Inet4Address ) { // this will run in cases of IPv4-mapped IPv6 addresses
1113
1119
IPType = "4" ;
1114
1120
}
1115
- A1 = new BigInteger (IPType );
1116
1121
A2 = new BigInteger (1 , Bytes );
1122
+
1123
+ if (A2 .compareTo (FROM_6TO4 ) >= 0 && A2 .compareTo (TO_6TO4 ) <= 0 ) {
1124
+ // 6to4 so need to remap to ipv4
1125
+ IPType = "4" ;
1126
+ A2 = A2 .shiftRight (80 );
1127
+ A2 = A2 .and (LAST_32BITS );
1128
+ }
1129
+ else if (A2 .compareTo (FROM_TEREDO ) >= 0 && A2 .compareTo (TO_TEREDO ) <= 0 ) {
1130
+ // Teredo so need to remap to ipv4
1131
+ IPType = "4" ;
1132
+ A2 = A2 .not ();
1133
+ A2 = A2 .and (LAST_32BITS );
1134
+ }
1135
+ A1 = new BigInteger (IPType );
1117
1136
}
1118
1137
BigInteger [] BI = new BigInteger [] { A1 , A2 , A3 };
1119
1138
0 commit comments