Exemplo n.º 1
0
            public IBytesStorage <TKey> Create <TKey>(string path, IBytesPool bytesPool)
                where TKey : notnull, IEquatable <TKey>
            {
                var result = new LiteDatabaseBytesStorage <TKey>(path, bytesPool);

                return(result);
            }
Exemplo n.º 2
0
        public UnbufferedFileStream(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, IBytesPool bytesPool)
        {
            _path      = path;
            _bytesPool = bytesPool;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                const FileOptions FileFlagNoBuffering = (FileOptions)0x20000000;

                _stream = new FileStream(path, mode, access, share, 8, options | FileFlagNoBuffering);
            }
            else
            {
                _stream = new FileStream(path, mode, access, share, 8, options);
            }

            _blockIsUpdated = false;
            _blockPosition  = -1;
            _blockOffset    = 0;
            _blockCount     = 0;
            _blockBuffer    = _bytesPool.Array.Rent(SectorSize);

            _position = _stream.Position;
            _length   = _stream.Length;
        }
 public ConnectionReceiver(IMessagePipeReader <ArraySegment <byte> > dataReader, IMessagePipeWriter dataAcceptedWriter, IBytesPool bytesPool, CancellationToken cancellationToken)
 {
     _dataReader         = dataReader;
     _dataAcceptedWriter = dataAcceptedWriter;
     _bytesPool          = bytesPool;
     _cancellationToken  = cancellationToken;
 }
    public static Memory <byte> ToMemory(this ReadOnlySequence <byte> sequence, IBytesPool bytesPool)
    {
        var bytes = new byte[sequence.Length];

        sequence.CopyTo(bytes.AsSpan());
        return(bytes);
    }
Exemplo n.º 5
0
 public RocketRemotingListener(IConnection connection, uint functionId, IErrorMessageFactory <TError> errorMessageFactory, IBytesPool bytesPool)
 {
     _connection          = connection;
     this.FunctionId      = functionId;
     _errorMessageFactory = errorMessageFactory;
     _bytesPool           = bytesPool;
 }
Exemplo n.º 6
0
 public Authenticator(IConnection connection, OmniSecureConnectionType type, OmniDigitalSignature?digitalSignature, IBytesPool bytesPool)
 {
     _connection       = connection;
     _type             = type;
     _digitalSignature = digitalSignature;
     _bytesPool        = bytesPool;
 }
        public IKeyValueStorage <TKey> Create <TKey>(string path, IBytesPool bytesPool)
            where TKey : notnull
        {
            var result = new KeyValueLiteDatabaseStorage <TKey>(path, bytesPool);

            return(result);
        }
Exemplo n.º 8
0
 public RemotingSession(uint id, uint functionId, Remoting remoting, IBytesPool bytesPool)
 {
     this.Id         = id;
     this.FunctionId = functionId;
     _remoting       = remoting;
     _bytesPool      = bytesPool;
 }
    public ThumbnailGeneratorRepository(string filePath, IBytesPool bytesPool)
    {
        DirectoryHelper.CreateDirectory(Path.GetDirectoryName(filePath) !);

        _bytesPool           = bytesPool;
        _database            = new LiteDatabase(filePath);
        this.ThumbnailCaches = new ThumbnailCachesRepository(_database, _bytesPool);
    }
Exemplo n.º 10
0
    private ThumbnailGenerator(ThumbnailGeneratorOptions options)
    {
        _configPath  = options.ConfigDirectoryPath ?? throw new ArgumentNullException(nameof(options.ConfigDirectoryPath));
        _concurrency = options.Concurrency;
        _fileSystem  = options.FileSystem ?? throw new ArgumentNullException(nameof(options.FileSystem));
        _bytesPool   = options.BytesPool ?? BytesPool.Shared;

        _thumbnailGeneratorRepository = new ThumbnailGeneratorRepository(Path.Combine(_configPath, "thumbnails.db"), _bytesPool);
    }
 public ConnectionSender(int maxDataQueueSize, IMessagePipeWriter <ArraySegment <byte> > dataWriter, IActionListener dataAcceptedListener, IBytesPool bytesPool, CancellationToken cancellationToken)
 {
     _semaphoreSlim        = new SemaphoreSlim(maxDataQueueSize, maxDataQueueSize);
     _dataWriter           = dataWriter;
     _dataAcceptedListener = dataAcceptedListener;
     _dataAcceptedListener.Listen(() => _semaphoreSlim.Release()).AddTo(_disposables);
     _bytesPool         = bytesPool;
     _cancellationToken = cancellationToken;
 }
