ClientValidationConfig

ClientValidationConfig contains configuration options used to ensure security between the client and server in Tarnet. These configurations allow only specific clients to connect and provide IP validation mechanisms to block potential malicious connections.


Properties

  • authKey

    • Type: string

    • Description: The key used for authentication between the server and the client.

    • What does it do? authKey is used to secure communication between the server and the client. This key ensures that only authorized clients can connect, increasing security.

    • How does it work? The client attempting to connect must provide the correct authKey. If the key matches, the server accepts the connection. Otherwise, the connection is rejected.

    • Default Value: string.Empty (empty string)

  • ipWhiteList

    • Type: string[]

    • Description: A list of IP addresses that are allowed to connect.

    • What does it do? ipWhiteList allows only specified IP addresses to establish a connection. This ensures that only authorized clients can connect to the server.

    • How does it work?

      • If ipWhiteList is empty, all IP addresses except those in ipBlackList are allowed to connect.

      • If ipWhiteList contains IP addresses, only those IP addresses are allowed to connect.

    • Default Value: Array.Empty<string>() (empty array)

  • ipBlackList

    • Type: string[]

    • Description: A list of IP addresses that are denied access.

    • What does it do? ipBlackList provides protection against malicious connections by blocking IP addresses listed here.

    • How does it work? The server checks the IP address of incoming connection requests and denies any requests coming from IPs in the ipBlackList.

    • Default Value: Array.Empty<string>() (empty array)


How to Create ClientValidationConfig

  1. Through the Unity Editor

    Navigate to Assets > Create > Tarnet > ClientValidationConfig to create a new ClientValidationConfig instance.

  1. Through Code

ClientValidationConfig config = 
    ScriptableObject.CreateInstance<ClientValidationConfig>();

clientValidationConfig.authKey = "your-auth-key";
clientValidationConfig.ipWhiteList = new string[] { "192.168.1.1" };
clientValidationConfig.ipBlackList = new string[] { "192.168.1.3" };

Usages:

ClientValidationConfig is set via the SocketBuilder class. Here's an example of how to use this configuration:

socketBuilder.SetClientValidationConfig(clientValidationConfig);

These configurations are crucial for ensuring communication security in Tarnet. If ipWhiteList is empty, all networks except those in the ipBlackList are allowed to connect. If ipWhiteList contains IP addresses, only those networks are allowed to connect. This makes network security flexible and manageable dynamically.

Last updated