> For the complete documentation index, see [llms.txt](https://tariksavas.gitbook.io/tarnet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tariksavas.gitbook.io/tarnet/docs/how-to-use/configurations/clientvalidationconfig.md).

# 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.

<figure><img src="/files/95QSlyyhF6ckbklxgmOK" alt=""><figcaption></figcaption></figure>

2. **Through Code**

```csharp
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:

```csharp
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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tariksavas.gitbook.io/tarnet/docs/how-to-use/configurations/clientvalidationconfig.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
