# Server Configuration

**File Location:** `~/automodpack/automodpack-server.json`

This configuration file controls the behavior of the AutoModpack server-side component. It handles how files are synced to clients, how the hosting server binds to ports, and security validation.

## General Settings

| Setting                       | Default         | Description                                                                                                                             |
|-------------------------------|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `DO_NOT_CHANGE_IT`            | `<version>`     | Internal Use Only. Used to auto-migrate config versions during updates. Do not modify this manually.                                    |
| `modpackName`                 | `""`            | The display name of the modpack shown during download. This also determines the folder name inside `~/automodpack/modpacks/` on client. |
| `modpackHost`                 | `true`          | Enables or disables the internal host server that serves the modpack.                                                                   |
| `generateModpackOnStart`      | `true`          | Automatically scans files and regenerates modpack metadata every time the server starts.                                                |
| `autoExcludeServerSideMods`   | `true`          | Automatically excludes mods marked as "Server Side Only" in their metadata.                                                             |
| `autoExcludeUnnecessaryFiles` | `true`          | Automatically skips syncing files that are empty, hidden, temporary, disabled, or backup files.                                         |
| `requireAutoModpackOnClient`  | `true`          | If true, players are kicked if they do not have AutoModpack installed.                                                                  |
| `acceptedLoaders`             | `["<current>"]` | A list of modloaders allowed to connect (e.g., Fabric, Forge). Use with caution; most mods are loader-specific.                         |
| `selfUpdater`                 | `false`         | Enables AutoModpack to update its own jar file automatically when new version is published on modrinth.                                 |

## File Synchronization

These settings control which files are sent to the client and which files the client is allowed to customize.

| Setting                            | Default                                                                    | Description                                                                                                                                                                                       |
|------------------------------------|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `syncedFiles`                      | `["/mods/*.jar", "/kubejs/**", "!/kubejs/server_scripts/**", "/emotes/*"]` | List of relative paths to sync to the client. Supports wildcards.                                                                                                                                 |
| `allowEditsInFiles`                | `["/options.txt", "/config/**"]`                                           | Files clients download once but can edit locally. Updates to these files on the server are ignored by the client. Supports wildcards.                                                             |
| `forceCopyFilesToStandardLocation` | `[]`                                                                       | Forces specific files to copy to the standard Minecraft folder instead of the AutoModpack instance folder. Supports wildcards. Avoid using this option when possible, it breaks seamless updates. |
| `nonModpackFilesToDelete`          | `[]`                                                                       | List of files to request deletion from the client (e.g., old mods). See Deleting Files below.                                                                                                     |

## Globbing wildcards

For `syncedFiles`, `allowEditsInFiles` and `forceCopyFilesToStandardLocation`, use the following patterns relative to the server root:

- `*` : Matches files in a single directory (e.g., `/mods/*.jar`).
- `**` : Matches files recursively in all subdirectories (e.g., `/kubejs/**`).
- `!` : Prefix to exclude a file/folder (e.g., `!/kubejs/server_scripts/**`).

Read more about globbing on the [Globbing Wikipedia article](https://wikipedia.org/wiki/Glob_(programming)#Syntax).

## Deleting Files (nonModpackFilesToDelete)

If you simply want to remove a file from your modpack, **don't use** this option, instead just delete the file from your server.

This feature allows you to remove specific files from a client's machine which are not part of the modpack being synced. This is useful for cleaning up old mods or files that may conflict with the current modpack.

**Note:** This feature is stricter for security reasons. It requires exact file hashes and does not support wildcards.

### How to Configure

This setting accepts a list of objects containing a path and a SHA1 hash.

- **Exact Match:** The client checks if the file exists at the path and matches the hash. If yes, it is deleted.
- **Parent Scan:** If the file isn't found at the exact path or only a parent directory is provided, the client scans the directory for any file matching the hash and deletes it.

### Example


<CodeTabs>

```json !!tabs
"nonModpackFilesToDelete": {
  "/mods/lithium-fabric-0.15.1+mc1.21.1.jar": "6038cf136da413753345bf9d48e5798241439894",
  "/mods/": "97452cfadfde1f8f8c67838643019eabafa58fbb"
},
```

</CodeTabs>

<details>
<summary>How to get the SHA1 Hash</summary>

You must provide the hash for the specific version of the file you want to delete.

### Option 1: Linux Command Line


<CodeTabs>

```bash !!tabs
sha1sum path/to/file
```

</CodeTabs>

### Option 2: Online Tools

You can use a browser-based calculator like [SHA1 File Checksum](https://emn178.github.io/online-tools/sha1_checksum.html).
</details>

## Network & Hosting

These settings control how the file server is exposed to the internet.

| Setting                 | Default | Description                                                                                            |
|-------------------------|---------|--------------------------------------------------------------------------------------------------------|
| `bindAddress`           | `""`    | The local IP to bind the host to. Empty binds to 0.0.0.0 or ::0. Ignored if bindPort is -1.            |
| `bindPort`              | `-1`    | The TCP port to listen on. -1 uses the Minecraft Server's port (recommended).                          |
| `addressToSend`         | `""`    | The public IP/Domain sent to clients to start the download. Empty defaults to the connection address.  |
| `portToSend`            | `-1`    | The public TCP port sent to clients. -1 uses the connection port.                                      |
| `bandwidthLimit`        | `0`     | Upload speed limit in Mbps (0 = unlimited).                                                            |
| `disableInternalTLS`    | `false` | Disables internal TLS. Use this only if you handle SSL via a Reverse Proxy (like Nginx - recommended). |
| `requireMagicPackets`   | `false` | Requires a "Magic Packet" handshake to start downloads. Always enabled if bindPort is -1.              |
| `updateIpsOnEveryStart` | `false` | Updates addressToSend on startup. Useful for dynamic residential IPs.                                  |
| `validateSecrets`       | `true`  | Protects downloads using unique, temporary secrets per user.                                           |
| `secretLifetime`        | `336`   | How long (in hours) a download secret remains valid.                                                   |

## Nagging Un-modded Clients

If `requireAutoModpackOnClient` is set to `false`, you can annoy (nag) players who join without the mod installed.

| Setting               | Default            | Description                                     |
|-----------------------|--------------------|-------------------------------------------------|
| `nagUnModdedClients`  | `true`             | Enables the chat message for un-modded clients. |
| `nagMessage`          | `"This server..."` | The main text of the warning message.           |
| `nagClickableMessage` | `"Click here..."`  | The text that can be clicked.                   |
| `nagClickableLink`    | URL                | The URL opened when clicking the message.       |