Exemplo n.º 12
0
        public ConnectionSender(ICap cap, IBytesPool bytesPool, CancellationToken cancellationToken)
        {
            _cap               = cap;
            _bytesPool         = bytesPool;
            _cancellationToken = cancellationToken;

            _bytesPipe     = new BytesPipe(_bytesPool);
            _semaphoreSlim = new SemaphoreSlim(1, 1);
        }
Exemplo n.º 13
0
 public ConnectionReceiver(ICap cap, int maxReceiveByteCount, IBytesPool bytesPool, CancellationToken cancellationToken)
 {
     _cap = cap;
     _maxReceiveByteCount = maxReceiveByteCount;
     _bytesPool           = bytesPool;
     _cancellationToken   = cancellationToken;
     _bytesPipe           = new BytesPipe(_bytesPool);
     _semaphoreSlim       = new SemaphoreSlim(0, 1);
 }
Exemplo n.º 14
0
 private TcpConnectionConnector(IBandwidthLimiter senderBandwidthLimiter, IBandwidthLimiter receiverBandwidthLimiter, ISocks5ProxyClientFactory socks5ProxyClientFactory, IHttpProxyClientFactory httpProxyClientFactory, IBatchActionDispatcher batchActionDispatcher, IBytesPool bytesPool, TcpConnectionConnectorOptions options)
 {
     _senderBandwidthLimiter   = senderBandwidthLimiter;
     _receiverBandwidthLimiter = receiverBandwidthLimiter;
     _socks5ProxyClientFactory = socks5ProxyClientFactory;
     _httpProxyClientFactory   = httpProxyClientFactory;
     _batchActionDispatcher    = batchActionDispatcher;
     _bytesPool = bytesPool;
     _options   = options;
 }
Exemplo n.º 15
0
 internal BlockExchanger(string configPath, BlockExchangerOptions options,
                         IObjectStoreFactory objectStoreFactory, IConnectionController connectionController,
                         INodeExplorer nodeExplorer, IPublishStorage publishStorage, IWantStorage wantStorage, IBytesPool bytesPool)
 {
     _configPath           = configPath;
     _options              = options;
     _objectStoreFactory   = objectStoreFactory;
     _connectionController = connectionController;
     _nodeExplorer         = nodeExplorer;
     _publishStorage       = publishStorage;
     _wantStorage          = wantStorage;
     _bytesPool            = bytesPool;
 }
Exemplo n.º 16
0
        public ConnectionSender(IConnectionSender sender, CryptoAlgorithmType cryptoAlgorithmType, byte[] cryptoKey, byte[] nonce, IBytesPool bytesPool)
        {
            _sender = sender;

            if (cryptoAlgorithmType == CryptoAlgorithmType.Aes_Gcm_256)
            {
                _encrypter = new AesGcmEncrypter(cryptoKey, nonce, bytesPool);
            }
            else
            {
                throw new NotSupportedException(nameof(cryptoAlgorithmType));
            }

            _bytesPool = bytesPool;
        }
Exemplo n.º 17
0
        public ConnectionReceiver(IConnectionReceiver receiver, CryptoAlgorithmType cryptoAlgorithmType, int maxReceiveByteCount, byte[] cryptoKey, byte[] nonce, IBytesPool bytesPool)
        {
            _receiver            = receiver;
            _maxReceiveByteCount = maxReceiveByteCount;

            if (cryptoAlgorithmType == CryptoAlgorithmType.Aes_Gcm_256)
            {
                _decrypter = new AesGcmDecrypter(cryptoKey, nonce, bytesPool);
            }
            else
            {
                throw new NotSupportedException(nameof(cryptoAlgorithmType));
            }

            _bytesPool = bytesPool;
        }
Exemplo n.º 18
0
        public SecureConnection(IConnection connection, OmniSecureConnectionOptions options)
        {
            _connection = connection ?? throw new ArgumentNullException(nameof(connection));

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (!EnumHelper.IsValid(options.Type))
            {
                throw new ArgumentException(nameof(options.Type));
            }

            _type      = options.Type;
            _passwords = options.Passwords ?? Array.Empty <string>();
            _bytesPool = options.BufferPool ?? BytesPool.Shared;
        }
