Skip to content

Commit

Permalink
Update NAT types and fix segmentation fault (tindy2013#95)
Browse files Browse the repository at this point in the history
* Update ntt.cpp

* Update renderer.cpp

* Fix segmentation fault
  • Loading branch information
Connection Refused authored Sep 11, 2020
1 parent 36c070b commit cb0e8f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ntt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum NAT_TYPE
SYMMETRIC_NAT
};

const char *NAT_TYPE_STR[] = {"Unknown", "Blocked", "Full-cone NAT", "Restricted-cone NAT", "Restricted-port NAT", "Symmetric NAT"};
const char *NAT_TYPE_STR[] = {"Unknown", "Blocked", "FullCone", "RestrictedCone", "PortRestrictedCone", "Symmetric"};

struct STUN_RESPONSE
{
Expand Down
16 changes: 8 additions & 8 deletions src/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ void rendererInit(const std::string &font, int fontsize)
widDot = getWidth(&png, font, fontsize, ".");
widUnkn = getWidth(&png, font, fontsize, "Unknown");
widBlock = getWidth(&png, font, fontsize, "Blocked");
widFullCone = getWidth(&png, font, fontsize, "Full-cone NAT");
widRestCone = getWidth(&png, font, fontsize, "Restricted-cone NAT");
widPortRest = getWidth(&png, font, fontsize, "Restricted-port NAT");
widSym = getWidth(&png, font, fontsize, "Symmetric NAT");
widFullCone = getWidth(&png, font, fontsize, "FullCone");
widRestCone = getWidth(&png, font, fontsize, "RestrictedCone");
widPortRest = getWidth(&png, font, fontsize, "PortRestrictedCone");
widSym = getWidth(&png, font, fontsize, "Symmetric");
writeLog(LOG_TYPE_RENDER, "Calculated basic string widths: Number=" + std::to_string(widNumber) + " N/A=" + std::to_string(widNA) + " KB=" + std::to_string(widKB) \
+ " MB=" + std::to_string(widMB) + " GB=" + std::to_string(widGB) + " Percent=" + std::to_string(widPercent) + " Dot=" + std::to_string(widDot));
}
Expand All @@ -123,13 +123,13 @@ static inline int getTextWidth(pngwriter *png, const std::string &font, int font
return widBlock;
case "Unknown"_hash:
return widUnkn;
case "Full-cone NAT"_hash:
case "FullCone"_hash:
return widFullCone;
case "Restricted-cone NAT"_hash:
case "RestrictedCone"_hash:
return widRestCone;
case "Restricted-port NAT"_hash:
case "PortRestrictedCone"_hash:
return widPortRest;
case "Symmetric NAT"_hash:
case "Symmetric"_hash:
return widSym;
}

Expand Down
3 changes: 1 addition & 2 deletions src/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,10 @@ std::string hostnameToIPAddr(std::string host)
//new function
int retVal;
std::string retstr;
struct addrinfo hint = {}, *retAddrInfo, *cur;
struct addrinfo hint = {}, *retAddrInfo = NULL, *cur;
retVal = getaddrinfo(host.data(), NULL, &hint, &retAddrInfo);
if(retVal != 0)
{
freeaddrinfo(retAddrInfo);
return std::string();
}

Expand Down

0 comments on commit cb0e8f3

Please sign in to comment.