Open laduke opened 7 years ago
This would be really interesting. We'd wan't to expose the functions in include/libzt.h
to the user. For now you'd want to use the experimental
branch, but soon that will be merged back into master.
getting somewhere, but it fails to compile.
git clone https://github.com/laduke/libzt.git libzt-laduke
git checkout laduke-gyp
npm install
npm run -s -- node-gyp rebuild
make: *** No rule to make target `zto/controller/EmbeddedNetworkController.o', needed by `static_lib'. Stop.
which is the same error I get from just running make static_lib
(on Darwin and Linux)
We have something that compiles now. Manual process to get it running:
git clone git@github.com:laduke/libzt.git
git fetch origin laduke-gyp
git checkout laduke-gyp
git submodule init
git submodule update
make static_lib
npm install //automatically compiles binding.cc
node test.js
Important files:
binding.cc
binding.gyp
test.js
rebuild binding.cc:
npm run -- node-gyp rebuild
This branch^ has a compiled libzt.a in ./darwin, which is not ideal, but I saw that was how that go-lang repo was doing it. Getting node-gyp to compile picotcp and libzt correctly would be better, but I tried and it was quite hard.
All it does right now:
running 0
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol ethernet registered (layer: 2).
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol ipv4 registered (layer: 3).
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol ipv6 registered (layer: 3).
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol icmp4 registered (layer: 4).
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol icmp6 registered (layer: 4).
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol igmp registered (layer: 4).
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol udp registered (layer: 4).
EXTRA[0] : pico_protocol.c: 225: pico_protocol_init: Protocol tcp registered (layer: 4).
INFO [0] : libzt.cpp: 1867: zts_start_service: homeDir=./networks/8056c2e21c000001
INFO [0] : SocketTap.cpp: 105: SocketTap: set device name to: libzt0
EXTRA[0] : pico_ipv4.c: 1321: pico_ipv4_link_add: Assigned ipv4 29.18.59.241 to device libzt0
INFO [0] : picoTCP.cpp: 114: pico_init_interface: addr = 29.18.59.241/7
INFO [0] : picoTCP.cpp: 127: pico_init_interface: addr6 = fd80:56c2:e21c::199:9342:d912:3aac
running 1
note to self: https://github.com/mafintosh/prebuildify https://github.com/mafintosh/turbo-net/blob/master/package.json
prebuild the libs
What happened to the merged pull request? Why are the nodejs examples removed?
Notes to self on creating a ztnet.createConnection()
that returns a custom NodeJs Socket which _write() and _read() calls zts_send and zts_recv, to work with any existing npm libraries that use https://nodejs.org/docs/latest-v12.x/api/net.html#net_net_createconnection
Monkey-patching may be applied manually on a per-project basis to cause ztnet.createConnection to be called instead of net.createConnection.
https://github.com/zerotier/libzt/blob/master/examples/cpp/nonblockingclient.cpp
https://nodejs.org/docs/latest-v12.x/api/stream.html#stream_api_for_stream_implementers
https://github.com/altangent/lntools/tree/master/packages/noise
https://github.com/nodejs/node/blob/master/lib/internal/js_stream_socket.js
https://github.com/nodejs/node/issues/18795#issuecomment-649882045
https://www.audero.it/blog/2016/12/05/monkey-patching-javascript/
I never got it into any kind of production state and libzt has changed a little since then. gonna check out your PR!
Are there any questions I can answer about the library in order to help this effort, @heri16?
@laduke did you manage to get this working?
Hi @heri16 I thought your PR got merged in? I haven't been able to follow this closely lately.
Did you end up using it for anything?
It did get merged in, but enough changed since its merge that I cant guarantee that it works hence it being moved to the attic. If there's enough interest in bringing it up to feature-parity with the C API I'm not opposed to it being brought back.
Really looking forward to see js binding and use zt in our JavaScript/NodeJS based projects.
I'm looking for underlying module/solutions for building a new semi-private p2p application.
Hi all (@laduke @joseph-henry @heri16 @bluet ),
So far any solution to integrate zerotier into JavaScript/Node.js based application?
Thanks!
@jerrychong25 I have no idea. There's no update here.
@jerrychong25 I have no idea. There's no update here.
Ok thanks @bluet !
Let's hope for good news soon =)
I've opened a new issue at #234
😎 Not sure how one goes about hooking a c library to javascript.
All the projects in my node_modules that use external c libraries use https://github.com/nodejs/node-gyp
and there's this thing which may or may not help https://github.com/charto/nbind
I'm going to give it a shot on the weekend and see how far I get.