Commit 33186d76 authored by byronap's avatar byronap

add an example windows service

parent 4562e132
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="WindowsServiceExample.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<applicationSettings>
<WindowsServiceExample.Properties.Settings>
<setting name="ListeningPort" serializeAs="String">
<value>8080</value>
</setting>
<setting name="EnableIpV6" serializeAs="String">
<value>True</value>
</setting>
<setting name="CheckCertificateRevocation" serializeAs="String">
<value>NoCheck</value>
</setting>
<setting name="ConnectionTimeOutSeconds" serializeAs="String">
<value>30</value>
</setting>
<setting name="Enable100ContinueBehaviour" serializeAs="String">
<value>False</value>
</setting>
<setting name="EnableConnectionPool" serializeAs="String">
<value>True</value>
</setting>
<setting name="EnableTcpServerConnectionPrefetch" serializeAs="String">
<value>True</value>
</setting>
<setting name="EnableWinAuth" serializeAs="String">
<value>False</value>
</setting>
<setting name="ForwardToUpstreamGateway" serializeAs="String">
<value>False</value>
</setting>
<setting name="MaxCachedConnections" serializeAs="String">
<value>2</value>
</setting>
<setting name="ReuseSocket" serializeAs="String">
<value>True</value>
</setting>
<setting name="TcpTimeWaitSeconds" serializeAs="String">
<value>30</value>
</setting>
<setting name="SaveFakeCertificates" serializeAs="String">
<value>True</value>
</setting>
<setting name="EnableHttp2" serializeAs="String">
<value>False</value>
</setting>
<setting name="NoDelay" serializeAs="String">
<value>True</value>
</setting>
<setting name="ThreadPoolWorkerThreads" serializeAs="String">
<value>-1</value>
</setting>
<setting name="DecryptSsl" serializeAs="String">
<value>False</value>
</setting>
<setting name="LogErrors" serializeAs="String">
<value>True</value>
</setting>
</WindowsServiceExample.Properties.Settings>
</applicationSettings>
</configuration>
\ No newline at end of file
using System.ServiceProcess;
namespace WindowsServiceExample
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new ProxyService()
};
ServiceBase.Run(ServicesToRun);
}
}
}
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WindowsServiceExample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindowsServiceExample")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("63635f50-7d6f-4a93-84c6-04cf9d2754c5")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WindowsServiceExample.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("8080")]
public int ListeningPort
{
get
{
return ((int)(this["ListeningPort"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool EnableIpV6
{
get
{
return ((bool)(this["EnableIpV6"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("NoCheck")]
public global::System.Security.Cryptography.X509Certificates.X509RevocationMode CheckCertificateRevocation
{
get
{
return ((global::System.Security.Cryptography.X509Certificates.X509RevocationMode)(this["CheckCertificateRevocation"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("30")]
public int ConnectionTimeOutSeconds
{
get
{
return ((int)(this["ConnectionTimeOutSeconds"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool Enable100ContinueBehaviour
{
get
{
return ((bool)(this["Enable100ContinueBehaviour"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool EnableConnectionPool
{
get
{
return ((bool)(this["EnableConnectionPool"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool EnableTcpServerConnectionPrefetch
{
get
{
return ((bool)(this["EnableTcpServerConnectionPrefetch"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool EnableWinAuth
{
get
{
return ((bool)(this["EnableWinAuth"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool ForwardToUpstreamGateway
{
get
{
return ((bool)(this["ForwardToUpstreamGateway"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("2")]
public int MaxCachedConnections
{
get
{
return ((int)(this["MaxCachedConnections"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ReuseSocket
{
get
{
return ((bool)(this["ReuseSocket"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("30")]
public int TcpTimeWaitSeconds
{
get
{
return ((int)(this["TcpTimeWaitSeconds"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool SaveFakeCertificates
{
get
{
return ((bool)(this["SaveFakeCertificates"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool EnableHttp2
{
get
{
return ((bool)(this["EnableHttp2"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool NoDelay
{
get
{
return ((bool)(this["NoDelay"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("-1")]
public int ThreadPoolWorkerThreads
{
get
{
return ((int)(this["ThreadPoolWorkerThreads"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool DecryptSsl
{
get
{
return ((bool)(this["DecryptSsl"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool LogErrors
{
get
{
return ((bool)(this["LogErrors"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.IDictionary StateCollection
{
get
{
return ((global::System.Collections.IDictionary)(this["StateCollection"]));
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="WindowsServiceExample.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ListeningPort" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">8080</Value>
</Setting>
<Setting Name="EnableIpV6" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="CheckCertificateRevocation" Type="System.Security.Cryptography.X509Certificates.X509RevocationMode" Scope="Application">
<Value Profile="(Default)">NoCheck</Value>
</Setting>
<Setting Name="ConnectionTimeOutSeconds" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">30</Value>
</Setting>
<Setting Name="Enable100ContinueBehaviour" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="EnableConnectionPool" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="EnableTcpServerConnectionPrefetch" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="EnableWinAuth" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ForwardToUpstreamGateway" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="MaxCachedConnections" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">2</Value>
</Setting>
<Setting Name="ReuseSocket" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="TcpTimeWaitSeconds" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">30</Value>
</Setting>
<Setting Name="SaveFakeCertificates" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="EnableHttp2" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="NoDelay" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ThreadPoolWorkerThreads" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">-1</Value>
</Setting>
<Setting Name="DecryptSsl" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="LogErrors" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="StateCollection" Type="System.Collections.ArrayList" Scope="Application">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
namespace WindowsServiceExample
{
partial class ProxyService
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ProxyServiceEventLog = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.ProxyServiceEventLog)).BeginInit();
//
// ProxyServiceEventLog
//
this.ProxyServiceEventLog.Log = "Application";
this.ProxyServiceEventLog.Source = "ProxyService";
//
// ProxyService
//
this.ServiceName = "ProxyService";
((System.ComponentModel.ISupportInitialize)(this.ProxyServiceEventLog)).EndInit();
}
#endregion
private System.Diagnostics.EventLog ProxyServiceEventLog;
}
}
using System;
using System.Net;
using System.ServiceProcess;
using Titanium.Web.Proxy;
using Titanium.Web.Proxy.Exceptions;
using Titanium.Web.Proxy.Models;
namespace WindowsServiceExample
{
partial class ProxyService : ServiceBase
{
private static ProxyServer _proxyServerInstance;
public ProxyService()
{
InitializeComponent();
AppDomain.CurrentDomain.UnhandledException += UnhandledDomainException;
}
protected override void OnStart(string[] args)
{
// we do all this in here so we can reload settings with a simple restart
_proxyServerInstance = new ProxyServer();
if (Properties.Settings.Default.ListeningPort <= 0 ||
Properties.Settings.Default.ListeningPort > 65535)
throw new Exception("Invalid listening port");
_proxyServerInstance.CheckCertificateRevocation = Properties.Settings.Default.CheckCertificateRevocation;
_proxyServerInstance.ConnectionTimeOutSeconds = Properties.Settings.Default.ConnectionTimeOutSeconds;
_proxyServerInstance.Enable100ContinueBehaviour = Properties.Settings.Default.Enable100ContinueBehaviour;
_proxyServerInstance.EnableConnectionPool = Properties.Settings.Default.EnableConnectionPool;
_proxyServerInstance.EnableTcpServerConnectionPrefetch = Properties.Settings.Default.EnableTcpServerConnectionPrefetch;
_proxyServerInstance.EnableWinAuth = Properties.Settings.Default.EnableWinAuth;
_proxyServerInstance.ForwardToUpstreamGateway = Properties.Settings.Default.ForwardToUpstreamGateway;
_proxyServerInstance.MaxCachedConnections = Properties.Settings.Default.MaxCachedConnections;
_proxyServerInstance.ReuseSocket = Properties.Settings.Default.ReuseSocket;
_proxyServerInstance.TcpTimeWaitSeconds = Properties.Settings.Default.TcpTimeWaitSeconds;
_proxyServerInstance.CertificateManager.SaveFakeCertificates = Properties.Settings.Default.SaveFakeCertificates;
_proxyServerInstance.EnableHttp2 = Properties.Settings.Default.EnableHttp2;
_proxyServerInstance.NoDelay = Properties.Settings.Default.NoDelay;
if (Properties.Settings.Default.ThreadPoolWorkerThreads < 0)
{
_proxyServerInstance.ThreadPoolWorkerThread = Environment.ProcessorCount;
}
else
{
_proxyServerInstance.ThreadPoolWorkerThread = Properties.Settings.Default.ThreadPoolWorkerThreads;
}
if (Properties.Settings.Default.ThreadPoolWorkerThreads < Environment.ProcessorCount)
{
ProxyServiceEventLog.WriteEntry(
$"Worker thread count of {Properties.Settings.Default.ThreadPoolWorkerThreads} is below the " +
$"processor count of {Environment.ProcessorCount}. This may be on purpose.", System.Diagnostics.EventLogEntryType.Warning);
}
var explicitEndPointV4 = new ExplicitProxyEndPoint(IPAddress.Any, Properties.Settings.Default.ListeningPort, Properties.Settings.Default.DecryptSsl);
_proxyServerInstance.AddEndPoint(explicitEndPointV4);
if (Properties.Settings.Default.EnableIpV6)
{
var explicitEndPointV6 = new ExplicitProxyEndPoint(IPAddress.IPv6Any, Properties.Settings.Default.ListeningPort, Properties.Settings.Default.DecryptSsl);
_proxyServerInstance.AddEndPoint(explicitEndPointV6);
}
if (Properties.Settings.Default.LogErrors)
_proxyServerInstance.ExceptionFunc = ProxyException;
_proxyServerInstance.Start();
ProxyServiceEventLog.WriteEntry($"Service Listening on port {Properties.Settings.Default.ListeningPort}", System.Diagnostics.EventLogEntryType.Information);
}
protected override void OnStop()
{
_proxyServerInstance.Stop();
// clean up here since we make a new instance when starting
_proxyServerInstance.Dispose();
}
private void ProxyException(Exception exception)
{
string message;
if (exception is ProxyHttpException pEx)
{
message = $"Unhandled Proxy Exception in ProxyServer, UserData = {pEx.Session?.UserData}, URL = {pEx.Session?.HttpClient.Request.RequestUri} Exception = {pEx}";
}
else
{
message = $"Unhandled Exception in ProxyServer, Exception = {exception}";
}
ProxyServiceEventLog.WriteEntry(message, System.Diagnostics.EventLogEntryType.Error);
}
private void UnhandledDomainException(object sender, UnhandledExceptionEventArgs e)
{
ProxyServiceEventLog.WriteEntry($"Unhandled Exception in AppDomain, Exception = {e}", System.Diagnostics.EventLogEntryType.Error);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ProxyServiceEventLog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63635F50-7D6F-4A93-84C6-04CF9D2754C5}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WindowsServiceExample</RootNamespace>
<AssemblyName>WindowsServiceExample</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>WindowsServiceExample.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="ProxyService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProxyService.Designer.cs">
<DependentUpon>ProxyService.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="remove.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="install.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProxyService.resx">
<DependentUpon>ProxyService.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry">
<Version>4.6.0</Version>
</PackageReference>
<PackageReference Include="System.Numerics.Vectors">
<Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>4.6.0</Version>
</PackageReference>
<PackageReference Include="System.ServiceProcess.ServiceController">
<Version>4.6.0</Version>
</PackageReference>
<PackageReference Include="System.Threading.Tasks.Extensions">
<Version>4.5.3</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Titanium.Web.Proxy\Titanium.Web.Proxy.csproj" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
#
# There are several ways to install a service on windows, this methods uses PowerShell.
#
# Self-elevate the script if required.
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
# This is the name of the service and will also show as the display name in services.msc.
[String] $ServiceName = "ProxyService"
# This is the name of the executable of the service.
[String] $ServiceExeName = "WindowsServiceExample.exe"
# Use the directory of the runnign script and the service executable name to create a full path.
[String] $ServiceExePath = [string]($PSScriptRoot) + "\" + $ServiceExeName
# Get the information for the executable file.
[IO.FileInfo] $ExeFileInfo = $ServiceExePath
# Check if the executable file exists.
if(!$ExeFileInfo.Exists) {
# OH NO the executable was not found.
Write-host "Service executable not found $ServiceExePath"
Write-Host "Please fix and try again."
}else{
# Lets install the service.
Write-host "Installing service $ServiceExePath"
New-Service -Name $ServiceName -BinaryPathName $ServiceExePath -Description "HTTP proxy service" -StartupType "Automatic"
# Service installed, lets start it.
Start-Service -Name $ServiceName
}
Read-Host -Prompt "Press Enter to exit"
\ No newline at end of file
# Self-elevate the script if required.
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
$CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
Exit
}
}
# This is the name of the service and will also show as the display name in services.msc.
# This must match what the service was installed as.
$ServiceName = "ProxyService"
# Make sure the service is stopped.
Stop-Service -Name $ServiceName
# Remove the service, this doesnt always work. (Requires PS 6+)
Remove-Service -Name $ServiceName
# Make sure the service gets unregistered even if the last command failed.
sc.exe delete $ServiceName
Read-Host -Prompt "Press Enter to exit"
\ No newline at end of file
...@@ -31,6 +31,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Titanium.Web.Proxy.Examples ...@@ -31,6 +31,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Titanium.Web.Proxy.Examples
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Titanium.Web.Proxy.IntegrationTests", "..\tests\Titanium.Web.Proxy.IntegrationTests\Titanium.Web.Proxy.IntegrationTests.csproj", "{1D053D72-DCB4-4517-ACDD-D35ADC186950}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Titanium.Web.Proxy.IntegrationTests", "..\tests\Titanium.Web.Proxy.IntegrationTests\Titanium.Web.Proxy.IntegrationTests.csproj", "{1D053D72-DCB4-4517-ACDD-D35ADC186950}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Titanium.Web.Proxy.Examples.WindowsService", "..\examples\Titanium.Web.Proxy.Examples.WindowsService\Titanium.Web.Proxy.Examples.WindowsService.csproj", "{63635F50-7D6F-4A93-84C6-04CF9D2754C5}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -79,6 +81,14 @@ Global ...@@ -79,6 +81,14 @@ Global
{1D053D72-DCB4-4517-ACDD-D35ADC186950}.Release|Any CPU.Build.0 = Release|Any CPU {1D053D72-DCB4-4517-ACDD-D35ADC186950}.Release|Any CPU.Build.0 = Release|Any CPU
{1D053D72-DCB4-4517-ACDD-D35ADC186950}.Release|x64.ActiveCfg = Release|Any CPU {1D053D72-DCB4-4517-ACDD-D35ADC186950}.Release|x64.ActiveCfg = Release|Any CPU
{1D053D72-DCB4-4517-ACDD-D35ADC186950}.Release|x64.Build.0 = Release|Any CPU {1D053D72-DCB4-4517-ACDD-D35ADC186950}.Release|x64.Build.0 = Release|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Debug|x64.ActiveCfg = Debug|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Debug|x64.Build.0 = Debug|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Release|Any CPU.Build.0 = Release|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Release|x64.ActiveCfg = Release|Any CPU
{63635F50-7D6F-4A93-84C6-04CF9D2754C5}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -88,9 +98,10 @@ Global ...@@ -88,9 +98,10 @@ Global
{1FAC4205-4445-4F2B-BB8F-618E8A0C15FD} = {B6DBABDC-C985-4872-9C38-B4E5079CBC4B} {1FAC4205-4445-4F2B-BB8F-618E8A0C15FD} = {B6DBABDC-C985-4872-9C38-B4E5079CBC4B}
{4406CE17-9A39-4F28-8363-6169A4F799C1} = {B6DBABDC-C985-4872-9C38-B4E5079CBC4B} {4406CE17-9A39-4F28-8363-6169A4F799C1} = {B6DBABDC-C985-4872-9C38-B4E5079CBC4B}
{1D053D72-DCB4-4517-ACDD-D35ADC186950} = {BC1E0789-D348-49CF-8B67-5E99D50EDF64} {1D053D72-DCB4-4517-ACDD-D35ADC186950} = {BC1E0789-D348-49CF-8B67-5E99D50EDF64}
{63635F50-7D6F-4A93-84C6-04CF9D2754C5} = {B6DBABDC-C985-4872-9C38-B4E5079CBC4B}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EnterpriseLibraryConfigurationToolBinariesPath = .1.505.2\lib\NET35
SolutionGuid = {625C1EB5-44CF-47DE-A85A-B4C8C40ED90A} SolutionGuid = {625C1EB5-44CF-47DE-A85A-B4C8C40ED90A}
EnterpriseLibraryConfigurationToolBinariesPath = .1.505.2\lib\NET35
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment