net.DebugAppendResolverAddress

net.DebugAppendResolverAddress

#Overview

name: net.DebugAppendResolverAddress

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of net.DebugAppendResolverAddress is to provide a debugging tool for IP address resolution in networked Unreal Engine applications. It allows developers to inject a specific IP address into the list of resolved addresses for testing purposes.

This setting variable is primarily used by the Online Subsystem Utils plugin, specifically within the network address resolution system. It’s part of the networking infrastructure of Unreal Engine.

The value of this variable is set through the console or configuration files. It’s implemented as a console variable (CVar) using the TAutoConsoleVariable class.

The associated variable CVarNetDebugAddResolverAddress directly interacts with net.DebugAppendResolverAddress. They essentially represent the same setting, with CVarNetDebugAddResolverAddress being the C++ implementation of the console variable.

Developers must be aware of several important points when using this variable:

  1. It’s only available in non-shipping builds (#if !UE_BUILD_SHIPPING).
  2. It’s marked with ECVF_Cheat flag, indicating it’s for debugging/cheating purposes and should not be used in production.
  3. When set, it affects all IP address resolution methods in the engine.

Best practices for using this variable include:

  1. Only use it for debugging and testing purposes.
  2. Be cautious when using it in multiplayer scenarios, as it could affect network behavior.
  3. Always clear the value when not actively debugging to avoid unintended effects.
  4. Use it in conjunction with other networking debug tools for comprehensive testing.

Regarding the associated variable CVarNetDebugAddResolverAddress:

The purpose of CVarNetDebugAddResolverAddress is to implement the console variable net.DebugAppendResolverAddress in C++ code.

It’s used within the Online Subsystem Utils plugin, specifically in the network address resolution system.

The value is set through the console or configuration files, and it’s retrieved in the code using the GetValueOnAnyThread() method.

It directly interacts with net.DebugAppendResolverAddress, as they represent the same setting.

Developers should be aware that this variable is used to inject an additional IP address into the resolution results for debugging purposes.

Best practices include using it carefully in controlled testing environments and ensuring it’s not accidentally left set in builds that might be distributed or used for regular testing.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/NetAddressResolution.cpp:14

Scope: file

Source code excerpt:

#if !UE_BUILD_SHIPPING
TAutoConsoleVariable<FString> CVarNetDebugAddResolverAddress(
	TEXT("net.DebugAppendResolverAddress"),
	TEXT(""),
	TEXT("If this is set, all IP address resolution methods will add the value of this CVAR to the list of results.")
		TEXT("This allows for testing resolution functionality across all multiple addresses with the end goal of having a successful result")
		TEXT("(being the value of this CVAR)"),
	ECVF_Default | ECVF_Cheat);
#endif

#Associated Variable and Callsites

This variable is associated with another variable named CVarNetDebugAddResolverAddress. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/NetAddressResolution.cpp:13

Scope: file

Source code excerpt:

// CVars
#if !UE_BUILD_SHIPPING
TAutoConsoleVariable<FString> CVarNetDebugAddResolverAddress(
	TEXT("net.DebugAppendResolverAddress"),
	TEXT(""),
	TEXT("If this is set, all IP address resolution methods will add the value of this CVAR to the list of results.")
		TEXT("This allows for testing resolution functionality across all multiple addresses with the end goal of having a successful result")
		TEXT("(being the value of this CVAR)"),
	ECVF_Default | ECVF_Cheat);

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/NetAddressResolution.cpp:121

Scope (from outer to inner):

file
namespace    UE::Net::Private
function     void FNetDriverAddressResolution::InitConnect
lambda-function

Source code excerpt:

#if !UE_BUILD_SHIPPING
				// This is useful for injecting a good result into the array to test the resolution system
				const FString DebugAddressAddition = CVarNetDebugAddResolverAddress.GetValueOnAnyThread();
				if (!DebugAddressAddition.IsEmpty())
				{
					TSharedPtr<FInternetAddr> SpecialResultAddr = SocketSubsystem->GetAddressFromString(DebugAddressAddition);
					if (SpecialResultAddr.IsValid())
					{
						SpecialResultAddr->SetPort(DestinationPort);