zerotier / libzt

Encrypted P2P sockets over ZeroTier

Home Page:https://zerotier.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node.js bindings

janvanbouwel opened this issue · comments

Last month I've worked on new bindings for node.js in typescript using node-gypand node-addon-api. Blocking calls are made asynchronous, using the latter API to interact with libuv. TCP matches closely to nodes net module and should be interoperable with e.g. the http module. Same for UDP (node:dgram), though UDP does not support connections yet (instead specify destination every time).

It's not finished, but I've had less time to work on it so thought I'd share it already, to also get some feedback. Biggest issue currently is figuring out how to best build/package it, something I don't have much experience with. (It's also currently Linux only as I don't have Windows or Mac to test on, it's hopefully just configuring the paths.)

Code is here: https://github.com/janvanbouwel/libzt/tree/node/src/bindings/nodejs (I'll create a PR as well)

https://github.com/janvanbouwel/libzt/tree/node-test-release is an attempt at packaging it. It includes a prebuilt libzt.a. It can be installed using npm, which builds the bindings and links it automatically. The only issue is npm not liking a package being placed in a subfolder of a git repository, instead https://gitpkg.now.sh/janvanbouwel/libzt/src/bindings/nodejs?node-test-release can be used. I've made an example project at https://github.com/janvanbouwel/libzt-node-example that demonstrates this.

Dude, this is awesome. I'll try to take a look soon and not keep you and your PR hanging. This is something we've wanted to properly support for a long time.

Nice to hear. I'm sure many improvements are possible, but it works and I've tried to make a solid base to work off of. That being said, documentation is a bit sparse, so let me know if anything needs clarification.

Closing this to consolidate discussion into your PR #235