summaryrefslogtreecommitdiff
path: root/windows
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2017-03-08 14:50:37 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2017-03-08 14:50:37 -0800
commitc8e66a2b45f52c72ef35b0472a68ff5cd1374092 (patch)
tree141253d184e972117cca023d7dc4f81f56d0d36d /windows
parent6eb2e3ffa994fbca0cc09b876bbd1049c210281e (diff)
downloadinfinitytier-c8e66a2b45f52c72ef35b0472a68ff5cd1374092.tar.gz
infinitytier-c8e66a2b45f52c72ef35b0472a68ff5cd1374092.zip
Don't crash when attempting to join a network while the zerotier service isn't running
Diffstat (limited to 'windows')
-rw-r--r--windows/WinUI/APIHandler.cs27
1 files changed, 17 insertions, 10 deletions
diff --git a/windows/WinUI/APIHandler.cs b/windows/WinUI/APIHandler.cs
index a762fff7..81c5b775 100644
--- a/windows/WinUI/APIHandler.cs
+++ b/windows/WinUI/APIHandler.cs
@@ -230,16 +230,23 @@ namespace WinUI
request.Method = "POST";
request.ContentType = "applicaiton/json";
request.Timeout = 10000;
-
- using (var streamWriter = new StreamWriter(((HttpWebRequest)request).GetRequestStream()))
- {
- string json = "{\"allowManaged\":" + (allowManaged ? "true" : "false") + "," +
- "\"allowGlobal\":" + (allowGlobal ? "true" : "false") + "," +
- "\"allowDefault\":" + (allowDefault ? "true" : "false") + "}";
- streamWriter.Write(json);
- streamWriter.Flush();
- streamWriter.Close();
- }
+ try
+ {
+ using (var streamWriter = new StreamWriter(((HttpWebRequest)request).GetRequestStream()))
+ {
+ string json = "{\"allowManaged\":" + (allowManaged ? "true" : "false") + "," +
+ "\"allowGlobal\":" + (allowGlobal ? "true" : "false") + "," +
+ "\"allowDefault\":" + (allowDefault ? "true" : "false") + "}";
+ streamWriter.Write(json);
+ streamWriter.Flush();
+ streamWriter.Close();
+ }
+ }
+ catch (System.Net.WebException)
+ {
+ MessageBox.Show("Error Joining Network: Cannot connect to ZeroTier service.");
+ return;
+ }
try
{