2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-04-03 20:08:21 +00:00
This commit is contained in:
2026-04-02 19:42:54 +03:00
parent 4fae21deaf
commit 74830eea0c
82 changed files with 2501 additions and 3008 deletions

View File

@@ -0,0 +1,20 @@
using Esiur.Security.Authority;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Protocol.Authentication
{
public class HashAnonymousAuthenticator : IAuthenticationHandler
{
public AuthenticationResult Initiate(Session session)
{
throw new NotImplementedException();
}
public AuthenticationResult Process(object handshakePayload)
{
throw new NotImplementedException();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -50,12 +50,12 @@ partial class EpConnection
KeyList<uint, WeakReference<EpResource>> suspendedResources = new KeyList<uint, WeakReference<EpResource>>();
KeyList<uint, EpResourceAttachRequestInfo> resourceRequests = new KeyList<uint, EpResourceAttachRequestInfo>();
KeyList<UUID, AsyncReply<TypeDef>> typeDefsByIdRequests = new KeyList<UUID, AsyncReply<TypeDef>>();
KeyList<Uuid, AsyncReply<TypeDef>> typeDefsByIdRequests = new KeyList<Uuid, AsyncReply<TypeDef>>();
KeyList<string, AsyncReply<TypeDef>> typeDefsByNameRequests = new KeyList<string, AsyncReply<TypeDef>>();
Dictionary<UUID, TypeDef> typeDefs = new Dictionary<UUID, TypeDef>();
Dictionary<Uuid, TypeDef> typeDefs = new Dictionary<Uuid, TypeDef>();
KeyList<uint, AsyncReply> requests = new KeyList<uint, AsyncReply>();
@@ -186,7 +186,7 @@ partial class EpConnection
}
public AsyncReply StaticCall(UUID typeId, byte index, object parameters)
public AsyncReply StaticCall(Uuid typeId, byte index, object parameters)
{
return SendRequest(EpPacketRequest.StaticCall, typeId, index, parameters);
}
@@ -270,7 +270,7 @@ partial class EpConnection
SendReply(EpPacketReply.Chunk, callbackId, chunk);
}
void EpReplyCompleted(uint callbackId, ParsedTDU dataType)
void EpReplyCompleted(uint callbackId, ParsedTdu dataType)
{
var req = requests.Take(callbackId);
@@ -301,12 +301,12 @@ partial class EpConnection
}
}
void EpExtensionAction(byte actionId, ParsedTDU? dataType, byte[] data)
void EpExtensionAction(byte actionId, ParsedTdu? dataType, byte[] data)
{
// nothing is supported now
}
void EpReplyPropagated(uint callbackId, ParsedTDU dataType, byte[] data)
void EpReplyPropagated(uint callbackId, ParsedTdu dataType, byte[] data)
{
var req = requests[callbackId];
@@ -330,7 +330,7 @@ partial class EpConnection
}
}
void EpReplyError(uint callbackId, ParsedTDU dataType, byte[] data, ErrorType type)
void EpReplyError(uint callbackId, ParsedTdu dataType, byte[] data, ErrorType type)
{
var req = requests.Take(callbackId);
@@ -349,7 +349,7 @@ partial class EpConnection
req.TriggerError(new AsyncException(type, errorCode, errorMsg));
}
void EpReplyProgress(uint callbackId, ParsedTDU dataType, byte[] data)
void EpReplyProgress(uint callbackId, ParsedTdu dataType, byte[] data)
{
var req = requests[callbackId];
@@ -368,7 +368,7 @@ partial class EpConnection
req.TriggerProgress(ProgressType.Execution, current, total);
}
void EpReplyWarning(uint callbackId, ParsedTDU dataType, byte[] data)
void EpReplyWarning(uint callbackId, ParsedTdu dataType, byte[] data)
{
var req = requests[callbackId];
@@ -389,7 +389,7 @@ partial class EpConnection
void EpReplyChunk(uint callbackId, ParsedTDU dataType)
void EpReplyChunk(uint callbackId, ParsedTdu dataType)
{
var req = requests[callbackId];
@@ -404,16 +404,16 @@ partial class EpConnection
req.TriggerChunk(parsed);
}
void EpNotificationResourceReassigned(ParsedTDU dataType)
void EpNotificationResourceReassigned(ParsedTdu dataType)
{
// uint resourceId, uint newResourceId
}
void EpNotificationResourceMoved(ParsedTDU dataType, byte[] data) { }
void EpNotificationResourceMoved(ParsedTdu dataType, byte[] data) { }
void EpNotificationSystemFailure(ParsedTDU dataType, byte[] data) { }
void EpNotificationSystemFailure(ParsedTdu dataType, byte[] data) { }
void EpNotificationResourceDestroyed(ParsedTDU dataType, byte[] data)
void EpNotificationResourceDestroyed(ParsedTdu dataType, byte[] data)
{
var (size, rt) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -444,7 +444,7 @@ partial class EpConnection
}
void EpNotificationPropertyModified(ParsedTDU dataType)
void EpNotificationPropertyModified(ParsedTdu dataType)
{
// resourceId, index, value
var (valueOffset, valueSize, args) =
@@ -488,7 +488,7 @@ partial class EpConnection
}
void EpNotificationEventOccurred(ParsedTDU dataType, byte[] data)
void EpNotificationEventOccurred(ParsedTdu dataType, byte[] data)
{
// resourceId, index, value
var (valueOffset, valueSize, args) =
@@ -537,7 +537,7 @@ partial class EpConnection
});
}
void EpRequestAttachResource(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestAttachResource(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -579,7 +579,7 @@ partial class EpConnection
});
}
void EpRequestReattachResource(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestReattachResource(uint callback, ParsedTdu dataType, byte[] data)
{
// resourceId, index, value
var (valueOffset, valueSize, args) =
@@ -627,7 +627,7 @@ partial class EpConnection
});
}
void EpRequestDetachResource(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestDetachResource(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -658,7 +658,7 @@ partial class EpConnection
});
}
void EpRequestCreateResource(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestCreateResource(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, parsed) = Codec.ParseAsync(dataType, this, null);
@@ -668,8 +668,8 @@ partial class EpConnection
TypeDef type = null;
if (args[1] is UUID)
type = Instance.Warehouse.GetTypeDefById((UUID)args[1]);
if (args[1] is Uuid)
type = Instance.Warehouse.GetTypeDefById((Uuid)args[1]);
else if (args[1] is string)
type = Instance.Warehouse.GetTypeDefByName((string)args[1]);
@@ -719,7 +719,7 @@ partial class EpConnection
}
void EpRequestDeleteResource(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestDeleteResource(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -748,7 +748,7 @@ partial class EpConnection
});
}
void EpRequestMoveResource(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestMoveResource(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
@@ -789,12 +789,12 @@ partial class EpConnection
void EpRequestToken(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestToken(uint callback, ParsedTdu dataType, byte[] data)
{
// @TODO: To be implemented
}
void EpRequestLinkTypeDefs(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestLinkTypeDefs(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -827,7 +827,7 @@ partial class EpConnection
Instance.Warehouse.Query(resourceLink).Then(queryCallback);
}
void EpRequestTypeDefByName(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestTypeDefByName(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -846,12 +846,12 @@ partial class EpConnection
}
}
void EpRequestTypeDefById(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestTypeDefById(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
var typeId = (UUID)value;
var typeId = (Uuid)value;
var t = Instance.Warehouse.GetTypeDefById(typeId);
@@ -868,7 +868,7 @@ partial class EpConnection
void EpRequestTypeDefByResourceId(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestTypeDefByResourceId(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, value) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -891,7 +891,7 @@ partial class EpConnection
void EpRequestGetResourceIdByLink(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestGetResourceIdByLink(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, parsed) = Codec.ParseSync(dataType, Instance.Warehouse);
var resourceLink = (string)parsed;
@@ -919,7 +919,7 @@ partial class EpConnection
}
void EpRequestQueryResources(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestQueryResources(uint callback, ParsedTdu dataType, byte[] data)
{
var (_, parsed) = Codec.ParseSync(dataType, Instance.Warehouse);
@@ -977,7 +977,7 @@ partial class EpConnection
}
void EpRequestProcedureCall(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestProcedureCall(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, Instance.Warehouse, 1);
@@ -1037,12 +1037,12 @@ partial class EpConnection
}
}
void EpRequestStaticCall(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestStaticCall(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, Instance.Warehouse, 2);
var typeId = new UUID((byte[])args[0]);
var typeId = new Uuid((byte[])args[0]);
var index = (byte)args[1];
@@ -1114,7 +1114,7 @@ partial class EpConnection
}
}
void EpRequestInvokeFunction(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestInvokeFunction(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
dataType.ContentLength, Instance.Warehouse, 2);
@@ -1466,7 +1466,7 @@ partial class EpConnection
}
}
void EpRequestSubscribe(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestSubscribe(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
@@ -1525,7 +1525,7 @@ partial class EpConnection
}
void EpRequestUnsubscribe(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestUnsubscribe(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
@@ -1586,7 +1586,7 @@ partial class EpConnection
void EpRequestSetProperty(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestSetProperty(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
@@ -1719,7 +1719,7 @@ partial class EpConnection
/// </summary>
/// <param name="typeId">Type UUID.</param>
/// <returns>TypeSchema.</returns>
public AsyncReply<TypeDef> GetTypeDefById(UUID typeId)
public AsyncReply<TypeDef> GetTypeDefById(Uuid typeId)
{
if (typeDefs.ContainsKey(typeId))
return new AsyncReply<TypeDef>(typeDefs[typeId]);
@@ -1902,7 +1902,7 @@ partial class EpConnection
// TypeId, Age, Link, Hops, PropertyValue[]
var args = (object[])result;
var typeId = (UUID)args[0];
var typeId = (Uuid)args[0];
var age = Convert.ToUInt64(args[1]);
var link = (string)args[2];
var hops = (byte)args[3];
@@ -2156,7 +2156,7 @@ partial class EpConnection
void EpRequestKeepAlive(uint callback, ParsedTDU dataType, byte[] data)
void EpRequestKeepAlive(uint callback, ParsedTdu dataType, byte[] data)
{
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,

View File

@@ -59,23 +59,23 @@ public class EpServer : NetworkServer<EpConnection>, IResource
get => membership;
set
{
if (membership != null)
membership.Authorization -= Membership_Authorization;
//if (membership != null)
// membership.Authorization -= Membership_Authorization;
membership = value;
if (membership != null)
membership.Authorization += Membership_Authorization;
//if (membership != null)
// membership.Authorization += Membership_Authorization;
}
}
private void Membership_Authorization(AuthorizationIndication indication)
{
lock (Connections.SyncRoot)
foreach (var connection in Connections)
if (connection.Session == indication.Session)
connection.ProcessAuthorization(indication.Results);
}
//private void Membership_Authorization(AuthorizationIndication indication)
//{
// lock (Connections.SyncRoot)
// foreach (var connection in Connections)
// if (connection.Session == indication.Session)
// connection.ProcessAuthorization(indication.Results);
//}
[Attribute]
public EntryPoint EntryPoint

View File

@@ -1,37 +0,0 @@
/*
Copyright (c) 2017 Ahmed Kh. Zamil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using Esiur.Net;
using Esiur.Net.Sockets;
using Esiur.Security.Authority;
namespace Esiur.Protocol;
public class EpSession : NetworkSession
{
public Source Source { get; set; }
public Authentication Authentication { get; set; }
}