Merge pull request #218 from zerotier/brenton/fix-typos

Brenton/fix typos
This commit is contained in:
Joseph Henry
2023-05-26 10:12:24 -07:00
committed by GitHub
6 changed files with 39 additions and 39 deletions

View File

@@ -1023,7 +1023,7 @@ typedef struct {
#ifndef ZTS_DISABLE_CENTRAL_API #ifndef ZTS_DISABLE_CENTRAL_API
#define ZTS_CENTRAL_DEFAULT_URL "https://my.zerotier.com" #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_TOKEN_LEN 32
#define ZTS_CENTRAL_RESP_BUF_DEFAULT_SZ (128 * 1024) #define ZTS_CENTRAL_RESP_BUF_DEFAULT_SZ (128 * 1024)

View File

@@ -25,7 +25,7 @@
#define REQ_LEN 64 #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 api_token[ZTS_CENTRAL_TOKEN_LEN + 1];
char* _resp_buf; 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 // Initialize all curl internal submodules
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
int url_len = strnlen(url_str, ZTS_CENRTAL_MAX_URL_LEN); int url_len = strnlen(url_str, ZTS_CENTRAL_MAX_URL_LEN);
if (url_len < 3 || url_len > ZTS_CENRTAL_MAX_URL_LEN) { if (url_len < 3 || url_len > ZTS_CENTRAL_MAX_URL_LEN) {
return ZTS_ERR_ARG; return ZTS_ERR_ARG;
} }
else { 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); strncpy(api_url, url_str, url_len);
} }
int token_len = strnlen(token_str, ZTS_CENTRAL_TOKEN_LEN); int token_len = strnlen(token_str, ZTS_CENTRAL_TOKEN_LEN);
@@ -146,19 +146,19 @@ int central_req(
return ZTS_ERR_SERVICE; return ZTS_ERR_SERVICE;
} }
zts_central_clear_resp_buf(); zts_central_clear_resp_buf();
int central_strlen = strnlen(central_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_CENRTAL_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 token_strlen = strnlen(token_str, ZTS_CENTRAL_TOKEN_LEN);
int url_len = central_strlen + api_route_strlen; int url_len = central_strlen + api_route_strlen;
if (token_strlen > ZTS_CENTRAL_TOKEN_LEN) { if (token_strlen > ZTS_CENTRAL_TOKEN_LEN) {
return ZTS_ERR_ARG; return ZTS_ERR_ARG;
} }
if (url_len > ZTS_CENRTAL_MAX_URL_LEN) { if (url_len > ZTS_CENTRAL_MAX_URL_LEN) {
return ZTS_ERR_ARG; return ZTS_ERR_ARG;
} }
char req_url[ZTS_CENRTAL_MAX_URL_LEN] = { 0 }; char req_url[ZTS_CENTRAL_MAX_URL_LEN] = { 0 };
strncpy(req_url, central_str, ZTS_CENRTAL_MAX_URL_LEN); strncpy(req_url, central_str, ZTS_CENTRAL_MAX_URL_LEN);
strncat(req_url, api_route_str, ZTS_CENRTAL_MAX_URL_LEN); strncat(req_url, api_route_str, ZTS_CENTRAL_MAX_URL_LEN);
CURL* curl; CURL* curl;
CURLcode res; CURLcode res;

View File

@@ -165,7 +165,7 @@ public class ZeroTierDatagramSocket {
0, 0,
packet.getLength()); packet.getLength());
if ((bytesRead <= 0) | (bytesRead == -104) /* EINTR, from SO_RCVTIMEO */) { 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 class ZeroTierDatagramSocket {
* Return whether this ZeroTierSocket is bound to a local address * Return whether this ZeroTierSocket is bound to a local address
* @return true or false * @return true or false
*/ */
public boolean isBound() public boolean isBound()
{ {
return _socket.isBound(); return _socket.isBound();
} }
/** /**
* Return whether this ZeroTierSocket has been closed * Return whether this ZeroTierSocket has been closed
* @return true or false * @return true or false
*/ */
public boolean isClosed() public boolean isClosed()
{ {
return _socket.isClosed(); return _socket.isClosed();
} }
@@ -295,7 +295,7 @@ public class ZeroTierDatagramSocket {
* Return whether this ZeroTierSocket is connected to a remote address * Return whether this ZeroTierSocket is connected to a remote address
* @return true or false * @return true or false
*/ */
public boolean isConnected() public boolean isConnected()
{ {
return _socket.isConnected(); return _socket.isConnected();
} }

View File

@@ -30,7 +30,7 @@ public class ZeroTierInputStream extends InputStream {
* Close the ZeroTierInputStream * Close the ZeroTierInputStream
* @exception IOException when an I/O error occurs * @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 /* 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 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 * @return Number of bytes transferred
* @exception IOException when an I/O error occurs * @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"); Objects.requireNonNull(destStream, "destStream must not be null");
int bytesTransferred = 0, bytesRead; int bytesTransferred = 0, bytesRead;
@@ -64,7 +64,7 @@ public class ZeroTierInputStream extends InputStream {
* @return Single byte read * @return Single byte read
* @exception IOException when an I/O error occurs * @exception IOException when an I/O error occurs
*/ */
public int read() throws IOException public int read() throws IOException
{ {
byte[] buf = new byte[1]; byte[] buf = new byte[1];
// Unlike a native read(), if nothing is read we should return -1 // Unlike a native read(), if nothing is read we should return -1
@@ -73,7 +73,7 @@ public class ZeroTierInputStream extends InputStream {
return -1; return -1;
} }
if (retval < 0) { if (retval < 0) {
throw new IOException("read(), errno=" + retval); throw new IOException("read(), errno=" + retval);
} }
return buf[0]; return buf[0];
} }
@@ -84,7 +84,7 @@ public class ZeroTierInputStream extends InputStream {
* @return Number of bytes read * @return Number of bytes read
* @exception IOException when an I/O error occurs * @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"); Objects.requireNonNull(destBuffer, "input byte array must not be null");
// Unlike a native read(), if nothing is read we should return -1 // Unlike a native read(), if nothing is read we should return -1
@@ -93,7 +93,7 @@ public class ZeroTierInputStream extends InputStream {
return -1; return -1;
} }
if (retval < 0) { if (retval < 0) {
throw new IOException("read(destBuffer), errno=" + retval); throw new IOException("read(destBuffer), errno=" + retval);
} }
return retval; return retval;
} }
@@ -106,7 +106,7 @@ public class ZeroTierInputStream extends InputStream {
* @return Number of bytes read. * @return Number of bytes read.
* @exception IOException when an I/O error occurs * @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"); Objects.requireNonNull(destBuffer, "input byte array must not be null");
if (offset < 0) { if (offset < 0) {
@@ -127,7 +127,7 @@ public class ZeroTierInputStream extends InputStream {
return -1; return -1;
} }
if (retval < 0) { if (retval < 0) {
throw new IOException("read(destBuffer, offset, numBytes), errno=" + retval); throw new IOException("read(destBuffer, offset, numBytes), errno=" + retval);
} }
return retval; return retval;
} }
@@ -137,7 +137,7 @@ public class ZeroTierInputStream extends InputStream {
* @return Array of bytes * @return Array of bytes
* @exception IOException when an I/O error occurs * @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); int pendingDataSize = ZeroTierNative.zts_get_pending_data_size(zfd);
byte[] buf = new byte[pendingDataSize]; byte[] buf = new byte[pendingDataSize];
@@ -146,7 +146,7 @@ public class ZeroTierInputStream extends InputStream {
// No action needed // No action needed
} }
if (retval < 0) { if (retval < 0) {
throw new IOException("readAllBytes(), errno=" + retval); throw new IOException("readAllBytes(), errno=" + retval);
} }
return buf; return buf;
} }
@@ -159,7 +159,7 @@ public class ZeroTierInputStream extends InputStream {
* @return Nothing. * @return Nothing.
* @exception IOException when an I/O error occurs * @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"); Objects.requireNonNull(destBuffer, "input byte array must not be null");
if (offset < 0) { if (offset < 0) {
@@ -179,7 +179,7 @@ public class ZeroTierInputStream extends InputStream {
// No action needed // No action needed
} }
if (retval < 0) { if (retval < 0) {
throw new IOException("readNBytes(destBuffer, offset, numBytes), errno=" + retval); throw new IOException("readNBytes(destBuffer, offset, numBytes), errno=" + retval);
} }
return retval; return retval;
} }
@@ -190,7 +190,7 @@ public class ZeroTierInputStream extends InputStream {
* @return Nothing. * @return Nothing.
* @exception IOException when an I/O error occurs * @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) { if (numBytes <= 0) {
return 0; return 0;

View File

@@ -232,12 +232,12 @@ public class ZeroTierSocket {
if (_zfd < 0) { if (_zfd < 0) {
throw new IOException("Invalid socket (fd < 0)"); throw new IOException("Invalid socket (fd < 0)");
} }
int accetpedFd = -1; int acceptedFd = -1;
ZeroTierSocketAddress addr = new ZeroTierSocketAddress(); ZeroTierSocketAddress addr = new ZeroTierSocketAddress();
if ((accetpedFd = ZeroTierNative.zts_bsd_accept(_zfd, addr)) < 0) { if ((acceptedFd = ZeroTierNative.zts_bsd_accept(_zfd, addr)) < 0) {
throw new IOException("Error while accepting connection (" + accetpedFd + ")"); throw new IOException("Error while accepting connection (" + acceptedFd + ")");
} }
return new ZeroTierSocket(_family, _type, _protocol, accetpedFd); return new ZeroTierSocket(_family, _type, _protocol, acceptedFd);
} }
/** /**
@@ -421,7 +421,7 @@ public class ZeroTierSocket {
* Return whether this ZeroTierSocket is bound to a local address * Return whether this ZeroTierSocket is bound to a local address
* @return true or false * @return true or false
*/ */
public boolean isBound() public boolean isBound()
{ {
return _isBound; return _isBound;
} }
@@ -430,7 +430,7 @@ public class ZeroTierSocket {
* Return whether this ZeroTierSocket has been closed * Return whether this ZeroTierSocket has been closed
* @return true or false * @return true or false
*/ */
public boolean isClosed() public boolean isClosed()
{ {
return _isClosed; return _isClosed;
} }
@@ -439,7 +439,7 @@ public class ZeroTierSocket {
* Return whether this ZeroTierSocket is connected to a remote address * Return whether this ZeroTierSocket is connected to a remote address
* @return true or false * @return true or false
*/ */
public boolean isConnected() public boolean isConnected()
{ {
return _isConnected; return _isConnected;
} }
@@ -526,7 +526,7 @@ public class ZeroTierSocket {
* Return whether the input-aspect of the ZeroTierSocket has been disabled. * Return whether the input-aspect of the ZeroTierSocket has been disabled.
* @return true or false * @return true or false
*/ */
public boolean inputStreamHasBeenShutdown() public boolean inputStreamHasBeenShutdown()
{ {
return _inputHasBeenShutdown; return _inputHasBeenShutdown;
} }
@@ -535,7 +535,7 @@ public class ZeroTierSocket {
* Return whether the output-aspect of the ZeroTierSocket has been disabled. * Return whether the output-aspect of the ZeroTierSocket has been disabled.
* @return true or false * @return true or false
*/ */
public boolean outputStreamHasBeenShutdown() public boolean outputStreamHasBeenShutdown()
{ {
return _outputHasBeenShutdown; return _outputHasBeenShutdown;
} }

View File

@@ -149,7 +149,7 @@ happening sooner than they should.
#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL #define TCP_FAST_INTERVAL TCP_TMR_INTERVAL
#endif /* TCP_FAST_INTERVAL */ #endif /* TCP_FAST_INTERVAL */
#ifndef TCP_SLOW_INTERVALs #ifndef TCP_SLOW_INTERVAL
/* the coarse grained timeout in milliseconds */ /* the coarse grained timeout in milliseconds */
#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) #define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL)
#endif /* TCP_SLOW_INTERVAL */ #endif /* TCP_SLOW_INTERVAL */