Skip to content

Commit

Permalink
Private IPv4 address bitwise inversion is added to P2P algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Koifman committed Sep 23, 2023
1 parent cd35e1a commit cb1efdb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Softnet.Proxy/TcpConnectorV4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ void ProcessMessage_ClientP2P(byte[] message)
byte[] hostIep = asnSequence.OctetString(6);
asnSequence.End();

if (ByteArray.Equals(hostIep, 0, PublicIEP, 0, 4) == false)
byte[] hostIp = new byte[4];
for (int i = 0; i < 4; i++)
hostIp[i] = (byte)~hostIep[i];

if (ByteArray.Equals(hostIp, 0, PublicIEP, 0, 4) == false)
PrivateIEP = hostIep;

m_ConnectorState = ConnectorState.AUTH_REQUIRED;
Expand All @@ -150,7 +154,11 @@ void ProcessMessage_ServiceP2P(byte[] message)
byte[] hostIep = asnSequence.OctetString(6);
asnSequence.End();

if (ByteArray.Equals(hostIep, 0, PublicIEP, 0, 4) == false)
byte[] hostIp = new byte[4];
for (int i = 0; i < 4; i++)
hostIp[i] = (byte)~hostIep[i];

if (ByteArray.Equals(hostIp, 0, PublicIEP, 0, 4) == false)
PrivateIEP = hostIep;

m_ConnectorState = ConnectorState.AUTH_REQUIRED;
Expand Down

0 comments on commit cb1efdb

Please sign in to comment.