zerotier / libzt

Encrypted P2P sockets over ZeroTier

Home Page:https://zerotier.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java Windows: Could not get IPs correctly and Could not send data via sockets.

MegumiKasuga opened this issue · comments

I compiled my jar with ./build.sh host-jar and
the lib with . .\build.ps1; Build-Library -BuildType "Release" -Arch "x64" -LangBinding "java"
using cmake3, gcc 11.4.0 and OpenJDK 17.0.8 (ms build)

To fix compile errors,
I have replaced Visual Studio 16 2019 with Visual Studio 17 2022 in build.ps1 and build.sh.
replaced s_addr with S_addr in src/bindings/java/JavaSockets.cxx (line 393 and line 431)
add return 0; for

  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1get (line 594)
  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1get_1all (line 614)
  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1compute_16plane (line 626)
  • Java_com_zerotier_sockets_ZeroTierNative_zts_1addr_1compute_1rfc4193 (line 636)

(They are all empty method, but the compiler said that they must have something to return, so I make them all return 0)
add include_directories(${ZTO_SRC_DIR}/ext/), and changed the JNI path to my own path (in CMakeFiles.txt)

Then, I moved my lib and jar into my IDE workspace, and write an example program just like example.java

2

The program now has some Unexpected bugs:

  • Could not get IPs correctly (Included IPv4 and IPv6), The native method returns (empty) so that it(getAddressMethod) returns me with 127.0.0.1.
  • Could not send and recive datas through sockets. The program got stuck in connecting phase.

But it acts normal in:

  • joining networks.
  • get MAC address.
  • get NodeID.

I have test my program using libzt.dll of 1.8.10 and 1.8.4, and they both have the problems mentioned above.

See solutions here: #267