Identify server (with UUID or something)

Discussion in 'Spigot Plugin Development' started by SIndybad, Jul 7, 2015.

  1. Is there any way to differentiate servers(e.g. server UUID)?
     
  2. Creeoer

    Supporter

    You could try getting the ip?
    EDIT: There's another method called getServerID, not exactly sure what that returns but you could try it. You can even get the server name if you want.
     
  3. I tried getServerID() and it returns unnamed(you can change it in server.properties). If you don't have a static ip, wouldn't it change, though?
     
  4. nvm, I will just create a UUID in a file
     
  5. wait, that wouldn't be good as people could just copy their UUID and put it on another server... any ideas?
     
  6. Depends on what you are going to be using this for. If you need something to uniquely identify servers in a "relative" safe environment then you can use UUIDs. You can generate random ones using
    Code (Text):
    UUID.randomUUID();
    The UUID v4 is a 122 random bit UUID, meaning there should be 5,31e+36 (2^122) possibilities. This means in practice that if you generate random UUIDs you will never get two that are the same (since the chance of that happening is so low).


    This is spoofable though, so if that is a problem (that someone got access to the UUID, which should be stored in some file, and spoof the server) then you could try using a combination of the ip:port.

    You could also use a session system, like either get a UUID from some central or generate one each time the server starts up. This would not be good if you need consistency for each server over a longer period of time but would on the other hand prevent spoofing as long as the connection is secure and you don't have programs/plugins which got access to read the real time memory of the server (and get the UUID).
     
  7. UUID would be good, but if you want something related to the process id, server id, and time. Take a look at MongoDB's ObjectID.