Remove networking functions that can be found elsewhere
This commit is contained in:
@@ -215,11 +215,11 @@ int main(int argc, char **argv)
|
||||
int ztServicePort = atoi(argv[5]); // Port ZT uses to send encrypted UDP packets to peers (try something like 9994)
|
||||
|
||||
struct zts_sockaddr_in in4;
|
||||
in4.sin_port = zts_htons(remotePort);
|
||||
in4.sin_port = htons(remotePort);
|
||||
#if defined(_WIN32)
|
||||
in4.sin_addr.S_addr = zts_inet_addr(remoteAddr.c_str());
|
||||
zts_inet_pton(ZTS_AF_INET, remoteAddr.c_str(), &(in4.sin_addr.S_addr));
|
||||
#else
|
||||
in4.sin_addr.s_addr = zts_inet_addr(remoteAddr.c_str());
|
||||
zts_inet_pton(ZTS_AF_INET, remoteAddr.c_str(), &(in4.sin_addr.s_addr));
|
||||
#endif
|
||||
in4.sin_family = ZTS_AF_INET;
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ void printPeerDetails(const char *msgStr, struct zts_peer_details *d)
|
||||
if (sa->sa_family == ZTS_AF_INET) {
|
||||
struct zts_sockaddr_in *in4 = (struct zts_sockaddr_in*)sa;
|
||||
zts_inet_ntop(ZTS_AF_INET, &(in4->sin_addr), ipstr, ZTS_INET_ADDRSTRLEN);
|
||||
port = zts_ntohs(in4->sin_port);
|
||||
port = ntohs(in4->sin_port);
|
||||
}
|
||||
if (sa->sa_family == ZTS_AF_INET6) {
|
||||
struct zts_sockaddr_in6 *in6 = (struct zts_sockaddr_in6*)sa;
|
||||
|
||||
@@ -218,11 +218,11 @@ int main(int argc, char **argv)
|
||||
int ztServicePort = atoi(argv[5]); // Port ZT uses to send encrypted UDP packets to peers (try something like 9994)
|
||||
|
||||
struct zts_sockaddr_in in4;
|
||||
in4.sin_port = zts_htons(remotePort);
|
||||
in4.sin_port = htons(remotePort);
|
||||
#if defined(_WIN32)
|
||||
in4.sin_addr.S_addr = zts_inet_addr(remoteAddr.c_str());
|
||||
zts_inet_pton(ZTS_AF_INET, remoteAddr.c_str(), &(in4.sin_addr.S_addr));
|
||||
#else
|
||||
in4.sin_addr.s_addr = zts_inet_addr(remoteAddr.c_str());
|
||||
zts_inet_pton(ZTS_AF_INET, remoteAddr.c_str(), &(in4.sin_addr.s_addr));
|
||||
#endif
|
||||
in4.sin_family = ZTS_AF_INET;
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ int main(int argc, char **argv)
|
||||
int ztServicePort = atoi(argv[4]); // Port ZT uses to send encrypted UDP packets to peers (try something like 9994)
|
||||
|
||||
struct zts_sockaddr_in in4, acc_in4;
|
||||
in4.sin_port = zts_htons(serverBindPort);
|
||||
in4.sin_port = htons(serverBindPort);
|
||||
#if defined(_WIN32)
|
||||
in4.sin_addr.S_addr = ZTS_INADDR_ANY;
|
||||
#else
|
||||
@@ -281,7 +281,7 @@ int main(int argc, char **argv)
|
||||
char ipstr[ZTS_INET_ADDRSTRLEN];
|
||||
memset(ipstr, 0, sizeof(ipstr));
|
||||
zts_inet_ntop(ZTS_AF_INET, &(acc_in4.sin_addr), ipstr, ZTS_INET_ADDRSTRLEN);
|
||||
printf("Accepted connection from %s:%d\n", ipstr, zts_ntohs(acc_in4.sin_port));
|
||||
printf("Accepted connection from %s:%d\n", ipstr, ntohs(acc_in4.sin_port));
|
||||
|
||||
int bytes=0;
|
||||
char recvBuf[128];
|
||||
|
||||
@@ -214,7 +214,7 @@ int main(int argc, char **argv)
|
||||
int ztServicePort = atoi(argv[4]); // Port ZT uses to send encrypted UDP packets to peers (try something like 9994)
|
||||
|
||||
struct zts_sockaddr_in in4, acc_in4;
|
||||
in4.sin_port = zts_htons(serverBindPort);
|
||||
in4.sin_port = htons(serverBindPort);
|
||||
#if defined(_WIN32)
|
||||
in4.sin_addr.S_addr = ZTS_INADDR_ANY;
|
||||
#else
|
||||
@@ -284,7 +284,7 @@ int main(int argc, char **argv)
|
||||
char ipstr[ZTS_INET_ADDRSTRLEN];
|
||||
memset(ipstr, 0, sizeof(ipstr));
|
||||
zts_inet_ntop(ZTS_AF_INET, &(acc_in4.sin_addr), ipstr, ZTS_INET_ADDRSTRLEN);
|
||||
printf("Accepted connection from %s:%d\n", ipstr, zts_ntohs(acc_in4.sin_port));
|
||||
printf("Accepted connection from %s:%d\n", ipstr, ntohs(acc_in4.sin_port));
|
||||
|
||||
printf("Reading message string from client...\n");
|
||||
if((bytes = zts_read(accfd, recvBuf, sizeof(recvBuf))) < 0) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "ZeroTierSockets.h"
|
||||
#include "nbind/api.h"
|
||||
@@ -130,11 +131,11 @@ void on_zts_event(void *msgPtr)
|
||||
zts_sockaddr_in sockaddr_in(const char *remoteAddr, const int remotePort)
|
||||
{
|
||||
struct zts_sockaddr_in in4;
|
||||
in4.sin_port = zts_htons(remotePort);
|
||||
in4.sin_port = htons(remotePort);
|
||||
#if defined(_WIN32)
|
||||
in4.sin_addr.S_addr = zts_inet_addr(remoteAddr);
|
||||
zts_inet_pton(ZTS_AF_INET, remoteAddr.c_str(), &(in4.sin_addr.S_addr));
|
||||
#else
|
||||
in4.sin_addr.s_addr = zts_inet_addr(remoteAddr);
|
||||
zts_inet_pton(ZTS_AF_INET, remoteAddr.c_str(), &(in4.sin_addr.s_addr));
|
||||
#endif
|
||||
in4.sin_family = ZTS_AF_INET;
|
||||
return in4;
|
||||
|
||||
Reference in New Issue
Block a user