Commit Graph

537 Commits

Author SHA1 Message Date
Joseph Henry
ea71b85627 Minor Windows build fixes 2021-03-19 22:57:21 -07:00
Joseph Henry
3aa402582f Remove out-of-place includes for signal handler functions 2021-03-19 22:33:15 -07:00
Sean Reifschneider
2ca8e01864 Fixing some bugs in socket blocking.
There were some bugs in my blocking code that are fixed in this.
I had the setblocking() flag reversed, and wasn't passing the
flag along to the underlying code properly.
2021-03-19 10:44:29 -06:00
Sean Reifschneider
14e70ec876 Assorted Python changes based on a code review.
Many changes were based on conventions in the Python socketmodule.

Changed many of the docstrings to match the Python socket library
conventions and enhancing them.  I can either remove the prototype
part or add it to other docstrings in the library, depending on
feedback I get.

Changed setblocking to use the flag argument instead of always
just setting NONBLOCK.

Added enable/disable threading around more lwip calls.

Implementing optional backlog on listen().

Removing a few seemingly unneeded Py_INCREF(Py_None) calls.

Moved getblocking function based on alpha sorting of names.
2021-03-18 22:55:37 -06:00
Joseph Henry
2e2a66c9f7 Move Python license into ext/THIRDPARTY.txt 2021-03-17 14:34:51 -07:00
Joseph Henry
73e26c1a79 Bugfix: Check argument types and encodings in zts_py_send() 2021-03-16 23:30:14 -07:00
Joseph Henry
bf1788919b Merge branch 'py_recv_bytes' of https://github.com/linsomniac/libzt into linsomniac-py_recv_bytes 2021-03-16 18:58:43 -07:00
Sean Reifschneider
7dbf42d899 Attempt to fix zts_recv for Python.
There were a few I'm attempting to fix in zts_py_recv():

Was allocating a static buffer of 4096, but taking whatever
length the user passed in.  This change allocates a PyBytes
object of the size the user requests.

Was converting to a string without giving a size.  Which probably
led to the UnicodeDecodeError I was seeing below, trying to
decode a character beyond the received bytes.  Would also lead
to problems reading binary data that included embedded NULs.
Used the number of bytes received as the size of the returned data.

Variable "err" was being used, changed that to "bytes_read" as
that's what lwip_recv() returns, with <0 bytes read indicating
error.

Read data was being returned as a Unicode string, leading to this
response when I tried talking to my SSH server:

    UnicodeDecodeError: 'utf-8' codec can't decode
    byte 0xa1 in position 42: invalid start byte

My ssh banner is 40 bytes long, so I think position 42 was outside
the received buffer.  Changed it to a PyBytes response as is
normal for network data.  This code was cribbed from the Python
socketmodule

This was producing this error, as it was still returning the tuple:

    SystemError: <built-in function zts_py_recv> returned a
    result with an error set

This indicates that the UnicodeDecodeError had set an exception,
but a tuple was being returned instead of NULL.

In the case of a lwip_recv() error, the error response was not
being sent back to the wrapper code.  Instead, a "return NULL;"
was done.  I changed this case to return the tuple (err, None)
to the wrapper.

NOTE: this code built using "./build.sh host-python release", but
there was some sort of build problem I didn't understand which
produced a _libzt.so that I couldn't import, due to:

    ImportError: dynamic module does not define module export
    function (PyInit__libzt)

