Skip to content

Commit b7c9293

Browse files
committed
Added support for 6to4 and Teredo
1 parent f1ca678 commit b7c9293

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

IP2ProxyComponent/IP2Proxy.vb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ Public Class Component
6363

6464
Private _FromBI As New BigInteger(281470681743360)
6565
Private _ToBI As New BigInteger(281474976710655)
66+
Private _FromBI2 As BigInteger = BigInteger.Parse("42545680458834377588178886921629466624")
67+
Private _ToBI2 As BigInteger = BigInteger.Parse("42550872755692912415807417417958686719")
68+
Private _FromBI3 As BigInteger = BigInteger.Parse("42540488161975842760550356425300246528")
69+
Private _ToBI3 As BigInteger = BigInteger.Parse("42540488241204005274814694018844196863")
70+
Private _DivBI As BigInteger = New BigInteger(4294967295)
6671

6772
Private Const MAX_IPV4_RANGE As Long = 4294967295
6873
Private MAX_IPV6_RANGE As BigInteger = BigInteger.Pow(2, 128) - 1
@@ -867,6 +872,18 @@ Public Class Component
867872
Tmp = String.Join("", Enumerable.Repeat("0000:", 5).ToList)
868873
FinalIP = FinalIP.Replace("::", Tmp)
869874
End If
875+
ElseIf IPNum >= _FromBI2 AndAlso IPNum <= _ToBI2 Then
876+
'6to4 so need to remap to ipv4
877+
StrIPType = 4
878+
879+
IPNum = IPNum >> 80
880+
IPNum = IPNum And _DivBI ' get last 32 bits
881+
ElseIf IPNum >= _FromBI3 AndAlso IPNum <= _ToBI3 Then
882+
'Teredo so need to remap to ipv4
883+
StrIPType = 4
884+
885+
IPNum = Not IPNum
886+
IPNum = IPNum And _DivBI ' get last 32 bits
870887
ElseIf IPNum <= MAX_IPV4_RANGE Then
871888
'ipv4-compatible ipv6 (DEPRECATED BUT STILL SUPPORTED BY .NET)
872889
StrIPType = 4

IP2ProxyComponent/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("2.0.0.0")>
35-
<Assembly: AssemblyFileVersion("2.0.0.0")>
34+
<Assembly: AssemblyVersion("2.1.0.0")>
35+
<Assembly: AssemblyFileVersion("2.1.0.0")>

0 commit comments

Comments
 (0)