From 8952a6bf95d7ee45ba9d14a771bca749754a8ae7 Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Fri, 9 Dec 2022 06:55:17 -0500 Subject: [PATCH 1/4] Fix typos ZTS_CENRTAL_MAX_URL_LEN -> ZTS_CENTRAL_MAX_URL_LEN --- include/ZeroTierSockets.h | 2 +- src/Central.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/ZeroTierSockets.h b/include/ZeroTierSockets.h index f57cd242..0374bac0 100644 --- a/include/ZeroTierSockets.h +++ b/include/ZeroTierSockets.h @@ -1023,7 +1023,7 @@ typedef struct { #ifndef ZTS_DISABLE_CENTRAL_API #define ZTS_CENTRAL_DEFAULT_URL "https://my.zerotier.com" -#define ZTS_CENRTAL_MAX_URL_LEN 128 +#define ZTS_CENTRAL_MAX_URL_LEN 128 #define ZTS_CENTRAL_TOKEN_LEN 32 #define ZTS_CENTRAL_RESP_BUF_DEFAULT_SZ (128 * 1024) diff --git a/src/Central.cpp b/src/Central.cpp index 247d0b2d..e6ea8b07 100644 --- a/src/Central.cpp +++ b/src/Central.cpp @@ -25,7 +25,7 @@ #define REQ_LEN 64 -char api_url[ZTS_CENRTAL_MAX_URL_LEN]; +char api_url[ZTS_CENTRAL_MAX_URL_LEN]; char api_token[ZTS_CENTRAL_TOKEN_LEN + 1]; char* _resp_buf; @@ -97,12 +97,12 @@ int zts_central_init(const char* url_str, const char* token_str, char* resp_buf, // Initialize all curl internal submodules curl_global_init(CURL_GLOBAL_ALL); - int url_len = strnlen(url_str, ZTS_CENRTAL_MAX_URL_LEN); - if (url_len < 3 || url_len > ZTS_CENRTAL_MAX_URL_LEN) { + int url_len = strnlen(url_str, ZTS_CENTRAL_MAX_URL_LEN); + if (url_len < 3 || url_len > ZTS_CENTRAL_MAX_URL_LEN) { return ZTS_ERR_ARG; } else { - memset(api_url, 0, ZTS_CENRTAL_MAX_URL_LEN); + memset(api_url, 0, ZTS_CENTRAL_MAX_URL_LEN); strncpy(api_url, url_str, url_len); } int token_len = strnlen(token_str, ZTS_CENTRAL_TOKEN_LEN); @@ -146,19 +146,19 @@ int central_req( return ZTS_ERR_SERVICE; } zts_central_clear_resp_buf(); - int central_strlen = strnlen(central_str, ZTS_CENRTAL_MAX_URL_LEN); - int api_route_strlen = strnlen(api_route_str, ZTS_CENRTAL_MAX_URL_LEN); + int central_strlen = strnlen(central_str, ZTS_CENTRAL_MAX_URL_LEN); + int api_route_strlen = strnlen(api_route_str, ZTS_CENTRAL_MAX_URL_LEN); int token_strlen = strnlen(token_str, ZTS_CENTRAL_TOKEN_LEN); int url_len = central_strlen + api_route_strlen; if (token_strlen > ZTS_CENTRAL_TOKEN_LEN) { return ZTS_ERR_ARG; } - if (url_len > ZTS_CENRTAL_MAX_URL_LEN) { + if (url_len > ZTS_CENTRAL_MAX_URL_LEN) { return ZTS_ERR_ARG; } - char req_url[ZTS_CENRTAL_MAX_URL_LEN] = { 0 }; - strncpy(req_url, central_str, ZTS_CENRTAL_MAX_URL_LEN); - strncat(req_url, api_route_str, ZTS_CENRTAL_MAX_URL_LEN); + char req_url[ZTS_CENTRAL_MAX_URL_LEN] = { 0 }; + strncpy(req_url, central_str, ZTS_CENTRAL_MAX_URL_LEN); + strncat(req_url, api_route_str, ZTS_CENTRAL_MAX_URL_LEN); CURL* curl; CURLcode res; From d00f72ae925be96da977df358251907a72b1da80 Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Fri, 9 Dec 2022 06:56:31 -0500 Subject: [PATCH 2/4] Fix typo accetpedFd -> acceptedFd --- .../java/com/zerotier/sockets/ZeroTierSocket.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java b/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java index ffedb3bc..66e79464 100644 --- a/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java +++ b/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java @@ -232,12 +232,12 @@ public ZeroTierSocket accept() throws IOException if (_zfd < 0) { throw new IOException("Invalid socket (fd < 0)"); } - int accetpedFd = -1; + int acceptedFd = -1; ZeroTierSocketAddress addr = new ZeroTierSocketAddress(); - if ((accetpedFd = ZeroTierNative.zts_bsd_accept(_zfd, addr)) < 0) { - throw new IOException("Error while accepting connection (" + accetpedFd + ")"); + if ((acceptedFd = ZeroTierNative.zts_bsd_accept(_zfd, addr)) < 0) { + throw new IOException("Error while accepting connection (" + acceptedFd + ")"); } - return new ZeroTierSocket(_family, _type, _protocol, accetpedFd); + return new ZeroTierSocket(_family, _type, _protocol, acceptedFd); } /** From 51af6aacd944f52e952d0fefcee2cb196ffc7ae3 Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Fri, 9 Dec 2022 07:04:52 -0500 Subject: [PATCH 3/4] Fix typo TCP_SLOW_INTERVALs -> TCP_SLOW_INTERVAL --- src/lwipopts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lwipopts.h b/src/lwipopts.h index 20e74378..5ddb269c 100644 --- a/src/lwipopts.h +++ b/src/lwipopts.h @@ -149,7 +149,7 @@ happening sooner than they should. #define TCP_FAST_INTERVAL TCP_TMR_INTERVAL #endif /* TCP_FAST_INTERVAL */ -#ifndef TCP_SLOW_INTERVALs +#ifndef TCP_SLOW_INTERVAL /* the coarse grained timeout in milliseconds */ #define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) #endif /* TCP_SLOW_INTERVAL */ From 8bd9a18a386141bbaa69249a2c28b2bb50705cf9 Mon Sep 17 00:00:00 2001 From: Brenton Bostick Date: Fri, 9 Dec 2022 06:52:14 -0500 Subject: [PATCH 4/4] remove stray U+200b characters --- .../sockets/ZeroTierDatagramSocket.java | 10 +++---- .../zerotier/sockets/ZeroTierInputStream.java | 26 +++++++++---------- .../com/zerotier/sockets/ZeroTierSocket.java | 10 +++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/bindings/java/com/zerotier/sockets/ZeroTierDatagramSocket.java b/src/bindings/java/com/zerotier/sockets/ZeroTierDatagramSocket.java index a37608d0..34d44700 100644 --- a/src/bindings/java/com/zerotier/sockets/ZeroTierDatagramSocket.java +++ b/src/bindings/java/com/zerotier/sockets/ZeroTierDatagramSocket.java @@ -165,7 +165,7 @@ public void receive(DatagramPacket packet) throws IOException 0, packet.getLength()); if ((bytesRead <= 0) | (bytesRead == -104) /* EINTR, from SO_RCVTIMEO */) { - throw new IOException("read​(DatagramPacket), errno=" + bytesRead); + throw new IOException("read(DatagramPacket), errno=" + bytesRead); } } @@ -277,16 +277,16 @@ public int getSoTimeout() throws SocketException * Return whether this ZeroTierSocket is bound to a local address * @return true or false */ - public boolean isBound​() + public boolean isBound() { - return _socket.isBound​(); + return _socket.isBound(); } /** * Return whether this ZeroTierSocket has been closed * @return true or false */ - public boolean isClosed​() + public boolean isClosed() { return _socket.isClosed(); } @@ -295,7 +295,7 @@ public int getSoTimeout() throws SocketException * Return whether this ZeroTierSocket is connected to a remote address * @return true or false */ - public boolean isConnected​() + public boolean isConnected() { return _socket.isConnected(); } diff --git a/src/bindings/java/com/zerotier/sockets/ZeroTierInputStream.java b/src/bindings/java/com/zerotier/sockets/ZeroTierInputStream.java index 8d23d881..e5d2d4f3 100644 --- a/src/bindings/java/com/zerotier/sockets/ZeroTierInputStream.java +++ b/src/bindings/java/com/zerotier/sockets/ZeroTierInputStream.java @@ -30,7 +30,7 @@ public class ZeroTierInputStream extends InputStream { * Close the ZeroTierInputStream * @exception IOException when an I/O error occurs */ - public void close​() throws IOException + public void close() throws IOException { /* Note: this operation currently only stops RX on a socket that is shared between both I/OStreams. This means that closing this stream will only shutdown @@ -47,7 +47,7 @@ public class ZeroTierInputStream extends InputStream { * @return Number of bytes transferred * @exception IOException when an I/O error occurs */ - public long transferTo​(OutputStream destStream) throws IOException + public long transferTo(OutputStream destStream) throws IOException { Objects.requireNonNull(destStream, "destStream must not be null"); int bytesTransferred = 0, bytesRead; @@ -64,7 +64,7 @@ public class ZeroTierInputStream extends InputStream { * @return Single byte read * @exception IOException when an I/O error occurs */ - public int read​() throws IOException + public int read() throws IOException { byte[] buf = new byte[1]; // Unlike a native read(), if nothing is read we should return -1 @@ -73,7 +73,7 @@ public class ZeroTierInputStream extends InputStream { return -1; } if (retval < 0) { - throw new IOException("read​(), errno=" + retval); + throw new IOException("read(), errno=" + retval); } return buf[0]; } @@ -84,7 +84,7 @@ public class ZeroTierInputStream extends InputStream { * @return Number of bytes read * @exception IOException when an I/O error occurs */ - public int read​(byte[] destBuffer) throws IOException + public int read(byte[] destBuffer) throws IOException { Objects.requireNonNull(destBuffer, "input byte array must not be null"); // Unlike a native read(), if nothing is read we should return -1 @@ -93,7 +93,7 @@ public class ZeroTierInputStream extends InputStream { return -1; } if (retval < 0) { - throw new IOException("read​(destBuffer), errno=" + retval); + throw new IOException("read(destBuffer), errno=" + retval); } return retval; } @@ -106,7 +106,7 @@ public class ZeroTierInputStream extends InputStream { * @return Number of bytes read. * @exception IOException when an I/O error occurs */ - public int read​(byte[] destBuffer, int offset, int numBytes) throws IOException + public int read(byte[] destBuffer, int offset, int numBytes) throws IOException { Objects.requireNonNull(destBuffer, "input byte array must not be null"); if (offset < 0) { @@ -127,7 +127,7 @@ public class ZeroTierInputStream extends InputStream { return -1; } if (retval < 0) { - throw new IOException("read​(destBuffer, offset, numBytes), errno=" + retval); + throw new IOException("read(destBuffer, offset, numBytes), errno=" + retval); } return retval; } @@ -137,7 +137,7 @@ public class ZeroTierInputStream extends InputStream { * @return Array of bytes * @exception IOException when an I/O error occurs */ - public byte[] readAllBytes​() throws IOException + public byte[] readAllBytes() throws IOException { int pendingDataSize = ZeroTierNative.zts_get_pending_data_size(zfd); byte[] buf = new byte[pendingDataSize]; @@ -146,7 +146,7 @@ public class ZeroTierInputStream extends InputStream { // No action needed } if (retval < 0) { - throw new IOException("readAllBytes​(), errno=" + retval); + throw new IOException("readAllBytes(), errno=" + retval); } return buf; } @@ -159,7 +159,7 @@ public class ZeroTierInputStream extends InputStream { * @return Nothing. * @exception IOException when an I/O error occurs */ - public int readNBytes​(byte[] destBuffer, int offset, int numBytes) throws IOException + public int readNBytes(byte[] destBuffer, int offset, int numBytes) throws IOException { Objects.requireNonNull(destBuffer, "input byte array must not be null"); if (offset < 0) { @@ -179,7 +179,7 @@ public class ZeroTierInputStream extends InputStream { // No action needed } if (retval < 0) { - throw new IOException("readNBytes​(destBuffer, offset, numBytes), errno=" + retval); + throw new IOException("readNBytes(destBuffer, offset, numBytes), errno=" + retval); } return retval; } @@ -190,7 +190,7 @@ public class ZeroTierInputStream extends InputStream { * @return Nothing. * @exception IOException when an I/O error occurs */ - public long skip​(long numBytes) throws IOException + public long skip(long numBytes) throws IOException { if (numBytes <= 0) { return 0; diff --git a/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java b/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java index 66e79464..7b0fea30 100644 --- a/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java +++ b/src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java @@ -421,7 +421,7 @@ public boolean tcpNoDelayEnabled() throws SocketException * Return whether this ZeroTierSocket is bound to a local address * @return true or false */ - public boolean isBound​() + public boolean isBound() { return _isBound; } @@ -430,7 +430,7 @@ public boolean tcpNoDelayEnabled() throws SocketException * Return whether this ZeroTierSocket has been closed * @return true or false */ - public boolean isClosed​() + public boolean isClosed() { return _isClosed; } @@ -439,7 +439,7 @@ public boolean tcpNoDelayEnabled() throws SocketException * Return whether this ZeroTierSocket is connected to a remote address * @return true or false */ - public boolean isConnected​() + public boolean isConnected() { return _isConnected; } @@ -526,7 +526,7 @@ public ZeroTierOutputStream getOutputStream() throws SocketException * Return whether the input-aspect of the ZeroTierSocket has been disabled. * @return true or false */ - public boolean inputStreamHasBeenShutdown​() + public boolean inputStreamHasBeenShutdown() { return _inputHasBeenShutdown; } @@ -535,7 +535,7 @@ public ZeroTierOutputStream getOutputStream() throws SocketException * Return whether the output-aspect of the ZeroTierSocket has been disabled. * @return true or false */ - public boolean outputStreamHasBeenShutdown​() + public boolean outputStreamHasBeenShutdown() { return _outputHasBeenShutdown; }