Raised This Month: $51 Target: $400
 12% 

Server ID ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-20-2018 , 03:52   Server ID ?
Reply With Quote #1

Hello,

I'm trying to search a value that is unique for every servers and that can be shared. Something like an ID in a database table.

Is there such a thing ? I'm just trying to indentify my servers.
__________________
Want to check my plugins ?
Arkarr is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-20-2018 , 03:54   Re: Server ID ?
Reply With Quote #2

Add auto increment field to DB along with hostname.

Use INSERT INTO ON DUPLICATE
UPDATE
mysql syntax.
__________________

Last edited by Neuro Toxin; 03-20-2018 at 03:56.
Neuro Toxin is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-20-2018 , 04:21   Re: Server ID ?
Reply With Quote #3

Quote:
Originally Posted by Neuro Toxin View Post
Add auto increment field to DB along with hostname.

Use INSERT INTO ON DUPLICATE
UPDATE
mysql syntax.
But hostname can change ? I mean, for exemple, I know some server change there hostname like this :

Bla bla bla server name | some more infos | 7/32 players

A few minutes later :

Bla bla bla server name | some more infos | 2/32 players


And now I have 2 entry for the same server. Also, I'm not doing any SQL or anything. I'm just trying to find something unique to every server.
__________________
Want to check my plugins ?
Arkarr is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 03-20-2018 , 04:33   Re: Server ID ?
Reply With Quote #4

Every server downloads the same binary files from the server and should be identical by default. The only variables that are kind of static that you could use would probably be the ip address + port combination. of course these can change too but so can anything if you change it... Other then that i'd suggest you create the unique identifier for each server. It all depends on what you are trying to accomplish exactly
__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-20-2018 , 04:37   Re: Server ID ?
Reply With Quote #5

Quote:
Originally Posted by 1337norway View Post
Every server downloads the same binary files from the server and should be identical by default. The only variables that are kind of static that you could use would probably be the ip address + port combination. of course these can change too but so can anything if you change it... Other then that i'd suggest you create the unique identifier for each server. It all depends on what you are trying to accomplish exactly
The thing is, I create socket on servers and once in a while (map change, server reboot, etc...) socket get destroyed or disconnect, without notifing the main server (and it's normal). Immediatly after, the server's socket reconnect, but now I have 2 entries. The 'old' connection and the new one. I'm forced to send a data to the 'old' socket and see if it crash (doesn't bother me too much) but then I don't know for sure what's the new correct socket for that server.

I am using IP+port combination already (and checking server's hostname, but that's not safe), but as you said, it can change.

EDIT: Not sure if it was clear enough ?
__________________
Want to check my plugins ?

Last edited by Arkarr; 03-20-2018 at 04:38.
Arkarr is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-20-2018 , 05:17   Re: Server ID ?
Reply With Quote #6

I believe IP: Port is the most unique property a server has. Yes, it can change, but it's not like you change your server's IP every day. Another way would be that each server has a UUID that it should keep sercret and use that to identify itself.

P.S. I don't know if UUIDs are cryptographically secure. But there are many other algorithms you can use to generate a secret key.
__________________

Last edited by klippy; 03-20-2018 at 05:23.
klippy is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-20-2018 , 05:29   Re: Server ID ?
Reply With Quote #7

Alright, thanks. I don't really need it to be secure. I just need something to select servers distinctly.
__________________
Want to check my plugins ?
Arkarr is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 03-20-2018 , 12:11   Re: Server ID ?
Reply With Quote #8

Quote:
Originally Posted by Arkarr View Post
Hello,

I'm trying to search a value that is unique for every servers and that can be shared. Something like an ID in a database table.

Is there such a thing ? I'm just trying to indentify my servers.
Yes.

The GSLT systems helps you, e.g.:

Code:
status
[...]
udp/ip  : 127.0.0.1:27015  (public ip: 127.0.0.1
steamid : [G:1:123] (12345678901234567)
[...]
^ The "steamid" is unique, based on the GSLT for your server (e..g. sv_setsteamaccount).

The Server Steam ID can be retrieved via GetServerSteamAccountId (short "123" from "[G:1:123]"), and GetServerAuthId (long "12345678901234567").

I would suggest taking the long one though, as the "64-bit Steam ID's" are the only one that hasn't ever changed it's "format".


Quote:
Originally Posted by 1337norway View Post
Every server downloads the same binary files from the server and should be identical by default. The only variables that are kind of static that you could use would probably be the ip address + port combination. of course these can change too but so can anything if you change it... Other then that i'd suggest you create the unique identifier for each server. It all depends on what you are trying to accomplish exactly
The Server Steam ID will be a better factor to use (at least, for games that supports that, such as CS:S, CS:GO, and TF2).

Quote:
Originally Posted by Arkarr View Post
I am using IP+port combination already (and checking server's hostname, but that's not safe), but as you said, it can change.
Use the "advantages" of the GSLT system.

Quote:
Originally Posted by KliPPy View Post
I believe IP: Port is the most unique property a server has. Yes, it can change, but it's not like you change your server's IP every day. Another way would be that each server has a UUID that it should keep sercret and use that to identify itself.

P.S. I don't know if UUIDs are cryptographically secure. But there are many other algorithms you can use to generate a secret key.
Not if you take the GSLT system into consideration.

Only places where the GSLT system won't work properly, would be if you are running nasty things where you "need" to change sv_steamaccount frequently, otherwise "steamid" will always be the same for the same "sv_setsteamaccount" token.

Quote:
Originally Posted by Arkarr View Post
Alright, thanks. I don't really need it to be secure. I just need something to select servers distinctly.
GSLT is your best bet.

It will only complicate things, if you need to support those kind of nasty things that Valve is actually blacklisting servers for.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 03-20-2018 at 12:14.
DarkDeviL is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-20-2018 , 13:31   Re: Server ID ?
Reply With Quote #9

Quote:
Originally Posted by arne1288 View Post
Yes.

The GSLT systems helps you, e.g.:

Code:
status
[...]
udp/ip  : 127.0.0.1:27015  (public ip: 127.0.0.1
steamid : [G:1:123] (12345678901234567)
[...]
^ The "steamid" is unique, based on the GSLT for your server (e..g. sv_setsteamaccount).

The Server Steam ID can be retrieved via GetServerSteamAccountId (short "123" from "[G:1:123]"), and GetServerAuthId (long "12345678901234567").

I would suggest taking the long one though, as the "64-bit Steam ID's" are the only one that hasn't ever changed it's "format".
The account IDs have never changed, it's just that Valve had a weird way of displaying them in SteamID2. Instead of the account ID being a single number, they did this:

STEAM_x:last bit:remaining bits shifted right by 1

STEAM_x because it'll be either STEAM_0 or STEAM_1 depending on whether the game is misreporting the realm as Invalid (0) or not (1)

Hence why STEAM_1:0:1081621 changes to [U:1:2163242] because (1081621 << 1) | 0 results in 2163242
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-20-2018 , 13:57   Re: Server ID ?
Reply With Quote #10

@arne1288 I knew about GSLT, but does that apply to all Source games? I know it's required for some games.
__________________
klippy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode