forked from justcoding121/titanium-web-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
887add6
commit e332c90
Showing
23 changed files
with
590 additions
and
685 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" /> | ||
</startup> | ||
</configuration> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Text; | ||
using Titanium.Web.Proxy.Helpers; | ||
|
||
namespace Titanium.Web.Proxy.Test | ||
{ | ||
public class Program | ||
{ | ||
static ProxyTestController controller = new ProxyTestController(); | ||
private static readonly ProxyTestController Controller = new ProxyTestController(); | ||
|
||
public static void Main(string[] args) | ||
{ | ||
//On Console exit make sure we also exit the proxy | ||
NativeMethods.handler = new NativeMethods.ConsoleEventDelegate(ConsoleEventCallback); | ||
NativeMethods.SetConsoleCtrlHandler(NativeMethods.handler, true); | ||
|
||
NativeMethods.Handler = ConsoleEventCallback; | ||
NativeMethods.SetConsoleCtrlHandler(NativeMethods.Handler, true); | ||
|
||
|
||
Console.Write("Do you want to monitor HTTPS? (Y/N):"); | ||
|
||
if (Console.ReadLine().Trim().ToLower() == "y") | ||
var readLine = Console.ReadLine(); | ||
if (readLine != null && readLine.Trim().ToLower() == "y") | ||
{ | ||
controller.EnableSSL = true; | ||
|
||
Controller.EnableSsl = true; | ||
} | ||
|
||
Console.Write("Do you want to set this as a System Proxy? (Y/N):"); | ||
|
||
if (Console.ReadLine().Trim().ToLower() == "y") | ||
var line = Console.ReadLine(); | ||
if (line != null && line.Trim().ToLower() == "y") | ||
{ | ||
controller.SetAsSystemProxy = true; | ||
|
||
Controller.SetAsSystemProxy = true; | ||
} | ||
|
||
//Start proxy controller | ||
controller.StartProxy(); | ||
Controller.StartProxy(); | ||
|
||
Console.WriteLine("Hit any key to exit.."); | ||
Console.WriteLine(); | ||
Console.Read(); | ||
|
||
controller.Stop(); | ||
Controller.Stop(); | ||
} | ||
|
||
|
||
static bool ConsoleEventCallback(int eventType) | ||
private static bool ConsoleEventCallback(int eventType) | ||
{ | ||
if (eventType == 2) | ||
{ | ||
try | ||
{ | ||
controller.Stop(); | ||
|
||
Controller.Stop(); | ||
} | ||
catch | ||
{ | ||
// ignored | ||
} | ||
catch { } | ||
} | ||
return false; | ||
} | ||
|
||
} | ||
|
||
internal static class NativeMethods | ||
{ | ||
// Keeps it from getting garbage collected | ||
internal static ConsoleEventDelegate Handler; | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
internal static extern bool SetConsoleCtrlHandler(ConsoleEventDelegate callback, bool add); | ||
|
||
// Pinvoke | ||
internal delegate bool ConsoleEventDelegate(int eventType); | ||
|
||
|
||
// Keeps it from getting garbage collected | ||
internal static ConsoleEventDelegate handler; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.