Skip to content

Commit

Permalink
fix commit to main that slipped in and add a bit more to the setup sc…
Browse files Browse the repository at this point in the history
…ript
  • Loading branch information
dovholuknf committed Apr 21, 2023
1 parent cb2d242 commit 6017e5b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ cmake-build-debug-msvc/

*.jwt
*.snupkg

weather.demo.json
20 changes: 3 additions & 17 deletions Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,15 @@
using NLog;
using System.Threading.Tasks;
using System.Collections.Generic;
using OpenZiti.legacy;

namespace OpenZiti.Samples {
public class Program {
static async Task Main(string[] args) {
try {
//uncomment these lines to enable logging
Console.WriteLine("before native call");
OpenZiti.legacy.Logging.SimpleConsoleLogging(LogLevel.Trace);
OpenZiti.legacy.API.NativeLogger = OpenZiti.legacy.API.DefaultNativeLogFunction;
Console.WriteLine("after native call");

OpenZiti.legacy.API.Enroll(args[1], afterEnrollcb, null);

if(true) {
return;
}
OpenZiti.Logging.SimpleConsoleLogging(LogLevel.Trace);
OpenZiti.API.NativeLogger = OpenZiti.API.DefaultNativeLogFunction;

Console.Clear();

if (args == null || args.Length < 1) {
Expand Down Expand Up @@ -57,11 +49,5 @@ static async Task Main(string[] args) {
Console.WriteLine("==============================================================");
}
}

private static void afterEnrollcb(ZitiEnrollment.EnrollmentResult result) {

Console.WriteLine(result.Json);
Console.WriteLine(result.Message);
}
}
}
3 changes: 2 additions & 1 deletion Samples/Weather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace OpenZiti.Samples {
public class Weather : SampleBase {
public static void Run(string[] args) {
if (args == null || args.Length < 2) {
throw new Exception("This example expects the second paramter to be an unenrolled .jwt");
throw new Exception(@"This example expects the second paramter to be an unenrolled .jwt.
Please login to your controller using 'ziti edge login' then run 'pwsh setup-scripts/weather.ps1'");
}
string outputPath = Directory.GetCurrentDirectory() + "/weather.demo.json";
try {
Expand Down
15 changes: 9 additions & 6 deletions Samples/setup-scripts/weather.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if("$args[1]".ToLower().StartsWith("y")) {
}

if (!${EdgeRouter}) {
$ers = ziti edge list edge-routers -j | ConvertFrom-Json
$ers = ziti edge list edge-routers "limit none" -j | ConvertFrom-Json
echo "Router list:"
foreach($r in $ers.data) {
echo " - $($r.name)"
Expand All @@ -26,7 +26,7 @@ if (!${EdgeRouter}) {
}

echo "EdgeRouter identity: ${EdgeRouter} will be used as the router to offload traffic for the demo."
$er=ziti edge list identities "name=\`"${EdgeRouter}\`"" -j | ConvertFrom-Json
$er=ziti edge list identities "name=`"${EdgeRouter}`" limit none" -j | ConvertFrom-Json

$weatherAttr="weather-svc.binders"
if($er.data.id) {
Expand All @@ -45,7 +45,7 @@ if($er.data.id) {
throw "ERROR: provided edge router identity [${EdgeRouter}] does not exist! Cannot continue."
}

$demoId = ziti edge list identities "name=\`"weather.demo\`"" -j | ConvertFrom-Json
$demoId = ziti edge list identities "name=`"weather.demo`"" -j | ConvertFrom-Json
if ($demoId.data.id) {
if($prompt) {
$createId = Read-Host "weather.demo identity exists. Delete and overwrite?"
Expand All @@ -68,7 +68,7 @@ if ($createId) {
}

$createServices = $true
$service = ziti edge list services "name=\`"weather-svc\`"" -j | ConvertFrom-Json
$service = ziti edge list services "name=`"weather-svc`" limit none" -j | ConvertFrom-Json
if($service.data.id) {
if($prompt) {
$svcCleanUp = Read-Host "Looks like the service already exists. Try to cleanup/start again?"
Expand All @@ -85,8 +85,8 @@ if($service.data.id) {

if ($createServices) {
# create the weather sample example
ziti edge create config "weather-svc.host.v1" host.v1 "{\`"protocol\`":\`"tcp\`", \`"address\`":\`"wttr.in\`",\`"port\`":443}"
ziti edge create config "weather-svc.intercept.v1" intercept.v1 "{\`"protocols\`":[\`"tcp\`"],\`"addresses\`":[\`"wttr.in\`"],\`"portRanges\`":[{\`"low\`":80, \`"high\`":443}]}"
ziti edge create config "weather-svc.host.v1" host.v1 "{`"protocol`":`"tcp`", `"address`":`"wttr.in`",`"port`":443}"
ziti edge create config "weather-svc.intercept.v1" intercept.v1 "{`"protocols`":[`"tcp`"],`"addresses`":[`"wttr.in`"],`"portRanges`":[{`"low`":80, `"high`":443}]}"
ziti edge create service "weather-svc"--configs "weather-svc.intercept.v1,weather-svc.host.v1" -a "sdk.service"

# authorize sdk clients to dial the sdk example services
Expand All @@ -101,5 +101,8 @@ echo "If this is the first time running this script, allow "
echo "time for the services to propegate to the router "
echo "before running the sample or you may receive an error"
echo "like: no terminators exist for service "
echo ""
echo "then, execute the sample using: "
echo " dotnet run weather setup-scripts/weather.demo.jwt "
echo "====================================================="
echo " "
27 changes: 0 additions & 27 deletions TestProject/TestProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,6 @@
<None Include="..\Samples\setup-scripts\weather.ps1" Link="setup-scripts\weather.ps1" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\API.cs" Link="src\legacy\OpenZiti\API.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ExtensionMethods.cs" Link="src\legacy\OpenZiti\ExtensionMethods.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\Logging.cs" Link="src\legacy\OpenZiti\Logging.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\Native\IdentityFile.cs" Link="src\legacy\OpenZiti\native\IdentityFile.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\Native\nAPI.cs" Link="src\legacy\OpenZiti\native\nAPI.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\Native\NativeHelperFunctions.cs" Link="src\legacy\OpenZiti\native\NativeHelperFunctions.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\UVLoop.cs" Link="src\legacy\OpenZiti\UVLoop.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiConnection.cs" Link="src\legacy\OpenZiti\ZitiConnection.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiContext.cs" Link="src\legacy\OpenZiti\ZitiContext.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiEnrollment.cs" Link="src\legacy\OpenZiti\ZitiEnrollment.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiException.cs" Link="src\legacy\OpenZiti\ZitiException.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiIdentity.cs" Link="src\legacy\OpenZiti\ZitiIdentity.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiIdentityFormat.cs" Link="src\legacy\OpenZiti\ZitiIdentityFormat.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiService.cs" Link="src\legacy\OpenZiti\ZitiService.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiStatus.cs" Link="src\legacy\OpenZiti\ZitiStatus.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiStatusExtensions.cs" Link="src\legacy\OpenZiti\ZitiStatusExtensions.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiStream.cs" Link="src\legacy\OpenZiti\ZitiStream.cs" />
<Compile Include="..\OpenZiti.NET\src\legacy\OpenZiti\ZitiUtil.cs" Link="src\legacy\OpenZiti\ZitiUtil.cs" />


<Compile Include="..\Samples\legacy\Util\ConsoleHelper.cs" Link="Samples\legacy\Util\ConsoleHelper.cs" />
<Compile Include="..\Samples\legacy\Weather.cs" Link="Samples\legacy\Weather.cs" />
<Compile Include="..\Samples\legacy\WeatherStream.cs" Link="Samples\legacy\WeatherStream.cs" />
<Compile Include="..\Samples\legacy\Enrollment.cs" Link="Samples\legacy\Enrollment.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NLog" Version="5.0.5" />
<PackageReference Include="OpenZiti.NET.native" Version="0.30.8-build.20230323173752" />
Expand Down

0 comments on commit 6017e5b

Please sign in to comment.