2 Star 4 Fork 4

精易科技/eapi

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
eapi_46_GetRemoteName.cpp 866 Bytes
一键复制 编辑 原始数据 按行查看 历史
AlongsCode 提交于 2023-02-09 00:42 +08:00 . 部分重构
#include<string>
#include <ws2tcpip.h>
inline std::string GetRemoteHostname(const char* ip)
{
struct addrinfo hints, * result;
char hostname[NI_MAXHOST]{ 0 };
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if (getaddrinfo(ip, NULL, &hints, &result) == 0)
{
if (getnameinfo(result->ai_addr, result->ai_addrlen, hostname, sizeof hostname, NULL, 0, 0) == 0)
{
freeaddrinfo(result);
return hostname;
}
freeaddrinfo(result);
}
return {};
}
#include "..\include_eapi_header.h"
// 调用格式: SDT_TEXT 取远程机器名, 命令说明: "根据指定的IP地址取远程机器名称。失败返回空"
// 参数<1>: IP地址 SDT_TEXT, 参数说明: NULL
EAPI_EXTERN_C void eapi_GetRemoteName_46_eapi(PMDATA_INF pRetData, INT nArgCount, PMDATA_INF pArgInf)
{
pRetData->m_pText = CloneTextData(GetRemoteHostname(pArgInf->m_pText).c_str());
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/JYtechnology/eapi.git
git@gitee.com:JYtechnology/eapi.git
JYtechnology
eapi
eapi
master

搜索帮助