Skip to content

Commit

Permalink
add copyright, add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dovholuknf committed Feb 27, 2024
1 parent a2c55ce commit 0126675
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
6 changes: 1 addition & 5 deletions OpenZiti.NET.Samples/src/Appetizer/AppetizerSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ public override async Task<object> RunAsync(string[] args) {
while (true) {
Console.Write("Enter some text to send: ");
var input = Console.ReadLine();

// Send the input to the server
await writer.WriteAsync(input);
await writer.FlushAsync();

// Receive and print the server's response
var response = reader.ReadLine();
var response = await reader.ReadLineAsync();
Console.WriteLine($"Received: {response}");
} //this just loops forever and c# is smart enough not to need a 'return' -- neat
}
Expand Down
36 changes: 36 additions & 0 deletions OpenZiti.NET.Samples/src/Appetizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Appetizer - reflect server

This sample demonstrates how to write data to a stream and receive data. It uses the https://openziti.io/appetizer
demonstration environment which is capable of genearting an identity for you, to be used with this sample. It
utilizes the reflect server functionality to return whatever data you send to the server back to you. The reflect
server also is tied to an LLM which is attempting to classify your input. If you use something that seems "hateful"
you will receive an error message indicating your input was not accepted. The server is written in go and the
source for the server is available at https://github.com/openziti-test-kitchen/appetizer.

## OpenZiti Concepts Demonstrated

This sample demonstrates some key OpenZiti concepts:

* Application-embedded zero trust client written in C# to a golang-based application embedded zero trust server.
* Sending data in a line-delimeted protocol to a server deployed out in the cloud, then receiving and displaying
the response.
* Directly dialing a service by service name, in this case it is named "reflectService"
* Creating a a strong identity by enrolling a one-time use token provided by the appetizer server.

## Setup

This sample is unlike others. It relies on an instance of the appetizer demo to be deployed. It's easiest to use
the instance OpenZiti has deployed by going to https://appetizer.openziti.io/. You'll see a screen asking you to
enter something unique, like your email address. There's a button to click named "Add to OpenZiti". After you click
the button, you'll be able to save/download a one-time use token.

To run the sample, simply provide the path to that token as a argument to the program.

## Running the Sample

After downloading the .jwt, you should be able to just run it directly.

Example:
```
dotnet run --project OpenZiti.NET.Samples/OpenZiti.NET.Samples.csproj appetizer-reflect
```
14 changes: 13 additions & 1 deletion OpenZiti.NET.Samples/src/Common/AppetizerSetup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
using NLog.Fluent;
/*
Copyright NetFoundry Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

using System.IO;
using System.Text;

Expand Down

0 comments on commit 0126675

Please sign in to comment.