ArnLib  4.0.x
Active Registry Network
ArnServer Class Reference

Class for making an Arn Server. More...

#include <ArnServer.hpp>

Inheritance diagram for ArnServer:
Collaboration diagram for ArnServer:

Classes

struct  Type
 

Public Member Functions

 ArnServer (Type serverType, QObject *parent=arnNullptr)
 Create an Arn server object. More...
 
 ~ArnServer ()
 
void start (int port=-1, QHostAddress listenAddr=QHostAddress::Any)
 Start the Arn server More...
 
int port ()
 Port number of the Arn server More...
 
QHostAddress listenAddress ()
 Address of the interface used to listening for connections to the Arn server More...
 
void addAccess (const QString &userName, const QString &password, Arn::Allow allow)
 Add an access entry. More...
 
bool isDemandLogin () const
 Get servers demand for login. More...
 
void setDemandLogin (bool isDemandLogin)
 Set servers demand for login. More...
 
void setNoLoginNets (const QStringList &noLoginNets)
 Set the nets not demanding login. More...
 
QStringList noLoginNets () const
 Get the nets not demanding login. More...
 
bool isDemandLoginNet (const QHostAddress &remoteAddr) const
 Return if a host address demands login. More...
 
void addFreePath (const QString &path)
 Add a new "freePath". More...
 
QStringList freePaths () const
 Returns current list of freePaths. More...
 
void setWhoIAm (const Arn::XStringMap &whoIAmXsm)
 Set servers human readable identification information. More...
 

Detailed Description

Class for making an Arn Server.

About Sharing Arn Data Objects

Example usage

// In class declare
ArnServer* _server;
// In class code
_server = new ArnServer( ArnServer::Type::NetSync, this);
_server->start();
Examples:
ArnDemoChatServer/MainWindow.cpp, and ArnDemoChatServer/MainWindow.hpp.

Definition at line 98 of file ArnServer.hpp.

Constructor & Destructor Documentation

◆ ArnServer()

ArnServer::ArnServer ( Type  serverType,
QObject *  parent = arnNullptr 
)

Create an Arn server object.

Parameters
[in]serverTypeFor now only NetSync is available.
[in]parent

Definition at line 198 of file ArnServer.cpp.

◆ ~ArnServer()

ArnServer::~ArnServer ( )

Definition at line 212 of file ArnServer.cpp.

Member Function Documentation

◆ addAccess()

void ArnServer::addAccess ( const QString &  userName,
const QString &  password,
Arn::Allow  allow 
)

Add an access entry.

This adds an entry to build an access table for the server. This access table restricts the operations of connected clients. Each client refer to one entry by its userName. Each entry must have a unique userName. Any equal userName is making the entry being replaced by the last added one. The password can be in clear text or a Hashed password which can be generated by ArnClient::passwordHash() (see also ArnBrowser Settings).

Parameters
[in]userName
[in]passwordin clear text or Hashed
[in]allowhave flags defining allowed basic operations (write, delete ...)

Definition at line 263 of file ArnServer.cpp.

◆ addFreePath()

void ArnServer::addFreePath ( const QString &  path)

Add a new "freePath".

A freePath can be used even if not logged in to an ArnServer that demands login. Also all children below freePath is free to use. Usage is restricted to read operations and alike from ArnServer to ArnClient. Setting a freePath at ArnServer gives the actual permision for read usage. All wanted freePaths must be added before ArnServer is started.

Parameters
[in]pathis the freePath, eg "/Local/Sys/Legal/".
See also
freePaths()

Definition at line 363 of file ArnServer.cpp.

◆ freePaths()

QStringList ArnServer::freePaths ( ) const

Returns current list of freePaths.

The list of freePaths is used to give permision for read uasge of the paths.

Returns
the freePath list.
See also
addFreePath()

Definition at line 372 of file ArnServer.cpp.

◆ isDemandLogin()

bool ArnServer::isDemandLogin ( ) const

Get servers demand for login.

If any of server or client demand login, it must be used.

Return values
trueif server demand login.
See also
setDemandLogin()

Definition at line 271 of file ArnServer.cpp.

◆ isDemandLoginNet()

bool ArnServer::isDemandLoginNet ( const QHostAddress &  remoteAddr) const

Return if a host address demands login.

Parameters
[in]remoteAddris the tested host address.
Return values
falseif the host address belongs to any net not demanding login
See also
setNoLoginNets()

Definition at line 303 of file ArnServer.cpp.

◆ listenAddress()

QHostAddress ArnServer::listenAddress ( )

Address of the interface used to listening for connections to the Arn server

Return values
isthe address (which usually is QHostAddress::Any).
See also
start()

Definition at line 254 of file ArnServer.cpp.

◆ noLoginNets()

QStringList ArnServer::noLoginNets ( ) const

Get the nets not demanding login.

Returns
the nets not demanding login.
See also
setNoLoginNets()

Definition at line 295 of file ArnServer.cpp.

◆ port()

int ArnServer::port ( )

Port number of the Arn server

Return values
isthe port number.

Definition at line 246 of file ArnServer.cpp.

◆ setDemandLogin()

void ArnServer::setDemandLogin ( bool  isDemandLogin)

Set servers demand for login.

If any of server or client demand login, it must be used.

Parameters
[in]isDemandLogintrue if server demand login.
See also
isDemandLogin()

Definition at line 279 of file ArnServer.cpp.

◆ setNoLoginNets()

void ArnServer::setNoLoginNets ( const QStringList &  noLoginNets)

Set the nets not demanding login.

The net can be "localhost", "localnet", "any" or a subnet using syntax from QHostAddress::parseSubnet(). The "localnet" matches direct adresses on all of the available interfaces. The "any" will effectively turn off setDemandLogin().

Parameters
[in]noLoginNetsis the list of no login nets, e.g ("localhost" "192.168.1.0/255.255.255.0").
See also
noLoginNets()
isDemandLoginNet()
QHostAddress::parseSubnet()

Definition at line 287 of file ArnServer.cpp.

◆ setWhoIAm()

void ArnServer::setWhoIAm ( const Arn::XStringMap whoIAmXsm)

Set servers human readable identification information.

This is used to identify the server. Standard keys to use are: Contact, Location, Description.

Example usage

xsm.add("Contact", "arn@arnas.se");
xsm.add("Location", "The Longhouse");
xsm.add("Description", "Bring connection and integration to the people");
_arnServer->setWhoIAm( xsm);
Parameters
[in]whoIAmXsmcontains the information.
See also
remoteWhoIAm()

Definition at line 404 of file ArnServer.cpp.

◆ start()

void ArnServer::start ( int  port = -1,
QHostAddress  listenAddr = QHostAddress::Any 
)

Start the Arn server

Parameters
[in]portis the server port, -1 gives Arn::defaultTcpPort, 0 gives dynamic port
[in]listenAddris the interface address to listen for connections (default any)

Definition at line 218 of file ArnServer.cpp.


The documentation for this class was generated from the following files: