Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about usage Server #127

Closed
franklupo opened this issue Jul 20, 2023 · 4 comments
Closed

Question about usage Server #127

franklupo opened this issue Jul 20, 2023 · 4 comments

Comments

@franklupo
Copy link

Hi,
First I wanted to thank you for your great work for this great library.

  • how can I access only from some ip of my network card?
  • how can I view only some items depending on the login (username, password)?
  • according to your experience, how is it better to save the data in memori and storage?

best regards

@franklupo franklupo changed the title Question about usage Question about usage Server Jul 20, 2023
@nauful
Copy link
Owner

nauful commented Jul 21, 2023

Hello,

Glad you like my library.

IP binding

I don't expose this by default but you can promote IPEndPoint to a parameter for this function:

IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, Port);

Then you can pass in an ip to bind to here:
server.Start();

For user-level permissions,

Create a session object (any type of your design) and return a new instance here: https://github.com/nauful/LibUA/blob/c8e642d10b1f39543bc1487c8e0fa496ef743b17/NET%20Core/TestServer/Program.cs#L105C41-L105C61
E.g. session.state == Unassigned now
When the client sends a username + password, assign it to your session object here:


E.g. session.state == Logged in, session.username == username now
Implement this in your Application: https://github.com/nauful/LibUA/blob/c8e642d10b1f39543bc1487c8e0fa496ef743b17/NET%20Core/LibUA/Application.cs#L633
Now you can check if session[Logged in, username] has permission to access any particular NodeId.

Storage

For memory I use a Dictionary<NodeId, MyDataTypes>.
For storage you can use a normal database (sqlite, MySql, etc) or any time-series database (my original use case when I started this library). You can write to Dictionary and db when receiving a ua write, read from dictionary or read from db and cache in dictionary.

@franklupo
Copy link
Author

Hi,

IP binding

https://github.com/nauful/LibUA/blob/c8e642d10b1f39543bc1487c8e0fa496ef743b17/NET%20Core/LibUA/Server.cs#L35C11-L35C17it would be nice to pass endpoint to constructor

For user-level permissions,

https://github.com/nauful/LibUA/blob/c8e642d10b1f39543bc1487c8e0fa496ef743b17/NET%20Core/LibUA/Application.cs#L633
the SessionHasPermissionToRead is not virtual, ovveride is not possible

best regards

@nauful
Copy link
Owner

nauful commented Jul 21, 2023

Done both, please try now.

@nauful
Copy link
Owner

nauful commented Jul 26, 2023

Closed, finished work.

@nauful nauful closed this as completed Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants