├── .gitattributes
├── .github
└── workflows
│ ├── actions.yml
│ └── release.yml
├── .gitignore
├── LICENSE.md
├── README.md
├── certificate
├── README.md
├── bytewizer
│ ├── bytewizer.local
│ │ ├── bytewizer.local.crt
│ │ ├── bytewizer.local.key
│ │ ├── bytewizer.local.pem
│ │ └── bytewizer.local_key.pem
│ ├── bytewizer_root_ca.cer
│ └── bytewizer_root_ca.pem
├── create_certificate.ps1
├── openssl
│ ├── buildcert.cmd
│ ├── ca.cnf
│ ├── ca.crt
│ ├── ca.srl
│ ├── ca_privatekey.pem
│ ├── server.cnf
│ ├── server.csr
│ ├── server_v3.ext
│ ├── servercert.crt
│ └── serverkey.key
└── sample
│ ├── Bytewizer.TinyCLR.Secure
│ ├── Bytewizer.TinyCLR.Core.csproj
│ ├── Bytewizer.TinyCLR.Secure.csproj
│ ├── Bytewizer.TinyCLR.Secure.sln
│ ├── Middleware
│ │ ├── HttpResponse.cs
│ │ └── HttpResponseExtensions.cs
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
│ └── Bytewizer.TinyCLR.SslServer
│ ├── Bytewizer.TinyCLR.SslServer.csproj
│ ├── Bytewizer.TinyCLR.SslServer.sln
│ ├── Program.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
│ └── Resources
│ ├── servercert.crt
│ └── serverkey.key
├── images
├── favicon.bin
├── favicon.ico
├── package-logo.png
├── pipeline.jpeg
├── resources.jpg
└── telnet-server.jpg
├── playground
├── Bytewizer.TinyCLR.Playground.sln
├── auth
│ ├── Bytewizer.Playground.Authentication.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
├── blazor
│ ├── Bytewizer.Playground.Blazor.csproj
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── microsd-root.zip
│ └── packages.config
├── cookies
│ ├── Bytewizer.Playground.Cookies.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── app.config
│ └── packages.config
├── embedded
│ ├── Bytewizer.Playground.Embedded.csproj
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── 1280.bin
│ │ ├── 1920.bin
│ │ ├── 640.bin
│ │ ├── favicon.bin
│ │ └── image.bin
│ ├── app.config
│ └── packages.config
├── ftp
│ ├── Bytewizer.Playground.Ftp.csproj
│ ├── Middleware
│ │ └── FtpResponseExtensions.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ └── Resources
│ │ ├── servercert.crt
│ │ └── serverkey.key
├── hardware
│ ├── Bytewizer.TinyCLR.Hardware.csproj
│ ├── Hardware
│ │ ├── FlashObject.cs
│ │ ├── NetworkProvider.cs
│ │ ├── SettingsProvider.cs
│ │ └── StorageProvider.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── hosting
│ ├── Bytewizer.Playground.Hosting.csproj
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Startup.cs
│ ├── WorkerService1.cs
│ ├── WorkerService2.cs
│ └── app.config
├── http
│ ├── Bytewizer.Playground.Http.csproj
│ ├── Middleware
│ │ ├── HttpPerfMiddleware.cs
│ │ └── HttpPerfMiddlewareExtensions.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── favicon.bin
│ │ └── favicon.ico
│ ├── app.config
│ └── packages.config
├── json
│ ├── Bytewizer.Playground.Json.csproj
│ ├── Models
│ │ ├── DeviceModel.cs
│ │ ├── Gender.cs
│ │ └── Person.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── app.config
│ └── packages.config
├── mvc
│ ├── Bytewizer.Playground.Mvc.csproj
│ ├── Controllers
│ │ ├── ActionController.cs
│ │ ├── CircutController.cs
│ │ ├── ErrorController.cs
│ │ ├── HomeController.cs
│ │ └── JsonController.cs
│ ├── Models
│ │ ├── Gender.cs
│ │ └── Person.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── app.config
│ ├── microsd-root.zip
│ └── packages.config
├── nuget.config
├── pagebuilder
│ ├── Bytewizer.Playground.PageBuilder.csproj
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ └── favicon.bin
│ ├── app.config
│ └── packages.config
├── securesockets
│ ├── Bytewizer.Playground.Sockets.csproj
│ ├── Middleware
│ │ ├── HttpResponse.cs
│ │ └── HttpResponseExtensions.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── servercert.crt
│ │ └── serverkey.key
│ └── packages.config
├── sntp
│ ├── Bytewizer.Playground.Sntp.csproj
│ ├── Hardware
│ │ └── ClockProvider.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
├── sockets
│ ├── Bytewizer.Playground.Sockets.csproj
│ ├── Middleware
│ │ ├── HttpResponse.cs
│ │ └── HttpResponseExtensions.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── servercert.crt
│ │ └── serverkey.key
│ └── packages.config
├── ssl
│ ├── Bytewizer.Playground.Ssl.csproj
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── favicon.bin
│ │ ├── servercert.crt
│ │ └── serverkey.key
│ ├── app.config
│ └── packages.config
├── staticfiles
│ ├── Bytewizer.Playground.StaticFiles.csproj
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── favicon.bin
│ │ └── image.bin
│ ├── app.config
│ ├── microsd-root.zip
│ └── packages.config
├── terminal
│ ├── Bytewizer.Playground.Terminal.csproj
│ ├── Commands
│ │ ├── HelloCommand.cs
│ │ └── LedCommand.cs
│ ├── Extensions
│ │ └── FilterContextExtensions.cs
│ ├── Hardware
│ │ ├── GpioLed.cs
│ │ ├── StatusLed.cs
│ │ └── StatusProvider.cs
│ ├── Middleware
│ │ └── FtpResponseExtensions.cs
│ ├── Program.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
└── websocket
│ ├── Bytewizer.Playground.WebSocket.csproj
│ ├── Hubs
│ └── ChatHub.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── app.config
│ └── packages.config
├── samples
└── src
│ ├── DuinoAPI
│ ├── Bytewizer.DuinoAPI.sln
│ ├── BytewizerTinyCLR.DuinoAPI.csproj
│ ├── Controllers
│ │ └── JsonController.cs
│ ├── Hardware
│ │ └── NetworkProvider.cs
│ ├── Models
│ │ ├── DeviceModel.cs
│ │ └── NetworkModel.cs
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── packages.config
│ ├── DuinoEmbedded
│ ├── Bytewizer.TinyCLR.DuinoEmbedded.sln
│ ├── BytewizerTinyCLR.DuinoEmbedded.csproj
│ ├── Hardware
│ │ ├── ClockProvider.cs
│ │ ├── NetworkProvider.cs
│ │ └── StorageProvider.cs
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── favicon.bin
│ │ └── image.bin
│ ├── embeded-files.zip
│ ├── nuget.config
│ └── packages.config
│ └── DuinoWeb
│ ├── Bytewizer.TinyCLR.DuinoWeb.sln
│ ├── BytewizerTinyCLR.DuinoWeb.csproj
│ ├── Hardware
│ ├── ClockProvider.cs
│ ├── NetworkProvider.cs
│ └── StorageProvider.cs
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── microsd-root.zip
│ └── packages.config
└── src
├── .editorconfig
├── Bytewizer.TinyCLR.Microserver.sln
├── Bytewizer.TinyCLR.Microserver.wip
├── Directory.Build.props
├── Directory.Build.targets
├── ftp
├── Bytewizer.TinyCLR.Ftp.Authentication
│ ├── Bytewizer.TinyCLR.Ftp.Authentication.csproj
│ ├── Middleware
│ │ ├── AuthenticationMiddleware.cs
│ │ ├── AuthenticationMiddlewareExtensions.cs
│ │ └── AuthenticationOptions.cs
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Bytewizer.TinyCLR.Ftp
│ ├── Bytewizer.TinyCLR.Ftp.csproj
│ ├── Channel
│ │ ├── ActiveDataChannel.cs
│ │ └── PassiveDataChannel.cs
│ ├── Extensions
│ │ ├── DateTimeExtensions.cs
│ │ └── DiagnosticsLoggerExtensions.cs
│ ├── Features
│ │ └── SessionFeature.cs
│ ├── File
│ │ └── FileProvider.cs
│ ├── Ftp
│ │ ├── DataMode.cs
│ │ ├── FtpCommand.cs
│ │ ├── FtpContext.cs
│ │ ├── FtpRequest.cs
│ │ ├── FtpResponse.cs
│ │ ├── FtpResponseExtensions.cs
│ │ ├── RequestDelegate.cs
│ │ ├── SecurityType.cs
│ │ ├── StructureType.cs
│ │ ├── TransferMode.cs
│ │ └── TransferType.cs
│ ├── FtpSession
│ │ ├── Commands
│ │ │ ├── Appe.cs
│ │ │ ├── Auth.cs
│ │ │ ├── Cdup.cs
│ │ │ ├── Cwd.cs
│ │ │ ├── Dele.cs
│ │ │ ├── Eprt.cs
│ │ │ ├── Epsv.cs
│ │ │ ├── Feat.cs
│ │ │ ├── Help.cs
│ │ │ ├── List.cs
│ │ │ ├── Mdtm.cs
│ │ │ ├── Mkd.cs
│ │ │ ├── Mlsd.cs
│ │ │ ├── Mlst.cs
│ │ │ ├── Mode.cs
│ │ │ ├── Nlst.cs
│ │ │ ├── Noop.cs
│ │ │ ├── Opts.cs
│ │ │ ├── Pass.cs
│ │ │ ├── Pasv.cs
│ │ │ ├── Pbsz.cs
│ │ │ ├── Port.cs
│ │ │ ├── Prot.cs
│ │ │ ├── Pwd.cs
│ │ │ ├── Quit.cs
│ │ │ ├── Rest.cs
│ │ │ ├── Retr.cs
│ │ │ ├── Rmd.cs
│ │ │ ├── Rnfr.cs
│ │ │ ├── Rnto.cs
│ │ │ ├── Size.cs
│ │ │ ├── Stor.cs
│ │ │ ├── Stru.cs
│ │ │ ├── Syst.cs
│ │ │ ├── Type.cs
│ │ │ └── User.cs
│ │ ├── FtpSession.cs
│ │ └── ListArguments.cs
│ ├── Middleware
│ │ ├── FtpMiddleware.cs
│ │ └── Middleware.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── Server
│ │ ├── FtpServer.cs
│ │ ├── FtpServerOptions.cs
│ │ ├── FtpServerOptionsDelegate.cs
│ │ ├── FtpServerOptionsExtensions.cs
│ │ └── SecurityMethod.cs
└── README.md
├── hosting
└── Bytewizer.TinyCLR.Hosting
│ ├── Bytewizer.TinyCLR.Hosting.csproj
│ ├── Hosting
│ ├── BackgroundService.cs
│ ├── Delegates.cs
│ ├── Host.cs
│ ├── HostBuilder.cs
│ ├── HostBuilderContext.cs
│ ├── HostingAbstractionsHostExtensions.cs
│ ├── HostingHostBuilderExtensions.cs
│ ├── HostingLoggerExtensions.cs
│ ├── IConfigureContainerAdapter.cs
│ ├── IHost.cs
│ ├── IHostBuilder.cs
│ ├── IHostedService.cs
│ ├── Internal
│ │ └── Host.cs
│ ├── ServiceCollectionHostedServiceExtensions.cs
│ └── ServiceContextDelegate.cs
│ ├── Http
│ ├── ConfigureWebHostDefaults.cs
│ ├── GenericWebHostedService.cs
│ ├── HttpServiceCollectionExtensions.cs
│ ├── IWebHostBuilder.cs
│ ├── WebHostBuilderExtensions.cs
│ └── internal
│ │ └── WebHostBuilder.cs
│ ├── Logging
│ ├── DebugLoggerFactoryExtensions.cs
│ ├── ILoggingBuilder.cs
│ ├── Internal
│ │ ├── LoggerEventIds.cs
│ │ └── LoggingBuilder.cs
│ ├── LoggingBuilderDelegate.cs
│ ├── LoggingBuilderExtensions.cs
│ └── LoggingServiceCollectionExtensions.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── README.md
├── http
├── Bytewizer.TinyCLR.Http.Authentication
│ ├── Authenticator
│ │ ├── AuthenticateResult.cs
│ │ ├── BasicAuthenticationProvider.cs
│ │ └── DigestAuthenticationProvider.cs
│ ├── Bytewizer.TinyCLR.Http.Authentication.csproj
│ ├── Features
│ │ ├── HttpAuthenticationFeature.cs
│ │ └── IHttpAuthenticationFeature.cs
│ ├── Http
│ │ ├── AuthHelper.cs
│ │ ├── HttpContextExtensions.cs
│ │ ├── IAuthenticationProvider.cs
│ │ └── IdentityProviderExtensions.cs
│ ├── Middleware
│ │ ├── AuthenticationMiddleware.cs
│ │ ├── AuthenticationMiddlewareExtensions.cs
│ │ └── AuthenticationOptions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.Cookies
│ ├── Bytewizer.TinyCLR.Http.Cookies.csproj
│ ├── Http
│ │ ├── Cookies
│ │ │ ├── CookieCollection.cs
│ │ │ ├── CookieEnumerator.cs
│ │ │ ├── CookieParser.cs
│ │ │ ├── CookieValue.cs
│ │ │ ├── ICookieCollection.cs
│ │ │ └── IResponseCookies.cs
│ │ └── HttpContextExtensions.cs
│ ├── Middleware
│ │ ├── CookiesMiddleware.cs
│ │ ├── CookiesMiddlewareExtensions.cs
│ │ └── Features
│ │ │ ├── HttpCookiesFeature.cs
│ │ │ └── IHttpCookiesFeature.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.Cors
│ ├── Bytewizer.TinyCLR.Http.Cors.csproj
│ ├── Middleware
│ │ ├── CorsMiddleware.cs
│ │ ├── CorsMiddlewareExtensions.cs
│ │ ├── CorsOptions.cs
│ │ └── ParsingHelpers.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.Diagnostics
│ ├── Bytewizer.TinyCLR.Http.Diagnostics.csproj
│ ├── Middleware
│ │ ├── DeveloperExceptionPageExtensions.cs
│ │ ├── DeveloperExceptionPageMiddleware.cs
│ │ ├── DeveloperExceptionPageOptions.cs
│ │ ├── MemoryInfoMiddleware.cs
│ │ └── MemoryInfoMiddlewareExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.Hosting
│ ├── Bytewizer.TinyCLR.Http.Hosting.csproj
│ └── Properties
│ │ └── AssemblyInfo.cs
├── Bytewizer.TinyCLR.Http.Json
│ ├── Bytewizer.TinyCLR.Http.Json.csproj
│ ├── Http
│ │ ├── HttpRequestExtensions.cs
│ │ └── HttpResponseExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.Mvc
│ ├── ActionResults
│ │ ├── ActionResult.cs
│ │ ├── BadRequestResult.cs
│ │ ├── ContentResult.cs
│ │ ├── EmptyResult.cs
│ │ ├── FileResult.cs
│ │ ├── FileStreamResult.cs
│ │ ├── JsonResult.cs
│ │ ├── NotFoundResult.cs
│ │ ├── OkResult.cs
│ │ ├── RedirectResult.cs
│ │ ├── StatusCodeResult.cs
│ │ └── ViewResult.cs
│ ├── Bytewizer.TinyCLR.Http.Mvc.csproj
│ ├── Filters
│ │ ├── ActionExecutedContext.cs
│ │ ├── ActionExecutingContext.cs
│ │ ├── ExceptionContext.cs
│ │ └── FilterContext.cs
│ ├── Http
│ │ └── Route.cs
│ ├── ModelBinding
│ │ ├── IModelBinder.cs
│ │ ├── IModelBinderContext.cs
│ │ ├── IValueProvider.cs
│ │ ├── ModelBinderContext.cs
│ │ ├── ModelBindingException.cs
│ │ ├── ModelMapper.cs
│ │ ├── PrimitiveModelBinder.cs
│ │ └── RequestValueProvider.cs
│ ├── Mvc
│ │ ├── ActionContext.cs
│ │ ├── ActionDescriptor.cs
│ │ ├── Controller.cs
│ │ ├── ControllerActionDescriptor.cs
│ │ ├── ControllerBase.cs
│ │ ├── ControllerContext.cs
│ │ └── IActionResult.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── README.md
│ ├── Routing
│ │ ├── ControllerEndpointRouteBuilderExtensions.cs
│ │ └── Internal
│ │ │ ├── ControllerDelegateFactory.cs
│ │ │ └── ControllerEndpointProvider.cs
│ └── Stubble
│ │ ├── ClosingElement.cs
│ │ ├── FieldExtensions.cs
│ │ ├── SerializedView.cs
│ │ ├── ViewCache.cs
│ │ ├── ViewChild.cs
│ │ ├── ViewData.cs
│ │ ├── ViewDictionary.cs
│ │ ├── ViewElement.cs
│ │ ├── ViewEngine.cs
│ │ └── ViewPartial.cs
├── Bytewizer.TinyCLR.Http.PageBuilder
│ ├── Bytewizer.TinyCLR.Http.PageBuilder.csproj
│ ├── Http
│ │ └── HttpResponseExtensions.cs
│ ├── PageBuilder
│ │ ├── HtmlBody.cs
│ │ ├── HtmlHead.cs
│ │ └── HtmlPage.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.ResourceManager
│ ├── Bytewizer.TinyCLR.Http.ResourceManager.csproj
│ ├── Http
│ │ ├── HttpContextExtensions.cs
│ │ ├── HttpResponseExtensions.cs
│ │ └── ResourceStream.cs
│ ├── Middleware
│ │ ├── Features
│ │ │ ├── IResourceManagerFeature.cs
│ │ │ └── ResourceManagerFeature.cs
│ │ ├── ResourceMiddleware.cs
│ │ └── UseResourcesExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.StaticFiles.Blazor
│ ├── Bytewizer.TinyCLR.Http.StaticFiles.Blazor.csproj
│ ├── Middleware
│ │ ├── BlazorFrameworkExtensions.cs
│ │ └── BlazorFrameworkMiddleware.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.StaticFiles.Resources
│ ├── Bytewizer.TinyCLR.Http.StaticFiles.Resources.csproj
│ ├── Middleware
│ │ ├── ResourceFileExtensions.cs
│ │ ├── ResourceFileMiddleware.cs
│ │ └── ResourceFileOptions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.StaticFiles
│ ├── Bytewizer.TinyCLR.Http.StaticFiles.csproj
│ ├── CONTENTTYPES.md
│ ├── Http
│ │ ├── DefaultContentTypeProvider.cs
│ │ └── IContentTypeProvider.cs
│ ├── Middleware
│ │ ├── DefaultFilesExtensions.cs
│ │ ├── DefaultFilesMiddleware.cs
│ │ ├── DefaultFilesOptions.cs
│ │ ├── FileServerExtensions.cs
│ │ ├── StaticFileExtensions.cs
│ │ ├── StaticFileMiddleware.cs
│ │ └── StaticFileOptions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Http.WebSocket
│ ├── Bytewizer.TinyCLR.Http.WebSockets.csproj
│ ├── Extensions
│ │ ├── ByteArrayExtensions.cs
│ │ ├── ByteOrder.cs
│ │ └── StreamExtensions.cs
│ ├── Features
│ │ ├── HttpWebSocketFeature.cs
│ │ └── IHttpWebSocketFeature.cs
│ ├── Http
│ │ └── HttpContextExtensions.cs
│ ├── Middleware
│ │ ├── WebSocketMiddleware.cs
│ │ ├── WebSocketMiddlewareExtensions.cs
│ │ └── WebSocketOptions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── README.md
│ ├── Routing
│ │ ├── HubEndpointRouteBuilderExtensions.cs
│ │ └── Internal
│ │ │ ├── HubDelegateFactory.cs
│ │ │ └── HubEndpointProvider.cs
│ └── WebSockets
│ │ ├── Clients
│ │ ├── Clients.All.cs
│ │ ├── Clients.Caller.cs
│ │ ├── Clients.Others.cs
│ │ ├── Clients.cs
│ │ ├── IClientsAll.cs
│ │ ├── IClientsCaller.cs
│ │ └── IClientsOthers.cs
│ │ ├── CloseStatusCode.cs
│ │ ├── Hub.cs
│ │ ├── HubCallerContext.cs
│ │ ├── IHub.cs
│ │ ├── WebSocket.cs
│ │ ├── WebSocketContext.cs
│ │ ├── WebSocketState.cs
│ │ └── internal
│ │ ├── Fin.cs
│ │ ├── Mask.cs
│ │ ├── Opcode.cs
│ │ ├── OpcodeExtensions.cs
│ │ ├── PayloadData.cs
│ │ ├── Rsv.cs
│ │ └── WebSocketFrame.cs
├── Bytewizer.TinyCLR.Http
│ ├── Bytewizer.TinyCLR.Http.csproj
│ ├── Extensions
│ │ ├── CharExtensions.cs
│ │ ├── DiagnosticsLoggerExtensions.cs
│ │ ├── StreamReaderExtensions.cs
│ │ └── StringExtensions.cs
│ ├── Http
│ │ ├── Header
│ │ │ ├── HeaderDictionary.cs
│ │ │ ├── HeaderEnumerator.cs
│ │ │ ├── HeaderValue.cs
│ │ │ └── IHeaderDictionary.cs
│ │ ├── HeaderNames.cs
│ │ ├── HttpContext.cs
│ │ ├── HttpContextExtensions.cs
│ │ ├── HttpMethods.cs
│ │ ├── HttpProtocol.cs
│ │ ├── HttpRequest.cs
│ │ ├── HttpRequestExtensions.cs
│ │ ├── HttpResponse.cs
│ │ ├── HttpResponseExtensions.cs
│ │ ├── Middleware.cs
│ │ ├── Query
│ │ │ ├── IQueryCollection.cs
│ │ │ ├── QueryCollection.cs
│ │ │ ├── QueryEnumerator.cs
│ │ │ ├── QueryParser.cs
│ │ │ └── QueryValue.cs
│ │ ├── RequestDelegate.cs
│ │ └── StatusCodes.cs
│ ├── Internal
│ │ ├── DateTimeHelper.cs
│ │ ├── HttpMessage.cs
│ │ ├── HttpMiddleware.cs
│ │ ├── HttpReasonPhrase.cs
│ │ └── UriHelper.cs
│ ├── Middleware
│ │ ├── Features
│ │ │ ├── IStatusCodePagesFeature.cs
│ │ │ └── StatusCodePagesFeature.cs
│ │ ├── Routing
│ │ │ ├── EndpointMiddleware.cs
│ │ │ ├── EndpointRoutingExtensions.cs
│ │ │ └── EndpointRoutingMiddleware.cs
│ │ ├── StatusCodePagesExtensions.cs
│ │ ├── StatusCodePagesMiddleware.cs
│ │ ├── StatusCodePagesOptions.cs
│ │ ├── UseMiddlewareExtensions.cs
│ │ ├── UsePathBaseExtensions.cs
│ │ └── UsePathBaseMiddleware.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Routing
│ │ ├── Endpoint.cs
│ │ ├── EndpointBuilder.cs
│ │ ├── EndpointRouteBuilderExtensions.cs
│ │ ├── EndpointRouteDelegate.cs
│ │ ├── Features
│ │ │ ├── EndpointFeature.cs
│ │ │ └── IEndpointFeature.cs
│ │ ├── IEndpointRouteBuilder.cs
│ │ ├── Internal
│ │ │ └── DefaultEndpointRouteBuilder.cs
│ │ ├── RouteEndpoint.cs
│ │ └── RouteEndpointBuilder.cs
│ └── Server
│ │ ├── HttpServer.cs
│ │ ├── HttpServerLimits.cs
│ │ └── HttpServerOptions.cs
└── README.md
├── nuget.config
├── sntp
├── Bytewizer.TinyCLR.Sntp
│ ├── Bytewizer.TinyCLR.Sntp.csproj
│ ├── Extensions
│ │ └── DiagnosticsLoggerExtensions.cs
│ ├── Internal
│ │ └── IPAddressHelper.cs
│ ├── Middleware
│ │ ├── SntpMiddleware.cs
│ │ └── SntpMiddlewareExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Server
│ │ ├── SntpServer.cs
│ │ ├── SntpServerOptions.cs
│ │ └── SntpServerOptionsDelegate.cs
│ └── Sntp
│ │ ├── LeapIndicator.cs
│ │ ├── NtpClient.cs
│ │ ├── NtpMode.cs
│ │ ├── NtpPacket.cs
│ │ ├── ReferenceId.cs
│ │ ├── Stratum.cs
│ │ └── VersionNumber.cs
└── README.md
├── sockets
├── Bytewizer.TinyCLR.Sockets.Filtering
│ ├── Bytewizer.TinyCLR.Sockets.Filtering.csproj
│ ├── Filtering
│ │ └── CidrNotation.cs
│ ├── Middleware
│ │ ├── IpFilteringMiddleware.cs
│ │ └── IpFilteringMiddlewareExtensions.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── README.md
├── Bytewizer.TinyCLR.Sockets.TcpClient
│ ├── Bytewizer.TinyCLR.Sockets.TcpClient.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── README.md
│ └── TcpClient
│ │ └── TcpClient.cs
├── Bytewizer.TinyCLR.Sockets.UdpClient
│ ├── Bytewizer.TinyCLR.Sockets.UdpClient.csproj
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── README.md
│ └── UdpClient
│ │ ├── MulticastOption.cs
│ │ └── UdpClient.cs
├── Bytewizer.TinyCLR.Sockets
│ ├── Bytewizer.TinyCLR.Sockets.csproj
│ ├── Channel
│ │ ├── ConnectionInfo.cs
│ │ ├── LoggerStream.cs
│ │ ├── SocketChannel.cs
│ │ └── SslStreamBuilder.cs
│ ├── Extensions
│ │ ├── DiagnosticsLoggerExtensions.cs
│ │ └── SocketExceptionExtensions.cs
│ ├── Listeners
│ │ ├── SocketListener.cs
│ │ ├── SocketListenerOptions.cs
│ │ ├── SocketListenerOptionsDelegate.cs
│ │ ├── TcpListener.cs
│ │ └── UdpListener.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Server
│ │ ├── IServerOptions.cs
│ │ ├── ServerLimits.cs
│ │ ├── ServerOptions.cs
│ │ ├── ServerOptionsDelegate.cs
│ │ └── SocketServer.cs
│ └── Sockets
│ │ ├── ConnectedHandler.cs
│ │ ├── DisconnectedHandler.cs
│ │ ├── ISocketContext.cs
│ │ ├── SocketContext.cs
│ │ ├── SocketErrorHandler.cs
│ │ ├── SocketListenerOptionsExtensions.cs
│ │ └── SocketService.cs
└── README.md
└── terminal
├── Bytewizer.TinyCLR.Terminal.Ansi
├── Ansi
│ ├── AnsiBackgroundColor.cs
│ ├── AnsiForegroundColor.cs
│ ├── AnsiHandler.cs
│ └── AnsiTextAttribute.cs
├── Bytewizer.TinyCLR.Terminal.Ansi.csproj
├── Extensions
│ └── StringBuilderExtensions.cs
└── Properties
│ └── AssemblyInfo.cs
├── Bytewizer.TinyCLR.Terminal.Authentication
├── Bytewizer.TinyCLR.Terminal.Authentication.csproj
├── Middleware
│ ├── AuthenticationMiddleware.cs
│ ├── AuthenticationMiddlewareExtensions.cs
│ └── AuthenticationOptions.cs
└── Properties
│ └── AssemblyInfo.cs
├── Bytewizer.TinyCLR.Terminal.Console
├── Bytewizer.TinyCLR.Terminal.Console.csproj
├── Channel
│ ├── ConsoleChannel.cs
│ └── ConsoleErrorHandler.cs
├── Console
│ ├── ConsoleContext.cs
│ └── ConsoleSession.cs
├── Extensions
│ └── DiagnosticsLoggerExtensions.cs
├── Middleware
│ ├── CommandExtensions.cs
│ └── ConsoleMiddleware.cs
├── Properties
│ └── AssemblyInfo.cs
└── Server
│ ├── ConsoleServer.cs
│ ├── ConsoleServerOptions.cs
│ └── ConsoleServerOptionsDelegate.cs
├── Bytewizer.TinyCLR.Terminal.Ssh
├── Bytewizer.TinyCLR.Terminal.Ssh.csproj
├── Properties
│ └── AssemblyInfo.cs
└── Terminal
│ ├── Algorithms
│ ├── CompressionAlgorithm.cs
│ ├── EncryptionAlgorithm.cs
│ ├── HmacAlgorithm.cs
│ ├── KexAlgorithm.cs
│ ├── NoCompression.cs
│ ├── NoEncryption.cs
│ ├── PublicKeyAlgorithm.cs
│ ├── RandomNumberGenerator.cs
│ ├── RsaKey.cs
│ └── Sha1HmacAlgorithm.cs
│ ├── DisconnectReason.cs
│ ├── Exceptions
│ └── ConnectionException.cs
│ ├── Messages
│ ├── Connection
│ │ └── ChannelRequestMessage.cs
│ ├── ConnectionServiceMessage.cs
│ ├── DisconnectMessage.cs
│ ├── KeyExchangeDhInitMessage.cs
│ ├── KeyExchangeDhReplyMessage.cs
│ ├── KeyExchangeInitMessage.cs
│ ├── Message.cs
│ ├── NewKeysMessage.cs
│ ├── ServiceAcceptMessage.cs
│ ├── ServiceRequestMessage.cs
│ ├── UnimplementedMessage.cs
│ ├── UnknownMessage.cs
│ ├── Userauth
│ │ ├── FailureMessage.cs
│ │ ├── PasswordRequestMessage.cs
│ │ ├── PublicKeyOkMessage.cs
│ │ ├── PublicKeyRequestMessage.cs
│ │ ├── RequestMessage.cs
│ │ └── SuccessMessage.cs
│ ├── UserauthServiceMessage.cs
│ └── WindowChangeMessage.cs
│ ├── SecureShellSession.cs
│ └── SshDataWorker.cs
├── Bytewizer.TinyCLR.Terminal.Telnet
├── Bytewizer.TinyCLR.Terminal.Telnet.csproj
├── Channel
│ ├── SecureShellReader.cs
│ └── TerminalStream.cs
├── Extensions
│ └── DiagnosticsLoggerExtensions.cs
├── Middleware
│ ├── CommandExtensions.cs
│ └── TelnetMiddleware.cs
├── Properties
│ └── AssemblyInfo.cs
├── Server
│ ├── TelnetServer.cs
│ ├── TelnetServerOptions.cs
│ └── TelnetServerOptionsDelegate.cs
└── Terminal
│ ├── TelnetContext.cs
│ └── TelnetSession.cs
├── Bytewizer.TinyCLR.Terminal
├── Bytewizer.TinyCLR.Terminal.csproj
├── Commands
│ ├── ActionContext.cs
│ ├── ActionDescriptor.cs
│ ├── ActionResults
│ │ ├── ActionResult.cs
│ │ ├── BufferResponseResult
│ │ │ ├── BufferDirection.cs
│ │ │ ├── BufferResponseResult.cs
│ │ │ └── OutputBuffer.cs
│ │ ├── ClearResult.cs
│ │ ├── EmptyResult.cs
│ │ ├── IActionResult.cs
│ │ └── ResponseResult.cs
│ ├── Builtin
│ │ ├── ClearCommand.cs
│ │ ├── ExitCommand.cs
│ │ ├── HelpCommand.cs
│ │ └── WhoamiCommand.cs
│ ├── CommandActionDescriptor.cs
│ ├── CommandContext.cs
│ ├── CommandContextExtensions.cs
│ ├── Endpoint.cs
│ ├── Filters
│ │ ├── ActionExecutedContext.cs
│ │ ├── ActionExecutingContext.cs
│ │ ├── ExceptionContext.cs
│ │ └── FilterContext.cs
│ ├── Internal
│ │ ├── CommandDelegateFactory.cs
│ │ ├── EndpointProvider.cs
│ │ └── ModelMapper.cs
│ └── ServerCommand.cs
├── Extensions
│ └── ByteArrayExtensions.cs
├── Features
│ ├── EndpointFeature.cs
│ ├── SecureShellFeature.cs
│ └── SessionFeature.cs
├── Middleware
│ ├── AutoMappingMiddleware.cs
│ ├── AutoMappingMiddlewareExtensions.cs
│ ├── CommandExtensions.cs
│ ├── EndpointMiddleware.cs
│ ├── EndpointMiddlewareExtensions.cs
│ └── Middleware.cs
├── Numerics
│ └── RandomNumberGenerator.cs
├── Properties
│ └── AssemblyInfo.cs
├── Server
│ └── TerminalServerOptions.cs
├── Terminal
│ ├── AnsiSequences.cs
│ ├── ArgumentParser.cs
│ ├── CommandLine.cs
│ ├── ITerminalContext.cs
│ ├── TerminalContext.cs
│ ├── TerminalContextExtensions.cs
│ ├── TerminalOptions.cs
│ ├── TerminalRequest.cs
│ ├── TerminalResponse.cs
│ └── TerminalResponseExtensions.cs
└── Text
│ └── ASCIIEncoding.cs
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/certificate/README.md:
--------------------------------------------------------------------------------
1 | # Self-signed SSL certificate
2 |
3 | Install the following browsers certs from the "bytewizer.local" directory by clicking on both files:
4 |
5 | * bytewizer.local.cer - Install domain certificate to the current user store.
6 | * bytewizer.local.pfx - Install CA certificate to the Trusted Root Certification Authorities (required elevated privileges) with password of "bytewizer.local".
7 |
8 | To create your own self signed certs install OpenSSL (https://slproweb.com/products/Win32OpenSSL.html) and check out the create_certificate.ps1 powershell script. See
9 | https://github.com/henrikstengaard/hst-tools/tree/master/ssl for more information on this script.
10 |
11 | ```console
12 | .\create_certificate.ps1 -rootCaName 'Bytewizer' -domainDnsName '*.bytewizer.local' -outputDir '.\'
13 | ```
14 |
15 | Running script will create the following files that can be added as Binary Resources "files" in your Visual Studio Project.
16 |
17 | * bytewizer.local_key.pem - Private key used to generate domain certificate in pkcs12 format.
18 | * bytewizer.local.pem - Domain certificate in pkcs12 format.
19 |
--------------------------------------------------------------------------------
/certificate/bytewizer/bytewizer_root_ca.cer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/certificate/bytewizer/bytewizer_root_ca.cer
--------------------------------------------------------------------------------
/certificate/bytewizer/bytewizer_root_ca.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDMDCCAhigAwIBAgIQLKeF/7VztphOkIlVq+BxQTANBgkqhkiG9w0BAQsFADAc
3 | MRowGAYDVQQDDBFCeXRld2l6ZXIgUm9vdCBDQTAeFw0yMDA1MDkyMTM4MzdaFw0y
4 | NTA1MDkyMTQ4MzdaMBwxGjAYBgNVBAMMEUJ5dGV3aXplciBSb290IENBMIIBIjAN
5 | BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxAuIqgIXrg+cPe1EXb9Z13zS+Kc1
6 | 2hhtsXqayu/H+Brkqyyv58+wahZwCV3FY9nB+/YUSgEawcrmB7q3hW7fnyDTK4pd
7 | 6D0muPRAV5xQ9g1kKSpSL3fwZNP0umzlVff+qQah6nwgTDqVtfmfPifL1TklKkYG
8 | eDf/qBUXckwTbDrOsdXf74t5ez0UpULvAx8uTBNvK+fap04+o8AJ359L1K966IwR
9 | sZLskE32vb4NsrXqIf9m9tsKeuR2Ib/RM2N+hCqExKdnCAVrCVmaieIH5GDlIROX
10 | fWNzY8bWuuC+LfbDb7jg01TGekL0dJw4nCwFI+e60AeItGYcNAAdtY/EBQIDAQAB
11 | o24wbDAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUF
12 | BwMBMBwGA1UdEQQVMBOCEUJ5dGV3aXplciBSb290IENBMB0GA1UdDgQWBBRqYN0k
13 | iIKAsdcHVXdOZC3fQyiasDANBgkqhkiG9w0BAQsFAAOCAQEAQqiIcHdUr5vbcMYy
14 | ZzMS79PTDqI7i7jWlgJ+jvjJq8926uDhYD5RSM/7+57cIXIM8V/GVDOfBQ/CiyrZ
15 | n6+Cz9MDXBZ2EidOtW5kKnZgFohKQcZ4pDYlfaNRGAxL26sbgj3F1BVjAMgncng4
16 | 1Cu0UoFRhRmFKJo8DTFQqDx4rpRzq2ekUoaFgas1nNNW7y49XPRVIBTdMSdiV2Pc
17 | oY327rpbW/24qBzL9oco61ZZRdzaprNF3iQJKfCvYQ4sm2jBN27vJnmQ7cN/WqQ4
18 | 5kNGdK3/7N3SvxOICEGgWVRCBKuQ2iz92SyI/WpyAumBpZikOQTNSp1RkfgNOs2R
19 | OJi1cg==
20 | -----END CERTIFICATE-----
21 |
--------------------------------------------------------------------------------
/certificate/openssl/buildcert.cmd:
--------------------------------------------------------------------------------
1 | "C:\Program Files\OpenSSL-Win64\bin\openssl.exe" genrsa -out ca_privatekey.pem 2048
2 | "C:\Program Files\OpenSSL-Win64\bin\openssl.exe" req -new -x509 -days 3650 -nodes -key ca_privatekey.pem -sha256 -out ca.crt -config ca.cnf
3 | "C:\Program Files\OpenSSL-Win64\bin\openssl.exe" req -new -nodes -out server.csr -keyout serverkey.key -config server.cnf
4 | "C:\Program Files\OpenSSL-Win64\bin\openssl.exe" x509 -req -in server.csr -CA ca.crt -CAkey ca_privatekey.pem -CAcreateserial -out servercert.crt -days 365 -extfile server_v3.ext
--------------------------------------------------------------------------------
/certificate/openssl/ca.cnf:
--------------------------------------------------------------------------------
1 | [req]
2 | prompt = no
3 | distinguished_name = req_distinguished_name
4 |
5 | [req_distinguished_name]
6 | C = US
7 | ST = CA
8 | L = Orange County
9 | O = Bytewizer
--------------------------------------------------------------------------------
/certificate/openssl/ca.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIDEzCCAfsCFEhAoS/Umvf8CuPfJSzY8HQQfn1ZMA0GCSqGSIb3DQEBCwUAMEYx
3 | CzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNT3JhbmdlIENvdW50
4 | eTESMBAGA1UECgwJQnl0ZXdpemVyMB4XDTIxMTEyODIzMDkyOFoXDTMxMTEyNjIz
5 | MDkyOFowRjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1PcmFu
6 | Z2UgQ291bnR5MRIwEAYDVQQKDAlCeXRld2l6ZXIwggEiMA0GCSqGSIb3DQEBAQUA
7 | A4IBDwAwggEKAoIBAQDJHkP+ESvMtd4t422JpaWMVacYyMzNzfNTASBCUnAk1hZW
8 | xAqWFVGUIiVaPeYrvBGHEbySOqk7uB2Pi7V1Qnc7lsUOG0wDDnbOYOmDgnv7+FMj
9 | HjP1AKuJEO7qQtwYm7wu+DqEiVIOlb3R6crO+/4vb2WZsGJcNylcluLmPyLdB//U
10 | 6jTaCAg5MCRr/ftFWC0kh9sA8FpUUHqSb3uDZako2Bys3DBNOcNPVaIdnhgqefPE
11 | GHypzLxTvZIrRFQSTsMPKomWDKPr8oni0G+mth72oXaCiuOvYVi6CcpRuvEVw1eY
12 | 3uDzSd9g7sRV2ZMTkdlxwXmjVv/lam/iSyXSrOdPAgMBAAEwDQYJKoZIhvcNAQEL
13 | BQADggEBAEmfBYezLSH4nEhDRv92f534EIw/dAY2NHOI1SkZzFpycRM2zVimmnw9
14 | kV/lfqWMVtnFQ9euAGs+8F8eJhnMJPZlLNG5/rrp8+kU+35Yh1clGGSLoZJ/1JcQ
15 | sF0C6Sfc5rgdFSalJOIvAtmuM93XaOe2GTKNwImwz3M7qXWiwgbYmrh6QluFGRpT
16 | a3js8JIzcbxOAq83nwdhKavRkRtvoFw+Zcu7OQOcsvVdThKIyfayEShDl2xaljv9
17 | D6z6P3hrseKXhtJJEOlfoQw45l2lBW3cUvqJamX1BkeZOo4LO22k6mvNOOeHCROM
18 | 8121/QcHp2SxjhIv4JU3lMjQUZE0Cuo=
19 | -----END CERTIFICATE-----
20 |
--------------------------------------------------------------------------------
/certificate/openssl/ca.srl:
--------------------------------------------------------------------------------
1 | 12CAE08C6E320CE631333D56C8666175E38A7C2C
2 |
--------------------------------------------------------------------------------
/certificate/openssl/server.cnf:
--------------------------------------------------------------------------------
1 | [req]
2 | default_bits = 2048
3 | prompt = no
4 | default_md = sha256
5 | distinguished_name = req_distinguished_name
6 |
7 | [req_distinguished_name]
8 | C = AT
9 | ST = CA
10 | L = Orange County
11 | O = Bytewizer
12 | CN = MS200
--------------------------------------------------------------------------------
/certificate/openssl/server.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIICmzCCAYMCAQAwVjELMAkGA1UEBhMCQVQxCzAJBgNVBAgMAkNBMRYwFAYDVQQH
3 | DA1PcmFuZ2UgQ291bnR5MRIwEAYDVQQKDAlCeXRld2l6ZXIxDjAMBgNVBAMMBU1T
4 | MjAwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwM6byiUtn660EIyy
5 | f1xFTUe0a5fddMR5Qn0nNWuho+Uu4ubdd3J71eAP0skiBvFX+9DANQKvaKH8PzbM
6 | 28hZf8qMh3zflerevL9eGm4SZFl0LykeUWtL92wnSIkESMLfATJrg425y7mmKYC6
7 | CoSURFHZ+tL/L6Ti3blGruzOLFGPwYREJsN5oVGObBUI4QSKd4t7EDyaEG8kiVri
8 | VfYBkR0kmSNmSd+FAyLS4HdKR5Blg/OkQxnLrO7DDzJaYjsfl13GF5jbsoiJabkw
9 | //Oh/MO3uX6U9un+89//wvRAvC/0mb+zd9mmXoVvmvBCbk5o1S7XP0avJgzhEnFg
10 | 1vtBAwIDAQABoAAwDQYJKoZIhvcNAQELBQADggEBAHVWFaJUvvb+HbmTaafR7sNv
11 | YBOuyvSVyJRnRtQnSUApFTBIY1hwJ92pZ1lzWfjT8Eb4QJD/uuwiuz2i5XgsK/V+
12 | BBQ8TnehyyCJZo2GC/MRxtJOxenjzd0f+zq+oTOL1t9PWRU2TcOtDLYIBhIgbFd+
13 | XSBtdvjfBUcFT/E5b7aEL3T7PN9fJFJA3pnP7NZW4D7ykZTrshTVFBjYkre6Ts74
14 | v3N8KbMRP6AtsS5/aSNtgDRK0tbU9gvFyaoSM0QvqLkaIOgv2dlyRAW9kRX6eBcI
15 | 2L4/YUzjkNfDTzRDU6WLiswzQy6QY4VOQOvY1mJouCmo+m22KheH6btZ41DlxiE=
16 | -----END CERTIFICATE REQUEST-----
17 |
--------------------------------------------------------------------------------
/certificate/openssl/server_v3.ext:
--------------------------------------------------------------------------------
1 | authorityKeyIdentifier=keyid,issuer
2 | basicConstraints=CA:FALSE
3 | keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
4 | subjectAltName = @alt_names
5 |
6 | [alt_names]
7 | DNS.1 = MS200
8 | IP.1 = 192.168.1.200
--------------------------------------------------------------------------------
/certificate/sample/Bytewizer.TinyCLR.Secure/Middleware/HttpResponseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.TinyCLR.Secure
6 | {
7 | public static class HttpResponseExtensions
8 | {
9 | public static void UseHttpResponse(this IApplicationBuilder app )
10 | {
11 | if (app == null)
12 | {
13 | throw new ArgumentNullException(nameof(app));
14 | }
15 |
16 | app.Use(new HttpResponse());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/certificate/sample/Bytewizer.TinyCLR.Secure/Program.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Sockets;
2 | using System;
3 | using System.Collections;
4 | using System.Diagnostics;
5 | using System.Text;
6 | using System.Threading;
7 |
8 | namespace Bytewizer.TinyCLR.Secure
9 | {
10 | internal class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | IServer server = new SocketServer(options =>
15 | {
16 | options.Pipeline(app =>
17 | {
18 | app.UseHttpResponse();
19 | });
20 |
21 | });
22 | server.Start();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/images/favicon.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/images/favicon.bin
--------------------------------------------------------------------------------
/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/images/favicon.ico
--------------------------------------------------------------------------------
/images/package-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/images/package-logo.png
--------------------------------------------------------------------------------
/images/pipeline.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/images/pipeline.jpeg
--------------------------------------------------------------------------------
/images/resources.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/images/resources.jpg
--------------------------------------------------------------------------------
/images/telnet-server.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/images/telnet-server.jpg
--------------------------------------------------------------------------------
/playground/blazor/Program.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Http;
2 |
3 | namespace Bytewizer.Playground.Blazor
4 | {
5 | class Program
6 | {
7 | static void Main()
8 | {
9 | StorageProvider.Initialize();
10 | NetworkProvider.InitializeEthernet();
11 |
12 | var server = new HttpServer(options =>
13 | {
14 | options.Pipeline(app =>
15 | {
16 | app.UseBlazorFrameworkFiles("/blazor");
17 | });
18 | });
19 | server.Start();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/playground/blazor/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Bytewizer.Playground.Blazor.Properties
12 | {
13 |
14 | internal partial class Resources
15 | {
16 | private static System.Resources.ResourceManager manager;
17 | internal static System.Resources.ResourceManager ResourceManager
18 | {
19 | get
20 | {
21 | if ((Resources.manager == null))
22 | {
23 | Resources.manager = new System.Resources.ResourceManager("Bytewizer.Playground.Blazor.Properties.Resources", typeof(Resources).Assembly);
24 | }
25 | return Resources.manager;
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/playground/blazor/microsd-root.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/blazor/microsd-root.zip
--------------------------------------------------------------------------------
/playground/blazor/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/playground/cookies/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/cookies/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/playground/embedded/Resources/1280.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/embedded/Resources/1280.bin
--------------------------------------------------------------------------------
/playground/embedded/Resources/1920.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/embedded/Resources/1920.bin
--------------------------------------------------------------------------------
/playground/embedded/Resources/640.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/embedded/Resources/640.bin
--------------------------------------------------------------------------------
/playground/embedded/Resources/favicon.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/embedded/Resources/favicon.bin
--------------------------------------------------------------------------------
/playground/embedded/Resources/image.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/embedded/Resources/image.bin
--------------------------------------------------------------------------------
/playground/embedded/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/ftp/Middleware/FtpResponseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.Playground.Ftp
6 | {
7 | public static class HttpResponseExtensions
8 | {
9 | public static void UseFtpResponse(this IApplicationBuilder app )
10 | {
11 | if (app == null)
12 | {
13 | throw new ArgumentNullException(nameof(app));
14 | }
15 |
16 | app.Use(new HttpResponse());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/playground/hardware/Hardware/FlashObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace Bytewizer.Playground
5 | {
6 | [Serializable]
7 | public class FlashObject
8 | {
9 | public FlashObject()
10 | {
11 | Ssid = "ssid";
12 | Password = "password";
13 | }
14 |
15 | public string Ssid { get; set; }
16 | public string Password { get; set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/playground/hosting/Program.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Hosting;
2 | using Bytewizer.TinyCLR.Logging;
3 |
4 | namespace Bytewizer.Playground.Hosting
5 | {
6 | class Program
7 | {
8 | static void Main()
9 | {
10 | CreateHostBuilder().Build().Run();
11 | }
12 |
13 | public static IHostBuilder CreateHostBuilder() =>
14 | Host.CreateDefaultBuilder()
15 | .ConfigureWebHostDefaults(webBuilder =>
16 | {
17 | webBuilder.UseStartup(typeof(Startup));
18 | })
19 | .ConfigureLogging((context, logging) => {
20 | logging.SetMinimumLevel(LogLevel.Debug);
21 | });
22 | }
23 | }
--------------------------------------------------------------------------------
/playground/hosting/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Http;
4 | using Bytewizer.TinyCLR.Pipeline.Builder;
5 | using Bytewizer.TinyCLR.DependencyInjection;
6 |
7 | namespace Bytewizer.Playground.Hosting
8 | {
9 | public class Startup
10 | {
11 | public void ConfigureServices(IServiceCollection services)
12 | {
13 | services.AddHttpServer(options =>
14 | {
15 | options.Listen(8080);
16 | });
17 | }
18 |
19 | public void Configure(IApplicationBuilder app)
20 | {
21 | app.UseRouting();
22 | app.UseEndpoints(endpoints =>
23 | {
24 | endpoints.Map("/", context =>
25 | {
26 | string response = "Hello, world!" +
27 | "" +
28 | "" + DateTime.Now.Ticks.ToString() + "
";
29 |
30 | context.Response.Write(response);
31 | });
32 | });
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/playground/hosting/WorkerService1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Hosting;
4 | using Bytewizer.TinyCLR.Logging;
5 |
6 |
7 | namespace Bytewizer.Playground.Hosting
8 | {
9 | public class WorkerService1 : BackgroundService
10 | {
11 | public WorkerService1(ILoggerFactory loggerFactory)
12 | {
13 | Logger = loggerFactory.CreateLogger(typeof(WorkerService1));
14 | }
15 |
16 | public ILogger Logger { get; }
17 |
18 | protected override void ExecuteAsync()
19 | {
20 | long count;
21 | for (count = 0; count < 100; count++)
22 | {
23 | if (IsCancellationRequested)
24 | {
25 | return;
26 | }
27 |
28 | Logger.LogInformation($"[Worker Service 1] - #{count}");
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/playground/hosting/WorkerService2.cs:
--------------------------------------------------------------------------------
1 |
2 | using Bytewizer.TinyCLR.Hosting;
3 | using Bytewizer.TinyCLR.Logging;
4 |
5 | namespace Bytewizer.Playground.Hosting
6 | {
7 | public class WorkerService2 : BackgroundService
8 | {
9 | public WorkerService2(ILoggerFactory loggerFactory)
10 | {
11 | Logger = loggerFactory.CreateLogger(typeof(WorkerService2));
12 | }
13 |
14 | public ILogger Logger { get; }
15 |
16 | protected override void ExecuteAsync()
17 | {
18 | long count;
19 | for (count = 0; count < 100; count++)
20 | {
21 | if (IsCancellationRequested)
22 | {
23 | return;
24 | }
25 |
26 | Logger.LogInformation($"[Worker Service 2] - #{count}");
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/playground/hosting/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/http/Middleware/HttpPerfMiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Http;
4 | using Bytewizer.TinyCLR.Pipeline.Builder;
5 |
6 | namespace Bytewizer.Playground.Http
7 | {
8 | public static class HttpPerfMiddlewareExtensions
9 | {
10 | public static void UseHttpPerf(this IApplicationBuilder app)
11 | {
12 | if (app == null)
13 | {
14 | throw new ArgumentNullException(nameof(app));
15 | }
16 |
17 | app.UseMiddleware(typeof(HttpPerfMiddleware));
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/http/Resources/favicon.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/http/Resources/favicon.bin
--------------------------------------------------------------------------------
/playground/http/Resources/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/http/Resources/favicon.ico
--------------------------------------------------------------------------------
/playground/http/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/json/Models/DeviceModel.cs:
--------------------------------------------------------------------------------
1 |
2 | using GHIElectronics.TinyCLR.Native;
3 |
4 | namespace Bytewizer.Playground.Json.Models
5 | {
6 | public class DeviceModel
7 | {
8 | public DeviceModel()
9 | {
10 | ManufacturerName = DeviceInformation.ManufacturerName;
11 | DeviceName = DeviceInformation.DeviceName;
12 |
13 | var major = (ushort)((DeviceInformation.Version >> 48) & 0xFFFF);
14 | var minor = (ushort)((DeviceInformation.Version >> 32) & 0xFFFF);
15 | var build = (ushort)((DeviceInformation.Version >> 16) & 0xFFFF);
16 | var revision = (ushort)((DeviceInformation.Version >> 0) & 0xFFFF);
17 | Version = $"{major}.{minor}.{build}.{revision}";
18 | }
19 |
20 | public string Version { get; private set; }
21 | public string DeviceName { get; private set;}
22 | public string ManufacturerName { get; private set;}
23 | }
24 | }
--------------------------------------------------------------------------------
/playground/json/Models/Gender.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.Playground.Json.Models
2 | {
3 | public enum Gender
4 | {
5 | Male,
6 | Female
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/playground/json/Models/Person.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.Playground.Json.Models
4 | {
5 | public class Person
6 | {
7 | public int Id { get; set; }
8 |
9 | public string Suffix { get; set; }
10 |
11 | public string Title { get; set; }
12 |
13 | public string LastName { get; set; }
14 |
15 | public string Phone { get; set; }
16 |
17 | public Gender Gender { get; set; }
18 |
19 | public string FirstName { get; set; }
20 |
21 | public string MiddleName { get; set; }
22 |
23 | public string Email { get; set; }
24 |
25 | public DateTime DOB { get; set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/playground/json/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/json/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/playground/mvc/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Http.Mvc;
4 |
5 | namespace Bytewizer.Playground.Mvc
6 | {
7 | public class HomeController : Controller
8 | {
9 | // Any public IActionResult method inherited from Controller is made available as an endpoint
10 | public IActionResult Index()
11 | {
12 | string response = "Hello, world!" +
13 | "" +
14 | "" + $"{DateTime.Now.Ticks}" + "
";
15 |
16 | return Content(response);
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/playground/mvc/Models/Gender.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.Playground.Mvc.Models
2 | {
3 | public enum Gender
4 | {
5 | Male,
6 | Female
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/playground/mvc/Models/Person.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.Playground.Mvc.Models
4 | {
5 | public class Person
6 | {
7 | public int Id { get; set; }
8 |
9 | public string FirstName { get; set; }
10 |
11 | public string MiddleName { get; set; }
12 |
13 | public string LastName { get; set; }
14 |
15 | public string Title { get; set; }
16 |
17 | public DateTime DOB { get; set; }
18 |
19 | public string Email { get; set; }
20 |
21 | public Gender Gender { get; set; }
22 |
23 | public string SSN { get; set; }
24 |
25 | public string Suffix { get; set; }
26 |
27 | public string Phone { get; set; }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/playground/mvc/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/mvc/microsd-root.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/mvc/microsd-root.zip
--------------------------------------------------------------------------------
/playground/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/playground/pagebuilder/Resources/favicon.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/pagebuilder/Resources/favicon.bin
--------------------------------------------------------------------------------
/playground/pagebuilder/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/securesockets/Middleware/HttpResponseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.Playground.Sockets
6 | {
7 | public static class HttpResponseExtensions
8 | {
9 | public static void UseHttpResponse(this IApplicationBuilder app )
10 | {
11 | if (app == null)
12 | {
13 | throw new ArgumentNullException(nameof(app));
14 | }
15 |
16 | app.SetProperty("key", "custom object/setting");
17 | app.Use(new HttpResponse());
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/securesockets/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/playground/sntp/Hardware/ClockProvider.cs:
--------------------------------------------------------------------------------
1 | using GHIElectronics.TinyCLR.Native;
2 | using GHIElectronics.TinyCLR.Devices.Rtc;
3 |
4 | namespace Bytewizer.Playground
5 | {
6 | public static class ClockProvider
7 | {
8 | private static readonly object _lock = new object();
9 |
10 | private static bool _initialized;
11 |
12 | public static RtcController Controller { get; private set; }
13 |
14 | public static void Initialize()
15 | {
16 | if (_initialized)
17 | return;
18 |
19 | lock (_lock)
20 | {
21 | if (_initialized)
22 | return;
23 |
24 | Controller = RtcController.GetDefault();
25 | Controller.SetChargeMode(BatteryChargeMode.Fast);
26 |
27 | if (Controller.IsValid)
28 | {
29 | SystemTime.SetTime(Controller.Now);
30 | }
31 |
32 | _initialized = true;
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/playground/sockets/Middleware/HttpResponseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.Playground.Sockets
6 | {
7 | public static class HttpResponseExtensions
8 | {
9 | public static void UseHttpResponse(this IApplicationBuilder app )
10 | {
11 | if (app == null)
12 | {
13 | throw new ArgumentNullException(nameof(app));
14 | }
15 |
16 | app.SetProperty("key", "custom object/setting");
17 | app.Use(new HttpResponse());
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/playground/sockets/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/playground/ssl/Resources/favicon.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/ssl/Resources/favicon.bin
--------------------------------------------------------------------------------
/playground/ssl/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/staticfiles/Resources/favicon.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/staticfiles/Resources/favicon.bin
--------------------------------------------------------------------------------
/playground/staticfiles/Resources/image.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/staticfiles/Resources/image.bin
--------------------------------------------------------------------------------
/playground/staticfiles/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/staticfiles/microsd-root.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/playground/staticfiles/microsd-root.zip
--------------------------------------------------------------------------------
/playground/staticfiles/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/playground/terminal/Extensions/FilterContextExtensions.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Terminal;
2 |
3 | namespace Bytewizer.Playground.Terminal
4 | {
5 | ///
6 | /// Extension methods for related to routing.
7 | ///
8 | public static class FilterContextExtensions
9 | {
10 | ///
11 | /// Extension method for getting the arguments for the current request.
12 | ///
13 | /// The context.
14 | public static int GetArgumentOrDefault(this ActionExecutingContext filterContext, string key, int defaultValue)
15 | {
16 | if (filterContext.Arguments.Contains(key))
17 | {
18 | var value = (string)filterContext.Arguments[key];
19 | if (!int.TryParse(value, out int number))
20 | {
21 | filterContext.Result = new ResponseResult($"An error occurred parsing the --{value} flag.");
22 | }
23 |
24 | return number;
25 | }
26 |
27 | return defaultValue;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/playground/terminal/Hardware/StatusLed.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.Playground.Terminal
2 | {
3 | public class StatusLed : GpioLed
4 | {
5 | public StatusLed(int pinNumber)
6 | : base(pinNumber)
7 | {
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/playground/terminal/Hardware/StatusProvider.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.Playground.Terminal
2 | {
3 | public static class StatusProvider
4 | {
5 | private static readonly object _lock = new object();
6 |
7 | private static bool _initialized;
8 |
9 | public static StatusLed Led { get; private set; }
10 |
11 | public static void Initialize(int pinNumber)
12 | {
13 | if (_initialized)
14 | return;
15 |
16 | lock (_lock)
17 | {
18 | if (_initialized)
19 | return;
20 |
21 | Led = new StatusLed(pinNumber);
22 | }
23 |
24 | _initialized = true;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/playground/terminal/Middleware/FtpResponseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.Playground.Ftp
6 | {
7 | public static class HttpResponseExtensions
8 | {
9 | public static void UseFtpResponse(this IApplicationBuilder app )
10 | {
11 | if (app == null)
12 | {
13 | throw new ArgumentNullException(nameof(app));
14 | }
15 |
16 | app.Use(new HttpResponse());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/playground/websocket/Hubs/ChatHub.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Diagnostics;
4 |
5 | using Bytewizer.TinyCLR.Http.WebSockets;
6 |
7 | namespace Bytewizer.Playground.WebSocket
8 | {
9 | public class ChatHub : Hub
10 | {
11 | public ChatHub()
12 | {
13 | Debug.WriteLine("Hit Constructor");
14 | }
15 |
16 | public override void OnConnected()
17 | {
18 | Debug.WriteLine(Caller.ConnectionId);
19 | Debug.WriteLine(Caller.GetHttpContext().Request.ToString());
20 | }
21 |
22 | public override void OnMessage(WebSocketContext context)
23 | {
24 | if (context.IsText)
25 | {
26 | var encodedPayload = Encoding.UTF8.GetString(context.Payload);
27 | Clients.Caller.SendText($"ECHO: {encodedPayload}");
28 | }
29 | }
30 |
31 | public override void OnDisconnected(Exception exception)
32 | {
33 | Debug.WriteLine(exception.Message);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/playground/websocket/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/playground/websocket/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/src/DuinoAPI/Models/DeviceModel.cs:
--------------------------------------------------------------------------------
1 | using GHIElectronics.TinyCLR.Native;
2 |
3 | namespace Bytewizer.TinyCLR.DuinoAPI
4 | {
5 | public class DeviceModel
6 | {
7 | public DeviceModel()
8 | {
9 | UniqueId = DeviceInformation.GetUniqueId();
10 | ManufacturerName = DeviceInformation.ManufacturerName;
11 | DeviceName = DeviceInformation.DeviceName;
12 |
13 | var major = (ushort)((DeviceInformation.Version >> 48) & 0xFFFF);
14 | var minor = (ushort)((DeviceInformation.Version >> 32) & 0xFFFF);
15 | var build = (ushort)((DeviceInformation.Version >> 16) & 0xFFFF);
16 | var revision = (ushort)((DeviceInformation.Version >> 0) & 0xFFFF);
17 | Version = $"{major}.{minor}.{build}.{revision}";
18 | }
19 |
20 | public byte[] UniqueId { get; private set; }
21 | public string ManufacturerName { get; private set; }
22 | public string DeviceName { get; private set; }
23 | public string Version { get; private set; }
24 | }
25 | }
--------------------------------------------------------------------------------
/samples/src/DuinoAPI/Models/NetworkModel.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.DuinoAPI
2 | {
3 | public class NetworkModel
4 | {
5 | public NetworkModel()
6 | {
7 | var settings = NetworkProvider.Controller.GetIPProperties();
8 |
9 | Address = settings.Address.GetAddressBytes();
10 | GatewayAddress = settings.GatewayAddress.GetAddressBytes();
11 | SubnetMask = settings.SubnetMask.GetAddressBytes();
12 | }
13 |
14 | public byte[] Address { get; private set; }
15 | public byte[] GatewayAddress { get; private set; }
16 | public byte[] SubnetMask { get; private set; }
17 | }
18 | }
--------------------------------------------------------------------------------
/samples/src/DuinoEmbedded/Hardware/ClockProvider.cs:
--------------------------------------------------------------------------------
1 | using GHIElectronics.TinyCLR.Native;
2 | using GHIElectronics.TinyCLR.Devices.Rtc;
3 |
4 | namespace Bytewizer.TinyCLR
5 | {
6 | public static class ClockProvider
7 | {
8 | private static readonly object _lock = new object();
9 |
10 | private static bool _initialized;
11 |
12 | public static RtcController Controller { get; private set; }
13 |
14 | public static void Initialize()
15 | {
16 | if (_initialized)
17 | return;
18 |
19 | lock (_lock)
20 | {
21 | if (_initialized)
22 | return;
23 |
24 | Controller = RtcController.GetDefault();
25 | Controller.SetChargeMode(BatteryChargeMode.Fast);
26 |
27 | if (Controller.IsValid)
28 | {
29 | SystemTime.SetTime(Controller.Now);
30 | }
31 |
32 | _initialized = true;
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/samples/src/DuinoEmbedded/Hardware/StorageProvider.cs:
--------------------------------------------------------------------------------
1 | using GHIElectronics.TinyCLR.IO;
2 | using GHIElectronics.TinyCLR.Pins;
3 | using GHIElectronics.TinyCLR.Devices.Storage;
4 |
5 | namespace Bytewizer.TinyCLR
6 | {
7 | public static class StorageProvider
8 | {
9 | private static readonly object _lock = new();
10 |
11 | private static bool _initialized;
12 |
13 | public static StorageController Controller { get; private set; }
14 |
15 | public static IDriveProvider Drive { get; private set; }
16 |
17 | public static void Initialize()
18 | {
19 | if (_initialized)
20 | return;
21 |
22 | lock (_lock)
23 | {
24 | if (_initialized)
25 | return;
26 |
27 | Controller = StorageController.FromName(SC20260.StorageController.SdCard);
28 | Drive = FileSystem.Mount(Controller.Hdc);
29 | }
30 |
31 | _initialized = true;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/samples/src/DuinoEmbedded/Resources/favicon.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/samples/src/DuinoEmbedded/Resources/favicon.bin
--------------------------------------------------------------------------------
/samples/src/DuinoEmbedded/Resources/image.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/samples/src/DuinoEmbedded/Resources/image.bin
--------------------------------------------------------------------------------
/samples/src/DuinoEmbedded/embeded-files.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/samples/src/DuinoEmbedded/embeded-files.zip
--------------------------------------------------------------------------------
/samples/src/DuinoEmbedded/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/src/DuinoWeb/Hardware/ClockProvider.cs:
--------------------------------------------------------------------------------
1 | using GHIElectronics.TinyCLR.Native;
2 | using GHIElectronics.TinyCLR.Devices.Rtc;
3 |
4 | namespace Bytewizer.TinyCLR
5 | {
6 | public static class ClockProvider
7 | {
8 | private static readonly object _lock = new object();
9 |
10 | private static bool _initialized;
11 |
12 | public static RtcController Controller { get; private set; }
13 |
14 | public static void Initialize()
15 | {
16 | if (_initialized)
17 | return;
18 |
19 | lock (_lock)
20 | {
21 | if (_initialized)
22 | return;
23 |
24 | Controller = RtcController.GetDefault();
25 | Controller.SetChargeMode(BatteryChargeMode.Fast);
26 |
27 | if (Controller.IsValid)
28 | {
29 | SystemTime.SetTime(Controller.Now);
30 | }
31 |
32 | _initialized = true;
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/samples/src/DuinoWeb/Hardware/StorageProvider.cs:
--------------------------------------------------------------------------------
1 | using GHIElectronics.TinyCLR.IO;
2 | using GHIElectronics.TinyCLR.Pins;
3 | using GHIElectronics.TinyCLR.Devices.Storage;
4 |
5 | namespace Bytewizer.TinyCLR
6 | {
7 | public static class StorageProvider
8 | {
9 | private static readonly object _lock = new();
10 |
11 | private static bool _initialized;
12 |
13 | public static StorageController Controller { get; private set; }
14 |
15 | public static IDriveProvider Drive { get; private set; }
16 |
17 | public static void Initialize()
18 | {
19 | if (_initialized)
20 | return;
21 |
22 | lock (_lock)
23 | {
24 | if (_initialized)
25 | return;
26 |
27 | Controller = StorageController.FromName(SC20260.StorageController.SdCard);
28 | Drive = FileSystem.Mount(Controller.Hdc);
29 | }
30 |
31 | _initialized = true;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/samples/src/DuinoWeb/microsd-root.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bytewizer/microserver/0c8e04da4ef960d74ce67c2cd03eaa4b77d0c30c/samples/src/DuinoWeb/microsd-root.zip
--------------------------------------------------------------------------------
/src/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # IDE0016: Use 'throw' expression
4 | csharp_style_throw_expression = true:none
5 |
6 | # Microsoft.CodeAnalysis.CSharp.Features
7 | dotnet_diagnostic.IDE0090.severity = none # Use new(...)
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp.Authentication/Middleware/AuthenticationOptions.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Identity;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | ///
6 | /// Options for selecting authentication scheme and account services.
7 | ///
8 | public class AuthenticationOptions
9 | {
10 | ///
11 | /// Configuration for the .
12 | ///
13 | public AuthenticationOptions()
14 | {
15 | IdentityProvider = new IdentityProvider();
16 | }
17 |
18 | ///
19 | /// Account service for the authentication scheme.
20 | ///
21 | public IIdentityProvider IdentityProvider { get; set; }
22 |
23 | ///
24 | /// Gets or sets a value indicating whether login is allowed by anonymous users.
25 | ///
26 | public bool AllowAnonymous { get; set; } = false;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp.Authentication/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: AssemblyConfiguration("Secure")]
6 | [assembly: Guid("a3819878-1d51-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Extensions/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
6 |
7 | public static class DateTimeExtensions
8 | {
9 | public static string ToTimeString( this DateTime dateTime)
10 | {
11 | return dateTime.ToUniversalTime().ToString("yyyyMMddHHmmss");
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Ftp/DataMode.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | ///
4 | /// Defines FTP data modes.
5 | ///
6 | public enum DataMode
7 | {
8 | ///
9 | /// No data mode defined.
10 | ///
11 | None,
12 |
13 | ///
14 | /// Passive data mode.
15 | ///
16 | Passive,
17 |
18 | ///
19 | /// Active data mode.
20 | ///
21 | Active,
22 |
23 | ///
24 | /// Extended passive data mode.
25 | ///
26 | ExtendedPassive,
27 |
28 | ///
29 | /// Extended active data mode.
30 | ///
31 | ExtendedActive
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Ftp/FtpResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | ///
6 | /// Represents the outgoing side of an individual FTP request.
7 | ///
8 | public class FtpResponse
9 | {
10 | ///
11 | /// Gets the response message.
12 | ///
13 | public string Message { get; set; }
14 |
15 | ///
16 | /// Gets the response code.
17 | ///
18 | public override string ToString()
19 | {
20 | var message = "[null]";
21 |
22 | if (Message != null)
23 | {
24 | message = Message.Replace("\r\n", string.Empty);
25 | }
26 |
27 | return message;
28 | }
29 |
30 | ///
31 | /// Clears the headers, cookies and body.
32 | ///
33 | public void Clear()
34 | {
35 | Message = default;
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Ftp/RequestDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | ///
4 | /// A function that can process a FTP request.
5 | ///
6 | /// The context for the request.
7 | public delegate void RequestDelegate(FtpContext context);
8 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Ftp/SecurityType.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | ///
4 | /// Defines FTP transport layer security types.
5 | ///
6 | public enum SecurityType
7 | {
8 | ///
9 | /// No security type defined.
10 | ///
11 | None,
12 |
13 | ///
14 | /// Transport Layer Security (TLS) type.
15 | ///
16 | Tls,
17 |
18 | ///
19 | /// Secure Sockets Layer (SSL) type.
20 | ///
21 | Ssl,
22 | }
23 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Ftp/StructureType.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | ///
4 | /// Defines FTP structure types.
5 | ///
6 | public enum StructureType
7 | {
8 | ///
9 | /// File structure type.
10 | ///
11 | File,
12 |
13 | ///
14 | /// Record structure type.
15 | ///
16 | Record,
17 |
18 | ///
19 | /// Page structure type.
20 | ///
21 | Page
22 | }
23 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Ftp/TransferMode.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | ///
4 | /// Defines FTP transfer modes.
5 | ///
6 | public enum TransferMode
7 | {
8 | ///
9 | /// Stream transfer mode.
10 | ///
11 | Stream,
12 |
13 | ///
14 | /// Block transfer mode.
15 | ///
16 | Block,
17 |
18 | ///
19 | /// Compress transfer mode.
20 | ///
21 | Compressed,
22 |
23 | ///
24 | /// Deflate transfer mode.
25 | ///
26 | Deflate
27 | }
28 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Ftp/TransferType.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | ///
4 | /// Defines FTP transfer types.
5 | ///
6 | public enum TransferType
7 | {
8 | ///
9 | /// ASCII data type.
10 | ///
11 | Ascii,
12 |
13 | ///
14 | /// EBCDIC data type.
15 | ///
16 | Ebcdic,
17 |
18 | ///
19 | /// IMAGE data type.
20 | ///
21 | Image,
22 |
23 | ///
24 | /// LOCAL data type.
25 | ///
26 | Local
27 | }
28 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Cdup.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the CDUP command.
9 | ///
10 | private void Cdup()
11 | {
12 | try
13 | {
14 | var path = _fileProvider.GetLocalDirectory();
15 | var directoryInfo = new DirectoryInfo(path);
16 |
17 | _fileProvider.SetWorkingDirectory(directoryInfo.Parent.FullName);
18 | _context.Response.Write(200, $"Working directory changed to {_fileProvider.GetWorkingDirectory()}.");
19 | }
20 | catch
21 | {
22 | _context.Response.Write(550, "Not a valid directory.");
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Cwd.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the CWD command.
7 | ///
8 | private void Cwd()
9 | {
10 | var path = _context.Request.Command.Argument;
11 |
12 | if (_fileProvider.SetWorkingDirectory(path))
13 | {
14 | _context.Response.Write(250, $"Successful ({_fileProvider.GetWorkingDirectory()})");
15 | }
16 | else
17 | {
18 | _context.Response.Write(550, "Not a valid directory.");
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Dele.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the DELE command.
7 | ///
8 | private void Dele()
9 | {
10 | var file = _context.Request.Command.Argument;
11 |
12 | try
13 | {
14 | _fileProvider.Delete(file);
15 | _context.Response.Write(250, "File deleted successfull.");
16 |
17 | }
18 | catch
19 | {
20 | _context.Response.Write(550, $"File not found.");
21 | }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Eprt.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the EPRT command.
9 | ///
10 | private void Eprt()
11 | {
12 | try
13 | {
14 | var addr = _context.Request.Command.Argument.Split(new char[] { ',' });
15 | var ip = $"{addr[0]}.{addr[1]}.{addr[2]}.{addr[3]}";
16 | var port = (int.Parse(addr[4]) * 0x100) + int.Parse(addr[5]);
17 |
18 | _endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
19 | if (_endpoint == null)
20 | {
21 | _context.Response.Write(501, "Syntax error in parameters or arguments.");
22 | }
23 |
24 | _context.Request.DataMode = DataMode.ExtendedActive;
25 | _context.Response.Write(200, "EPRT command successful.");
26 | }
27 | catch
28 | {
29 | _context.Request.DataMode = DataMode.None;
30 | _context.Response.Write(500, "EPRT command failed.");
31 | }
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Epsv.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the EPSV command.
7 | ///
8 | private void Epsv()
9 | {
10 | var port = _listener.ActivePort;
11 |
12 | if (port != -1)
13 | {
14 | _context.Request.DataMode = DataMode.ExtendedPassive;
15 | _context.Channel.Write(229, $"Entering extended passive mode (|||{port}|)");
16 | }
17 | else
18 | {
19 | _context.Request.DataMode = DataMode.None;
20 | _context.Channel.Write(500, "EPSV command failed.");
21 | }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Feat.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the FEAT command.
9 | ///
10 | private void Feat()
11 | {
12 | StringBuilder sb = new StringBuilder();
13 |
14 | sb.AppendLine("211-Extensions supported:");
15 | sb.AppendLine(" AUTH TLS;TLS-C");
16 | sb.AppendLine(" UTF8");
17 | sb.AppendLine(" EPSV");
18 | sb.AppendLine(" EPRT");
19 | sb.AppendLine(" PASV");
20 | sb.AppendLine(" PBSZ");
21 | sb.AppendLine(" MLST type*;size*;modify*;create*;");
22 | sb.AppendLine(" PROT C;P;");
23 | //sb.AppendLine(" MLSD");
24 | sb.AppendLine(" MDTM");
25 | sb.AppendLine(" SIZE");
26 | sb.AppendLine(" REST STREAM");
27 | sb.AppendLine("211 End");
28 |
29 | _context.Response.Write(sb.ToString());
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Mdtm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the MDTM command.
9 | ///
10 | private void Mdtm()
11 | {
12 | var path = _context.Request.Command.Argument;
13 |
14 | try
15 | {
16 | if (_fileProvider.GetLastWriteTime(path, out DateTime dateTime))
17 | {
18 | _context.Response.Write(213, dateTime.ToTimeString());
19 | }
20 | else
21 | {
22 | _context.Response.Write(550, "File not found.");
23 | }
24 | }
25 | catch
26 | {
27 | _context.Response.Write(500, "MDTM command failed.");
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Mkd.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the MKD command.
7 | ///
8 | private void Mkd()
9 | {
10 | var path = _context.Request.Command.Argument;
11 |
12 | try
13 | {
14 | _fileProvider.CreateDirectory(path);
15 | _context.Response.Write(257, $"Directory created successfull.");
16 |
17 | }
18 | catch
19 | {
20 | _context.Response.Write(500, $"CDUP command failed.");
21 | }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Mode.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the MODE command.
7 | ///
8 | private void Mode()
9 | {
10 | switch (_context.Request.Argument)
11 | {
12 | case "S":
13 | _context.Request.TransferMode = TransferMode.Stream;
14 | _context.Response.Write(200, $"MODE set to stream mode.");
15 | break;
16 |
17 | case "B":
18 | case "C":
19 | case "D":
20 | ParameterNotImplemented();
21 | break;
22 |
23 | default:
24 | ParameterNotRecognized();
25 | break;
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Noop.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the NOOP command.
7 | ///
8 | private void Noop()
9 | {
10 | _context.Response.Write(200, "NOOP command successfull.");
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Opts.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the OPTS command.
7 | ///
8 | private void Opts()
9 | {
10 | switch (_context.Request.Command.Argument.ToUpper())
11 | {
12 | case "UTF8 ON":
13 | _context.Response.Write(200, "UTF-8 is on.");
14 | break;
15 |
16 | case "UTF8 OFF":
17 | CommandNotImplemented();
18 | break;
19 |
20 | default:
21 | ParameterNotImplemented();
22 | return;
23 | }
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Pbsz.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Ftp.Features;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// The PBSZ command handler.
9 | ///
10 | private void Pbsz()
11 | {
12 | //if (_context.Request.SecurityType == SecurityType.None)
13 | //{
14 | // BadSequenceOfCommands();
15 | // return;
16 | //}
17 |
18 | var size = _context.Request.Command.Argument;
19 |
20 | try
21 | {
22 | var feature = new SessionFeature()
23 | {
24 | TlsBlockSize = int.Parse(size)
25 | };
26 |
27 | _context.Features.Set(typeof(SessionFeature), feature);
28 | _context.Response.Write(200, $"Protection buffer size set to {size}.");
29 | }
30 | catch
31 | {
32 | _context.Response.Write(500, "PBSZ command failed.");
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Port.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the PORT commands.
9 | ///
10 | private void Port()
11 | {
12 | try
13 | {
14 | var addr = _context.Request.Command.Argument.Split(new char[] { ',' });
15 | var ip = $"{addr[0]}.{addr[1]}.{addr[2]}.{addr[3]}";
16 | var port = (int.Parse(addr[4]) * 0x100) + int.Parse(addr[5]);
17 |
18 | _endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
19 |
20 | _context.Request.DataMode = DataMode.Active;
21 | _context.Response.Write(200, "PORT command successful.");
22 | }
23 | catch
24 | {
25 | _context.Request.DataMode = DataMode.None;
26 | _context.Response.Write(500, "PORT command failed.");
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Pwd.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Ftp.Features;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the PWD command.
9 | ///
10 | private void Pwd()
11 | {
12 | try
13 | {
14 | var path = _fileProvider.GetWorkingDirectory();
15 | _context.Response.Write(257, $"\"{path}\"");
16 | }
17 | catch
18 | {
19 | _context.Response.Write(500, "PWD command failed.");
20 | }
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Quit.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the QUIT command.
7 | ///
8 | private void Quit()
9 | {
10 | _context.Response.Write(221, "Service closing control connection.");
11 | _context.Active = false;
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Rest.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Ftp.Features;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the REST command.
9 | ///
10 | private void Rest()
11 | {
12 | try
13 | {
14 | var feature = (SessionFeature)_context.Features.Get(typeof(SessionFeature));
15 | feature.RestPosition = int.Parse(_context.Request.Command.Argument);
16 |
17 | _context.Response.Write(350, $"Restarting next transfer from position {feature.RestPosition}. Send STOR or RETR to initiate transfer.");
18 | }
19 | catch
20 | {
21 | _context.Response.Write(500, "REST command failed.");
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Rmd.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the RMD command.
7 | ///
8 | private void Rmd()
9 | {
10 | var path = _context.Request.Command.Argument;
11 |
12 | try
13 | {
14 | _fileProvider.DeleteDirectory(path);
15 | _context.Response.Write(250, "Directory removed.");
16 |
17 | }
18 | catch
19 | {
20 | _context.Response.Write(550, "Not a valid directory.");
21 | }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Rnfr.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Ftp.Features;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the RNFR command.
9 | ///
10 | private void Rnfr()
11 | {
12 | try
13 | {
14 | var feature = (SessionFeature)_context.Features.Get(typeof(SessionFeature));
15 |
16 | // TODO: Check to make sure directory or file exist
17 | // 550, "Directory doesn't exist."
18 | // 550, "Source entry doesn't exist."
19 |
20 |
21 | feature.FromPath = _context.Request.Command.Argument;
22 |
23 | _context.Response.Write(350, "Rename started waiting for RNTO.");
24 |
25 | }
26 | catch
27 | {
28 | _context.Response.Write(500, "RNFR command failed.");
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Rnto.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Ftp.Features;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the RNTO command.
9 | ///
10 | private void Rnto()
11 | {
12 | try
13 | {
14 | var feature = (SessionFeature)_context.Features.Get(typeof(SessionFeature));
15 | var fromPath = feature.FromPath;
16 |
17 | if (string.IsNullOrEmpty(fromPath))
18 | {
19 | _context.Response.Write(503, "RNTO must be preceded by a RNFR.");
20 | return;
21 | }
22 |
23 | var toPath = _context.Request.Command.Argument;
24 |
25 | _fileProvider.Rename(fromPath, toPath);
26 | fromPath = null;
27 |
28 | _context.Response.Write(250, "Rename succeeded.");
29 |
30 | }
31 | catch
32 | {
33 | _context.Response.Write(500, "RNTO command failed.");
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Size.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the SIZE command.
7 | ///
8 | private void Size()
9 | {
10 | var file = _context.Request.Command.Argument;
11 |
12 | try
13 | {
14 | if (_fileProvider.GetFileSize(file, out long size))
15 | {
16 | _context.Response.Write(213, size.ToString());
17 | }
18 | else
19 | {
20 | _context.Response.Write(550, "File not found.");
21 | }
22 | }
23 | catch
24 | {
25 | _context.Response.Write(500, "SIZE command failed.");
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Stru.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the STRU command.
7 | ///
8 | private void Stru()
9 | {
10 | switch (_context.Request.Argument)
11 | {
12 | case "F":
13 | _context.Request.StructureType = StructureType.File;
14 | _context.Response.Write(200, $"Structure set to File.");
15 | break;
16 |
17 | case "R":
18 | case "P":
19 | ParameterNotImplemented();
20 | break;
21 |
22 | default:
23 | ParameterNotRecognized();
24 | break;
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Syst.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the SYST command.
7 | ///
8 | private void Syst()
9 | {
10 | _context.Response.Write(215, "UNIX simulated by TinyCLR OS.");
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/Type.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | internal partial class FtpSession
4 | {
5 | ///
6 | /// Implements the TYPE command.
7 | ///
8 | private void Type()
9 | {
10 | switch (_context.Request.Argument)
11 | {
12 | case "I":
13 | _context.Request.TransferType = TransferType.Image;
14 | _context.Response.Write(200, "Binary transfer mode active.");
15 | break;
16 |
17 | case "A":
18 | _context.Request.TransferType = TransferType.Ascii;
19 | _context.Response.Write(200, "ASCII transfer mode active.");
20 | break;
21 |
22 | case "E":
23 | case "L":
24 | ParameterNotImplemented();
25 | break;
26 |
27 | default:
28 | ParameterNotRecognized();
29 | break;
30 | }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/FtpSession/Commands/User.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Ftp.Features;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | internal partial class FtpSession
6 | {
7 | ///
8 | /// Implements the USER command.
9 | ///
10 | private void User()
11 | {
12 | var AllowAnonymous = true;
13 |
14 | var feature = (SessionFeature)_context.Features.Get(typeof(SessionFeature));
15 | if (feature != null)
16 | {
17 | AllowAnonymous = feature.AllowAnonymous;
18 | }
19 |
20 | if (_context.Request.Argument == "ANONYMOUS" && AllowAnonymous)
21 | {
22 | _context.Response.Write(331, "Anonymous access allowed, send identity (e-mail name) as password.");
23 | }
24 | else
25 | {
26 | _context.Response.Write(331, $"Password required for {_context.Request.Command.Argument}.");
27 | }
28 |
29 | _context.Request.Name = _context.Request.Command.Argument;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("a3819878-1d41-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Server/FtpServerOptionsDelegate.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Sockets;
2 |
3 | namespace Bytewizer.TinyCLR.Ftp
4 | {
5 | ///
6 | /// Represents an options method to configure specific features.
7 | ///
8 | /// The configuration specific features.
9 | public delegate void ServerOptionsDelegate(FtpServerOptions configure);
10 | }
--------------------------------------------------------------------------------
/src/ftp/Bytewizer.TinyCLR.Ftp/Server/SecurityMethod.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Ftp
2 | {
3 | ///
4 | /// Defines FTP security methods.
5 | ///
6 | public enum SecurityMethod
7 | {
8 | ///
9 | /// Plain FTP method.
10 | ///
11 | None,
12 |
13 | ///
14 | /// Explicit FTPS method.
15 | ///
16 | Explicit,
17 |
18 | ///
19 | /// Explicit FTPS method.
20 | ///
21 | Implicit
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/ftp/README.md:
--------------------------------------------------------------------------------
1 | # FTP
2 |
3 | Privides a File Transfer Protocol (FTP/FTPS) server to provide simple file transfers built for TinyCLR OS.
4 |
5 | ## Simple Ftp Server Example
6 |
7 | ```CSharp
8 | static void Main()
9 | {
10 | // Initialize networking before starting service
11 |
12 | var server = new FtpServer()
13 | server.Start();
14 | }
15 | ```
16 |
17 | ## TinyCLR Packages
18 | Install release package from [NuGet](https://www.nuget.org/packages?q=bytewizer.tinyclr) or using the Package Manager Console :
19 | ```powershell
20 | PM> Install-Package Bytewizer.TinyCLR.Ftp
21 | ```
22 |
23 | ## RFC - Related Request for Comments
24 | - [RFC 114 - File Transfer Protocol (FTP)](https://tools.ietf.org/html/rfc114)
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/Delegates.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Logging;
4 | using Bytewizer.TinyCLR.DependencyInjection;
5 |
6 | namespace Bytewizer.TinyCLR.Hosting
7 | {
8 | //public delegate void HostConfigAction(IHostBuilder obj);
9 | //public delegate void AppConfigAction(HostBuilderContext obj1, IHostBuilder obj2);
10 |
11 | //public delegate void ConfigAction(IConfigurationBuilder obj);
12 |
13 | public delegate void ServiceAction(IServiceCollection obj);
14 | //public delegate void ServiceContextDelegate(HostBuilderContext obj1, IServiceCollection obj2);
15 |
16 | public delegate void ServiceDelegate(HostBuilderContext context, IServiceCollection serviceCollection);
17 |
18 | public delegate void LoggingAction(ILoggingBuilder obj);
19 | public delegate void LoggingContextDelegate(HostBuilderContext context, ILoggingBuilder builder);
20 | }
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/Host.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Logging.Debug;
4 |
5 | namespace Bytewizer.TinyCLR.Hosting
6 | {
7 | ///
8 | /// Provides convenience methods for creating instances of with pre-configured defaults.
9 | ///
10 | public static class Host
11 | {
12 | ///
13 | /// Initializes a new instance of the class with pre-configured defaults.
14 | ///
15 | /// The initialized .
16 | public static IHostBuilder CreateDefaultBuilder()
17 | {
18 | var builder = new HostBuilder();
19 |
20 | builder.ConfigureLogging((context, logging) =>
21 | {
22 | logging.AddDebug();
23 | });
24 |
25 | return builder;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/HostBuilderContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace Bytewizer.TinyCLR.Hosting
5 | {
6 | ///
7 | /// Context containing the common services on the . Some properties may be null until set by the .
8 | ///
9 | public class HostBuilderContext
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | public HostBuilderContext(IDictionary properties)
15 | {
16 | Properties = properties ?? throw new ArgumentNullException(nameof(properties));
17 | }
18 |
19 | ///
20 | /// A central location for sharing state between components during the host building process.
21 | ///
22 | public IDictionary Properties { get; }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/IConfigureContainerAdapter.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Hosting.Internal
2 | {
3 | internal interface IConfigureContainerAdapter
4 | {
5 | void ConfigureContainer(HostBuilderContext hostContext);
6 | }
7 | }
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/IHost.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Hosting
4 | {
5 | ///
6 | /// A program abstraction.
7 | ///
8 | public interface IHost : IDisposable
9 | {
10 | ///
11 | /// The programs configured services.
12 | ///
13 | IServiceProvider Services { get; }
14 |
15 | ///
16 | /// Start the program.
17 | ///
18 | void Start();
19 |
20 | ///
21 | /// Attempts to gracefully stop the program.
22 | ///
23 | void Stop();
24 | }
25 | }
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/IHostedService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 |
3 | namespace Bytewizer.TinyCLR.Hosting
4 | {
5 | ///
6 | /// Defines methods for objects that are managed by the host.
7 | ///
8 | public interface IHostedService
9 | {
10 | ///
11 | /// Triggered when the application host is ready to start the service.
12 | ///
13 | Thread Start();
14 |
15 | ///
16 | /// Triggered when the application host is performing a graceful shutdown.
17 | ///
18 | void Stop(int timeout = 1000);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/ServiceCollectionHostedServiceExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.DependencyInjection;
4 |
5 | namespace Bytewizer.TinyCLR.Hosting
6 | {
7 | public static class ServiceCollectionHostedServiceExtensions
8 | {
9 | ///
10 | /// Add an registration for the given type.
11 | ///
12 | /// The to register with.
13 | /// The implementation type of the service.
14 | /// The original .
15 | public static IServiceCollection AddHostedService(this IServiceCollection services, Type implementationType)
16 | {
17 | services.AddSingleton(typeof(IHostedService), implementationType);
18 |
19 | return services;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Hosting/ServiceContextDelegate.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.DependencyInjection;
2 |
3 | namespace Bytewizer.TinyCLR.Hosting
4 | {
5 | ///
6 | /// Represents a function that can process a request.
7 | ///
8 | /// The context for the request.
9 | /// Specifies the contract for a collection of service descriptors.
10 | public delegate void ServiceContextDelegate(HostBuilderContext context, IServiceCollection serviceCollection);
11 | }
12 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Http/GenericWebHostedService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 |
3 | using Bytewizer.TinyCLR.Sockets;
4 |
5 | namespace Bytewizer.TinyCLR.Hosting
6 | {
7 | internal class GenericWebHostedService : IHostedService
8 | {
9 | public GenericWebHostedService(IServer server)
10 | {
11 | Server = server;
12 | }
13 |
14 | public IServer Server { get; }
15 |
16 | public Thread Start()
17 | {
18 | Server.Start();
19 | return Thread.CurrentThread;
20 | }
21 |
22 | public void Stop(int timeout = 1000)
23 | {
24 | Server.Stop();
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Http/IWebHostBuilder.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Sockets;
2 |
3 | namespace Bytewizer.TinyCLR.Hosting
4 | {
5 | public interface IWebHostBuilder
6 | {
7 | ///
8 | /// Builds an which hosts a web application.
9 | ///
10 | IServer Build();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Http/internal/WebHostBuilder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.DependencyInjection;
4 | using Bytewizer.TinyCLR.Sockets;
5 |
6 | namespace Bytewizer.TinyCLR.Hosting
7 | {
8 | internal sealed class WebHostBuilder : IWebHostBuilder
9 | {
10 | public WebHostBuilder(IServiceCollection services)
11 | {
12 | Services = services;
13 | }
14 |
15 | public IServiceCollection Services { get; }
16 |
17 | public IServer Build()
18 | {
19 | throw new NotImplementedException();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Logging/DebugLoggerFactoryExtensions.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.DependencyInjection;
2 |
3 | namespace Bytewizer.TinyCLR.Logging.Debug
4 | {
5 | public static class DebugLoggerFactoryExtensions
6 | {
7 | ///
8 | /// Adds a debug logger to the factory.
9 | ///
10 | /// The extension method argument.
11 | public static ILoggingBuilder AddDebug(this ILoggingBuilder builder)
12 | {
13 | builder.Services.AddSingleton(typeof(ILoggerProvider), typeof(DebugLoggerProvider));
14 |
15 | return builder;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Logging/ILoggingBuilder.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.DependencyInjection;
2 |
3 | namespace Bytewizer.TinyCLR.Logging
4 | {
5 | ///
6 | /// An interface for configuring logging providers.
7 | ///
8 | public interface ILoggingBuilder
9 | {
10 | ///
11 | /// Gets the where Logging services are configured.
12 | ///
13 | IServiceCollection Services { get; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Logging/Internal/LoggerEventIds.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Logging;
2 |
3 | namespace Bytewizer.TinyCLR.Hosting
4 | {
5 | internal static class LoggerEventIds
6 | {
7 | public static readonly EventId Starting = new EventId(1, "Starting");
8 | public static readonly EventId Started = new EventId(2, "Started");
9 | public static readonly EventId Stopping = new EventId(3, "Stopping");
10 | public static readonly EventId Stopped = new EventId(4, "Stopped");
11 | public static readonly EventId StoppedWithException = new EventId(5, "StoppedWithException");
12 | public static readonly EventId ApplicationStartupException = new EventId(6, "ApplicationStartupException");
13 | public static readonly EventId ApplicationStoppingException = new EventId(7, "ApplicationStoppingException");
14 | public static readonly EventId ApplicationStoppedException = new EventId(8, "ApplicationStoppedException");
15 | public static readonly EventId BackgroundServiceFaulted = new EventId(9, "BackgroundServiceFaulted");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Logging/Internal/LoggingBuilder.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.DependencyInjection;
2 |
3 | namespace Bytewizer.TinyCLR.Logging
4 | {
5 | internal class LoggingBuilder : ILoggingBuilder
6 | {
7 | public LoggingBuilder(IServiceCollection services)
8 | {
9 | Services = services;
10 | }
11 |
12 | public IServiceCollection Services { get; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Logging/LoggingBuilderDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Logging
2 | {
3 | public delegate void LoggingBuilderDelegate(ILoggingBuilder builder);
4 | }
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("9e368003-1168-49f2-863e-8799a9436bea")]
5 |
--------------------------------------------------------------------------------
/src/hosting/Bytewizer.TinyCLR.Hosting/README.md:
--------------------------------------------------------------------------------
1 | # Hosting Abstraction
2 |
3 | Provides a minimalistic hosting interface useful for libraries that does nothing.
4 |
5 | ## TinyCLR Packages
6 | Install release package from [NuGet](https://www.nuget.org/packages?q=bytewizer.tinyclr) or using the Package Manager Console :
7 | ```powershell
8 | PM> Install-Package Bytewizer.TinyCLR.Hosting.Abstractions
9 | ```
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Authentication/Authenticator/AuthenticateResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Authenticator
4 | {
5 | ///
6 | /// Contains the result of an authenticate call.
7 | ///
8 | public class AuthenticateResult
9 | {
10 | ///
11 | /// Indicates if authenticate was successful.
12 | ///
13 | public bool Succeeded { get; set; } = true;
14 |
15 | ///
16 | /// Holds failure information from the authentication.
17 | ///
18 | public string Failure { get; protected set; }
19 |
20 | ///
21 | /// Indicates that there was a failure during authentication.
22 | ///
23 | /// The failure message.
24 | public static AuthenticateResult Fail(string message)
25 | {
26 | return new AuthenticateResult()
27 | {
28 | Succeeded = false,
29 | Failure = message
30 | };
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Authentication/Features/HttpAuthenticationFeature.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Identity;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Features
4 | {
5 | ///
6 | public class HttpAuthenticationFeature : IHttpAuthenticationFeature
7 | {
8 | ///
9 | public IIdentityUser User { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Authentication/Features/IHttpAuthenticationFeature.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Identity;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Features
4 | {
5 | ///
6 | /// A feature interface for authentication. Use
7 | /// to access an instance associated with the current request.
8 | ///
9 | public interface IHttpAuthenticationFeature
10 | {
11 | ///
12 | /// Gets or sets security information for the current HTTP request.
13 | ///
14 | IIdentityUser User { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Authentication/Http/HttpContextExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Identity;
4 | using Bytewizer.TinyCLR.Http.Features;
5 |
6 | namespace Bytewizer.TinyCLR.Http
7 | {
8 | ///
9 | /// Extension methods for related to routing.
10 | ///
11 | public static class HttpContextExtensions
12 | {
13 | ///
14 | /// Extension method for getting the current user name request.
15 | ///
16 | /// The context.
17 | public static IIdentityUser GetCurrentUser(this HttpContext context)
18 | {
19 | if (context == null)
20 | {
21 | throw new ArgumentNullException(nameof(context));
22 | }
23 |
24 | var userFeature = (HttpAuthenticationFeature)context.Features.Get(typeof(IHttpAuthenticationFeature));
25 |
26 | return userFeature?.User;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Authentication/Http/IdentityProviderExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Identity;
4 |
5 | namespace Bytewizer.TinyCLR.Http
6 | {
7 | ///
8 | /// Convenience methods for .
9 | ///
10 | public static class IdentityProviderExtensions
11 | {
12 | public static IdentityResult Create(this IdentityProvider provider, IIdentityUser user, string realm, string secret)
13 | {
14 | var password = AuthHelper.ComputeA1Hash(user.UserName, realm, secret);
15 |
16 | user.Metadata = password;
17 |
18 | return provider.Create(user, password);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Authentication/Middleware/AuthenticationOptions.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Identity;
2 | using Bytewizer.TinyCLR.Http.Authenticator;
3 |
4 | namespace Bytewizer.TinyCLR.Http
5 | {
6 | ///
7 | /// Options for selecting authentication scheme and account services.
8 | ///
9 | public class AuthenticationOptions
10 | {
11 | ///
12 | /// Configuration for the .
13 | ///
14 | public AuthenticationOptions()
15 | {
16 | AuthenticationProvider = new DigestAuthenticationProvider();
17 | IdentityProvider = new IdentityProvider();
18 | }
19 |
20 | ///
21 | /// Authentication service for the specified authentication scheme.
22 | ///
23 | public IAuthenticationProvider AuthenticationProvider { get; set; }
24 |
25 | ///
26 | /// Account service for the specified authentication scheme.
27 | ///
28 | public IIdentityProvider IdentityProvider { get; set; }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Authentication/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: AssemblyConfiguration("Secure")]
6 | [assembly: Guid("2dd3d5ab-d849-4898-b6e9-1a49683955b2")]
7 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Cookies/Middleware/CookiesMiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.TinyCLR.Http
6 | {
7 | ///
8 | /// Extension methods for the .
9 | ///
10 | public static class CookiesMiddlewareExtensions
11 | {
12 | ///
13 | /// Enable cookie capabilities.
14 | ///
15 | /// The instance this method extends.
16 | public static IApplicationBuilder UseCookies(this IApplicationBuilder app)
17 | {
18 | if (app == null)
19 | {
20 | throw new ArgumentNullException(nameof(app));
21 | }
22 |
23 | return app.UseMiddleware(typeof(CookiesMiddleware));
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Cookies/Middleware/Features/HttpCookiesFeature.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Features
2 | {
3 | ///
4 | public class HttpCookiesFeature : IHttpCookiesFeature
5 | {
6 | ///
7 | public ICookieCollection Cookies { get; set; }
8 |
9 | ///
10 | public IResponseCookies ResponseCookies { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Cookies/Middleware/Features/IHttpCookiesFeature.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Features
2 | {
3 | ///
4 | /// A feature interface for authentication. Use
5 | /// to access an instance associated with the current request.
6 | ///
7 | public interface IHttpCookiesFeature
8 | {
9 | ///
10 | /// Gets the collection of Cookies for this request.
11 | ///
12 | ICookieCollection Cookies { get; set; }
13 |
14 | ///
15 | /// Gets an object that can be used to manage cookies for this response.
16 | ///
17 | IResponseCookies ResponseCookies { get; }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Cookies/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2da3d5ab-d848-4898-b6a9-1a44635955b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Cors/Middleware/CorsOptions.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Bytewizer.TinyCLR.Http
5 | {
6 | ///
7 | /// Options for configuring the .
8 | ///
9 | public class CorsOptions
10 | {
11 | ///
12 | /// Create an instance with the default options settings.
13 | ///
14 | public CorsOptions()
15 | {
16 | Origins = "*";
17 | Headers = "*";
18 | Methods = "*";
19 | }
20 |
21 | ///
22 | /// The origins allowed in a string of comma-seprated values.
23 | ///
24 | public string Origins { get; set; }
25 |
26 | ///
27 | /// The methods allowed in a string of comma-seprated values.
28 | ///
29 | public string Headers { get; set; }
30 |
31 | ///
32 | /// The headers allowed in a string of comma-seprated values.
33 | ///
34 | public string Methods { get; set; }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Cors/Middleware/ParsingHelpers.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Http
4 | {
5 | ///
6 | ///
7 | ///
8 | public static class ParsingHelper
9 | {
10 | ///
11 | ///
12 | ///
13 | ///
14 | public static ArrayList SplitByComma(string source)
15 | {
16 | var result = new ArrayList();
17 | var values = source.Split(new char[] { ',' });
18 |
19 | foreach (var value in values)
20 | {
21 | if (!string.IsNullOrEmpty(value))
22 | {
23 | result.Add(value.Trim().ToUpper());
24 | }
25 | }
26 |
27 | return result;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Cors/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2dd3d5ab-d849-4898-b6a9-1a44635955b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Diagnostics/Middleware/DeveloperExceptionPageOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http
2 | {
3 | ///
4 | /// Options for configuring the .
5 | ///
6 | public class DeveloperExceptionPageOptions
7 | {
8 | ///
9 | /// Create an instance with the default options settings.
10 | ///
11 | public DeveloperExceptionPageOptions()
12 | {
13 | DisplayStackTrace = true;
14 | }
15 |
16 | ///
17 | /// Include stack trace in exception page.
18 | ///
19 | public bool DisplayStackTrace { get; set; }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Diagnostics/Middleware/MemoryInfoMiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.Playground.Sockets
6 | {
7 | ///
8 | /// Extension methods for .
9 | ///
10 | public static class MemoryInfoMiddlewareExtensions
11 | {
12 | ///
13 | /// Adds a middleware that provides device memory information.
14 | ///
15 | /// The instance.
16 | public static void UseMemoryInfo(this IApplicationBuilder builder)
17 | {
18 | if (builder == null)
19 | {
20 | throw new ArgumentNullException(nameof(builder));
21 | }
22 |
23 | builder.Use(new MemoryInfoMiddleware());
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Diagnostics/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2dd3d5ab-d849-4398-b6a9-1a44635555b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Diagnostics/README.md:
--------------------------------------------------------------------------------
1 | # Diagnostics
2 |
3 | ## Developer Exception Page
4 |
5 | Enables and captures exception instances from the pipeline and generates HTML error responses. Use the
6 | UseDeveloperException() extension method to render the exception during the development mode. This method
7 | adds middleware into the request pipeline which displays developer-friendly exception detail page. This
8 | middleware should not be used in production.
9 |
10 | ```CSharp
11 | options.Pipeline(app =>
12 | {
13 | app.UseDeveloperExceptionPage(); // Should be called first in the pipeline.
14 | });
15 | ```
16 |
17 | ## TinyCLR Packages
18 | Install release package from [NuGet](https://www.nuget.org/packages?q=bytewizer.tinyclr) or using the Package Manager Console :
19 | ```powershell
20 | PM> Install-Package Bytewizer.TinyCLR.Http.Diagnostics
21 | ```
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Hosting/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2dd3d5ab-d849-4398-b6a9-1a44635955b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Json/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2dd3d5ab-a849-4398-c6a9-1a34635955b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/ActionResults/ActionResult.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Bytewizer.TinyCLR.Http.Mvc
5 | {
6 | ///
7 | /// A default implementation of .
8 | ///
9 | public abstract class ActionResult : IActionResult
10 | {
11 | ///
12 | /// Executes the result operation of the action method synchronously. This method is called by MVC to process
13 | /// the result of an action method.
14 | ///
15 | /// The context in which the result is executed. The context information includes
16 | /// information about the action that was executed and request information.
17 | public abstract void ExecuteResult(ActionContext context);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/ActionResults/BadRequestResult.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Bytewizer.TinyCLR.Http.Mvc
5 | {
6 | ///
7 | /// A that when executed will produce a Bad Request (400) response.
8 | ///
9 | public class BadRequestResult : StatusCodeResult
10 | {
11 | private const int DefaultStatusCode = StatusCodes.Status400BadRequest;
12 |
13 | ///
14 | /// Creates a new instance.
15 | ///
16 | public BadRequestResult()
17 | : base(DefaultStatusCode)
18 | {
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/ActionResults/EmptyResult.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Bytewizer.TinyCLR.Http.Mvc
5 | {
6 | ///
7 | /// Represents an that when executed will do nothing.
8 | ///
9 | public class EmptyResult : ActionResult
10 | {
11 | ///
12 | public override void ExecuteResult(ActionContext context)
13 | {
14 |
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/ActionResults/NotFoundResult.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Bytewizer.TinyCLR.Http.Mvc
5 | {
6 | ///
7 | /// Represents an that when executed will produce a Not Found (404) response.
8 | ///
9 | public class NotFoundResult : StatusCodeResult
10 | {
11 | private const int DefaultStatusCode = StatusCodes.Status404NotFound;
12 |
13 | ///
14 | /// Creates a new instance.
15 | ///
16 | public NotFoundResult() : base(DefaultStatusCode)
17 | {
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/ActionResults/OkResult.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Bytewizer.TinyCLR.Http.Mvc
5 | {
6 | ///
7 | /// An that when executed will produce an empty response.
8 | ///
9 | public class OkResult : StatusCodeResult
10 | {
11 | private const int DefaultStatusCode = StatusCodes.Status200OK;
12 |
13 | ///
14 | /// Initializes a new instance of the class.
15 | ///
16 | public OkResult()
17 | : base(DefaultStatusCode)
18 | {
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Filters/FilterContext.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace Bytewizer.TinyCLR.Http.Mvc.Filters
5 | {
6 | ///
7 | /// An abstract context for filters.
8 | ///
9 | public abstract class FilterContext : ActionContext
10 | {
11 | ///
12 | /// Instantiates a new instance.
13 | ///
14 | /// The .
15 | public FilterContext(ActionContext actionContext)
16 | : base(actionContext)
17 | {
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Http/Route.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http
2 | {
3 | ///
4 | /// Implementation of class.
5 | ///
6 | public class Route
7 | {
8 | #pragma warning disable IDE1006 // Naming Styles
9 |
10 | ///
11 | /// Get or sets the route controller.
12 | ///
13 | public string controller { get; set; }
14 |
15 |
16 | ///
17 | /// Get or sets the route action.
18 | ///
19 | public string action { get; set; }
20 |
21 | #pragma warning restore IDE1006 // Naming Styles
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/ModelBinding/IModelBinder.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Mvc.ModelBinding
2 | {
3 | ///
4 | /// Defines an interface for model binders.
5 | ///
6 | public interface IModelBinder
7 | {
8 | ///
9 | /// Attempts to bind a model.
10 | ///
11 | /// The .
12 | bool CanBind(IModelBinderContext context);
13 |
14 | ///
15 | /// Bind a model.
16 | ///
17 | /// The .
18 | object Bind(IModelBinderContext context);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/ModelBinding/IValueProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Mvc.ModelBinding
4 | {
5 | ///
6 | /// Defines the methods that are required for a value provider.
7 | ///
8 | public interface IValueProvider
9 | {
10 | ///
11 | /// Retrieves a value object using the specified key.
12 | ///
13 | /// The key of the value object to retrieve.
14 | string Get(string key);
15 |
16 | ///
17 | /// Retrieves all value object.
18 | ///
19 | ICollection GetValues();
20 |
21 | ///
22 | /// Find all parameters which starts with the specified argument.
23 | ///
24 | /// Beginning of the field name
25 | /// All matching parameters.
26 | IEnumerable Find(string prefix);
27 | }
28 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Mvc/ActionDescriptor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace Bytewizer.TinyCLR.Http.Mvc
5 | {
6 | ///
7 | /// Describes an MVC action.
8 | ///
9 | public class ActionDescriptor
10 | {
11 | ///
12 | /// Initializes a new instance of .
13 | ///
14 | public ActionDescriptor()
15 | {
16 | Id = DateTime.Now.Ticks.ToString();
17 | Properties = new Hashtable();
18 | }
19 |
20 | ///
21 | /// Gets an id which uniquely identifies the action.
22 | ///
23 | public string Id { get; }
24 |
25 | ///
26 | /// A friendly name for this action.
27 | ///
28 | public virtual string DisplayName { get; set; }
29 |
30 | ///
31 | /// Stores arbitrary metadata properties associated with the .
32 | ///
33 | public Hashtable Properties { get; set; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Mvc/Controller.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Http.Mvc.Filters;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Mvc
4 | {
5 | ///
6 | /// A base class for an MVC controller with view support.
7 | ///
8 | public abstract class Controller : ControllerBase
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | protected Controller()
14 | {
15 | }
16 |
17 | ///
18 | public virtual void OnActionExecuting(ActionExecutingContext context)
19 | {
20 | }
21 |
22 | ///
23 | public virtual void OnActionExecuted(ActionExecutedContext context)
24 | {
25 | }
26 |
27 | ///
28 | public virtual void OnException(ExceptionContext context)
29 | {
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Mvc/IActionResult.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Mvc
2 | {
3 | ///
4 | /// Defines a contract that represents the result of an action method.
5 | ///
6 | public interface IActionResult
7 | {
8 | ///
9 | /// Executes the result operation of the action method. This method is called by MVC to process
10 | /// the result of an action method.
11 | ///
12 | /// The context in which the result is executed. The context information includes
13 | /// information about the action that was executed and request information.
14 | void ExecuteResult(ActionContext context);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("048913f0-07e4-4cd5-bcfc-74ae37b01d74")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Stubble/ClosingElement.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Stubble
4 | {
5 | internal class ClosingElement
6 | {
7 | public string Name;
8 | public int Start;
9 | public int End;
10 | public ArrayList Show { get; set; } = new ArrayList(); //public List Show { get; set; } = new List();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Stubble/FieldExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Stubble
2 | {
3 | internal static class FieldExtensions
4 | {
5 | public static int[] Append(this int[] array, int filter)
6 | {
7 | if (array == null)
8 | {
9 | return new int[] { filter };
10 | }
11 |
12 | int[] result = new int[array.Length + 1];
13 | for (int i = 0; i < array.Length; i++)
14 | {
15 | result[i] = array[i];
16 | }
17 |
18 | result[array.Length] = filter;
19 | return result;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Stubble/SerializedView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace Bytewizer.TinyCLR.Stubble
5 | {
6 | [Serializable]
7 | internal struct SerializedView
8 | {
9 | public ViewData Data;
10 | public Hashtable Fields; //public IDictionary Fields;
11 | public IList Elements; //public List Elements;
12 | public IList Partials; //public List Partials;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Stubble/ViewCache.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Stubble
4 | {
5 | internal static class ViewCache
6 | {
7 | public static IDictionary Cache { get; set; } = new Hashtable(); //public static Dictionary cache { get; set; } = new Dictionary();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Stubble/ViewDictionary.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Stubble
4 | {
5 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
6 | public class ViewDictionary : Hashtable
7 | {
8 | private readonly ViewData _parent;
9 | private readonly string _id;
10 |
11 | public ViewDictionary(ViewData parent, string id)
12 | {
13 | _parent = parent;
14 | _id = id;
15 | }
16 |
17 | public string this[string key]
18 | {
19 | get
20 | {
21 | return _parent[_id + "-" + key];
22 | }
23 | set
24 | {
25 | _parent[_id + "-" + key] = value;
26 | }
27 | }
28 | }
29 | #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
30 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Stubble/ViewElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace Bytewizer.TinyCLR.Stubble
5 | {
6 | [Serializable]
7 | internal struct ViewElement
8 | {
9 | public string Name;
10 | public string Path;
11 | public string Htm;
12 | //public IDictionary Vars; //public Dictionary Vars;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.Mvc/Stubble/ViewPartial.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Stubble
4 | {
5 | [Serializable]
6 | internal class ViewPartial
7 | {
8 | public string Name { get; set; }
9 | public string Path { get; set; }
10 | public string Prefix { get; set; } //prefix used in html variable names after importing the partial
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.PageBuilder/Http/HttpResponseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Http.PageBuilder;
4 |
5 | namespace Bytewizer.TinyCLR.Http
6 | {
7 | ///
8 | /// Convenience methods for .
9 | ///
10 | public static class HttpResponseExtensions
11 | {
12 | ///
13 | /// Writes the given HTML to the response body.
14 | ///
15 | /// The .
16 | /// The document to write to the response.
17 | public static void Write(this HttpResponse response, HtmlPage content)
18 | {
19 | if (response == null)
20 | {
21 | throw new ArgumentNullException(nameof(response));
22 | }
23 |
24 | response.Write(content.ToString());
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.PageBuilder/PageBuilder/HtmlPage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Http.PageBuilder
4 | {
5 | ///
6 | /// HTML response page.
7 | ///
8 | public class HtmlPage
9 | {
10 |
11 | ///
12 | /// HTML document head.
13 | ///
14 | public HtmlHead Head { get; private set; } = new HtmlHead();
15 |
16 | ///
17 | /// HTML document body.
18 | ///
19 | public HtmlBody Body { get; private set; } = new HtmlBody();
20 |
21 |
22 | ///
23 | /// Instantiate the object.
24 | ///
25 | public HtmlPage()
26 | {
27 |
28 | }
29 |
30 | ///
31 | /// Create an HTML string from the document.
32 | ///
33 | /// HTML string.
34 | public override string ToString()
35 | {
36 | string ret =
37 | "" +
38 | "" +
39 | Head.Content +
40 | "" +
41 | Body.Content +
42 | "";
43 | return ret;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.PageBuilder/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2dd3d5ab-a849-4398-c6a9-1a34233955b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.ResourceManager/Http/HttpContextExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Resources;
3 |
4 | using Bytewizer.TinyCLR.Http.Features;
5 |
6 | namespace Bytewizer.TinyCLR.Http
7 | {
8 | ///
9 | /// Convenience methods for .
10 | ///
11 | public static class HttpContextExtensions
12 | {
13 | ///
14 | /// Extension method for getting the for the current request.
15 | ///
16 | /// The context.
17 | public static ResourceManager GetResourceManager(this HttpContext context)
18 | {
19 | if (context == null)
20 | {
21 | throw new ArgumentNullException(nameof(context));
22 | }
23 |
24 | var resourceManagerFeature = (ResourceManagerFeature)context.Features.Get(typeof(IResourceManagerFeature));
25 | if (resourceManagerFeature == null)
26 | {
27 | resourceManagerFeature = new ResourceManagerFeature();
28 | }
29 |
30 | return resourceManagerFeature.ResourceManager;
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.ResourceManager/Middleware/Features/IResourceManagerFeature.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Features
4 | {
5 | ///
6 | /// Represents the feature.
7 | ///
8 | public interface IResourceManagerFeature
9 | {
10 | ResourceManager ResourceManager { get; }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.ResourceManager/Middleware/Features/ResourceManagerFeature.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Features
4 | {
5 | ///
6 | /// Represents the feature.
7 | ///
8 | public class ResourceManagerFeature : IResourceManagerFeature
9 | {
10 | public ResourceManager ResourceManager { get; set; }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.ResourceManager/Middleware/UseResourcesExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Resources;
3 |
4 | using Bytewizer.TinyCLR.Pipeline.Builder;
5 |
6 | namespace Bytewizer.TinyCLR.Http
7 | {
8 | ///
9 | /// Extension methods for .
10 | ///
11 | public static class UseResourcesExtensions
12 | {
13 | ///
14 | /// Adds a middleware that includes a in the request.
15 | ///
16 | /// The instance.
17 | /// The for configuring the middleware.
18 | /// The instance.
19 | public static IApplicationBuilder UseResources(this IApplicationBuilder builder, ResourceManager resourceManager)
20 | {
21 | if (builder == null)
22 | {
23 | throw new ArgumentNullException(nameof(builder));
24 | }
25 |
26 | return builder.UseMiddleware(typeof(ResourceMiddleware), resourceManager);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.ResourceManager/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2dd3d5ab-a849-4398-c6a9-1b33635955b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.StaticFiles.Blazor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("048913f0-07e4-4cd5-bcfc-74ae37b01d74")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.StaticFiles.Blazor/README.md:
--------------------------------------------------------------------------------
1 | # Static File Handling
2 | Enables static files inteface for serving Blazor files to a client.
3 |
4 |
5 | ## TinyCLR Packages
6 | Install release package from [NuGet](https://www.nuget.org/packages?q=bytewizer.tinyclr) or using the Package Manager Console :
7 | ```powershell
8 | PM> Install-Package Bytewizer.TinyCLR.StaticFiles.Blazor
9 | ```
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.StaticFiles.Resources/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("048913f0-07e4-4cd5-bcfc-74ae37b01d74")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.StaticFiles/Http/IContentTypeProvider.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Bytewizer.TinyCLR.Http
3 | {
4 | ///
5 | /// Used to look up MIME types given a file path.
6 | ///
7 | public interface IContentTypeProvider
8 | {
9 | ///
10 | /// Given a file path, determine the MIME type.
11 | ///
12 | /// A file path
13 | /// The resulting MIME type
14 | /// True if MIME type could be determined
15 | bool TryGetContentType(string subpath, out string contentType);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.StaticFiles/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("048913f0-07e4-4cd5-bcfc-74ae37b01d74")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/Extensions/ByteOrder.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR
2 | {
3 | ///
4 | /// Specifies the byte order.
5 | ///
6 | public enum ByteOrder
7 | {
8 | ///
9 | /// Specifies Little-endian.
10 | ///
11 | Little,
12 |
13 | ///
14 | /// Specifies Big-endian.
15 | ///
16 | Big
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/Features/IHttpWebSocketFeature.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Features
2 | {
3 | ///
4 | /// A feature interface for websockets. Use
5 | /// to access an instance associated with the current request.
6 | ///
7 | public interface IHttpWebSocketFeature
8 | {
9 | ///
10 | /// Indicates if this is a WebSocket upgrade request.
11 | ///
12 | bool IsWebSocketRequest { get; }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2dd3d5ab-d839-4898-b6a9-1a44635455b2")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/README.md:
--------------------------------------------------------------------------------
1 | # WebSocket
2 |
3 | Enables two-way communication between a client and server.
4 |
5 | ## Getting Started
6 |
7 | This module has not yet reached a stable state.
8 |
9 | ## RFC - Related Request for Comments
10 | - [RFC 6455 - The WebSocket Protocol](https://tools.ietf.org/html/rfc6455)
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/Clients/Clients.All.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Sockets.Channel;
2 | using System;
3 | using System.Collections;
4 | using System.Text;
5 | using System.Threading;
6 |
7 | namespace Bytewizer.TinyCLR.Http.WebSockets
8 | {
9 | public partial class Clients : IClientsAll
10 | {
11 | ///
12 | /// Provides methods to access caller operations.
13 | ///
14 | public IClientsAll All { get { return this; } }
15 |
16 | void IClientsAll.SendText(string text)
17 | {
18 | var buffer = Encoding.UTF8.GetBytes(text);
19 | All.SendText(buffer, buffer.Length);
20 | }
21 |
22 | void IClientsAll.SendText(byte[] buffer, long length)
23 | {
24 | var payload = new PayloadData(buffer, length);
25 | var frame = new WebSocketFrame(Fin.Final, Opcode.Text, payload, false, false);
26 |
27 | foreach (SocketChannel session in _channels.Values)
28 | {
29 | session.OutputStream.Write(frame.ToArray());
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/Clients/Clients.Caller.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.IO;
4 | using System.Net.Sockets;
5 | using System.Text;
6 | using System.Threading;
7 |
8 | namespace Bytewizer.TinyCLR.Http.WebSockets
9 | {
10 | public partial class Clients : IClientsCaller
11 | {
12 | ///
13 | /// Provides methods to access caller operations.
14 | ///
15 | public IClientsCaller Caller { get { return this; } }
16 |
17 | void IClientsCaller.SendText(string text)
18 | {
19 | var buffer = Encoding.UTF8.GetBytes(text);
20 | Caller.SendText(buffer, buffer.Length);
21 | }
22 |
23 | void IClientsCaller.SendText(byte[] buffer, long length)
24 | {
25 | var payload = new PayloadData(buffer, length);
26 | var frame = new WebSocketFrame(Fin.Final, Opcode.Text, payload, false, false);
27 | _caller.OutputStream.Write(frame.ToArray());
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/Clients/Clients.Others.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Text;
4 | using System.Threading;
5 |
6 | namespace Bytewizer.TinyCLR.Http.WebSockets
7 | {
8 | public partial class Clients : IClientsOthers
9 | {
10 | ///
11 | /// Provides methods to access caller operations.
12 | ///
13 | public IClientsOthers Others { get { return this; } }
14 |
15 | void IClientsOthers.SendText(string text)
16 | {
17 | throw new NotImplementedException();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/Clients/IClientsAll.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Text;
4 | using System.Threading;
5 |
6 | namespace Bytewizer.TinyCLR.Http.WebSockets
7 | {
8 | public interface IClientsAll
9 | {
10 | void SendText(string text);
11 |
12 | void SendText(byte[] buffer, long length);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/Clients/IClientsCaller.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Text;
4 | using System.Threading;
5 |
6 | namespace Bytewizer.TinyCLR.Http.WebSockets
7 | {
8 | public interface IClientsCaller
9 | {
10 | void SendText(string text);
11 |
12 | void SendText( byte[] buffer, long length);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/Clients/IClientsOthers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Text;
4 | using System.Threading;
5 |
6 | namespace Bytewizer.TinyCLR.Http.WebSockets
7 | {
8 | public interface IClientsOthers
9 | {
10 | void SendText(string text);
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/IHub.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Http.WebSockets
4 | {
5 | public interface IHub
6 | {
7 | ///
8 | /// Called when a new message is sent to the hub.
9 | ///
10 | void OnMessage(WebSocketContext context);
11 |
12 | }
13 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/WebSocket.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Text;
4 | using System.Threading;
5 |
6 | namespace Bytewizer.TinyCLR.Http.WebSockets
7 | {
8 | public class WebSocket
9 | {
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/WebSocketContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Text;
4 | using System.Threading;
5 |
6 | namespace Bytewizer.TinyCLR.Http.WebSockets
7 | {
8 | public class WebSocketContext
9 | {
10 |
11 | public WebSocketContext(byte[] payload, bool isText)
12 | {
13 | Payload = payload;
14 | IsText = isText;
15 | //SubProtocols = subProtocols;
16 | }
17 |
18 | public byte[] Payload { get; private set; }
19 |
20 | public bool IsText { get; private set; }
21 |
22 | //public string[] SubProtocols { get; private set; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/WebSocketState.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.WebSockets
2 | {
3 | ///
4 | /// Indicates the state of a WebSocket connection.
5 | ///
6 | public enum WebSocketState : ushort
7 | {
8 | ///
9 | /// Equivalent to numeric value 0. Indicates that the connection has not
10 | /// yet been established.
11 | ///
12 | Connecting = 0,
13 |
14 | ///
15 | /// Equivalent to numeric value 1. Indicates that the connection has
16 | /// been established, and the communication is possible.
17 | ///
18 | Open = 1,
19 |
20 | ///
21 | /// Equivalent to numeric value 2. Indicates that the connection is
22 | /// going through the closing handshake, or the close method has
23 | /// been invoked.
24 | ///
25 | Closing = 2,
26 |
27 | ///
28 | /// Equivalent to numeric value 3. Indicates that the connection has
29 | /// been closed or could not be established.
30 | ///
31 | Closed = 3
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/internal/Fin.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.WebSockets
2 | {
3 | ///
4 | /// Indicates whether a WebSocket frame is the final frame of a message.
5 | ///
6 | internal enum Fin : byte
7 | {
8 | ///
9 | /// Equivalent to numeric value 0. Indicates more frames of a message follow.
10 | ///
11 | More = 0x0,
12 |
13 | ///
14 | /// Equivalent to numeric value 1. Indicates the final frame of a message.
15 | ///
16 | Final = 0x1
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/internal/Mask.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.WebSockets
2 | {
3 | ///
4 | /// Indicates whether the payload data of a WebSocket frame is masked.
5 | ///
6 | internal enum Mask : byte
7 | {
8 | ///
9 | /// Equivalent to numeric value 0. Indicates not masked.
10 | ///
11 | Off = 0x0,
12 |
13 | ///
14 | /// Equivalent to numeric value 1. Indicates masked.
15 | ///
16 | On = 0x1
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/internal/Opcode.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.WebSockets
2 | {
3 | ///
4 | /// Indicates the WebSocket frame type.
5 | ///
6 | internal enum Opcode : byte
7 | {
8 | ///
9 | /// Equivalent to numeric value 0. Indicates continuation frame.
10 | ///
11 | Cont = 0x0,
12 |
13 | ///
14 | /// Equivalent to numeric value 1. Indicates text frame.
15 | ///
16 | Text = 0x1,
17 |
18 | ///
19 | /// Equivalent to numeric value 2. Indicates binary frame.
20 | ///
21 | Binary = 0x2,
22 |
23 | ///
24 | /// Equivalent to numeric value 8. Indicates connection close frame.
25 | ///
26 | Close = 0x8,
27 |
28 | ///
29 | /// Equivalent to numeric value 9. Indicates ping frame.
30 | ///
31 | Ping = 0x9,
32 |
33 | ///
34 | /// Equivalent to numeric value 10. Indicates pong frame.
35 | ///
36 | Pong = 0xa
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/internal/OpcodeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Http.WebSockets
4 | {
5 | internal static class OpcodeExtensions
6 | {
7 | internal static bool IsData(this byte opcode)
8 | {
9 | return opcode == 0x1 || opcode == 0x2;
10 | }
11 |
12 | internal static bool IsData(this Opcode opcode)
13 | {
14 | return opcode == Opcode.Text || opcode == Opcode.Binary;
15 | }
16 |
17 | internal static bool IsControl(this byte opcode)
18 | {
19 | return opcode > 0x7 && opcode < 0x10;
20 | }
21 |
22 | internal static bool IsControl(this Opcode opcode)
23 | {
24 | return opcode >= Opcode.Close;
25 | }
26 | internal static bool IsSupported(this byte opcode)
27 | {
28 | return (opcode == (byte)Opcode.Binary)
29 | || opcode == (byte)Opcode.Close
30 | || opcode == (byte)Opcode.Cont
31 | || opcode == (byte)Opcode.Ping
32 | || opcode == (byte)Opcode.Pong
33 | || opcode == (byte)Opcode.Text;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http.WebSocket/WebSockets/internal/Rsv.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.WebSockets
2 | {
3 | ///
4 | /// Indicates whether each RSV (RSV1, RSV2, and RSV3) of a WebSocket frame is non-zero.
5 | ///
6 | internal enum Rsv : byte
7 | {
8 | ///
9 | /// Equivalent to numeric value 0. Indicates zero.
10 | ///
11 | Off = 0x0,
12 |
13 | ///
14 | /// Equivalent to numeric value 1. Indicates non-zero.
15 | ///
16 | On = 0x1
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Extensions/CharExtensions.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR
2 | {
3 | ///
4 | /// Contains extension methods for object.
5 | ///
6 | public static class CharExtensions
7 | {
8 | ///
9 | /// Indicates whether the specified Unicode character is categorized as white space.
10 | ///
11 | /// The Unicode character to evaluate.
12 | /// true if c is white space; otherwise, false.
13 | public static bool IsWhiteSpace(this char source)
14 | {
15 | return (source == ' ' || source == '\t' || source == '\n' || source == '\r' || source == '\v');
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Extensions/StreamReaderExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace Bytewizer.TinyCLR.Http
4 | {
5 | ///
6 | /// Contains extension methods for .
7 | ///
8 | static class StreamReaderExtensions
9 | {
10 | ///
11 | /// Skips white space in the current stream.
12 | ///
13 | /// The source .
14 | public static void SkipWhiteSpace(this StreamReader reader)
15 | {
16 | while (true)
17 | {
18 | var raw = reader.Peek();
19 | if (raw == -1)
20 | {
21 | break;
22 | }
23 | var ch = (char)raw;
24 | if (!ch.IsWhiteSpace())
25 | {
26 | break;
27 | }
28 | reader.Read();
29 | }
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Http/HttpMethods.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http
2 | {
3 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
4 | ///
5 | /// Contains methods to verify the request method of an HTTP request.
6 | ///
7 | public static class HttpMethods
8 | {
9 | public static readonly string Connect = "CONNECT";
10 | public static readonly string Delete = "DELETE";
11 | public static readonly string Get = "GET";
12 | public static readonly string Head = "HEAD";
13 | public static readonly string Options = "OPTIONS";
14 | public static readonly string Patch = "PATCH";
15 | public static readonly string Post = "POST";
16 | public static readonly string Put = "PUT";
17 | public static readonly string Trace = "TRACE";
18 | }
19 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Http/HttpProtocol.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http
2 | {
3 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
4 | ///
5 | /// Contains methods to verify the request protocol version of an HTTP request.
6 | ///
7 | public static class HttpProtocol
8 | {
9 | public static readonly string Http10 = "HTTP/1.0";
10 | public static readonly string Http11 = "HTTP/1.1";
11 | public static readonly string Http2 = "HTTP/2";
12 | public static readonly string Http3 = "HTTP/3";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Http/RequestDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http
2 | {
3 | ///
4 | /// A function that can process a http request.
5 | ///
6 | /// The context for the request.
7 | public delegate void RequestDelegate(HttpContext context);
8 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Middleware/Features/IStatusCodePagesFeature.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Features
2 | {
3 | ///
4 | /// Represents the Status code pages feature.
5 | ///
6 | public interface IStatusCodePagesFeature
7 | {
8 | ///
9 | /// Indicates if the status code middleware will handle responses.
10 | ///
11 | bool Enabled { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Middleware/Features/StatusCodePagesFeature.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Bytewizer.TinyCLR.Http.Features
3 | {
4 | ///
5 | /// Represents the Status code pages feature.
6 | ///
7 | public class StatusCodePagesFeature : IStatusCodePagesFeature
8 | {
9 | ///
10 | /// Enables or disables status code pages. The default value is true.
11 | /// Set this to false to prevent the
12 | /// from creating a response body while handling the error status code.
13 | ///
14 | public bool Enabled { get; set; } = true;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("674e936b-b2f0-4cc2-9b2d-901de786dd23")]
5 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Routing/EndpointRouteDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Routing
2 | {
3 | ///
4 | /// Represents a method to configure specific features.
5 | ///
6 | /// The configuration specific features.
7 | public delegate void EndpointRouteDelegate(IEndpointRouteBuilder configure);
8 | }
9 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Routing/Features/EndpointFeature.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Features
2 | {
3 | ///
4 | /// A feature for endpoint routing functionality.
5 | ///
6 | public class EndpointFeature : IEndpointFeature
7 | {
8 | ///
9 | public Endpoint Endpoint { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Routing/Features/IEndpointFeature.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Http.Features
2 | {
3 | ///
4 | /// A feature interface for endpoint routing functionality.
5 | ///
6 | public interface IEndpointFeature
7 | {
8 | ///
9 | /// Gets or sets the selected for the current request.
10 | ///
11 | Endpoint Endpoint { get; set; }
12 | }
13 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Routing/IEndpointRouteBuilder.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Http.Routing
4 | {
5 | ///
6 | /// Defines a contract for a route builder in an application. A route builder specifies the routes for an application.
7 | ///
8 | public interface IEndpointRouteBuilder
9 | {
10 | ///
11 | /// Gets the endpoint data sources configured in the builder.
12 | ///
13 | Hashtable DataSources { get; }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Routing/Internal/DefaultEndpointRouteBuilder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | using Bytewizer.TinyCLR.Http.Routing;
5 | using Bytewizer.TinyCLR.Pipeline.Builder;
6 |
7 | namespace Bytewizer.TinyCLR.Http
8 | {
9 | internal class DefaultEndpointRouteBuilder : IEndpointRouteBuilder
10 | {
11 | public DefaultEndpointRouteBuilder(IApplicationBuilder applicationBuilder)
12 | {
13 | if (applicationBuilder == null)
14 | {
15 | throw new ArgumentNullException(nameof(applicationBuilder));
16 | }
17 |
18 | ApplicationBuilder = applicationBuilder;
19 | DataSources = new Hashtable();
20 | }
21 |
22 | public IApplicationBuilder ApplicationBuilder { get; }
23 |
24 | public Hashtable DataSources { get; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/http/Bytewizer.TinyCLR.Http/Server/HttpServerOptions.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Sockets;
2 |
3 | namespace Bytewizer.TinyCLR.Http
4 | {
5 | ///
6 | /// Represents configuration options of server specific features.
7 | ///
8 | public class HttpServerOptions : ServerOptions
9 | {
10 | ///
11 | /// Specifies the name the server represents.
12 | ///
13 | public string Name { get; set; } = "Microserver";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/nuget.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/sntp/Bytewizer.TinyCLR.Sntp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("674e936b-b2f3-4aa2-5b2d-301de786dd23")]
5 |
--------------------------------------------------------------------------------
/src/sntp/Bytewizer.TinyCLR.Sntp/Server/SntpServerOptionsDelegate.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Sockets;
2 |
3 | namespace Bytewizer.TinyCLR.Sntp
4 | {
5 | ///
6 | /// Represents an options method to configure specific features.
7 | ///
8 | /// The configuration specific features.
9 | public delegate void ServerOptionsDelegate(SntpServerOptions configure);
10 | }
--------------------------------------------------------------------------------
/src/sntp/Bytewizer.TinyCLR.Sntp/Sntp/LeapIndicator.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Sntp
2 | {
3 | ///
4 | /// Represents leap second warning from the server that instructs the client to add or remove leap second.
5 | ///
6 | public enum LeapIndicator
7 | {
8 | ///
9 | /// No leap second warning. No action required.
10 | ///
11 | NoWarning = 0,
12 |
13 | ///
14 | /// Last minute has 61 seconds
15 | ///
16 | LastMinute61 = 1,
17 |
18 | ///
19 | /// Last minute has 59 seconds
20 | ///
21 | LastMinute59 = 2,
22 |
23 | ///
24 | /// Special value indicating that the server clock is unsynchronized and the returned time is unreliable.
25 | ///
26 | AlarmCondition = 3
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/sntp/Bytewizer.TinyCLR.Sntp/Sntp/NtpMode.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Sntp
2 | {
3 | ///
4 | /// Describes SNTP packet mode, i.e. client or server.
5 | ///
6 | public enum NtpMode
7 | {
8 | ///
9 | /// Identifies client-to-server SNTP packet.
10 | ///
11 | Client = 3,
12 |
13 | ///
14 | /// Identifies server-to-client SNTP packet.
15 | ///
16 | Server = 4,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/sntp/Bytewizer.TinyCLR.Sntp/Sntp/VersionNumber.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Sntp
2 | {
3 | ///
4 | /// Represents the NTP/SNTP version number.
5 | ///
6 | public enum VersionNumber
7 | {
8 | ///
9 | /// Version 3.
10 | ///
11 | Version3 = 3,
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.Filtering/Middleware/IpFilteringMiddleware.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Pipeline;
2 | using Bytewizer.TinyCLR.Sockets.Filtering;
3 |
4 | namespace Bytewizer.TinyCLR.Sockets
5 | {
6 | public class IpFilteringMiddleware : Middleware
7 | {
8 | private readonly CidrNotation _cidr;
9 |
10 | public IpFilteringMiddleware(string cidr)
11 | {
12 | _cidr = CidrNotation.Parse(cidr);
13 | }
14 |
15 | protected override void Invoke(IContext context, RequestDelegate next)
16 | {
17 | var ctx = context as ISocketContext;
18 |
19 | try
20 | {
21 | if (_cidr.Contains(ctx.Channel.Connection.RemoteIpAddress))
22 | {
23 | next(context);
24 | }
25 | }
26 | catch{}
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.Filtering/Middleware/IpFilteringMiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.TinyCLR.Sockets
6 | {
7 | public static class IpFilteringExtensions
8 | {
9 | public static IApplicationBuilder UseIpFiltering(this IApplicationBuilder builder, string cidr)
10 | {
11 | if (builder == null)
12 | {
13 | throw new ArgumentNullException(nameof(builder));
14 | }
15 |
16 | return builder.Use(new IpFilteringMiddleware(cidr));
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.Filtering/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2da3d5ab-a849-4398-c6a9-1a34635955b2")]
5 |
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.Filtering/README.md:
--------------------------------------------------------------------------------
1 | # Socket Filtering
2 |
3 | Provides a simple methods filtering connections over a network.
4 |
5 | ```CSharp
6 | static void Main(string[] args)
7 | {
8 | IServer server = new SocketServer(options =>
9 | {
10 | options.Pipeline(app =>
11 | {
12 | app.UseIpFiltering("192.168.1.0/24"); // blocks all inbound traffic not within this ip address range
13 | app.Use(new HttpResponse());
14 | });
15 | options.Listen(8080); // Listens on port 8080
16 | });
17 | server.Start();
18 | }
19 |
20 | ## TinyCLR Packages
21 | Install release package from [NuGet](https://www.nuget.org/packages?q=bytewizer.tinyclr) or using the Package Manager Console:
22 | ```powershell
23 | PM> Install-Package Bytewizer.TinyCLR.Sockets.Filtering
24 | ```
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.TcpClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2da3d5ab-a849-4398-c6a9-1a34635955b2")]
5 |
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.TcpClient/README.md:
--------------------------------------------------------------------------------
1 | # TCP Client
2 |
3 | Provides simple methods for connecting, sending, and receiving stream data over a network.
4 |
5 | ## TinyCLR Packages
6 | Install release package from [NuGet](https://www.nuget.org/packages?q=bytewizer.tinyclr) or using the Package Manager Console :
7 | ```powershell
8 | PM> Install-Package Bytewizer.TinyCLR.Sockets.TcpClient
9 | ```
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.UdpClient/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("2da3d5ab-a849-4398-c6a9-1a34635955b2")]
5 |
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets.UdpClient/README.md:
--------------------------------------------------------------------------------
1 | # UDP Client
2 |
3 | Provides simple methods for connecting, sending, and receiving stream data over a network.
4 |
5 | ## TinyCLR Packages
6 | Install release package from [NuGet](https://www.nuget.org/packages?q=bytewizer.tinyclr) or using the Package Manager Console :
7 | ```powershell
8 | PM> Install-Package Bytewizer.TinyCLR.Sockets.UdpClient
9 | ```
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Listeners/SocketListenerOptionsDelegate.cs:
--------------------------------------------------------------------------------
1 | #if NanoCLR
2 | namespace Bytewizer.NanoCLR.Sockets.Listener
3 | #else
4 | namespace Bytewizer.TinyCLR.Sockets.Listener
5 | #endif
6 | {
7 | ///
8 | /// Represents an options method to configure specific features.
9 | ///
10 | /// The configuration specific features.
11 | public delegate void SocketListenerOptionsDelegate(SocketListenerOptions configure);
12 | }
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("06e330d2-f947-4cca-8244-6117bfbf8ad5")]
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Server/ServerLimits.cs:
--------------------------------------------------------------------------------
1 | #if NanoCLR
2 | namespace Bytewizer.NanoCLR.Sockets
3 | #else
4 | namespace Bytewizer.TinyCLR.Sockets
5 | #endif
6 | {
7 | ///
8 | /// Represents configuration limits of server specific features.
9 | ///
10 | public class ServerLimits
11 | {
12 | ///
13 | /// Gets the maximum size in bytes of the request message.
14 | ///
15 | public long MaxMessageSize { get; set; } = 8 * 1024;
16 |
17 | ///
18 | /// Gets the minimum size in bytes of the request message.
19 | ///
20 | public long MinMessageSize { get; set; } = 0;
21 | }
22 | }
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Server/ServerOptionsDelegate.cs:
--------------------------------------------------------------------------------
1 | #if NanoCLR
2 | namespace Bytewizer.NanoCLR.Sockets
3 | #else
4 | namespace Bytewizer.TinyCLR.Sockets
5 | #endif
6 | {
7 | ///
8 | /// Represents an options method to configure specific features.
9 | ///
10 | /// The configuration specific features.
11 | public delegate void ServerOptionsDelegate(IServerOptions configure);
12 | }
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Sockets/ConnectedHandler.cs:
--------------------------------------------------------------------------------
1 | #if NanoCLR
2 | using Bytewizer.NanoCLR.Sockets.Channel;
3 | namespace Bytewizer.NanoCLR.Sockets
4 | #else
5 | using Bytewizer.TinyCLR.Sockets.Channel;
6 |
7 | namespace Bytewizer.TinyCLR.Sockets
8 | #endif
9 | {
10 | ///
11 | /// A delegate which is executed when a client has connected.
12 | ///
13 | /// The source of the event.
14 | /// The socket channel for the connected end point.
15 | public delegate void ConnectedHandler(object sender, SocketChannel channel);
16 | }
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Sockets/DisconnectedHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | #if NanoCLR
4 | namespace Bytewizer.NanoCLR.Sockets
5 | #else
6 | namespace Bytewizer.TinyCLR.Sockets
7 | #endif
8 | {
9 | ///
10 | /// A delegate which is executed when a client has disconnected.
11 | ///
12 | /// The source of the event.
13 | /// The for the error.
14 | public delegate void DisconnectedHandler(object sender, Exception execption);
15 | }
16 |
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Sockets/ISocketContext.cs:
--------------------------------------------------------------------------------
1 | #if NanoCLR
2 | using Bytewizer.NanoCLR.Pipeline;
3 | using Bytewizer.NanoCLR.Sockets.Channel;
4 |
5 | namespace Bytewizer.NanoCLR.Sockets
6 | #else
7 | using Bytewizer.TinyCLR.Pipeline;
8 | using Bytewizer.TinyCLR.Sockets.Channel;
9 |
10 | namespace Bytewizer.TinyCLR.Sockets
11 | #endif
12 | {
13 | ///
14 | /// An interface for .
15 | ///
16 | public interface ISocketContext : IContext
17 | {
18 | ///
19 | /// Gets or sets information about the underlying connection for this request.
20 | ///
21 | SocketChannel Channel { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Sockets/SocketContext.cs:
--------------------------------------------------------------------------------
1 | #if NanoCLR
2 | using Bytewizer.NanoCLR.Sockets.Channel;
3 |
4 | namespace Bytewizer.NanoCLR.Sockets
5 | #else
6 | using Bytewizer.TinyCLR.Sockets.Channel;
7 |
8 | namespace Bytewizer.TinyCLR.Sockets
9 | #endif
10 | {
11 | ///
12 | /// Encapsulates all socket specific information about an individual request.
13 | ///
14 | public class SocketContext : ISocketContext
15 | {
16 | ///
17 | public SocketChannel Channel { get; set; } = new SocketChannel();
18 |
19 | ///
20 | /// Aborts the connection underlying this request.
21 | ///
22 | public void Abort()
23 | {
24 | Channel?.Client?.Close();
25 | }
26 |
27 | ///
28 | public void Clear()
29 | {
30 | Channel?.Clear();
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/src/sockets/Bytewizer.TinyCLR.Sockets/Sockets/SocketErrorHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | #if NanoCLR
4 | namespace Bytewizer.NanoCLR.Sockets
5 | #else
6 | namespace Bytewizer.TinyCLR.Sockets
7 | #endif
8 | {
9 | ///
10 | /// A delegate which is executed when the socket has and error.
11 | ///
12 | /// The source of the event.
13 | /// The for the error.
14 | public delegate void SocketErrorHandler(object sender, Exception execption);
15 | }
16 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ansi/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: AssemblyConfiguration("Secure")]
6 | [assembly: Guid("a3819878-1d51-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Authentication/Middleware/AuthenticationOptions.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Identity;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal
4 | {
5 | ///
6 | /// Options for selecting authentication scheme and account services.
7 | ///
8 | public class AuthenticationOptions
9 | {
10 | ///
11 | /// Configuration for the .
12 | ///
13 | public AuthenticationOptions()
14 | {
15 | IdentityProvider = new IdentityProvider();
16 | }
17 |
18 | ///
19 | /// Account service for the authentication scheme.
20 | ///
21 | public IIdentityProvider IdentityProvider { get; set; }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Authentication/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: AssemblyConfiguration("Secure")]
6 | [assembly: Guid("a3819878-1d51-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Console/Channel/ConsoleErrorHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal
4 | {
5 | ///
6 | /// A delegate which is executed when the communications device class (CDC) for the connected client has and error.
7 | ///
8 | /// The source of the event.
9 | /// The for the error.
10 | public delegate void ConsoleErrorHandler(object sender, Exception execption);
11 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Console/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: AssemblyConfiguration("Secure")]
6 | [assembly: Guid("a3819878-1d51-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Console/Server/ConsoleServerOptionsDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// Represents an options method to configure specific features.
5 | ///
6 | /// The configuration specific features.
7 | public delegate void ServerOptionsDelegate(ConsoleServerOptions configure);
8 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: AssemblyConfiguration("Secure")]
6 | [assembly: Guid("a3819878-1d51-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Algorithms/CompressionAlgorithm.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Algorithms
2 | {
3 | public abstract class CompressionAlgorithm
4 | {
5 | public abstract byte[] Compress(byte[] input);
6 |
7 | public abstract byte[] Decompress(byte[] input);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Algorithms/EncryptionAlgorithm.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Algorithms
2 | {
3 | public class EncryptionAlgorithm
4 | {
5 |
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Algorithms/HmacAlgorithm.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Algorithms
2 | {
3 | public abstract class HmacAlgorithm
4 | {
5 |
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Algorithms/KexAlgorithm.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Algorithms
2 | {
3 | public abstract class KexAlgorithm
4 | {
5 | }
6 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Algorithms/NoCompression.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Bytewizer.TinyCLR.SecureShell.Algorithms
3 | {
4 | public class NoCompression : CompressionAlgorithm
5 | {
6 | public string Name
7 | {
8 | get { return "none"; }
9 | }
10 |
11 | public override byte[] Compress(byte[] input)
12 | {
13 | return input;
14 | }
15 |
16 | public override byte[] Decompress(byte[] input)
17 | {
18 | return input;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Algorithms/NoEncryption.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Algorithms
2 | {
3 | public class NoEncryption : EncryptionAlgorithm
4 | {
5 | public string Name
6 | {
7 | get { return "none"; }
8 | }
9 |
10 | public uint BlockSize
11 | {
12 | get { return 8;}
13 | }
14 |
15 | public uint KeySize
16 | {
17 | get { return 0; }
18 | }
19 |
20 | public byte[] Decrypt(byte[] data)
21 | {
22 | return data;
23 | }
24 |
25 | public byte[] Encrypt(byte[] data)
26 | {
27 | return data;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Algorithms/Sha1HmacAlgorithm.cs:
--------------------------------------------------------------------------------
1 | using GHIElectronics.TinyCLR.Cryptography;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Algorithms
4 | {
5 | public class HmacSha1Algorithm : HmacAlgorithm
6 | {
7 | private readonly HMACSHA1 _hmac = new HMACSHA1();
8 |
9 | public string Name
10 | {
11 | get { return "hmac-sha1"; }
12 | }
13 |
14 | public uint DigestLength
15 | {
16 | get { return 20; }
17 | }
18 |
19 | public uint KeySize
20 | {
21 | get { return 20; }
22 | }
23 |
24 | public byte[] ComputeHash(uint packetNumber, byte[] data)
25 | {
26 | using (var worker = new SshDataWorker())
27 | {
28 | worker.Write(packetNumber);
29 | worker.Write(data);
30 |
31 | return _hmac.ComputeHash(worker.ToByteArray());
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/DisconnectReason.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell
2 | {
3 | public enum DisconnectReason
4 | {
5 | None = 0, // Not used by protocol
6 | HostNotAllowedToConnect = 1,
7 | ProtocolError = 2,
8 | KeyExchangeFailed = 3,
9 | Reserved = 4,
10 | MacError = 5,
11 | CompressionError = 6,
12 | ServiceNotAvailable = 7,
13 | ProtocolVersionNotSupported = 8,
14 | HostKeyNotVerifiable = 9,
15 | ConnectionLost = 10,
16 | ByApplication = 11,
17 | TooManyConnections = 12,
18 | AuthCancelledByUser = 13,
19 | NoMoreAuthMethodsAvailable = 14,
20 | IllegalUserName = 15
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Exceptions/ConnectionException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell
4 | {
5 | public class ConnectionException : Exception
6 | {
7 | public ConnectionException()
8 | {
9 | }
10 |
11 | public ConnectionException(string message, DisconnectReason disconnectReason = DisconnectReason.None)
12 | : base(message)
13 | {
14 | DisconnectReason = disconnectReason;
15 | }
16 |
17 | public DisconnectReason DisconnectReason { get; private set; }
18 |
19 | public override string ToString()
20 | {
21 | return string.Format("Secure shell connection disconnected because {0}", DisconnectReason);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/Connection/ChannelRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages.Connection
4 | {
5 | public class ChannelRequestMessage : ConnectionServiceMessage
6 | {
7 | private const byte MessageNumber = 98; // SSH_MSG_CHANNEL_REQUEST
8 |
9 | public uint RecipientChannel { get; set; }
10 | public string RequestType { get; set; }
11 | public bool WantReply { get; set; }
12 |
13 | public override byte MessageType { get { return MessageNumber; } }
14 |
15 | protected override void OnLoad(SshDataWorker reader)
16 | {
17 | RecipientChannel = reader.ReadUInt32();
18 | RequestType = reader.ReadString(Encoding.UTF8);
19 | WantReply = reader.ReadBoolean();
20 | }
21 |
22 | protected override void OnGetPacket(SshDataWorker writer)
23 | {
24 | writer.Write(RecipientChannel);
25 | writer.Write(RequestType, Encoding.UTF8);
26 | writer.Write(WantReply);
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/ConnectionServiceMessage.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Bytewizer.TinyCLR.SecureShell.Messages
3 | {
4 | public abstract class ConnectionServiceMessage : Message
5 | {
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/KeyExchangeDhInitMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Messages
2 | {
3 | public class KeyExchangeDhInitMessage : Message
4 | {
5 | private const byte MessageNumber = 30; // SSH_MSG_KEXDH_INIT
6 |
7 | public byte[] E { get; private set; }
8 |
9 | public override byte MessageType { get { return MessageNumber; } }
10 |
11 | protected override void OnLoad(SshDataWorker reader)
12 | {
13 | E = reader.ReadMpint();
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/KeyExchangeDhReplyMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages
4 | {
5 | public class KeyExchangeDhReplyMessage : Message
6 | {
7 | private const byte MessageNumber = 31; // SSH_MSG_KEXDH_REPLY
8 |
9 | public byte[] HostKey { get; set; }
10 | public byte[] F { get; set; }
11 | public byte[] Signature { get; set; }
12 |
13 | public override byte MessageType { get { return MessageNumber; } }
14 |
15 | protected override void OnGetPacket(SshDataWorker writer)
16 | {
17 | writer.WriteBinary(HostKey);
18 | writer.WriteMpint(F);
19 | writer.WriteBinary(Signature);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/NewKeysMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Messages
2 | {
3 | public class NewKeysMessage : Message
4 | {
5 | private const byte MessageNumber = 21; // SSH_MSG_NEWKEYS
6 |
7 | public override byte MessageType { get { return MessageNumber; } }
8 |
9 | protected override void OnLoad(SshDataWorker reader)
10 | {
11 | }
12 |
13 | protected override void OnGetPacket(SshDataWorker writer)
14 | {
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/ServiceAcceptMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages
4 | {
5 | public class ServiceAcceptMessage : Message
6 | {
7 | private const byte MessageNumber = 6; // SSH_MSG_SERVICE_ACCEPT
8 |
9 | public ServiceAcceptMessage(string name)
10 | {
11 | ServiceName = name;
12 | }
13 |
14 | public string ServiceName { get; private set; }
15 |
16 | public override byte MessageType { get { return MessageNumber; } }
17 |
18 | protected override void OnGetPacket(SshDataWorker writer)
19 | {
20 | writer.Write(ServiceName, Encoding.UTF8);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/ServiceRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages
4 | {
5 | public class ServiceRequestMessage : Message
6 | {
7 | private const byte MessageNumber = 5; // SSH_MSG_SERVICE_REQUEST
8 |
9 | public string ServiceName { get; private set; }
10 |
11 | public override byte MessageType { get { return MessageNumber; } }
12 |
13 | protected override void OnLoad(SshDataWorker reader)
14 | {
15 | ServiceName = reader.ReadString(Encoding.UTF8);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/UnimplementedMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.SecureShell.Messages
2 | {
3 | public class UnimplementedMessage : Message
4 | {
5 | private const byte MessageNumber = 3; // SSH_MSG_UNIMPLEMENTED
6 |
7 | public uint SequenceNumber { get; set; }
8 |
9 | public override byte MessageType { get { return MessageNumber; } }
10 |
11 | protected override void OnLoad(SshDataWorker reader)
12 | {
13 | SequenceNumber = reader.ReadUInt32();
14 | }
15 |
16 | protected override void OnGetPacket(SshDataWorker writer)
17 | {
18 | writer.Write(SequenceNumber);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/UnknownMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages
4 | {
5 | public class UnknownMessage : Message
6 | {
7 | public uint SequenceNumber { get; set; }
8 |
9 | public byte UnknownMessageType { get; set; }
10 |
11 | public override byte MessageType { get { throw new NotSupportedException();} }
12 |
13 | public UnimplementedMessage MakeUnimplementedMessage()
14 | {
15 | return new UnimplementedMessage()
16 | {
17 | SequenceNumber = SequenceNumber
18 | };
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/Userauth/FailureMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages.Userauth
4 | {
5 | public class FailureMessage : UserauthServiceMessage
6 | {
7 | private const byte MessageNumber = 51; // SSH_MSG_USERAUTH_FAILURE
8 |
9 | public override byte MessageType { get { return MessageNumber; } }
10 |
11 | protected override void OnGetPacket(SshDataWorker writer)
12 | {
13 | writer.Write("password,publickey", Encoding.UTF8);
14 | writer.Write(false);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/Userauth/PasswordRequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace Bytewizer.TinyCLR.SecureShell.Messages.Userauth
5 | {
6 | public class PasswordRequestMessage : RequestMessage
7 | {
8 | public string Password { get; private set; }
9 |
10 | protected override void OnLoad(SshDataWorker reader)
11 | {
12 | base.OnLoad(reader);
13 |
14 | if (MethodName != "password")
15 | {
16 | throw new ArgumentException(string.Format("Method name {0} is not valid.", MethodName));
17 | }
18 |
19 | var isFalse = reader.ReadBoolean();
20 | Password = reader.ReadString(Encoding.UTF8);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/Userauth/PublicKeyOkMessage.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages.Userauth
4 | {
5 | public class PublicKeyOkMessage : UserauthServiceMessage
6 | {
7 | private const byte MessageNumber = 60; //SSH_MSG_USERAUTH_PK_OK
8 |
9 | public string KeyAlgorithmName { get; set; }
10 | public byte[] PublicKey { get; set; }
11 |
12 | public override byte MessageType { get { return MessageNumber; } }
13 |
14 | protected override void OnGetPacket(SshDataWorker writer)
15 | {
16 | writer.Write(KeyAlgorithmName, Encoding.UTF8);
17 | writer.WriteBinary(PublicKey);
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/Userauth/RequestMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace Bytewizer.TinyCLR.SecureShell.Messages.Userauth
5 | {
6 | public class RequestMessage : UserauthServiceMessage
7 | {
8 | protected const byte MessageNumber = 50; // SSH_MSG_USERAUTH_REQUEST
9 |
10 | public string Username { get; protected set; }
11 | public string ServiceName { get; protected set; }
12 | public string MethodName { get; protected set; }
13 |
14 | public override byte MessageType { get { return MessageNumber; } }
15 |
16 | protected override void OnLoad(SshDataWorker reader)
17 | {
18 | Username = reader.ReadString(Encoding.UTF8);
19 | ServiceName = reader.ReadString(Encoding.UTF8);
20 | MethodName = reader.ReadString(Encoding.UTF8);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/Userauth/SuccessMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages.Userauth
4 | {
5 | public class SuccessMessage : UserauthServiceMessage
6 | {
7 | private const byte MessageNumber = 52; // SSH_MSG_USERAUTH_SUCCESS
8 |
9 | public override byte MessageType { get { return MessageNumber; } }
10 |
11 | protected override void OnGetPacket(SshDataWorker writer)
12 | {
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/UserauthServiceMessage.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Bytewizer.TinyCLR.SecureShell.Messages
3 | {
4 | public abstract class UserauthServiceMessage : Message
5 | {
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Ssh/Terminal/Messages/WindowChangeMessage.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.SecureShell.Messages.Connection;
2 |
3 | namespace Bytewizer.TinyCLR.SecureShell.Messages
4 | {
5 | public class WindowChangeMessage : ChannelRequestMessage
6 | {
7 | public uint WidthColumns { get; private set; }
8 | public uint HeightRows { get; private set; }
9 | public uint WidthPixels { get; private set; }
10 | public uint HeightPixels { get; private set; }
11 |
12 | protected override void OnLoad(SshDataWorker reader)
13 | {
14 | base.OnLoad(reader);
15 |
16 | WidthColumns = reader.ReadUInt32();
17 | HeightRows = reader.ReadUInt32();
18 | WidthPixels = reader.ReadUInt32();
19 | HeightPixels = reader.ReadUInt32();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Telnet/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: AssemblyConfiguration("Secure")]
6 | [assembly: Guid("a3819878-1d51-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal.Telnet/Server/TelnetServerOptionsDelegate.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// Represents an options method to configure specific features.
5 | ///
6 | /// The configuration specific features.
7 | public delegate void ServerOptionsDelegate(TelnetServerOptions configure);
8 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/ActionDescriptor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace Bytewizer.TinyCLR.Terminal
5 | {
6 | ///
7 | /// Describes an command action.
8 | ///
9 | public class ActionDescriptor
10 | {
11 | ///
12 | /// Initializes a new instance of .
13 | ///
14 | public ActionDescriptor()
15 | {
16 | Id = DateTime.Now.Ticks.ToString();
17 | Properties = new Hashtable(0);
18 | }
19 |
20 | ///
21 | /// Gets an id which uniquely identifies the action.
22 | ///
23 | public string Id { get; }
24 |
25 | ///
26 | /// A friendly name for this action.
27 | ///
28 | public virtual string DisplayName { get; set; }
29 |
30 | ///
31 | /// Stores arbitrary metadata properties associated with the .
32 | ///
33 | public Hashtable Properties { get; set; }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/ActionResults/ActionResult.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// A default implementation of .
5 | ///
6 | public abstract class ActionResult : IActionResult
7 | {
8 | ///
9 | public abstract void ExecuteResult(ActionContext context);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/ActionResults/BufferResponseResult/BufferDirection.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal.Channel
2 | {
3 | ///
4 | /// Consumable types.
5 | ///
6 | public enum BufferDirection
7 | {
8 | ///
9 | /// Get the next set of data.
10 | ///
11 | Forward = 0,
12 |
13 | ///
14 | /// Get the prior set of data.
15 | ///
16 | Backward = 1,
17 |
18 | ///
19 | /// Repeat the last set of data.
20 | ///
21 | Repeat = 2,
22 |
23 | ///
24 | /// Moves forward sending all data.
25 | ///
26 | ForwardAllData = 3
27 | }
28 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/ActionResults/ClearResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal
4 | {
5 | ///
6 | /// An action result which cleares the screen to the client.
7 | ///
8 | public class ClearResult : ActionResult
9 | {
10 |
11 | ///
12 | public override void ExecuteResult(ActionContext context)
13 | {
14 | if (context == null)
15 | {
16 | throw new ArgumentNullException(nameof(context));
17 | }
18 |
19 | context.TerminalContext.Response.Write("\u001B[1J\u001B[H");
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/ActionResults/EmptyResult.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// Represents an that when executed will do nothing.
5 | ///
6 | public class EmptyResult : ActionResult
7 | {
8 | ///
9 | public override void ExecuteResult(ActionContext context)
10 | {
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/ActionResults/IActionResult.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// Defines a contract that represents the result of a command action method.
5 | ///
6 | public interface IActionResult
7 | {
8 | ///
9 | /// Executes the result operation of the command action method.
10 | ///
11 | /// The context in which the result is executed.
12 | void ExecuteResult(ActionContext context);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/Builtin/ClearCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal.Commands
4 | {
5 | ///
6 | /// Implements the clear terminal command.
7 | ///
8 | public class ClearCommand : ServerCommand
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public ClearCommand()
14 | {
15 | Description = "Clears the screen for the connected session";
16 | HelpCommands = new ArrayList()
17 | {
18 | { "clear" }
19 | };
20 | }
21 |
22 | ///
23 | /// Clears the screen for the connected client. This is the default action.
24 | ///
25 | public IActionResult Default()
26 | {
27 | return new ClearResult();
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/Builtin/ExitCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal.Commands
4 | {
5 | ///
6 | /// Implements the exit terminal command.
7 | ///
8 | public class ExitCommand : ServerCommand
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public ExitCommand()
14 | {
15 | Description = "Close open session and exit";
16 | HelpCommands = new ArrayList()
17 | {
18 | { "exit" }
19 | };
20 | }
21 |
22 | ///
23 | /// Disconnects the client by closing the connection. This is the default action.
24 | ///
25 | public IActionResult Default()
26 | {
27 | CommandContext.TerminalContext.Active = false;
28 |
29 | return new EmptyResult();
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/Builtin/WhoamiCommand.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal.Commands
4 | {
5 | ///
6 | /// Implements the whoami terminal command.
7 | ///
8 | public class WhoamiCommand : ServerCommand
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public WhoamiCommand()
14 | {
15 | Description = "Display the user name associated with the current session";
16 | HelpCommands = new ArrayList()
17 | {
18 | { "whoami" }
19 | };
20 | }
21 |
22 | ///
23 | /// Disconnects the client by closing the connection. This is the default action.
24 | ///
25 | public IActionResult Default()
26 | {
27 | var username = CommandContext.GetUserName();
28 | return new ResponseResult(username);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Commands/Filters/FilterContext.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// An abstract context for filters.
5 | ///
6 | public abstract class FilterContext : ActionContext
7 | {
8 | ///
9 | /// Instantiates a new instance.
10 | ///
11 | /// The .
12 | public FilterContext(ActionContext actionContext)
13 | : base(actionContext)
14 | {
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Features/EndpointFeature.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal.Features
4 | {
5 | ///
6 | /// A feature interface for this session. Use
7 | /// to access an instance associated with the current request.
8 | ///
9 | public class EndpointFeature
10 | {
11 | ///
12 | /// Gets or sets command endpoint for the current request.
13 | ///
14 | public Hashtable Endpoints { get; set; } = new Hashtable();
15 |
16 | ///
17 | /// Gets or sets command list for the current request.
18 | ///
19 | public Hashtable AvailableCommands { get; set; } = new Hashtable();
20 |
21 | ///
22 | /// Gets or sets a flag to enable auto mapping assemblies provider.
23 | ///
24 | public bool AutoMapping { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Features/SessionFeature.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Identity;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal.Features
4 | {
5 | ///
6 | /// A feature interface for this session. Use
7 | /// to access an instance associated with the current request.
8 | ///
9 | public class SessionFeature
10 | {
11 | ///
12 | /// Gets or sets security information for the current request.
13 | ///
14 | public IIdentityProvider IdentityProvider { get; set; }
15 |
16 | ///
17 | /// Gets or sets a login user name.
18 | ///
19 | public string UserName { get; set; }
20 |
21 | ///
22 | /// Gets a value indicating whether the request has been authenticated.
23 | ///
24 | public bool Authenticated { get; set; }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Middleware/AutoMappingMiddleware.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Pipeline;
2 | using Bytewizer.TinyCLR.Terminal.Features;
3 |
4 | namespace Bytewizer.TinyCLR.Terminal
5 | {
6 | ///
7 | /// Enables auto mapping of endpoints for command actions from assembly reflection.
8 | ///
9 | public class AutoMappingMiddleware : Middleware
10 | {
11 | ///
12 | protected override void Invoke(ITerminalContext context, RequestDelegate next)
13 | {
14 | var endpointFeature = (EndpointFeature)context.Features.Get(typeof(EndpointFeature));
15 | endpointFeature.AutoMapping = true;
16 |
17 | next(context);
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Middleware/AutoMappingMiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.TinyCLR.Terminal
6 | {
7 | ///
8 | /// extension methods for the .
9 | ///
10 | public static class AutoMappingMiddlewareExtensions
11 | {
12 | ///
13 | /// Adds auto mapping of endpoints for command actions from assembly reflection.
14 | ///
15 | /// The instance this method extends.
16 | public static IApplicationBuilder UseAutoMapping(this IApplicationBuilder builder)
17 | {
18 | if (builder == null)
19 | {
20 | throw new ArgumentNullException(nameof(builder));
21 | }
22 |
23 | return builder.Use(new AutoMappingMiddleware());
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Middleware/EndpointMiddlewareExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Bytewizer.TinyCLR.Pipeline.Builder;
4 |
5 | namespace Bytewizer.TinyCLR.Terminal
6 | {
7 | ///
8 | /// extension methods for the .
9 | ///
10 | public static class EndpointExtensions
11 | {
12 | ///
13 | /// Adds routing middleware features supporting endpoint routing.
14 | ///
15 | /// The instance this method extends.
16 | /// The instance this method extends.
17 | public static IApplicationBuilder UseEndpoint(this IApplicationBuilder builder, ServerCommand serverCommand)
18 | {
19 | if (builder == null)
20 | {
21 | throw new ArgumentNullException(nameof(builder));
22 | }
23 |
24 | return builder.Use(typeof(EndpointMiddleware), serverCommand);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Numerics/RandomNumberGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Numerics
4 | {
5 | public class RandomNumberGenerator
6 | {
7 | private static readonly object _lock = new object();
8 |
9 | public Random GetRandom { get { return rnd; } }
10 |
11 | private static readonly Random rnd;
12 |
13 | static RandomNumberGenerator()
14 | {
15 | rnd = new Random();
16 | }
17 |
18 | public static RandomNumberGenerator Create()
19 | {
20 | return new RandomNumberGenerator();
21 | }
22 |
23 | public void GetBytes(byte[] buffer)
24 | {
25 | lock (_lock)
26 | {
27 | rnd.NextBytes(buffer);
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("a3819878-1d41-4369-a436-d36181aacef3")]
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Terminal/AnsiSequences.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// Common ANSI sequences to simplify construction of correct ANSI for adherance to the telnet protocol.
5 | public class AnsiSequences
6 | {
7 | ///
8 | /// Gets the ANSI sequence to move the cursor to a new line.
9 | ///
10 | /// Explicitly avoids Environment.NewLine, as a Telnet server is always supposed to send new lines as CR LF.
11 | public const string NewLine = "\r\n";
12 |
13 | ///
14 | /// The ANSI 'escape sequence'.
15 | ///
16 | public const string Esc = "\x1B";
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Terminal/ITerminalContext.cs:
--------------------------------------------------------------------------------
1 | using Bytewizer.TinyCLR.Features;
2 | using Bytewizer.TinyCLR.Pipeline;
3 |
4 | namespace Bytewizer.TinyCLR.Terminal
5 | {
6 | public interface ITerminalContext : IContext
7 | {
8 | bool Active { get; set; }
9 | IFeatureCollection Features { get; }
10 | byte[] OptionCommands { get; set; }
11 | TerminalOptions Options { get; }
12 | TerminalRequest Request { get; }
13 | TerminalResponse Response { get; }
14 | }
15 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Terminal/TerminalRequest.cs:
--------------------------------------------------------------------------------
1 | namespace Bytewizer.TinyCLR.Terminal
2 | {
3 | ///
4 | /// Represents the incoming side of an individual terminal request.
5 | ///
6 | public class TerminalRequest
7 | {
8 | ///
9 | /// Initializes an instance of the class.
10 | ///
11 | public TerminalRequest()
12 | {
13 | }
14 |
15 | ///
16 | /// Gets the Terminal command to be executed.
17 | ///
18 | public CommandLine Command { get; set; }
19 |
20 |
21 | ///
22 | /// Clears the object.
23 | ///
24 | public void Clear()
25 | {
26 | Command?.Clear();
27 | }
28 |
29 | ///
30 | /// Gets the response code.
31 | ///
32 | public override string ToString()
33 | {
34 | return $"{Command}";
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/src/terminal/Bytewizer.TinyCLR.Terminal/Terminal/TerminalResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Bytewizer.TinyCLR.Terminal
4 | {
5 | ///
6 | /// Represents the outgoing side of an individual terminal request.
7 | ///
8 | public class TerminalResponse
9 | {
10 | ///
11 | /// Gets the response message.
12 | ///
13 | public string Message { get; set; }
14 |
15 | ///
16 | /// Gets the response message.
17 | ///
18 | public override string ToString()
19 | {
20 | if (Message != null)
21 | {
22 | return "[null]";
23 | }
24 |
25 | return Message;
26 | }
27 |
28 | ///
29 | /// Clears the messgae.
30 | ///
31 | public void Clear()
32 | {
33 | Message = default;
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------