![]() |
Protected variables
Similar to access specifiers in C++, it would be cool if we can create private or read-only variables so remote objects can't view and/or edit them.
I bring this up when as I realized that anyone could access the strings in my StaffRights dbnpc and read/change them. Thus I'd like an option to be able to protect objects and their associated variables. Only really needed serverside. I have no idea how hard this would be to implement but cool if we could make variables read only or private/hidden. Also, I'd also think it'd be great if we have an option to compile a weapon/class/npc 's coding with encryption. This could either be done by
With the recent use of weapon scripts that can steal servers, this may be a useful addition as well. These may have been requested before. If this is a stupid idea, at least say why >_<. |
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Well with the addition of NPC server rights, stealing servers is a bit harder. But i still want private and protected variables >_<
|
Eventually we could add some kind of "this.protected.var" or similar, or "thisr."
|
Great! ^^
|
I prefer "thisr.", "this.protected.var" makes me cringe.
|
Agreed
|
Problem with thisr. is ... then we also need thisor., gets complex :D
|
Quote:
How about something in the TGraalVar that when true makes an object only editable by its 'parent' object? I assume that variables are subobjects of the script? object.protected(true/false); object.final(true/false); Opinions? |
this.test = new TProtectedString();
or something similar to that could work ^^. |
this.protected.var seems reasonable enough if it clears the thisor. problem.
|
Quote:
Object.protected = true/false; |
Because it'd be one more bit applied to every variable ever...?
|
Hate to revive this but I love the idea of password protected NPCs and encrypted ones as well.
|
Heh..i'd much prefer my original idea of protected vars. this.protected.var would be awesome but this.var.protected = true; could also be cool ^^.
But soon! |
Maybe if we just had more control over public and private variables...I don't know if I like the idea of classes being downloaded onto the client so they can see "Huh, whatever variable z01 is, that's the password...so I'll just say that, and it'll match it up...oh, I see, they have it scripted so I have to say the password backwards...well, I say that then."
|
Quote:
|
Piffle, I could care about internal security (the relative risk of people who already have access to RC), but I shan't. It's not the sort of thing that seems to merit having its own script to repair.
|
Quote:
I requested protected variables. Kinda like making bank flags protected variables so staff members with any kind of script access (eg. level, weapon etc.) couldn't access the flags and change them from another object. Could also be like making a mud library into a DB with protected vars so weapons / items can't be changed without using the actual DB itself - thus logged. I don't see why we can't have it? Quote:
Quote:
|
I've recently given this a bit more thought and I think this could work
Private Variables: Set by default, only the current object and all child objects can access variables. Trust Variables: An extension of private. All variables will become private but you can add what objects are trusted. For example, a DBNPC called System may have trust with a DBNPC called Accounts. This one is not as important but it would be cool Public Variables: When created, the player will have to set the variable as public. Public variables will have two settings: read and read/write. This could be done like PHP Code:
Doable? :D |
Can't make private variables by default as it would mess a lot of servers up. Maybe like a server option: privatevariablebydefault=true or something
I also posted this in another thread: Quote:
|
I think I would prefer private/public status to be set using a function on the object, that way you could make a function to set the status of many variables at once.
|
I still desire these updates! Callstack access does rock but with protected vars: ultimate security! I will love you long time and bake many pizzas should you add this ^^
|
Hmmm In some languages there is a way to "freeze" an object. The variables of the frozen object cannot be edited anymore. That could eventually be added to Graal to make stuff like the DB-npcs not-modifiable. Eventually we could also make it so that you can "freeze" the object but still allow modifications from within the object itself.
A major problem for private variables is more the speed though, because it will need to check for each operation if the operation is allowed from the current object. Languages like C++ and Java only do private/protected stuff by the compiler, it's still possible to access those variables from outside with some tricks at runtime. So the scripting engine would need to remember the access rights for each object and check for access rights when the variable is read or modified. A "freezing" mechanism could make that faster because it would only set the access flag for all sub-variables at the time you freeze the object, and later just check for the access flag. It could also automatically block all attempts of calling join which could be used to extend the script of an object and then send a trigger to it to modify its own variables. |
One way you could do staff rights systems for now would be to use a system like this:
Have a folder that only the owner/manager and only essential staff have access to. In there, keep a file of flags (XML, saveVars, however you prefer to do it), and then each time you want to access something, reload it. Only save it when the function is called, etc. It's not that complicated, but could be difficult to implement. I find it nice to have a folder that only essential staff have access to anyway. Of course, hypothetically, you could just make a new folder, but many UC servers give every single staff rw */*, etc and then if they don't have that, everyone has change folder rights. Just an idea. |
Quote:
|
Quote:
New solution: script the whole damn server yourself. Noone else deserves rights! It is YOUR server, after all! I suppose, if all else fails, you could even manually edit the file, or, easier, just make a folder in your private folder where you have files such as rights_cbk1994.txt, and in it just a list such as PHP Code:
|
Quote:
Would this be a next Gserver update? :D |
Quote:
|
With the new callstack function, we could easily do some sort of protection.
Stefan could add some sort of onStrChanged(str, str, obj, str) params[0] could be the string being modified params[1] could be the new string value params[2] could be the object that is changing it params[3] could be the old string value Then add a check like if onStrChanged() is in the object's functions (the one with the string being modified - to relieve any possible confusion) then run through the function, otherwise, just modify the string without any nonsense. |
Quote:
Quote:
|
Quote:
onStrChanged()...... some of you people really don't seem to be getting this....when i say protected/private variables, only the local object can even see them let alone write to them! Other objects can't even read their contents or know if they exist! |
Well I suggested onVarChanged() along time ago myself.
By the way, you should call them variables instead of strings. Also, I had thought it might be a better idea to be able to define a read and write function for a variable, easily making variables read only or private or be able to notify the object of changes. Something like this: PHP Code:
And a more secure method would probably be a new type of script function definition: PHP Code:
|
Well we could eventually start with adding some flag to complete block access to variables from outside, and then you write functions for retrieving data.
The syntax for getters/setters would look more like "function set varname(value)" and "function get varname()" to be compatible with ECMA/JavaScript. |
Quote:
But whatever works ^^ |
| All times are GMT +2. The time now is 11:16 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.