Skip to content

Commit

Permalink
Merge pull request #218 from zerotier/brenton/fix-typos
Browse files Browse the repository at this point in the history
Brenton/fix typos
  • Loading branch information
joseph-henry authored May 26, 2023
2 parents bb578e9 + 8bd9a18 commit 7d82d0e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion include/ZeroTierSockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 10 additions & 10 deletions src/Central.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down
26 changes: 13 additions & 13 deletions src/bindings/java/com/zerotier/sockets/ZeroTierInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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];
}
Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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];
Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions src/bindings/java/com/zerotier/sockets/ZeroTierSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 7d82d0e

Please sign in to comment.