mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2026-01-06 16:53:59 +00:00
UserSession: updated code to convert ipv6 mapped ipv4 address.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Technitium DNS Server
|
||||
Copyright (C) 2022 Shreyas Zare (shreyas@technitium.com)
|
||||
Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -56,6 +56,9 @@ namespace DnsServerCore.Auth
|
||||
if ((tokenName is not null) && (tokenName.Length > 255))
|
||||
throw new ArgumentOutOfRangeException(nameof(tokenName), "Token name length cannot exceed 255 characters.");
|
||||
|
||||
if (remoteAddress.IsIPv4MappedToIPv6)
|
||||
remoteAddress = remoteAddress.MapToIPv4();
|
||||
|
||||
byte[] tokenBytes = new byte[32];
|
||||
_rng.GetBytes(tokenBytes);
|
||||
_token = Convert.ToHexString(tokenBytes).ToLower();
|
||||
@@ -104,6 +107,9 @@ namespace DnsServerCore.Auth
|
||||
|
||||
public void UpdateLastSeen(IPAddress remoteAddress, string lastSeenUserAgent)
|
||||
{
|
||||
if (remoteAddress.IsIPv4MappedToIPv6)
|
||||
remoteAddress = remoteAddress.MapToIPv4();
|
||||
|
||||
_lastSeen = DateTime.UtcNow;
|
||||
_lastSeenRemoteAddress = remoteAddress;
|
||||
_lastSeenUserAgent = lastSeenUserAgent;
|
||||
|
||||
Reference in New Issue
Block a user