So I don't have a way to test these changes.
2021-03-16 15:52:55 -06:00
Joseph Henry
2c5c1a6a5f Expose lwIP's DNS API in zts_* API. Fix preprocessor build bug 2021-03-16 00:31:45 -07:00
Joseph Henry
2a515822c8 Remove networking functions that can be found elsewhere 2021-03-15 01:59:18 -07:00
Joseph Henry
986828a51f Split Java portion of socket API into its own file 2021-03-14 01:37:24 -08:00
Joseph Henry
4eb8304efe Change error behavior: Return ZTS_ERR_SERVICE in all cases before checking anything else 2021-03-14 01:02:43 -08:00
Joseph Henry
c220bb7d2f Improve Central API 2021-03-14 01:01:04 -08:00
Joseph Henry
26454d2939 Bugfix: calling zts_free() before zts_start() would enter infinite loop 2021-03-13 22:30:33 -08:00
Joseph Henry
575cfc364e Remove non-standard API function accept4() 2021-03-13 21:22:44 -08:00
Joseph Henry
07a5830302 Add Python extension module wrapper code 2021-03-12 21:17:37 -08:00
Joseph Henry
58ad7fafc0 Merge refactored dev into master 2021-03-12 20:32:08 -08:00
MoogleTroupe
5ba67d918d fix GC issue in c#
Store a reference to the unmanaged delegate so that the c# garbage collector doesn't wipe it out which causes a hard crash since the unmanaged dll is still referencing it.
2021-03-09 20:52:24 -05:00
Joseph Henry
dd6cf48d61 Run Python language bindings and example code through a linter and formatter 2021-03-07 21:11:21 -08:00
Joseph Henry
5072d993b1 Implement more of the Python language binding. Minor adjustments to PyPI package 2021-03-05 00:18:11 -08:00
Joseph Henry
62354e142e Improvements to language binding facilities 2021-03-01 22:34:12 -08:00
Joseph Henry
66da0495a4 Change C# wrapper extension from cxx to cpp 2021-03-01 21:39:36 -08:00
Joseph Henry
64a0d5d0d7 Add working Python wrapper and examples (WIP) 2021-03-01 21:10:39 -08:00
Joseph Henry
7a82ef4a03 Improvements to language binding facilities. Add custom signal handler 2021-02-24 01:25:15 -08:00
Joseph Henry
e6b439acb5 Update C# wrapper 2021-02-16 21:56:44 -08:00
Joseph Henry
02a401bf7f Update C# wrapper (Namespace restructure, API additions, memory leak fix) 2021-02-16 00:14:26 -08:00
Joseph Henry
a6fc3e44b8 Remove WIP Java example wrapper 2021-02-10 02:26:01 -08:00
Joseph Henry
a6297b33e2 Add NuGet package and build scripts 2021-02-05 15:58:48 -08:00
Joseph Henry
59545833e6 Update license header dates 2021-02-04 11:03:55 -08:00
Joseph Henry
b8cfadde0e Fix various minor compile-time warnings 2021-02-02 11:36:51 -08:00
Joseph Henry
38ea47212d Restructure packaging directories. Move C# bindings, minor compilation fix. 2021-02-01 17:59:21 -08:00
Joseph Henry
3544eab41d Add prototype key management API 2021-01-30 13:53:49 -08:00
Joseph Henry
026d91dedf Remove block that generates authtoken (vestigial leftover from OneService) 2021-01-29 11:09:47 -08:00
Joseph Henry
097fc5d7f0 Add prototype Central API wrapper 2021-01-29 01:26:46 -08:00
Joseph Henry
04066dbc22 Remove errant file 2021-01-23 12:07:36 -08:00
Joseph Henry
8313ed5a9f e7no7nVRFItg 2021-01-23 11:58:06 -08:00
Joseph Henry
706f493f2d Fix bug that resulted in peer caching data being written to disk even with not allowed 2021-01-15 14:22:39 -08:00
Joseph Henry
4122110cea Add C# P/INVOKE wrapper and client/server example 2021-01-04 21:03:57 -08:00
Evan Olcott
abbe7957c7 Support for creating .xcframework
* `make macOS` builds a universal framework
* `make xcframework` builds an .xcframework containing frameworks for macOS (universal), iOS, and iOS Simulator
* Addresses a compiler warning
2020-11-29 17:49:18 -06:00
Joseph Henry
e304a89ddb Add check for netif before use in VirtualTap - Fixes bug mentioned in ticket #85 2020-11-19 10:08:31 -08:00
Joseph Henry
b021e82078 Fix zts_allow_*_caching() bug that prevents user from properly setting value before node startup 2020-10-21 14:26:29 -07:00
Joseph Henry
37c01e18cf Change event code numbering scheme, fix Windows startup bug, fix zts_free(), remove vestigial API functions, update documentation 2020-05-30 18:29:04 -07:00
Joseph Henry
5d2147921c Merge branch 'master' of https://github.com/zerotier/libzt 2020-05-29 11:27:23 -07:00
rossmc7
3f1e9f00d1 Fixing Android/Java crash on boot due to missing init method (#70)
* adding extern c to library methods to fix JNI crash on init

* changed style to use ifdef cplusplus
2020-05-29 11:24:22 -07:00
Joseph Henry
a2cbea6dee Merge branch 'master' of https://github.com/zerotier/libzt 2020-05-11 10:21:23 -07:00
Lann Martin
a708c72dfa Fix struct name in zts_get_rfc_*_addr 2020-05-07 22:56:54 -04:00
Joseph Henry
676ddd15d4 Change default MTU to 2800 2020-05-06 20:24:58 -07:00
Joseph Henry
112d66ea20 Fix non-blocking behavior of sockets (removal of a portion of the old compatibility layer) 2020-05-05 14:35:22 -07:00
Joseph Henry
a0b50530d3 Add portability and consistency fixes for C API, remove cruft, slight internal restructuring 2020-05-01 19:15:38 -07:00
Joseph Henry
894d3bf415 Fix (some) Windows compiler warnings 2020-04-20 23:50:21 -07:00