Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Commit

Permalink
替换已弃用的WINAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Srar committed Jul 18, 2019
1 parent eff306e commit 9bbc8a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-sstap",
"version": "1.34",
"version": "1.34.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
20 changes: 11 additions & 9 deletions src/native/ipforward_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ NAN_METHOD(N_GetIpforwardEntry)

/* Convert IPv4 addresses to strings */
IpAddr.S_un.S_addr = (u_long)pIpForwardTable->table[i].dwForwardDest;
strcpy_s(szDestIp, sizeof(szDestIp), inet_ntoa(IpAddr));
inet_ntop(AF_INET, &(IpAddr), szDestIp, sizeof(szDestIp));

IpAddr.S_un.S_addr = (u_long)pIpForwardTable->table[i].dwForwardMask;
strcpy_s(szMaskIp, sizeof(szMaskIp), inet_ntoa(IpAddr));
inet_ntop(AF_INET, &(IpAddr), szMaskIp, sizeof(szMaskIp));

IpAddr.S_un.S_addr = (u_long)pIpForwardTable->table[i].dwForwardNextHop;
strcpy_s(szGatewayIp, sizeof(szGatewayIp), inet_ntoa(IpAddr));
inet_ntop(AF_INET, &(IpAddr), szGatewayIp, sizeof(szGatewayIp));

Nan::Set(obj, Nan::New("destIp").ToLocalChecked(), Nan::New(szDestIp).ToLocalChecked());
Nan::Set(obj, Nan::New("netMask").ToLocalChecked(), Nan::New(szMaskIp).ToLocalChecked());
Expand Down Expand Up @@ -104,7 +106,7 @@ NAN_METHOD(N_CreateIpforwardEntry)
if (obj->Get(Nan::New<v8::String>("dwForwardDest").ToLocalChecked())->IsString())
{
std::string dwForwardDest = *v8::String::Utf8Value(obj->Get(Nan::New<v8::String>("dwForwardDest").ToLocalChecked())->ToString());
ifr.dwForwardDest = inet_addr(dwForwardDest.c_str());
inet_pton(AF_INET, dwForwardDest.c_str(), &(ifr.dwForwardDest));
}
}

Expand All @@ -115,7 +117,7 @@ NAN_METHOD(N_CreateIpforwardEntry)
if (obj->Get(Nan::New<v8::String>("dwForwardMask").ToLocalChecked())->IsString())
{
std::string dwForwardMask = *v8::String::Utf8Value(obj->Get(Nan::New<v8::String>("dwForwardMask").ToLocalChecked())->ToString());
ifr.dwForwardMask = inet_addr(dwForwardMask.c_str());
inet_pton(AF_INET, dwForwardMask.c_str(), &(ifr.dwForwardMask));
}
}

Expand All @@ -129,7 +131,7 @@ NAN_METHOD(N_CreateIpforwardEntry)
if (obj->Get(Nan::New<v8::String>("dwForwardNextHop").ToLocalChecked())->IsString())
{
std::string dwForwardNextHop = *v8::String::Utf8Value(obj->Get(Nan::New<v8::String>("dwForwardNextHop").ToLocalChecked())->ToString());
ifr.dwForwardNextHop = inet_addr(dwForwardNextHop.c_str());
inet_pton(AF_INET, dwForwardNextHop.c_str(), &(ifr.dwForwardNextHop));
}
}

Expand Down Expand Up @@ -198,7 +200,7 @@ NAN_METHOD(N_DeleteIpforwardEntry)
if (obj->Get(Nan::New<v8::String>("dwForwardDest").ToLocalChecked())->IsString())
{
std::string dwForwardDest = *v8::String::Utf8Value(obj->Get(Nan::New<v8::String>("dwForwardDest").ToLocalChecked())->ToString());
ifr.dwForwardDest = inet_addr(dwForwardDest.c_str());
inet_pton(AF_INET, dwForwardDest.c_str(), &(ifr.dwForwardDest));
}
}

Expand All @@ -209,7 +211,7 @@ NAN_METHOD(N_DeleteIpforwardEntry)
if (obj->Get(Nan::New<v8::String>("dwForwardMask").ToLocalChecked())->IsString())
{
std::string dwForwardMask = *v8::String::Utf8Value(obj->Get(Nan::New<v8::String>("dwForwardMask").ToLocalChecked())->ToString());
ifr.dwForwardMask = inet_addr(dwForwardMask.c_str());
inet_pton(AF_INET, dwForwardMask.c_str(), &(ifr.dwForwardMask));
}
}

Expand All @@ -223,7 +225,7 @@ NAN_METHOD(N_DeleteIpforwardEntry)
if (obj->Get(Nan::New<v8::String>("dwForwardNextHop").ToLocalChecked())->IsString())
{
std::string dwForwardNextHop = *v8::String::Utf8Value(obj->Get(Nan::New<v8::String>("dwForwardNextHop").ToLocalChecked())->ToString());
ifr.dwForwardNextHop = inet_addr(dwForwardNextHop.c_str());
inet_pton(AF_INET, dwForwardNextHop.c_str(), &(ifr.dwForwardNextHop));
}
}

Expand Down

0 comments on commit 9bbc8a6

Please sign in to comment.