Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js Integration #10

Open
laduke opened this issue Jun 22, 2017 · 16 comments
Open

Node.js Integration #10

laduke opened this issue Jun 22, 2017 · 16 comments

Comments

@laduke
Copy link
Contributor

laduke commented Jun 22, 2017

😎
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.

@joseph-henry
Copy link
Contributor

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.

@laduke
Copy link
Contributor Author

laduke commented Jun 22, 2017

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)

@laduke
Copy link
Contributor Author

laduke commented Aug 15, 2017

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

@laduke
Copy link
Contributor Author

laduke commented Mar 2, 2018

@heri16
Copy link

heri16 commented Aug 2, 2020

What happened to the merged pull request? Why are the nodejs examples removed?

@laduke
Copy link
Contributor Author

laduke commented Aug 7, 2020

I never got it into any kind of production state and libzt has changed a little since then. gonna check out your PR!

@joseph-henry
Copy link
Contributor

Are there any questions I can answer about the library in order to help this effort, @heri16?

@joseph-henry joseph-henry changed the title Need nodejs example Node.js Integration Sep 11, 2020
@heri16
Copy link

heri16 commented May 14, 2021

@laduke did you manage to get this working?

@laduke
Copy link
Contributor Author

laduke commented May 14, 2021

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?

@joseph-henry
Copy link
Contributor

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.

@joseph-henry joseph-henry reopened this May 14, 2021
@bluet
Copy link

bluet commented Jul 4, 2021

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.

@jerrychong25
Copy link

Hi all (@laduke @joseph-henry @heri16 @bluet ),

So far any solution to integrate zerotier into JavaScript/Node.js based application?

Thanks!

@bluet
Copy link

bluet commented Aug 8, 2022

@jerrychong25 I have no idea. There's no update here.

@jerrychong25
Copy link

@jerrychong25 I have no idea. There's no update here.

Ok thanks @bluet !

Let's hope for good news soon =)

@janvanbouwel
Copy link
Contributor

I've opened a new issue at #234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants