wohahobg / pterosync

PteroSync new WHMCS Pterodactyl Module
76 stars 17 forks source link

Port offset doest not work when using the IP Alias #23

Closed pimenta1807 closed 1 month ago

pimenta1807 commented 2 months ago

The log returns "Ports not found" with the port being available while using the alias IP. image

The port offset function does work fine when not using the alias option.

wohahobg commented 2 months ago

Hey can you please share with me your product setup. I assume that your product settings are not set in current way.

pimenta1807 commented 2 months ago

here is the product>module setting view image

A customer ordered one hour ago and it worked fine again. image

Now using the setting "use_alias_ip": true

image

pimenta1807 commented 2 months ago

in the last image, the server was created on the port 16342. The request shows the port 16343 available. https://pastebin.com/wUSAd83p#google_vignette image

just a guess, but perhaps the code is searching for [ip] instead of the [alias] here ?

maybe pteroSync_getServerIPAndPort should be called before server creation. I will test it and get back with the result.

wohahobg commented 2 months ago

The code is searching only for an ip same as pterodactyl.

wohahobg commented 2 months ago

How is work is:

It creating 1st the server by pterodactyl then it searching for an extra ports and etc if required on same ip as server ip, and if there is no matches it search for different ip and port until it match them.

pimenta1807 commented 2 months ago

I inserted this block of code in order to try to understand better what is happening. The first output is with the alias turned off, and then with the alias turned on. image

alias = false https://pastebin.com/YnWqz9YT

alias = true https://pastebin.com/guLbm4re

wohahobg commented 2 months ago

The allies is only used for display use in clinetarea.

The module won't search ip by allies.

pimenta1807 commented 2 months ago

Can you please confirm that $_SERVER_IP is not being replaced by the alias here ?

Because I don't understand why, when printing the $_SERVER_IP variable in the log, it shows the Alias IP. image

wohahobg commented 2 months ago

That replace it yes. But it does it and the end.

What is your goal ? To use allies ips instand of normal one to create a server?

pimenta1807 commented 2 months ago

Your module can create offset ports when "use_alias_ip": false When using "use_alias_ip": true, port offset does not work.

The module searches for new ports using the alias IP because the $_SERVER_IP is being redefined to the alias at the end.

To achieve the expected result, I edited the pteroSync_getServerIPAndPort() function so that it creates a specific variable for the alias when needed. If the boolean use_alias_ip is true, then pteroSync_updateServerDomain() is called using: pteroSync_updateServerDomain(alias, $_SERVER_PORT, $params);

wohahobg commented 2 months ago

Ahh I see where the issue was. I have added new variable that store the alias ip and used only when it need to store the IP in whmc. You can see in the commit 7aa0cd217a570df7abaabe21fc894f0a4c417855. Try to use the main branch.

pimenta1807 commented 2 months ago

Using the main branch, the server is created correctly with all ports and the domain is updated correctly with the alias, but in the client area, this error occurs: image

Passing the $serverAliasIp argument to the pteroSyncGenerateServerStatusArray() function and replacing $address with it worked 100% for me. Thank you very much for the module and your work.

wohahobg commented 2 months ago

Should be okay now.