|
| Node (SocketHandler _sock, Action< Node > _OnDisconnect) |
|
void | SetID (int id) |
| Sets the ID of the object.
|
|
async void | Disconnect () |
| Sets the isDisposed flag to true and disconnects the socket, disposes resources, and triggers the OnDisconnect event.
|
|
void | SetRecvTimeout (int ms) |
| Sets the receive timeout for the socket.
|
|
void | ResetRecvTimeout () |
| Resets the receive timeout for the socket.
|
|
bool | Connected () |
| Checks if the socket is connected and returns a boolean value indicating the connection status.
|
|
async Task< byte[]> | ReceiveAsync () |
| Asynchronously receives data from the socket and returns the received data as a byte array.
|
|
async Task< bool > | SendAsync (byte[] data) |
| Sends the provided data asynchronously and returns a boolean indicating the success of the operation.
|
|
string | GetIp () |
| Gets the IP address of the remote endpoint.
|
|
async Task< Node > | CreateSubNodeAsync (int Type) |
| Creates a sub node asynchronously and returns the created node.
|
|
void | AddTempOnDisconnect (Action< Node > function) |
| Adds a function to the list of actions to be executed when a node is disconnected.
|
|
void | RemoveTempOnDisconnect (Action< Node > function) |
| Removes the specified function from the list of temporary disconnect actions.
|
|
async Task | AddSubNode (Node subnode) |
| Adds a subnode to the list of subnodes.
|
|
async Task< bool > | AuthenticateAsync (int id) |
| Authenticates the client with the server using a random key exchange and returns a boolean indicating success or failure.
|
|
|
static int | memcmp (byte[] b1, byte[] b2, long count) |
| Compares two arrays of bytes and returns an integer that indicates their relative position in lexicographical order.
|
|
byte[] | GetByteArray (int size) |
| Generates a byte array of the specified size filled with random values.
|
|
bool | ByteArrayCompare (byte[] b1, byte[] b2) |
| Compares two byte arrays and returns true if they are equal; otherwise, false.
|
|
async Task< int > | GetSocketType () |
| Asynchronously receives a byte array from the socket, converts it to an integer representing the socket type, and returns the result.
|
|
◆ Node()
◆ AddSubNode()
async Task xeno_rat_server.Node.AddSubNode |
( |
Node | subnode | ) |
|
|
inline |
Adds a subnode to the list of subnodes.
- Parameters
-
subnode | The subnode to be added. |
- Exceptions
-
ArgumentException | Thrown when the subnode's SockType is not equal to 0. |
- Returns
- A task representing the asynchronous operation.
This method adds the specified subnode to the list of subnodes. If the subnode's SockType is not equal to 0, it waits for a response from the subnode and then adds it to the subNodeWait dictionary using the received ID as the key. If no response is received, the subnode is disconnected. If the SockType is equal to 0, the subnode is disconnected without waiting for a response. Finally, the subnode is added to the subNodes list.
◆ AddTempOnDisconnect()
void xeno_rat_server.Node.AddTempOnDisconnect |
( |
Action< Node > | function | ) |
|
|
inline |
Adds a function to the list of actions to be executed when a node is disconnected.
- Parameters
-
function | The function to be added to the list. |
This method adds the specified function to the list of actions to be executed when a node is disconnected.
◆ AuthenticateAsync()
async Task< bool > xeno_rat_server.Node.AuthenticateAsync |
( |
int | id | ) |
|
|
inline |
Authenticates the client with the server using a random key exchange and returns a boolean indicating success or failure.
- Parameters
-
id | The unique identifier of the client. |
- Returns
- True if the authentication is successful; otherwise, false.
This method initiates the authentication process by exchanging a random key with the server. If the key exchange is successful, it proceeds to validate the socket type and client ID before completing the authentication. If any step in the process fails, the method returns false.
◆ ByteArrayCompare()
bool xeno_rat_server.Node.ByteArrayCompare |
( |
byte[] | b1, |
|
|
byte[] | b2 ) |
|
inlineprivate |
Compares two byte arrays and returns true if they are equal; otherwise, false.
- Parameters
-
b1 | The first byte array to be compared. |
b2 | The second byte array to be compared. |
- Returns
- True if the byte arrays are equal; otherwise, false.
This method compares the lengths of the input byte arrays b1 and b2 . If the lengths are not equal, the method returns false. Otherwise, it uses the memcmp function to compare the contents of the byte arrays. The memcmp function returns 0 if the byte arrays are equal, and a non-zero value if they are not equal.
◆ Connected()
bool xeno_rat_server.Node.Connected |
( |
| ) |
|
|
inline |
Checks if the socket is connected and returns a boolean value indicating the connection status.
- Returns
- True if the socket is connected; otherwise, false.
This method checks the connection status of the socket and returns a boolean value indicating whether the socket is connected or not. If an exception occurs during the check, the method returns false.
◆ CreateSubNodeAsync()
async Task< Node > xeno_rat_server.Node.CreateSubNodeAsync |
( |
int | Type | ) |
|
|
inline |
Creates a sub node asynchronously and returns the created node.
- Parameters
-
Type | The type of the sub node to be created. Must be 1 or 2. |
- Exceptions
-
Exception | Thrown when the Type is less than 1 or greater than 2. |
- Returns
- The created sub node, or null if creation failed.
This method asynchronously creates a sub node with the specified Type . It generates a random ID for the sub node and sends a request to create the sub node. If the creation is successful, it waits for the sub node to be populated and returns it. If creation fails or the sub node is not populated within 10 seconds, it returns null.
◆ Disconnect()
async void xeno_rat_server.Node.Disconnect |
( |
| ) |
|
|
inline |
Sets the isDisposed flag to true and disconnects the socket, disposes resources, and triggers the OnDisconnect event.
This method sets the isDisposed flag to true and disconnects the socket if it is not null using asynchronous operation. It disposes the socket and the OneRecieveAtATime resource. If SockType is 0, it iterates through the subNodes list and calls the Disconnect method for each node with SockType not equal to 1. Finally, it triggers the OnDisconnect event and executes any temporary disconnect actions stored in TempOnDisconnects.
◆ GetByteArray()
byte[] xeno_rat_server.Node.GetByteArray |
( |
int | size | ) |
|
|
inlineprivate |
Generates a byte array of the specified size filled with random values.
- Parameters
-
size | The size of the byte array to be generated. |
- Returns
- A byte array of size size filled with random values.
This method creates a new instance of the Random class to generate random values and fills the byte array with these values using the NextBytes method.
◆ GetIp()
string xeno_rat_server.Node.GetIp |
( |
| ) |
|
|
inline |
Gets the IP address of the remote endpoint.
- Returns
- The IP address of the remote endpoint as a string. If the IP address cannot be retrieved, "N/A" is returned.
◆ GetSocketType()
async Task< int > xeno_rat_server.Node.GetSocketType |
( |
| ) |
|
|
inlineprivate |
Asynchronously receives a byte array from the socket, converts it to an integer representing the socket type, and returns the result.
- Returns
- The integer representing the socket type received from the socket.
- Exceptions
-
Exception | Thrown when the received byte array is null, indicating a disconnection, in which case the method also calls the Disconnect method and returns -1. |
◆ memcmp()
static int xeno_rat_server.Node.memcmp |
( |
byte[] | b1, |
|
|
byte[] | b2, |
|
|
long | count ) |
|
private |
Compares two arrays of bytes and returns an integer that indicates their relative position in lexicographical order.
- Parameters
-
b1 | The first array of bytes to be compared. |
b2 | The second array of bytes to be compared. |
count | The number of bytes to compare. |
- Returns
- An integer that indicates the relationship between the two arrays:
- Less than 0 if the first differing byte in b1 is less than the corresponding byte in b2 .
- 0 if the contents of both arrays are equal.
- Greater than 0 if the first differing byte in b1 is greater than the corresponding byte in b2 .
- Exceptions
-
ArgumentException | Thrown when the length of either array is less than count . |
◆ ReceiveAsync()
async Task< byte[]> xeno_rat_server.Node.ReceiveAsync |
( |
| ) |
|
|
inline |
Asynchronously receives data from the socket and returns the received data as a byte array.
- Returns
- The received data as a byte array, or null if the socket is disposed or if the received data is null.
- Exceptions
-
ObjectDisposedException | Thrown if the socket is disposed. |
◆ RemoveTempOnDisconnect()
void xeno_rat_server.Node.RemoveTempOnDisconnect |
( |
Action< Node > | function | ) |
|
|
inline |
Removes the specified function from the list of temporary disconnect actions.
- Parameters
-
function | The function to be removed from the list. |
This method removes the specified function from the list of temporary disconnect actions, if it exists. If the function does not exist in the list, no action is taken.
◆ ResetRecvTimeout()
void xeno_rat_server.Node.ResetRecvTimeout |
( |
| ) |
|
|
inline |
Resets the receive timeout for the socket.
This method resets the receive timeout for the underlying socket to the default value.
◆ SendAsync()
async Task< bool > xeno_rat_server.Node.SendAsync |
( |
byte[] | data | ) |
|
|
inline |
Sends the provided data asynchronously and returns a boolean indicating the success of the operation.
- Parameters
-
data | The byte array to be sent. |
- Returns
- True if the data was sent successfully; otherwise, false.
- Exceptions
-
Exception | Thrown when an error occurs during the send operation. |
This method sends the provided byte array data asynchronously using the underlying socket. If the send operation fails, the method disconnects from the socket and returns false.
◆ SetID()
void xeno_rat_server.Node.SetID |
( |
int | id | ) |
|
|
inline |
Sets the ID of the object.
- Parameters
-
◆ SetRecvTimeout()
void xeno_rat_server.Node.SetRecvTimeout |
( |
int | ms | ) |
|
|
inline |
Sets the receive timeout for the socket.
- Parameters
-
ms | The receive timeout value in milliseconds. |
This method sets the receive timeout for the underlying socket to the specified value in milliseconds. A receive timeout value of 0 indicates an infinite timeout.
◆ ID
int xeno_rat_server.Node.ID = -1 |
◆ isDisposed
bool xeno_rat_server.Node.isDisposed = false |
◆ OnDisconnect
Action<Node> xeno_rat_server.Node.OnDisconnect |
|
private |
◆ OneRecieveAtATime
SemaphoreSlim xeno_rat_server.Node.OneRecieveAtATime = new SemaphoreSlim(1) |
|
private |
◆ Parent
Node xeno_rat_server.Node.Parent |
◆ sock
◆ SockType
int xeno_rat_server.Node.SockType = 0 |
◆ SubNodeIdCount
int xeno_rat_server.Node.SubNodeIdCount = 0 |
◆ subNodes
List<Node> xeno_rat_server.Node.subNodes |
◆ subNodeWait
Dictionary<int, Node> xeno_rat_server.Node.subNodeWait |
|
private |
◆ TempOnDisconnects
List<Action<Node> > xeno_rat_server.Node.TempOnDisconnects = new List<Action<Node>>() |
|
private |
The documentation for this class was generated from the following file:
- /Users/sumansaurabh/Documents/my-startup/xeno-rat/xeno rat server/Node.cs