From bcba88ca73484a3323a8e57a06bb11a98a40eec9 Mon Sep 17 00:00:00 2001 From: domosekai <54519668+domosekai@users.noreply.github.com> Date: Mon, 5 Jul 2021 12:17:57 +0000 Subject: [PATCH] Cedar/Protocol.c: Use real server IP in creating node info under direct mode --- src/Cedar/Protocol.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Cedar/Protocol.c b/src/Cedar/Protocol.c index cb10825e..9696224a 100644 --- a/src/Cedar/Protocol.c +++ b/src/Cedar/Protocol.c @@ -3826,7 +3826,18 @@ void CreateNodeInfo(NODE_INFO *info, CONNECTION *c) // Server host name StrCpy(info->ServerHostname, sizeof(info->ServerHostname), c->ServerName); // Server IP address - if (GetIP(&ip, info->ServerHostname)) + if (s->ClientOption->ProxyType == PROXY_DIRECT) + { + if (IsIP6(&c->FirstSock->RemoteIP) == false) + { + info->ServerIpAddress = IPToUINT(&c->FirstSock->RemoteIP); + } + else + { + Copy(info->ServerIpAddress6, c->FirstSock->RemoteIP.address, sizeof(info->ServerIpAddress6)); + } + } + else if (GetIP(&ip, info->ServerHostname)) { if (IsIP6(&ip) == false) {