Skip to content

Instantly share code, notes, and snippets.

View Drawaes's full-sized avatar

Tim Seaward Drawaes

  • Pltfm Limited
  • London
View GitHub Profile
public static async Task<ConnectionContext> AdapterForTls(Task<ConnectionContext> contextTask)
{
var provider = new OpenSsl11.OpenSslTlsProvider();
var context = await contextTask;
var tlsTransport = await provider.AuthenticateAsServer(context.Transport, new ServerOptions());
context.Transport = tlsTransport;
return context;
}
timan@DESKTOP-2NGO9EF C:\code\Leto\openssl
> openssl s_client -connect corefx-net-tls.azurewebsites.net:443 -msg
CONNECTED(000001B8)
>>> ??? [length 0005]
16 03 01 00 ef
>>> TLS 1.3, Handshake [length 00ef], ClientHello
01 00 00 eb 03 03 5f 5a c9 6b 1f 81 98 ce 19 1e
3f 65 6a 21 bf 42 f4 60 3a 43 fc a8 c6 c0 1d 93
be 6a 32 62 81 0d 00 00 3e c0 2c c0 30 00 9f cc
public class OperationCache<K,T>
{
private Func<K, Task<T>> _operation;
private Dictionary<K, Task<T>> _tasks = new Dictionary<K, Task<T>>();
public OperationCache(Func<K, Task<T>> operation) => _operation;
// Simple you can now just await on this task
// If it is already running, then you will await on it until
// it completes (it will only run once)
Stack depth 73
EndWrite at offset 168 in file:line:column /home/bench/corefx/src/System.Net.Security/src/System/Net/Security/SslStreamInternal.cs:188:17
<BeginEndWriteAsync>b__55_1 at offset 33 in file:line:column <filename unknown>:0:0
Complete at offset 72 in file:line:column <filename unknown>:0:0
FromAsyncTrim<TInstance,TArgs> at offset 249 in file:line:column <filename unknown>:0:0
BeginEndWriteAsync at offset 394 in file:line:column <filename unknown>:0:0
WriteAsync at offset 41 in file:line:column <filename unknown>:0:0
MoveNext at offset 1264 in file:line:column <filename unknown>:0:0
Run at offset 113 in file:line:column <filename unknown>:0:0
FlushAsync at offset 470 in file:line:column <filename unknown>:0:0
@Drawaes
Drawaes / ChildProgram.cs
Created August 15, 2017 18:45
Simple Socket Open Test
namespace ChildSocketProgram
{
class Program
{
static void Main(string[] args)
{
try
{
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
bench@ubuntudev:~/corefx$ ./build-native.sh
Tools are already initialized
Running: /home/bench/corefx/src/Native/build-native.sh x64 Debug Linux --numproc 4 -portable toolSetDir=c:\tools\clr
Setting up directories for build
Checking pre-requisites...
Commencing build of corefx native components for Linux.x64.Debug
Invoking cmake with arguments: "/home/bench/corefx/src/Native/Unix" DEBUG -DFEATURE_DISTRO_AGNOSTIC_SSL=1 -DCMAKE_STATIC_LIB_LINK=0
-- The C compiler identification is Clang 3.5.0
-- The CXX compiler identification is Clang 3.5.0
-- Check for working C compiler: /usr/bin/clang-3.5
@Drawaes
Drawaes / gist:c04cd6540de4ae1545f3bbe004ba9e6c
Created July 20, 2017 21:21
Build Output Failing on added function
Tools are already initialized
Running: /home/bench/corefx/src/Native/build-native.sh x64 Debug Linux --numproc 4 -portable toolSetDir=c:\tools\clr
Setting up directories for build
Checking pre-requisites...
Commencing build of corefx native components for Linux.x64.Debug
Invoking cmake with arguments: "/home/bench/corefx/src/Native/Unix" DEBUG -DFEATURE_DISTRO_AGNOSTIC_SSL=1 -DCMAKE_STATIC_LIB_LINK=0
-- The C compiler identification is Clang 3.5.0
-- The CXX compiler identification is Clang 3.5.0
-- Check for working C compiler: /usr/bin/clang-3.5
-- Check for working C compiler: /usr/bin/clang-3.5 -- works
@Drawaes
Drawaes / AuthenticationMiddleware.cs
Created July 3, 2017 13:54 — forked from aaronhoffman/AuthenticationMiddleware.cs
asp.net core AuthenticationMiddleware Dependency Injection
public class MyAuthenticationMiddleware : AuthenticationMiddleware<MyAuthenticationOptions>
{
public MyAuthenticationMiddleware(
IMyService myService, // inject service here?? (via Startup.ConfigureServices(), services.AddTransient() )
RequestDelegate next,
IOptions<MyAuthenticationOptions> options,
ILoggerFactory loggerFactory,
UrlEncoder encoder)
: base(next, options, loggerFactory, encoder)
{
using System;
using System.Collections.Generic;
namespace ConsoleApp2
{
public class ReloadingCache:IDisposable
{
private List<string> _cachedItems;
private System.Threading.Timer _timer;
private System.Threading.Mutex _mutex = new System.Threading.Mutex();
@Drawaes
Drawaes / Cache.cs
Last active May 20, 2017 23:19
Simple resetting cache
using System.Collections.Generic;
public class ReloadingCache
{
private List<string> _cachedItems;
private System.Threading.Timer _timer;
public ReloadingCache()
{
//Load the first lot of data to stop consumers getting null