summaryrefslogtreecommitdiff
path: root/windows
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-05-21 19:14:49 -0700
committerGrant Limberg <glimberg@gmail.com>2015-05-21 19:14:49 -0700
commitc430d88bd40d178685ac0a2e648d8c4ea675996c (patch)
treef69f497428fa34c6389173d39c889563dea9506c /windows
parent9a00366b18bc2bdb3ddf4345edcc7a459eb5ed60 (diff)
parentd9006712f6ffc975d97097caf2d2b4264405b32c (diff)
downloadinfinitytier-c430d88bd40d178685ac0a2e648d8c4ea675996c.tar.gz
infinitytier-c430d88bd40d178685ac0a2e648d8c4ea675996c.zip
Merge branch 'adamierymenko-dev' into android-jni
Conflicts: .gitignore
Diffstat (limited to 'windows')
-rw-r--r--windows/WebUIWrapper/Form1.Designer.cs11
-rw-r--r--windows/WebUIWrapper/Program.cs70
-rw-r--r--windows/ZeroTierOne/ZeroTierOneService.cpp98
-rw-r--r--windows/ZeroTierOne/ZeroTierOneService.h3
4 files changed, 76 insertions, 106 deletions
diff --git a/windows/WebUIWrapper/Form1.Designer.cs b/windows/WebUIWrapper/Form1.Designer.cs
index 8d8eb9e9..81d69cd0 100644
--- a/windows/WebUIWrapper/Form1.Designer.cs
+++ b/windows/WebUIWrapper/Form1.Designer.cs
@@ -36,20 +36,21 @@
//
this.webContainer.AllowNavigation = false;
this.webContainer.Dock = System.Windows.Forms.DockStyle.Fill;
- this.webContainer.IsWebBrowserContextMenuEnabled = false;
this.webContainer.Location = new System.Drawing.Point(0, 0);
- this.webContainer.MinimumSize = new System.Drawing.Size(20, 20);
+ this.webContainer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.webContainer.MinimumSize = new System.Drawing.Size(18, 16);
this.webContainer.Name = "webContainer";
- this.webContainer.Size = new System.Drawing.Size(1012, 556);
+ this.webContainer.Size = new System.Drawing.Size(900, 445);
this.webContainer.TabIndex = 0;
//
// Form1
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1012, 556);
+ this.ClientSize = new System.Drawing.Size(900, 445);
this.Controls.Add(this.webContainer);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "Form1";
this.Text = "ZeroTier One";
this.Load += new System.EventHandler(this.Form1_Load);
diff --git a/windows/WebUIWrapper/Program.cs b/windows/WebUIWrapper/Program.cs
index 3dfdb94f..bfcdb831 100644
--- a/windows/WebUIWrapper/Program.cs
+++ b/windows/WebUIWrapper/Program.cs
@@ -3,17 +3,87 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
namespace WebUIWrapper
{
+ [ComImport, GuidAttribute("79EAC9EE-BAF9-11CE-8C82-00AA004BA90B"),
+ InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
+ public interface IInternetSecurityManager
+ {
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int SetSecuritySite([In] IntPtr pSite);
+
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int GetSecuritySite([Out] IntPtr pSite);
+
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int MapUrlToZone([In, MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, out UInt32 pdwZone, UInt32 dwFlags);
+
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int GetSecurityId([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, [MarshalAs(UnmanagedType.LPArray)] byte[] pbSecurityId, ref UInt32 pcbSecurityId, uint dwReserved);
+
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int ProcessUrlAction([In, MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, UInt32 dwAction, out byte pPolicy, UInt32 cbPolicy, byte pContext, UInt32 cbContext, UInt32 dwFlags, UInt32 dwReserved);
+
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int QueryCustomPolicy([In, MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, ref Guid guidKey, ref byte ppPolicy, ref UInt32 pcbPolicy, ref byte pContext, UInt32 cbContext, UInt32 dwReserved);
+
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int SetZoneMapping(UInt32 dwZone, [In, MarshalAs(UnmanagedType.LPWStr)] string lpszPattern, UInt32 dwFlags);
+
+ [return: MarshalAs(UnmanagedType.I4)]
+ [PreserveSig]
+ int GetZoneMappings(UInt32 dwZone, out UCOMIEnumString ppenumString, UInt32 dwFlags);
+ }
+
static class Program
{
+ // constants from urlmon.h
+ public const UInt32 URLZONE_LOCAL_MACHINE = 0;
+ public const UInt32 URLZONE_INTRANET = URLZONE_LOCAL_MACHINE + 1;
+ public const UInt32 URLZONE_TRUSTED = URLZONE_INTRANET + 1;
+ public const UInt32 URLZONE_INTERNET = URLZONE_TRUSTED + 1;
+ public const UInt32 URLZONE_UNTRUSTED = URLZONE_INTERNET + 1;
+ public const UInt32 URLZONE_ESC_FLAG = 0x100;
+ public const UInt32 SZM_CREATE = 0;
+ public const UInt32 SZM_DELETE = 0x1;
+
+ public static Guid CLSID_InternetSecurityManager = new Guid("7b8a2d94-0ac9-11d1-896c-00c04fb6bfc4");
+ public static Guid IID_IInternetSecurityManager = new Guid("79eac9ee-baf9-11ce-8c82-00aa004ba90b");
+
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
+ try
+ {
+ Type t = Type.GetTypeFromCLSID(CLSID_InternetSecurityManager);
+ object securityManager = Activator.CreateInstance(t);
+ if (securityManager != null)
+ {
+ IInternetSecurityManager ism = (IInternetSecurityManager)securityManager;
+ ism.SetZoneMapping(URLZONE_TRUSTED, "http://127.0.0.1", SZM_CREATE);
+ ism.SetZoneMapping(URLZONE_INTRANET, "http://127.0.0.1", SZM_CREATE);
+ ism.SetZoneMapping(URLZONE_ESC_FLAG | URLZONE_TRUSTED, "http://127.0.0.1", SZM_CREATE);
+ ism.SetZoneMapping(URLZONE_ESC_FLAG | URLZONE_INTRANET, "http://127.0.0.1", SZM_CREATE);
+ }
+ }
+ catch
+ {
+ // Okay to continue if adding URL to trusted zone doesn't work...
+ }
+
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
diff --git a/windows/ZeroTierOne/ZeroTierOneService.cpp b/windows/ZeroTierOne/ZeroTierOneService.cpp
index e5426dc2..984bcf00 100644
--- a/windows/ZeroTierOne/ZeroTierOneService.cpp
+++ b/windows/ZeroTierOne/ZeroTierOneService.cpp
@@ -117,77 +117,6 @@ restart_node:
default: // normal termination
break;
}
-
-#if 0
- std::string authToken(ZeroTier::NodeControlClient::getAuthToken((ZeroTier::ZT_DEFAULTS.defaultHomePath + ZT_PATH_SEPARATOR_S + "authtoken.secret").c_str(),true));
-
- ZeroTier::WindowsEthernetTapFactory tapFactory(ZeroTier::ZT_DEFAULTS.defaultHomePath.c_str());
- ZeroTier::WindowsRoutingTable routingTable;
- ZeroTier::NativeSocketManager socketManager(ZT_DEFAULT_UDP_PORT,0);
-
- {
- // start or restart
- ZeroTier::Mutex::Lock _l(_lock);
- delete _node;
- _node = new ZeroTier::Node(ZeroTier::ZT_DEFAULTS.defaultHomePath.c_str(),&tapFactory,&routingTable,&socketManager,false,(const char *)0);
- }
-
- ZeroTier::NodeControlService controlService(_node,authToken.c_str());
-
- switch(_node->run()) {
-
- case ZeroTier::Node::NODE_RESTART_FOR_UPGRADE: {
- // Shut down node
- ZeroTier::Node *n;
- {
- ZeroTier::Mutex::Lock _l(_lock);
- n = _node;
- _node = (ZeroTier::Node *)0;
- }
-
- // Get upgrade path, which will be its reason for termination
- std::string msiPath;
- if (n) {
- const char *msiPathTmp = n->terminationMessage();
- if (msiPathTmp)
- msiPath = msiPathTmp;
- }
-
- delete n;
-
- if ((!msiPath.length())||(!ZeroTier::Utils::fileExists(msiPath.c_str()))) {
- WriteEventLogEntry("auto-update failed: no msi path provided by Node",EVENTLOG_ERROR_TYPE);
- Sleep(5000);
- goto restart_node;
- }
-
- if (!doStartUpgrade(msiPath)) {
- WriteEventLogEntry("auto-update failed: unable to create InstallAndRestartService.bat",EVENTLOG_ERROR_TYPE);
- Sleep(5000);
- goto restart_node;
- }
-
- // Terminate service to allow updater to update
- Stop();
- } return;
-
- case ZeroTier::Node::NODE_UNRECOVERABLE_ERROR: {
- std::string err("ZeroTier node encountered an unrecoverable error: ");
- const char *r = _node->terminationMessage();
- if (r)
- err.append(r);
- else err.append("(unknown error)");
- err.append(" (restarting in 5 seconds)");
- WriteEventLogEntry(const_cast <PSTR>(err.c_str()),EVENTLOG_ERROR_TYPE);
- Sleep(5000);
- goto restart_node;
- } break;
-
- default: // includes normal termination, which will terminate thread
- break;
-
- }
-#endif
} catch ( ... ) {
// sanity check, shouldn't happen since Node::run() should catch all its own errors
// could also happen if we're out of memory though!
@@ -203,33 +132,6 @@ restart_node:
}
}
-bool ZeroTierOneService::doStartUpgrade(const std::string &msiPath)
-{
- std::string homePath(ZeroTier::OneService::platformDefaultHomePath());
-
- std::string msiLog(homePath + "\\LastUpdateLog.txt");
- ZeroTier::OSUtils::rm(msiLog);
-
- std::string bat(homePath + "\\InstallAndRestartService.bat");
- FILE *batf = fopen(bat.c_str(),"wb");
- if (!batf)
- return false;
- fprintf(batf,"TIMEOUT.EXE /T 1 /NOBREAK\r\n");
- fprintf(batf,"NET.EXE STOP \"ZeroTier One\"\r\n");
- fprintf(batf,"MSIEXEC.EXE /i \"%s\" /l* \"%s\" /qn\r\n",msiPath.c_str(),msiLog.c_str());
- fprintf(batf,"NET.EXE START \"ZeroTier One\"\r\n");
- fclose(batf);
-
- STARTUPINFOA si;
- PROCESS_INFORMATION pi;
- memset(&si,0,sizeof(si));
- memset(&pi,0,sizeof(pi));
- if (!CreateProcessA(NULL,const_cast <LPSTR>((std::string("CMD.EXE /c \"") + bat + "\"").c_str()),NULL,NULL,FALSE,CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP,NULL,NULL,&si,&pi))
- return false;
-
- return true;
-}
-
void ZeroTierOneService::OnStart(DWORD dwArgc, LPSTR *lpszArgv)
{
ZT_SVCDBG("ZeroTierOneService::OnStart()\r\n");
diff --git a/windows/ZeroTierOne/ZeroTierOneService.h b/windows/ZeroTierOne/ZeroTierOneService.h
index 1b97fd46..d4d1a7c6 100644
--- a/windows/ZeroTierOne/ZeroTierOneService.h
+++ b/windows/ZeroTierOne/ZeroTierOneService.h
@@ -68,9 +68,6 @@ public:
void threadMain()
throw();
- // Returns false on failure.
- static bool doStartUpgrade(const std::string &msiPath);
-
protected:
virtual void OnStart(DWORD dwArgc, PSTR *pszArgv);
virtual void OnStop();