diff --git a/.gitignore b/.gitignore index 607985e40..211ebf83b 100755 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,6 @@ java/doc/ java/build_win64/ java/build_win32/ /java/mac32_64/ +windows/WinUI/obj/ +windows/WinUI/bin/ +windows/ZeroTierOne/Debug/ diff --git a/windows/WinUI/APIHandler.cs b/windows/WinUI/APIHandler.cs new file mode 100644 index 000000000..8e7408a54 --- /dev/null +++ b/windows/WinUI/APIHandler.cs @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Net; +using System.IO; +using Newtonsoft.Json; + +namespace WinUI +{ + + + public class APIHandler + { + static string authtoken = "p3ptrzds5jkr2hbx5ipbyf04"; // delete me! + + private string url = null; + + public APIHandler() + { + url = "http://127.0.0.1:9993"; + } + + public APIHandler(string host, int port) + { + url = "http://" + host + ":" + port; + } + + public ZeroTierStatus GetStatus() + { + var request = WebRequest.Create(url + "/status" + "?auth=" + authtoken) as HttpWebRequest; + if (request != null) + { + request.Method = "GET"; + request.ContentType = "application/json"; + } + + var httpResponse = (HttpWebResponse)request.GetResponse(); + using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) + { + var responseText = streamReader.ReadToEnd(); + + ZeroTierStatus status = null; + try + { + status = JsonConvert.DeserializeObject(responseText); + } + catch (JsonReaderException e) + { + Console.WriteLine(e.ToString()); + } + return status; + } + } + + public List GetNetworks() + { + var request = WebRequest.Create(url + "/network" + "?auth=" + authtoken) as HttpWebRequest; + if (request == null) + { + return null; + } + + request.Method = "GET"; + request.ContentType = "application/json"; + + var httpResponse = (HttpWebResponse)request.GetResponse(); + using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) + { + var responseText = streamReader.ReadToEnd(); + + List networkList = null; + try + { + networkList = JsonConvert.DeserializeObject>(responseText); + } + catch (JsonReaderException e) + { + Console.WriteLine(e.ToString()); + } + return networkList; + } + } + + public void JoinNetwork(string nwid) + { + var request = WebRequest.Create(url + "/network/" + nwid + "?auth=" + authtoken) as HttpWebRequest; + if (request == null) + { + return; + } + + request.Method = "POST"; + + var httpResponse = (HttpWebResponse)request.GetResponse(); + + if (httpResponse.StatusCode != HttpStatusCode.OK) + { + Console.WriteLine("Error sending join network message"); + } + } + + public void LeaveNetwork(string nwid) + { + var request = WebRequest.Create(url + "/network/" + nwid + "?auth=" + authtoken) as HttpWebRequest; + if (request == null) + { + return; + } + + request.Method = "DELETE"; + + var httpResponse = (HttpWebResponse)request.GetResponse(); + + if (httpResponse.StatusCode != HttpStatusCode.OK) + { + Console.WriteLine("Error sending leave network message"); + } + } + + public List GetPeers() + { + var request = WebRequest.Create(url + "/peer" + "?auth=" + authtoken) as HttpWebRequest; + if (request == null) + { + return null; + } + + request.Method = "GET"; + request.ContentType = "application/json"; + + var httpResponse = (HttpWebResponse)request.GetResponse(); + using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) + { + var responseText = streamReader.ReadToEnd(); + + List peerList = null; + try + { + peerList = JsonConvert.DeserializeObject>(responseText); + } + catch (JsonReaderException e) + { + Console.WriteLine(e.ToString()); + } + return peerList; + } + } + } +} diff --git a/windows/WinUI/App.config b/windows/WinUI/App.config new file mode 100644 index 000000000..8e1564635 --- /dev/null +++ b/windows/WinUI/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/windows/WinUI/App.xaml b/windows/WinUI/App.xaml new file mode 100644 index 000000000..08b9b7921 --- /dev/null +++ b/windows/WinUI/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/windows/WinUI/App.xaml.cs b/windows/WinUI/App.xaml.cs new file mode 100644 index 000000000..a97edde74 --- /dev/null +++ b/windows/WinUI/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace WinUI +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/windows/WinUI/Fonts/segoeui.ttf b/windows/WinUI/Fonts/segoeui.ttf new file mode 100644 index 000000000..fc18ebd0a Binary files /dev/null and b/windows/WinUI/Fonts/segoeui.ttf differ diff --git a/windows/WinUI/Fonts/segoeuib.ttf b/windows/WinUI/Fonts/segoeuib.ttf new file mode 100644 index 000000000..5f31e0ca6 Binary files /dev/null and b/windows/WinUI/Fonts/segoeuib.ttf differ diff --git a/windows/WinUI/Fonts/segoeuii.ttf b/windows/WinUI/Fonts/segoeuii.ttf new file mode 100644 index 000000000..7efb70d60 Binary files /dev/null and b/windows/WinUI/Fonts/segoeuii.ttf differ diff --git a/windows/WinUI/Fonts/segoeuiz.ttf b/windows/WinUI/Fonts/segoeuiz.ttf new file mode 100644 index 000000000..d7bb186b3 Binary files /dev/null and b/windows/WinUI/Fonts/segoeuiz.ttf differ diff --git a/windows/WinUI/MainWindow.xaml b/windows/WinUI/MainWindow.xaml new file mode 100644 index 000000000..553d44fe4 --- /dev/null +++ b/windows/WinUI/MainWindow.xaml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +