Skip to content

feat: OTCv8 proxy system#978

Merged
mehah merged 5 commits intoopentibiabr:mainfrom
gesior:otcv8-proxy-system
Nov 29, 2024
Merged

feat: OTCv8 proxy system#978
mehah merged 5 commits intoopentibiabr:mainfrom
gesior:otcv8-proxy-system

Conversation

@gesior
Copy link
Contributor

@gesior gesior commented Nov 27, 2024

Description

OTCv8 Proxy System copied from https://github.com/OTCv8/otcv8-dev ( boost::asio replaced with asio )
With client_stats module renamed to client_debug_info - to view active proxy servers and their ping (CTRL+ALT+D to on/off).
OTCv8 Proxy System is pretty complicated, requires mutliple VPSes and a lot of server side setup. It also requires server side app, that was published by OTCv8 author on OTCv8 forum, which is offline (premium version of that app without 200 connections limit costed 1500$).
This feature is mostly for people who already use OTCv8 Proxy System and want to migrate to OTC Redemption.

Type of change

  • [*] New feature (non-breaking change which adds functionality)

How Has This Been Tested

  • compiled on Windows 10
  • compiled on Linux Ubuntu 22.04
  • logged-in 8.6 server without OTCv8 proxy
  • logged-in 8.6 server with OTCv8 proxy

How this works

OTC with Proxy System enabled will connect to multiple haproxy servers - each can be on other VPS behind other anti-DDoS system.
Each second it measures ping to OTS thru each haproxy - it measures real ping to OTS machine, not just ping to VPS hosting haproxy.
If there is any packet to send, OTC sends it thru 2 proxies with lowest ping (duplicates packet).

List of proxy server you must add in init.lua ex.:

g_proxy.addProxy('arm.skalski.pro', 6501, 0)
g_proxy.addProxy('arm.skalski.pro', 6502, 0)
g_proxy.addProxy('arm.skalski.pro', 6503, 0)
g_proxy.addProxy('arm.skalski.pro', 6504, 0)

Then every connection to 127.0.0.1 will be handled by Proxy System and send thru haproxy to OTS server machine.
On machine with OTS you must install "OTCv8 Proxy System server side app" (link on OTCv8 forum is dead, I'm working on re-host).
This server side app will detect duplicated packets and send only first packet that comes with given ID to OTS.
Packets send by OTS will also go thru this app, it will duplicate them and send thru 2 haproxy servers to OTC.
Server side app is compatible with send-proxy-v2 protocol and may send real IP of player to OTS - without that feature all players would have IP 127.0.0.1 on OTS, as connections to OTS come from server side proxy app.

Login screen with login to 127.0.0.1 (it will connect to my OTS arm.skalski.pro) and Debug Info with 4 proxies enabled:

otcv8proxy-login-screen

Game screen with proxy enable, in Debug Info you can see that client send/receive packets thru 2 connections (2 have higher In/Out packets count):

otcv8proxy-in-game-screen

@gesior
Copy link
Contributor Author

gesior commented Nov 27, 2024

@mehah
Do you know why this check failed? https://github.com/mehah/otclient/actions/runs/12054334287/job/33616239268?pr=978
Is it some problem with my code or worker processed code too slow and it was killed, because process ran out of time/memory?

@mehah
Copy link
Collaborator

mehah commented Nov 28, 2024

@gesior
I also don't know what happened, it gave these internal errors:
image

I put it to try again.

@mehah
Copy link
Collaborator

mehah commented Nov 28, 2024

the problem is in some includes, without the unity build it works perfectly, I will try to solve it later, in case you can't.

@poxis
Copy link
Contributor

poxis commented Nov 28, 2024

@gesior
why not publish "OTCv8 Proxy System server side app", it was available for free and especially as you plan to re-host the forum?

Here is also a description of how it works, but unfortunately the zip files are not archived.
http://web.archive.org/web/20201109120714/http://otclient.net/showthread.php?tid=438

@gesior
Copy link
Contributor Author

gesior commented Nov 28, 2024

the problem is in some includes, without the unity build it works perfectly, I will try to solve it later, in case you can't.

Visual Studio build works with unity build.
CMake build on Linux works with unity build.
CMake build on Windows works without unity build.
CMake build on Windows fails with unity build.

@mehah IDK how to fix it, if you have any idea what causes these errors, please fix it.

it was available for free and especially as you plan to re-host the forum?

I planned to re-host that .zip, not forum.

With OTCv8 author permission, I uploaded compiled (for x64, later I will publish ARM64) paid version of OTCv8 proxy server app to my host:
https://downloads-oracle.ots.me/?dir=data/otcv8-proxy-server
proxy_server - app without connections limit (free version had 200 connections limit), but without player IP passing code (all players in game have IP 127.0.0.1).
proxy_server_with_IP - full paid version, including code to pass IP in first packet after connecting to OTS. This version requires some changes in OTS, to read that extra packet.

App accepts 1 argument, it's port on which it listens: ./proxy_server 6501

When I will have some free time I will publish TFS 1.4/1.6 changes to read IP from first packet.

@sonarqubecloud
Copy link

@mehah mehah merged commit 35886cb into opentibiabr:main Nov 29, 2024
@Odisey25
Copy link

here I left the proxy system in otcv8 and it was working 100%.
opentibiabr/otcv8#16

@sundance
Copy link

@gesior I uploaded compiled (for x64, later I will publish ARM64) paid version of OTCv8 proxy server app to my host:
These don't run on Ubuntu24
$./proxy_server
zsh: segmentation fault (core dumped) ./proxy_server
$ gdb proxy_server
proxy_server": not in executable format: file format not recognized
$ file proxy_server
proxy_server: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, missing section headers at 2795672

@gesior
Copy link
Contributor Author

gesior commented Dec 1, 2024

@gesior I uploaded compiled (for x64, later I will publish ARM64) paid version of OTCv8 proxy server app to my host: These don't run on Ubuntu24 $./proxy_server zsh: segmentation fault (core dumped) ./proxy_server $ gdb proxy_server proxy_server": not in executable format: file format not recognized $ file proxy_server proxy_server: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, missing section headers at 2795672

There is something wrong with my host and FTP upload.
File loses some bytes, when I upload it thru FTP.
When I download it thru HTTP - downloads.ots.me site - I get file with these bytes missing.
When I download it thru FTP, it adds some bytes (even more bytes than it lose during upload).

ANYWAY. I've uploaded it to backup host in Oracle (which has SSH access, not FTP) and it works:
https://downloads-oracle.ots.me/?dir=data/otcv8-proxy-server

EDIT:
TFS 1.6 server side code to read IP from OTCv8 proxy and HAProxy (for port 7171 proxied by HAProxy, without OTCv8 proxy - useful when you want to add HAProxy server to otservlist etc., to hide real server IP):
gesior/forgottenserver-gesior@199b64d
Code not tested, it compiles in VS. It's based on TFS 1.4 code that was tested and used on 500+ online server. I will release TFS 1.4 version soon. From what I understand, Tibia 11+ uses login.php script to login into account, so to enable OTC proxy you have to return as IP of OTS 127.0.0.1 in that PHP script.

You can also use OTCv8 proxy with real Tibia Client ex. Giveria (13+) client "without updater" includes exe Giveria.exe and proxy.config that configures proxy, start real tibia client 13+ and pass this client connections to 127.0.0.1 thru OTCv8 proxy system:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants