PDA

View Full Version : Auto update host ip error



Remzo
04-03-2017, 12:39 PM
Hello.
My server is behind NAT and it has different IP in (192.168.x.x) and out off (193.110.x.x) machine. Probably you are using hostip cvar which contains only inside IP address and i guess it is reason why auto update doesn't work. Could you add support to "net_public_adr" cvar? In previous version of your auto-update plugin i just did "bridge" between your database and our, but this time you didn't attached source code of the plugin so i can't do anything to solve my problem.

Neuro Toxin
04-03-2017, 01:02 PM
Ok. Np.

I'll have an update with source in the next day.

Remzo
04-03-2017, 01:09 PM
Thank you very much :)

Remzo
06-03-2017, 10:41 AM
Hello
I noticed you updated the plugin, but you didn't do what i asked for - support for servers behind NAT. Now i can do it by myself, because you provide source code, but what about simple solution?



stock void GetServerIpAddress(char[] buffer, int length)
{
ConVar cvar = FindConVar("ip");
cvar.GetString(buffer, length);
delete cvar;
}


to:



stock void GetServerIpAddress(char[] buffer, int length)
{
ConVar cvar = FindConVar("net_public_adr");
cvar.GetString(buffer, length);
if(StrEqual(buffer, "", true)) {
delete cvar;

cvar = FindConVar("ip");
cvar.GetString(buffer, length);
delete cvar;
}
delete cvar;
}

Neuro Toxin
06-03-2017, 10:44 AM
I tried the best I could.

My issue is the public ip isnt available until a connection to steam servers is made.

The plugin then gets the wrong ip when it first boots.

What if i add a setting to autoexec.cfg for the future to override the ip used?

Remzo
06-03-2017, 11:01 AM
Yup, good idea. Just add cvar with ip address, and if it's not empty then use it instead automatic detect. This simple solution will solve problem ;)

Neuro Toxin
06-03-2017, 12:31 PM
Sweet. Please bump if you dont see an update in 2 days.

Remzo
06-03-2017, 12:39 PM
Sure, no problem. Currently i did it by myself, you can use if want. Put "tokenstash_gameserverip" in you autexec.cfg file ;)



stock bool GetConfigValues(char[] steamid, int steamidlength, char[] apikey, int apikeylength, char[] serverhost, int serverhostlength)
{
Dynamic s_AutoExecConfig = Dynamic();
s_AutoExecConfig.ReadConfig("cfg/autoexec.cfg", false, 512);

s_AutoExecConfig.GetString("tokenstash_steamid", steamid, steamidlength);
s_AutoExecConfig.GetString("tokenstash_apikey", apikey, apikeylength);
s_AutoExecConfig.GetString("tokenstash_gameserverip", serverhost, serverhostlength);

if(StrEqual(serverhost, "")) {
GetServerIpAddress(serverhost, serverhostlength);
}
Format(serverhost, serverhostlength, "%s:%d", realIp, GetServerPort());

s_AutoExecConfig.Dispose();
}


#Edit
I know u are also author of Dynamic Objects and i think i found bug. When I want to ReadString from config and the value contains "." (dot) some strange things happens, eg:
cfg: tokenstash_gameserverip "193.110.121.69"
s_AutoExecConfig.GetString("tokenstash_gameserverip", serverhost, serverhostlength);
PrintToServer("%s") prints 193.110001 - lol :O

Neuro Toxin
06-03-2017, 02:38 PM
Interesting. I'll push an update tonight.

I've gotta do some Dynamic testing first

Remzo
11-03-2017, 01:59 AM
BUMP, did u check the error?


autoexec.cfg


sv_setsteamaccount "XXXXXXXXXXXXFF51CC25FC"
tokenstash_steamid "XXXXX98047213722"
tokenstash_apikey "XXXXXXXuI5DLC1LcLRnovkUxIGSVWZq"
tokenstash_gameserverip "193.110.121.69"



Remake of GetConfigsValue function:


stock bool GetConfigValues(char[] steamid, int steamidlength, char[] apikey, int apikeylength, char[] serverhost, int serverhostlength)
{
Dynamic s_AutoExecConfig = Dynamic();
s_AutoExecConfig.ReadConfig("cfg/autoexec.cfg", false, 512);

s_AutoExecConfig.GetString("tokenstash_steamid", steamid, steamidlength);
s_AutoExecConfig.GetString("tokenstash_apikey", apikey, apikeylength);
s_AutoExecConfig.GetString("tokenstash_gameserverip", serverhost, serverhostlength); //this line returns broken server host, like: "193.110001:27015"

if(StrEqual(serverhost, "")) {
GetServerIpAddress(serverhost, serverhostlength);
}
Format(serverhost, serverhostlength, "%s:%d", serverhost, GetServerPort());

s_AutoExecConfig.Dispose();
}



/logs/tokenstash.txt


************************************************** ****************
*** TOKENSTASH.COM AUTO UPDATER V0.08
************************************************** ****************
*** -> tokenstash_steamid: 'XXXXX198047213722'
*** -> tokenstash_apikey: 'XXXXXXXXXX5DLC1LcLRnovkUxIGSVWZq'
*** -> tokenstash_serverhost: 'XXXXX198047213722_193.110001:27015'
*** -> sv_setsteamaccount: 'XXXXXXXXXX235A2AD106BEFF51CC25FC'
*** CURRENT GSLT TOKEN IS VALID
************************************************** ****************



/logs/errors_2017xxxx.log


L 03/08/2017 - 20:03:06: [SM] Exception reported: Not enough space on the heap
L 03/08/2017 - 20:03:06: [SM] Blaming: dynamic.smx
L 03/08/2017 - 20:03:06: [SM] Call stack trace:
L 03/08/2017 - 20:03:06: [SM] [1] Line 328, ..\dynamic/system/flatconfigs.sp::_Dynamic_WriteConfig
L 03/08/2017 - 20:03:06: [SM] [2] Line 128, ..\dynamic/system/natives.sp::Native_Dynamic_WriteConfig
L 03/08/2017 - 20:03:06: [SM] [4] Dynamic_WriteConfig
L 03/08/2017 - 20:03:06: [SM] [5] Line 110, F:\CounterStrike - GO\Kompilator 1.8\include\dynamic/methodmaps/dynamic.inc::Dynamic.WriteConfig
L 03/08/2017 - 20:03:06: [SM] [6] Line 171, F:\CounterStrike - GO\Kompilator 1.8\ts-auto-updater.sp::WriteToken
L 03/08/2017 - 20:03:06: [SM] [7] Line 131, F:\CounterStrike - GO\Kompilator 1.8\ts-auto-updater.sp::ValidateToken
L 03/08/2017 - 20:03:06: [SM] [8] Line 85, F:\CounterStrike - GO\Kompilator 1.8\ts-auto-updater.sp::APIWebResponse
L 03/08/2017 - 20:03:06: [SM] [10] SteamWorks_GetHTTPResponseBodyCallback
L 03/08/2017 - 20:03:06: [SM] [11] Line 74, F:\CounterStrike - GO\Kompilator 1.8\ts-auto-updater.sp::OnInfoReceived
L 03/08/2017 - 20:12:49: Error log file session closed.



I think this line says all about error:

L 03/08/2017 - 20:03:06: [SM] [1] Line 328, ..\dynamic/system/flatconfigs.sp::_Dynamic_WriteConfig

Probably it interprets serverip as float istead as string, and this is the problem.

Neuro Toxin
11-03-2017, 09:26 AM
Update to the latest dynamic.

Dynamic 0.0.25

- Garbage collector plugin handle patch (thx KyleS)
- changed dynamic.Index to offset.Index (thx jdlovins)
- Add Get/Set by offset to sm_dynamic_selftest
- Fix Native_Dynamic_SetVectorByOffset

https://github.com/ntoxin66/Dynamic/archive/0.0.25.zip