# Code Stripping (Pro Feature)

## Why use code stripping?

It helps secure your game server by removing sensitive logic that players shouldn’t see. This makes it harder for cheaters to figure out how the server works and keeps sensitive server data hidden.

## What gets stripped

FishNet Pro can remove server code from [non-server builds](#user-content-fn-1)[^1] and client code from [server builds](#user-content-fn-1)[^1]. The code it strips is code within [RPCs](/docs/guides/features/network-communication/remote-procedure-calls.md), code marked with the [Server or Client attributes](/docs/guides/features/server-and-client-identification/executing-on-server-or-client.md#method-attributes), as well as server and client only callbacks such as [OnStartServer/OnStartClient](/docs/guides/features/networked-gameobjects-and-scripts/network-behaviour-guides.md#callbacks).

## How to use it

1. To use FishNet's code stripping you will firstly need to have **FishNet Pro** installed, you can find details for how to install it here: [Upgrading to FishNet Pro](/docs/guides/updating-fishnet/upgrading-to-fishnet-pro.md)
2. Next, you can navigate to the **FishNet Configuration menu** through the Unity toolbar:

   <div align="center" data-with-frame="true"><figure><img src="/files/BVXhh2FR4DTRipFoIvwb" alt=""><figcaption><p><strong>(Tools → Fish-Networking → Configuration)</strong></p></figcaption></figure></div>
3. On the Configuration page you will see the option to **"Strip Release Builds"**, enable it.

   <div data-with-frame="true"><figure><img src="/files/hUesQ3JLD6BdWFrUimNy" alt=""><figcaption></figcaption></figure></div>
4. There is now the **"Stripping Type"** option that you can switch between **Redirect** and **Empty\_Experimental**. **Redirect** will replace the methods and calls with a dummy method that doesn't contain any of the logic, while **Empty\_Experimental** will keep the same method, but will strip its method body, leaving it empty. You can use either option you want to.
5. Now you will need your game to recompile its scripts, you can trigger this by changing something in your code. If your code is in a separate assembly, be sure to trigger that assembly to recompile as well. This is only needed after you change the FishNet stripping settings.
6. That's all you need to do, you can now build your game, and FishNet will automatically strip the code for you.

## Confirming it worked

It's always a good idea to check if the sensitive code was indeed stripped from the builds. For Unity Mono builds you can easily do so using a tool such as [ILSpy](https://github.com/icsharpcode/ILSpy).

You can download the above-mentioned tool or another of your choosing. Then you'll want to run it and load the chosen assembly in your built game's files. If you find your script, you should see how FishNet stripped its code according to the build.

In the picture below you can see how the `ClientMethod` has had its method body emptied in this server build.

<figure><img src="/files/P4XNJKb1xOvkymW6pSBQ" alt=""><figcaption></figcaption></figure>

[^1]: Server builds are considered builds made using Unity's "Dedicated server build profile" or its "headless mode" option in older Unity versions.\
    Any other builds are considered non-server builds.


---

# Agent Instructions: 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:

```
GET https://fish-networking.gitbook.io/docs/guides/features/code-stripping.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