Exemplo n.º 19
0
        internal NodeExplorer(string configPath, NodeExplorerOptions options,
                              IObjectStoreFactory objectStoreFactory, IConnectionController connectionController,
                              IPublishStorage publishStorage, IWantStorage wantStorage, IBytesPool bytesPool)
        {
            _configPath           = configPath;
            _options              = options;
            _objectStoreFactory   = objectStoreFactory;
            _connectionController = connectionController;
            _publishStorage       = publishStorage;
            _wantStorage          = wantStorage;
            _bytesPool            = bytesPool;

            {
                var id = new byte[32];
                using var random = RandomNumberGenerator.Create();
                random.GetBytes(id);
                _myId = id;
            }
        }
Exemplo n.º 20
0
        public OmniSecureConnection(IConnection connection, OmniSecureConnectionOptions options)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (!EnumHelper.IsValid(options.Type))
            {
                throw new ArgumentException(nameof(options.Type));
            }

            _connection = connection;
            _options    = options;
            _bytesPool  = options.BufferPool ?? BytesPool.Shared;
        }
Exemplo n.º 21
0
            public async ValueTask <INodeExplorer> CreateAsync(string configPath, NodeExplorerOptions options,
                                                               IObjectStoreFactory objectStoreFactory, IConnectionController connectionController,
                                                               IPublishStorage publishStorage, IWantStorage wantStorage, IBytesPool bytesPool)
            {
                var result = new NodeExplorer(configPath, options, objectStoreFactory, connectionController, publishStorage, wantStorage, bytesPool);
                await result.InitAsync();

                return(result);
            }
Exemplo n.º 22
0
 public RocketRemotingCallerFactory(IConnectionMultiplexer multiplexer, IBytesPool bytesPool)
 {
     _multiplexer = multiplexer;
     _bytesPool   = bytesPool;
 }
Exemplo n.º 23
0
            public async ValueTask <TcpConnector> CreateAsync(TcpConnectOptions tcpConnectOptions, TcpAcceptOptions tcpAcceptOptions, IBytesPool bytesPool)
            {
                var result = new TcpConnector(tcpConnectOptions, tcpAcceptOptions, bytesPool);
                await result.InitAsync();

                return(result);
            }
Exemplo n.º 24
0
 internal TcpConnector(TcpConnectOptions tcpConnectOptions, TcpAcceptOptions tcpAcceptOptions, IBytesPool bytesPool)
 {
     _tcpConnectOptions = tcpConnectOptions;
     _tcpAcceptOptions  = tcpAcceptOptions;
     _bytesPool         = bytesPool;
 }
Exemplo n.º 25
0
 public BytesPipe(IBytesPool bytesPool)
 {
     _state  = new BytesState(bytesPool);
     _reader = new BytesReader(_state);
     _writer = new BytesWriter(_state);
 }
Exemplo n.º 26
0
            public async ValueTask <AppState> CreateAsync(string stateDirectoryPath, string temporaryDirectoryPath, IBytesPool bytesPool)
            {
                var result = new AppState(stateDirectoryPath, temporaryDirectoryPath, bytesPool);
                await result.InitAsync();

                return(result);
            }
Exemplo n.º 27
0
 public AesGcmDecrypter(byte[] cryptoKey, byte[] nonce, IBytesPool bytesPool)
 {
     _aes       = new AesGcm(cryptoKey);
     _nonce     = nonce;
     _bytesPool = bytesPool;
 }
Exemplo n.º 28
0
            public IRemotingMessenger Create(IConnection connection, IRemotingMessageReceiver receiver, IBytesPool bytesPool)
            {
                var result = new RemotingMessenger(connection, receiver, bytesPool);

                return(result);
            }
Exemplo n.º 29
0
    public static OmniSecureConnection CreateV1(IConnection connection, IBytesPool bytesPool, V1.OmniSecureConnectionOptions options)
    {
        var secureConnection = new V1.Internal.SecureConnection(connection, bytesPool, options);

        return(new OmniSecureConnection(connection, secureConnection));
    }
 public ThumbnailCachesRepository(LiteDatabase database, IBytesPool bytesPool)
 {
     _database  = database;
     _bytesPool = bytesPool;
 }