-
-
Notifications
You must be signed in to change notification settings - Fork 46
[How To] Connect to an Open Tibia Server
While TibiaAPI is configured, by default, to connect to official Tibia servers, you can easily configure it to connect to an Open-Tibia server.
TibiaAPI only supports the login protocol that came with the official Tibia 11 client. Therefore, it does not currently support Open-Tibia servers that use the Open-Tibia Client (OTC), or any other unofficial client.
First, you need to locate the client executable and modify the loginWebService
to connect to your localhost (127.0.0.1). The best way to do this is to use a hex-editor (I recommend xvi32 on Windows and Hex Fiend on macOS) because you will need to make a note of the server's loginWebService
. Open the client executable in your hex-editor and search for loginWebService=
, then note the web address on the right-hand side of the =
sign. Next, overwrite their web address with your localhost and port of your choosing (e.g., http://127.0.0.1:7171/); by default, TibiaAPI listens on port 7171, but can be easily configured to listen on a different port. Overwrite the remaining bytes before the next string in the client (at the time of writing this it is clientWebService
) with 0x0A
(on Windows you may have to put 0x0D
after your address before filling the rest with 0x0A
).
Note that TibiaAPI currently only supports the official public RSA key and the, widely-used, Open-Tibia public RSA key for encrypting the login packet. If the Open-Tibia server you want to connect to uses a custom public RSA key, TibiaAPI will not work with it (unless you modify the source code directly). However, a fix will be implemented in the future to accept custom public RSA keys through the API itself.
The entry-point of TibiaAPI is the Client
class. This class is responsible for loading the .dat file, extracting the client version, and starting the proxy (among other things). By default, the Client
constructor loads the .dat file and pulls the client version (from package.json) using the default installation path. However, the constructor has an optional parameter that allows you to override this path; this is useful if you've installed the official client in another location, or, for our purposes, when you want to connect to an Open-Tibia server. On Linux, macOS, and Windows, this path is where package.json resides (e.g., C:\Users\jo3bingham\AppData\Local\Tibia\packages\Tibia).
For example, if the package.json file of the Open-Tibia server I wanted to connect to was located at C:\Open-Tibia Server\package.json
, my constructor would look like this:
using var client = new OXGaming.TibiaAPI.Client("C:\Open-Tibia Server\");
This line will pull the client version from package.json, and load the .dat file in the assets directory.
Next, you will need to start the proxy from your Client
object. By default, the proxy listens for login connections on port 7171, and connects to the official login service. However, you can easily override both of these when starting the proxy. The StartConnection()
function has two, optional parameters: port
and loginWebService
. port
needs to match the port you chose when overwriting the loginWebService
in the client executable (in our example above, we used 7171), and loginWebService
needs to be the one you noted down during the same process.
Here's an example where the loginWebService
an Open-Tibia server uses is hxxps://www.some-ot-site.com/login.php
, and I overwrote it with http://127.0.0.1:1234/.
client.StartConnection(1234, "hxxps://www.some-ot-site.com/login.php");
This line will start the proxy and listen for login attempts on port 1234 from your localhost, then forward those to the specified web address.
Now that you have a running proxy, all you need to do is run your modified client executable and log in like normal. The proxy will handle connecting to the login server of the Open-Tibia server and forwarding any data sent between them; login data, character list, etc. It will also handle connecting to the game server when you select a character.
- Some Open-Tibia servers don't include the package.json file with their client package. No worries, you can just create your own (it has to be put in the proper directory, though) and you only need to include the
version
in it. For example:
{
"version": "12.34.5678"
}
- The version specified in the package.json file must match the version of the client, not the version of the server. For example, some servers claim to use a 12.40 client, but it's actually a 12.00 client. You can easily verify the client version by running the client executable, going to settings/options, selecting Help/Misc->Help, and clicking the Info button. It is very important that the
version
in package.json matches that of the client executable because the proxy uses it to determine the correct protocol to use when parsing packets. - If you find an Open-Tibia server using an official 11.80+ client that the API does not work with, create an issue and I can look into it.