mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 16:50:03 +00:00
first stage of updates
This commit is contained in:
@@ -9,19 +9,7 @@ namespace ZitiTunneler.Models {
|
||||
public List<ZitiService> Services { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ControllerUrl { get; set; }
|
||||
|
||||
private bool isEnabled = false;
|
||||
public bool IsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return isEnabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.isEnabled = value;
|
||||
}
|
||||
}
|
||||
public bool IsEnabled { get; set; }
|
||||
public string EnrollmentStatus { get; set; }
|
||||
public string Status { get; set; }
|
||||
|
||||
|
||||
@@ -123,8 +123,17 @@ namespace ZitiTunneler.ServiceClient
|
||||
|
||||
public void SetTunnelState(bool onOff)
|
||||
{
|
||||
send(new BooleanFunction("TunnelState", onOff));
|
||||
read<SvcResponse>();
|
||||
try
|
||||
{
|
||||
send(new BooleanFunction("TunnelState", onOff));
|
||||
read<SvcResponse>();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
//almost certainly a problem with the pipe - recreate the pipe...
|
||||
setupPipe();
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
|
||||
public void IdentityOnOff(Identity id)
|
||||
|
||||
@@ -54,6 +54,26 @@ namespace ZitiTunneler.ServiceClient
|
||||
public BooleanPayload Payload { get; set; }
|
||||
}
|
||||
|
||||
public class IdentityTogglePayload
|
||||
{
|
||||
public bool OnOff { get; set; }
|
||||
public string Fingerprint { get; set; }
|
||||
}
|
||||
|
||||
public class IdentityToggleFunction : ServiceFunction
|
||||
{
|
||||
public IdentityToggleFunction(string fingerprint, bool theBool)
|
||||
{
|
||||
this.Function = "IdentityOnOff";
|
||||
this.Payload = new IdentityTogglePayload()
|
||||
{
|
||||
OnOff = theBool,
|
||||
Fingerprint = fingerprint
|
||||
};
|
||||
}
|
||||
public IdentityTogglePayload Payload { get; set; }
|
||||
}
|
||||
|
||||
public class FingerprintPayload
|
||||
{
|
||||
public string Fingerprint { get; set; }
|
||||
@@ -80,7 +100,6 @@ namespace ZitiTunneler.ServiceClient
|
||||
public class Identity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
//public string Jwt { get; set; }
|
||||
public string FingerPrint { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public Config Config { get; set; }
|
||||
|
||||
@@ -176,12 +176,6 @@
|
||||
<Version>4.5.3</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ZitiBackgroundTask\ZitiBackgroundTask.csproj">
|
||||
<Project>{7393400b-5f2d-493c-bc39-ab3198a9749f}</Project>
|
||||
<Name>ZitiBackgroundTask</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
+2
-54
@@ -1,17 +1,13 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.572
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29806.167
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D66B1C6A-ADFE-437E-B037-C4C849A6CA97}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZitiBackgroundTask", "ZitiBackgroundTask\ZitiBackgroundTask.csproj", "{7393400B-5F2D-493C-BC39-AB3198A9749F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZitiUWPClient", "ZitiUWPClient\ZitiUWPClient.csproj", "{F327E612-2CC2-42EF-93EB-DF12A5D1599E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZitiTunneler", "ZitiTunneler\ZitiTunneler.csproj", "{FA4291EA-A97E-4854-959F-91EE7B330B37}"
|
||||
EndProject
|
||||
Global
|
||||
@@ -28,54 +24,6 @@ Global
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x64.Build.0 = Debug|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Debug|x86.Build.0 = Debug|x86
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM.Build.0 = Release|ARM
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x64.ActiveCfg = Release|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x64.Build.0 = Release|x64
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x86.ActiveCfg = Release|x86
|
||||
{7393400B-5F2D-493C-BC39-AB3198A9749F}.Release|x86.Build.0 = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|Any CPU.Deploy.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|ARM64.Deploy.0 = Debug|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x64.Build.0 = Debug|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x86.Build.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM.Build.0 = Release|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|ARM64.Deploy.0 = Release|ARM64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x64.ActiveCfg = Release|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x64.Build.0 = Release|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x64.Deploy.0 = Release|x64
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x86.ActiveCfg = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x86.Build.0 = Release|x86
|
||||
{F327E612-2CC2-42EF-93EB-DF12A5D1599E}.Release|x86.Deploy.0 = Release|x86
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA4291EA-A97E-4854-959F-91EE7B330B37}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
|
||||
@@ -3,7 +3,13 @@ module wintun-testing
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.4.14
|
||||
github.com/michaelquigley/pfxlog v0.0.0-20190813191113-2be43bd0dccc
|
||||
github.com/netfoundry/ziti-foundation v0.9.8
|
||||
github.com/netfoundry/ziti-sdk-golang v0.11.16
|
||||
github.com/sirupsen/logrus v1.5.0
|
||||
golang.org/x/sys v0.0.0-20200406113430-c6e801f48ba2
|
||||
golang.zx2c4.com/wireguard v0.0.20200320
|
||||
golang.zx2c4.com/wireguard/windows v0.1.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||
)
|
||||
|
||||
@@ -1,17 +1,121 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=
|
||||
github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
|
||||
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
|
||||
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
|
||||
github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE=
|
||||
github.com/antlr/antlr4 v0.0.0-20191115170859-54daca92f7b0/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/biogo/store v0.0.0-20190426020002-884f370e325d/go.mod h1:Iev9Q3MErcn+w3UOJD/DkEzllvugfdx7bGcMOFhvr/4=
|
||||
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa h1:RDBNVkRviHZtvDvId8XSGPu3rmpmSe+wKRcEWNgsfWU=
|
||||
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/kataras/go-events v0.0.3-0.20170604004442-17d67be645c3/go.mod h1:6IxMW59VJdEIqj3bjFGJvGLRdb0WHtrlxPZy9qXctcg=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/lucas-clemente/quic-go v0.13.1/go.mod h1:Vn3/Fb0/77b02SGhQk36KzOUmXgVpFfizUfW5WMaqyU=
|
||||
github.com/lxn/walk v0.0.0-20191128110447-55ccb3a9f5c1/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
|
||||
github.com/lxn/win v0.0.0-20191128105842-2da648fda5b4/go.mod h1:ouWl4wViUNh8tPSIwxTVMuS014WakR1hqvBc2I0bMoA=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/marten-seemann/chacha20 v0.2.0/go.mod h1:HSdjFau7GzYRj+ahFNwsO3ouVJr1HFkWoEwNDb4TMtE=
|
||||
github.com/marten-seemann/qpack v0.1.0/go.mod h1:LFt1NU/Ptjip0C2CPkhimBz5CGE3WGDAUWqna+CNTrI=
|
||||
github.com/marten-seemann/qtls v0.4.1/go.mod h1:pxVXcHHw1pNIt8Qo0pwSYQEoZ8yYOOPXTCZLQQunvRc=
|
||||
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/michaelquigley/pfxlog v0.0.0-20190813191113-2be43bd0dccc h1:PQrqw9XKYcPRI9rKwoGZucMjWvfZpyfb5j8Lc13j8YY=
|
||||
github.com/michaelquigley/pfxlog v0.0.0-20190813191113-2be43bd0dccc/go.mod h1:Z0K0l/NScHvLeGoy4SZTps+ZxGv85ql4AvZqTqOxBY8=
|
||||
github.com/miekg/pkcs11 v1.0.3 h1:iMwmD7I5225wv84WxIG/bmxz9AXjWvTWIbM/TYHvWtw=
|
||||
github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/netfoundry/secretstream v0.1.1/go.mod h1:uasYkYSp0MmNSlKOWJ2sVzxPms8e58TS4ENq4yro86k=
|
||||
github.com/netfoundry/ziti-foundation v0.9.8 h1:Nyx4U+pZ6iPtXBYSIad8xg5nBVjQNLatCHg5krQmeWM=
|
||||
github.com/netfoundry/ziti-foundation v0.9.8/go.mod h1:desAxe5jN/V/+cYe99TGEqxtMVdlJ1HfSRzCmuPJD7M=
|
||||
github.com/netfoundry/ziti-sdk-golang v0.11.16 h1:YZxHtDq4o+r141ISHvElT0CH4DKdb+EeQaoxSDVJAq0=
|
||||
github.com/netfoundry/ziti-sdk-golang v0.11.16/go.mod h1:Onxp1kNm0xarDjl6S43Y9PQPVHfXgUFcM157KQKqHm4=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q=
|
||||
github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo=
|
||||
github.com/speps/go-hashids v2.0.0+incompatible/go.mod h1:P7hqPzMdnZOfyIk+xrlG1QaSMw+gCBdHKsBDnhpaZvc=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
|
||||
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190228165749-92fc7df08ae7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191003212358-c178f38b412c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200301040627-c5d0d7b4ec88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200406113430-c6e801f48ba2 h1:Z9pPywZscwuw0ijrLEbTzW9lppFgBY4HDgbvoDnreQs=
|
||||
@@ -21,8 +125,18 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3-0.20191230102452-929e72ca90de h1:aYKJLPSrddB2N7/6OKyFqJ337SXpo61bBuvO5p1+7iY=
|
||||
golang.org/x/text v0.3.3-0.20191230102452-929e72ca90de/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.zx2c4.com/wireguard v0.0.20200122-0.20200214175355-9cbcff10dd3e/go.mod h1:P2HsVp8SKwZEufsnezXZA4GRX/T49/HlU7DGuelXsU4=
|
||||
golang.zx2c4.com/wireguard v0.0.20200320 h1:1vE6zVeO7fix9cJX1Z9ZQ+ikPIIx7vIyU0o0tLDD88g=
|
||||
golang.zx2c4.com/wireguard v0.0.20200320/go.mod h1:lDian4Sw4poJ04SgHh35nzMVwGSYlPumkdnHcucAQoY=
|
||||
golang.zx2c4.com/wireguard/windows v0.1.0 h1:742izt2DAJBpIQT+DvrzN58P9p7fO4BUFOgMzY9qVhw=
|
||||
golang.zx2c4.com/wireguard/windows v0.1.0/go.mod h1:EK7CxrFnicmYJ0ZCF6crBh2/EMMeSxMlqgLlwN0Kv9s=
|
||||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/sirupsen/logrus"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func File() string {
|
||||
return Path() + string(os.PathSeparator) + "config.json"
|
||||
}
|
||||
func Path() string {
|
||||
path, _ := os.UserConfigDir()
|
||||
return path + string(os.PathSeparator) + "NetFoundry" + string(os.PathSeparator)
|
||||
}
|
||||
func LogFile() string {
|
||||
return Path() + string(os.PathSeparator) + "ziti-tunneler.log"
|
||||
}
|
||||
|
||||
func ParseLevel(lvl string) logrus.Level {
|
||||
switch strings.ToLower(lvl) {
|
||||
case "panic":
|
||||
return logrus.PanicLevel
|
||||
case "fatal":
|
||||
return logrus.FatalLevel
|
||||
case "error":
|
||||
return logrus.ErrorLevel
|
||||
case "warn", "warning":
|
||||
return logrus.WarnLevel
|
||||
case "info":
|
||||
return logrus.InfoLevel
|
||||
case "debug":
|
||||
return logrus.DebugLevel
|
||||
case "trace":
|
||||
return logrus.TraceLevel
|
||||
default:
|
||||
logrus.Warnf("level not recognized: %s. Using Info", lvl)
|
||||
return logrus.InfoLevel
|
||||
}
|
||||
}
|
||||
|
||||
func InitLogger(level string) {
|
||||
logLevel := ParseLevel(level)
|
||||
logrus.SetLevel(logLevel)
|
||||
|
||||
multiWriter := io.MultiWriter(os.Stdout, &lumberjack.Logger{
|
||||
Filename: LogFile(),
|
||||
MaxSize: 1, // megabytes
|
||||
MaxBackups: 2,
|
||||
MaxAge: 30, //days
|
||||
Compress: false, // disabled by default
|
||||
})
|
||||
|
||||
logrus.SetOutput(multiWriter)
|
||||
logrus.SetFormatter(pfxlog.NewFormatter())
|
||||
pfxlog.Logger().Infof("Logger initialized. Log file located at: %s", LogFile())
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
idcfg "github.com/netfoundry/ziti-sdk-golang/ziti/config"
|
||||
"github.com/netfoundry/ziti-sdk-golang/ziti/enroll"
|
||||
)
|
||||
|
||||
type AddIdentity struct {
|
||||
EnrollmentFlags enroll.EnrollmentFlags `json:"Flags"`
|
||||
Id Identity `json:"Id"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
Name string
|
||||
HostName string
|
||||
Port int16
|
||||
}
|
||||
|
||||
type Identity struct {
|
||||
Name string
|
||||
FingerPrint string
|
||||
Active bool
|
||||
Config idcfg.Config
|
||||
Status string
|
||||
Services []Service
|
||||
Metrics Metrics
|
||||
}
|
||||
type Metrics struct {
|
||||
TotalBytes int64
|
||||
}
|
||||
type CommandMsg struct {
|
||||
Function string
|
||||
Payload map[string]interface{}
|
||||
}
|
||||
type Response struct {
|
||||
Code int
|
||||
Message string
|
||||
Error string
|
||||
Payload interface{} `json:"Payload"`
|
||||
}
|
||||
type ZitiTunnelStatus struct {
|
||||
Code int
|
||||
Message string
|
||||
Error string
|
||||
Payload Identity
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="go build main.go" type="GoApplicationRunConfiguration" factoryName="Go Application" nameIsGenerated="true">
|
||||
<module name="wintun-testing" />
|
||||
<working_directory value="$PROJECT_DIR$/" />
|
||||
<go_parameters value="-i" />
|
||||
<envs>
|
||||
<env name="PATH" value="v:\dev\tools\mingw-w64\bin" />
|
||||
<env name="PFXLOG_NO_JSON" value="true" />
|
||||
</envs>
|
||||
<kind value="FILE" />
|
||||
<filePath value="$PROJECT_DIR$/winio/main.go" />
|
||||
<package value="wintun-testing" />
|
||||
<directory value="$PROJECT_DIR$/" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,369 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"github.com/netfoundry/ziti-foundation/identity/identity"
|
||||
idcfg "github.com/netfoundry/ziti-sdk-golang/ziti/config"
|
||||
"github.com/netfoundry/ziti-sdk-golang/ziti/enroll"
|
||||
|
||||
"wintun-testing/winio/config"
|
||||
"wintun-testing/winio/dto"
|
||||
"wintun-testing/winio/runtime"
|
||||
)
|
||||
|
||||
var ipcPipeName = `\\.\pipe\NetFoundry\tunneler\ipc`
|
||||
var logsPipeName = `\\.\pipe\NetFoundry\tunneler\logs`
|
||||
var finished chan bool
|
||||
var log = pfxlog.Logger()
|
||||
var state = runtime.TunnelerState{}
|
||||
|
||||
const (
|
||||
SUCCESS = 0
|
||||
COULD_NOT_WRITE_FILE = 1
|
||||
COULD_NOT_ENROLL = 2
|
||||
|
||||
UNKNOWN_ERROR = 100
|
||||
ERROR_DISCONNECTING_ID = 50
|
||||
IDENTITY_NOT_FOUND = 1000
|
||||
)
|
||||
|
||||
var debug = true
|
||||
|
||||
func main() {
|
||||
config.InitLogger("debug")
|
||||
|
||||
ipc, err := winio.ListenPipe(ipcPipeName, nil)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
defer ipc.Close()
|
||||
go acceptIPC(ipc)
|
||||
log.Info("IPC listener ready")
|
||||
|
||||
logs, err := winio.ListenPipe(logsPipeName, nil)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
defer logs.Close()
|
||||
go acceptLogs(logs)
|
||||
log.Info("log listener ready")
|
||||
|
||||
initialize()
|
||||
<-finished
|
||||
<-finished
|
||||
}
|
||||
|
||||
func acceptIPC(p net.Listener) {
|
||||
for {
|
||||
c, err := p.Accept()
|
||||
log.Debugf("accepting a new client")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
go serveIpc(c)
|
||||
}
|
||||
}
|
||||
|
||||
func initialize() error {
|
||||
log.Debugf("reading config file located at s%:", config.File())
|
||||
file, err := os.OpenFile(config.File(), os.O_RDONLY, 0640)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
r := bufio.NewReader(file)
|
||||
dec := json.NewDecoder(r)
|
||||
|
||||
_ = dec.Decode(&state)
|
||||
log.Debugf("initial state loaded")
|
||||
return nil
|
||||
}
|
||||
|
||||
func serveIpc(conn net.Conn) {
|
||||
log.Debug("beginning receive loop")
|
||||
defer conn.Close() //close the connection after this function invoked as go routine exits
|
||||
|
||||
writer := bufio.NewWriter(conn)
|
||||
rw := bufio.NewReadWriter(bufio.NewReader(conn), writer)
|
||||
dec := json.NewDecoder(rw)
|
||||
enc := json.NewEncoder(rw)
|
||||
|
||||
for {
|
||||
var cmd dto.CommandMsg
|
||||
if err := dec.Decode(&cmd); err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
switch cmd.Function {
|
||||
case "AddIdentity":
|
||||
var newId dto.AddIdentity
|
||||
if err := dec.Decode(&newId); err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
newIdentity(newId, enc)
|
||||
case "RemoveIdentity":
|
||||
log.Debugf("Request received to remove an identity")
|
||||
removeIdentity(enc, cmd.Payload["Fingerprint"].(string))
|
||||
case "GetLogData":
|
||||
log.Debugf("request for log data received")
|
||||
_ = enc.Encode(dto.Response{Message: "this is my message"})
|
||||
case "Status":
|
||||
reportStatus(enc)
|
||||
case "TunnelState":
|
||||
onOff := cmd.Payload["OnOff"].(bool)
|
||||
tunnelState(onOff, enc)
|
||||
case "IdentityOnOff":
|
||||
onOff := cmd.Payload["onOff"]
|
||||
fingerprint := cmd.Payload["fingerprint"]
|
||||
log.Debugf("toggle ziti on/off for %s: %t", fingerprint, onOff)
|
||||
_ = enc.Encode(dto.Response{Message: "this is my message"})
|
||||
default:
|
||||
log.Debugf("Unknown operation: %s. Returning error on pipe", cmd.Function)
|
||||
respondWithError(enc, "Something unexpected has happened", UNKNOWN_ERROR, nil)
|
||||
}
|
||||
_ = writer.WriteByte('\n')
|
||||
_ = rw.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
func acceptLogs(p net.Listener) {
|
||||
for {
|
||||
conn, err := p.Accept()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
go serveLogs(conn)
|
||||
}
|
||||
}
|
||||
|
||||
func serveLogs(conn net.Conn) {
|
||||
w := bufio.NewWriter(conn)
|
||||
|
||||
file, err := os.OpenFile(config.LogFile(), os.O_RDONLY, 0640)
|
||||
if err != nil {
|
||||
log.Errorf("could not open log file at %s", config.LogFile())
|
||||
return
|
||||
}
|
||||
|
||||
r := bufio.NewReader(file)
|
||||
err = file.Close()
|
||||
if err != nil {
|
||||
log.Error("error closing log file", err)
|
||||
}
|
||||
io.Copy(w,r)
|
||||
_ = conn.Close() //close the connection
|
||||
}
|
||||
|
||||
func reportStatus(out *json.Encoder) {
|
||||
log.Debugf("request for status")
|
||||
rtn := state
|
||||
|
||||
//remove the config from the status
|
||||
ids := make([]dto.Identity, len(rtn.Identities))
|
||||
for i, id := range rtn.Identities {
|
||||
ids[i] = cleanId(id)
|
||||
}
|
||||
rtn.Identities = ids
|
||||
_ = out.Encode(rtn)
|
||||
}
|
||||
|
||||
func tunnelState(onOff bool, out *json.Encoder) {
|
||||
log.Debugf("toggle ziti on/off: %t", onOff)
|
||||
runtime.TunState = onOff
|
||||
runtime.SaveState(&state)
|
||||
//TODO: actually turn the tunnel on and off as well as handle errors
|
||||
_ = out.Encode(dto.Response{Message: "this is my message", Code: SUCCESS, Error: "", Payload: nil})
|
||||
}
|
||||
|
||||
func removeTempFile(file os.File) {
|
||||
err := os.Remove(file.Name()) // clean up
|
||||
if err != nil {
|
||||
log.Warnf("could not remove temp file: %s", file.Name())
|
||||
}
|
||||
err = file.Close()
|
||||
if err != nil {
|
||||
log.Warnf("could not close the temp file: %s", file.Name())
|
||||
}
|
||||
}
|
||||
|
||||
func newIdentity(newId dto.AddIdentity, out *json.Encoder) {
|
||||
|
||||
log.Debugf("new identity for %s: %s", newId.Id.Name, newId.EnrollmentFlags.JwtString)
|
||||
|
||||
tokenStr := newId.EnrollmentFlags.JwtString
|
||||
log.Debugf("jwt to parse: %s", tokenStr)
|
||||
tkn, _, err := enroll.ParseToken(tokenStr)
|
||||
|
||||
if err != nil {
|
||||
respondWithError(out, "failed to parse JWT: %s", COULD_NOT_ENROLL, err)
|
||||
return
|
||||
}
|
||||
var certPath = ""
|
||||
var keyPath = ""
|
||||
var caOverride = ""
|
||||
|
||||
flags := enroll.EnrollmentFlags{
|
||||
CertFile: certPath,
|
||||
KeyFile: keyPath,
|
||||
Token: tkn,
|
||||
IDName: newId.Id.Name,
|
||||
AdditionalCAs: caOverride,
|
||||
}
|
||||
|
||||
//enroll identity using the file and go sdk
|
||||
conf, err := enroll.Enroll(flags)
|
||||
if err != nil {
|
||||
respondWithError(out, "failed to enroll", COULD_NOT_ENROLL, err)
|
||||
return
|
||||
}
|
||||
|
||||
enrolled, err := ioutil.TempFile("" /*temp dir*/, "ziti-enrollment-*")
|
||||
if err != nil {
|
||||
respondWithError(out, "Could not create temporary file in local storage. This is abnormal. "+
|
||||
"Check the process has access to the temporary folder", COULD_NOT_WRITE_FILE, err)
|
||||
return
|
||||
}
|
||||
defer removeTempFile(*enrolled)
|
||||
|
||||
enc := json.NewEncoder(enrolled)
|
||||
enc.SetEscapeHTML(false)
|
||||
encErr := enc.Encode(&conf)
|
||||
|
||||
outpath := enrolled.Name()
|
||||
if encErr != nil {
|
||||
respondWithError(out, fmt.Sprintf("enrollment successful but the identity file was not able to be written to: %s [%s]", outpath, encErr), COULD_NOT_ENROLL, err)
|
||||
return
|
||||
}
|
||||
|
||||
id, err := identity.LoadIdentity(conf.ID)
|
||||
if err != nil {
|
||||
respondWithError(out, "unable to load identity which was just created. this is abnormal", COULD_NOT_ENROLL, err)
|
||||
return
|
||||
}
|
||||
|
||||
//map fields onto new identity
|
||||
newId.Id.Config.ZtAPI = conf.ZtAPI
|
||||
newId.Id.Config.ID = conf.ID
|
||||
newId.Id.FingerPrint = fmt.Sprintf("%x", sha1.Sum(id.Cert().Leaf.Raw)) //generate fingerprint
|
||||
if newId.Id.Name == "" {
|
||||
newId.Id.Name = newId.Id.FingerPrint
|
||||
}
|
||||
newId.Id.Status = "Enrolled"
|
||||
|
||||
err = enrolled.Close()
|
||||
if err != nil{
|
||||
panic(err)
|
||||
}
|
||||
newPath := config.Path() + newId.Id.FingerPrint + ".json"
|
||||
|
||||
//move the temp file to its final home after enrollment
|
||||
err = os.Rename(enrolled.Name(), newPath)
|
||||
if err != nil{
|
||||
log.Errorf("unexpected issue renaming the enrollment! attempting to remove the temporary file at: %s", enrolled.Name())
|
||||
err = os.Remove(enrolled.Name()) //if this fails... we tried :(
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
//newId.Id.Active = false //set to false by default - enable the id after persisting
|
||||
log.Infof("enrolled successfully. identity file written to: %s", newPath)
|
||||
|
||||
if newId.Id.Active == true {
|
||||
connectIdentity(&newId.Id)
|
||||
}
|
||||
|
||||
//if successful parse the output and add the config to the identity
|
||||
state.Identities = append(state.Identities, newId.Id)
|
||||
|
||||
//save the state
|
||||
runtime.SaveState(&state)
|
||||
|
||||
//return successful message
|
||||
resp := dto.Response{Message: "success", Code: SUCCESS, Error: "", Payload: cleanId(newId.Id)}
|
||||
|
||||
respond(out, resp)
|
||||
}
|
||||
|
||||
func respondWithError(out *json.Encoder, msg string, code int, err error) {
|
||||
if err != nil {
|
||||
_ = out.Encode(dto.Response{Message: msg, Code: code, Error: err.Error()})
|
||||
} else {
|
||||
_ = out.Encode(dto.Response{Message: msg, Code: code, Error: ""})
|
||||
}
|
||||
}
|
||||
|
||||
func connectIdentity(id *dto.Identity) {
|
||||
//tell the c sdk to use the file from the id and connect
|
||||
log.Infof("Connecting identity: %s", id.Name)
|
||||
loadServices(id)
|
||||
}
|
||||
|
||||
func loadServices(id *dto.Identity) {
|
||||
id.Services = append(id.Services,
|
||||
dto.Service{Name: "ServiceOne", HostName: "MyServiceName", Port: 1111},
|
||||
dto.Service{Name: "SecondOne", HostName: "SecondService", Port: 2222},
|
||||
dto.Service{Name: "LastDummy Service With Spaces and is very very long", HostName: "10.10.10.10", Port: 3333},
|
||||
)
|
||||
}
|
||||
|
||||
func disconnectIdentity(id dto.Identity) error {
|
||||
//tell the c sdk to disconnect the identity/services etc
|
||||
log.Infof("Disconnecting identity: %s", id.Name)
|
||||
|
||||
//remove the file from the filesystem - first verify it's the proper file
|
||||
err := os.Remove(config.Path() + id.FingerPrint + ".json")
|
||||
if err != nil {
|
||||
log.Warn("could not remove file: %s", config.Path()+id.FingerPrint+".json")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func removeIdentity(out *json.Encoder, fingerprint string) {
|
||||
_, id := state.Find(fingerprint)
|
||||
if id == nil {
|
||||
respondWithError(out, fmt.Sprintf("Could not find identity by fingerprint: %s", fingerprint), IDENTITY_NOT_FOUND, nil)
|
||||
return
|
||||
}
|
||||
|
||||
err := disconnectIdentity(*id)
|
||||
if err != nil {
|
||||
respondWithError(out, "Error when disconnecting identity", ERROR_DISCONNECTING_ID, err)
|
||||
return
|
||||
}
|
||||
state.RemoveByIdentity(*id)
|
||||
runtime.SaveState(&state)
|
||||
|
||||
resp := dto.Response{Message: "success", Code: SUCCESS, Error: "", Payload: nil}
|
||||
_ = out.Encode(resp)
|
||||
}
|
||||
|
||||
func respond(out *json.Encoder, thing interface{}) {
|
||||
//debug json to stdout if needed _ = json.NewEncoder(os.Stdout).Encode(thing)
|
||||
_ = out.Encode(thing)
|
||||
}
|
||||
|
||||
//Removes the Config from the provided identity and returns a 'cleaned' id
|
||||
func cleanId(id dto.Identity) dto.Identity {
|
||||
nid := id
|
||||
nid.Config = idcfg.Config{}
|
||||
nid.Config.ZtAPI = id.Config.ZtAPI
|
||||
return nid
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"github.com/michaelquigley/pfxlog"
|
||||
"os"
|
||||
"wintun-testing/winio/config"
|
||||
"wintun-testing/winio/dto"
|
||||
)
|
||||
|
||||
var log = pfxlog.Logger()
|
||||
var TunState bool
|
||||
|
||||
type TunnelerState struct {
|
||||
TunnelActive bool
|
||||
Identities []dto.Identity
|
||||
}
|
||||
|
||||
|
||||
func (t *TunnelerState) RemoveByFingerprint(fingerprint string) {
|
||||
log.Debugf("removing fingerprint: %s", fingerprint)
|
||||
if index, _ := t.Find(fingerprint); index < len(t.Identities) {
|
||||
t.Identities = append(t.Identities[:index], t.Identities[index+1:]...)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *TunnelerState) Find(fingerprint string) (int, *dto.Identity) {
|
||||
for i, n := range t.Identities {
|
||||
if n.FingerPrint == fingerprint {
|
||||
return i, &n
|
||||
}
|
||||
}
|
||||
return len(t.Identities), nil
|
||||
}
|
||||
|
||||
func (t *TunnelerState) RemoveByIdentity(id dto.Identity) {
|
||||
t.RemoveByFingerprint(id.FingerPrint)
|
||||
}
|
||||
|
||||
func (t *TunnelerState) FindByIdentity(id dto.Identity) (int, *dto.Identity) {
|
||||
return t.Find(id.FingerPrint)
|
||||
}
|
||||
|
||||
func SaveState(s *TunnelerState) {
|
||||
// overwrite file if it exists
|
||||
_ = os.MkdirAll(config.Path(), 0640)
|
||||
|
||||
file, err := os.OpenFile(config.File(), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = file.Close()
|
||||
if err != nil{
|
||||
panic(err)
|
||||
}
|
||||
|
||||
w := bufio.NewWriter(bufio.NewWriter(file))
|
||||
enc := json.NewEncoder(w)
|
||||
enc.SetIndent("", " ")
|
||||
_ = enc.Encode(s)
|
||||
_ = w.Flush()
|
||||
}
|
||||
Reference in New Issue
Block a user