Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
39d351dc
Commit
39d351dc
authored
Sep 04, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix operating system checks
parent
c7a1ff75
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
14 deletions
+40
-14
Program.cs
examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
+4
-3
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+4
-6
RunTime.cs
src/Titanium.Web.Proxy/Helpers/RunTime.cs
+32
-5
No files found.
examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
View file @
39d351dc
using
System
;
using
System
;
using
System.Runtime.InteropServices
;
using
Titanium.Web.Proxy.Examples.Basic.Helpers
;
using
Titanium.Web.Proxy.Examples.Basic.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
namespace
Titanium.Web.Proxy.Examples.Basic
namespace
Titanium.Web.Proxy.Examples.Basic
{
{
...
@@ -10,7 +10,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -10,7 +10,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
public
static
void
Main
(
string
[]
args
)
public
static
void
Main
(
string
[]
args
)
{
{
if
(
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
))
if
(
RunTime
.
IsWindows
)
{
{
// fix console hang due to QuickEdit mode
// fix console hang due to QuickEdit mode
ConsoleHelper
.
DisableQuickEditMode
();
ConsoleHelper
.
DisableQuickEditMode
();
...
...
examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
39d351dc
...
@@ -10,7 +10,6 @@ using Titanium.Web.Proxy.Exceptions;
...
@@ -10,7 +10,6 @@ using Titanium.Web.Proxy.Exceptions;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Helpers
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Http
;
using
Titanium.Web.Proxy.Models
;
using
Titanium.Web.Proxy.Models
;
using
System.Runtime.InteropServices
;
namespace
Titanium.Web.Proxy.Examples.Basic
namespace
Titanium.Web.Proxy.Examples.Basic
{
{
...
@@ -109,12 +108,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -109,12 +108,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
endPoint
.
IpAddress
,
endPoint
.
Port
);
endPoint
.
IpAddress
,
endPoint
.
Port
);
}
}
if
(
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
))
{
// Only explicit proxies can be set as system proxy!
// Only explicit proxies can be set as system proxy!
//proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
//proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
//proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
//proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
if
(
RunTime
.
IsWindows
)
{
proxyServer
.
SetAsSystemProxy
(
explicitEndPoint
,
ProxyProtocolType
.
AllHttp
);
proxyServer
.
SetAsSystemProxy
(
explicitEndPoint
,
ProxyProtocolType
.
AllHttp
);
}
}
}
}
...
...
src/Titanium.Web.Proxy/Helpers/RunTime.cs
View file @
39d351dc
using
System
;
using
System
;
#if NETSTANDARD2_0
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
#endif
namespace
Titanium.Web.Proxy.Helpers
namespace
Titanium.Web.Proxy.Helpers
{
{
/// <summary>
/// <summary>
/// Run time helpers
/// Run time helpers
/// </summary>
/// </summary>
internal
class
RunTime
public
static
class
RunTime
{
{
/// <summary>
/// <summary>
/// cache for mono runtime check
/// cache for mono runtime check
...
@@ -14,6 +16,19 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -14,6 +16,19 @@ namespace Titanium.Web.Proxy.Helpers
/// <returns></returns>
/// <returns></returns>
private
static
readonly
Lazy
<
bool
>
isRunningOnMono
=
new
Lazy
<
bool
>(()
=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
private
static
readonly
Lazy
<
bool
>
isRunningOnMono
=
new
Lazy
<
bool
>(()
=>
Type
.
GetType
(
"Mono.Runtime"
)
!=
null
);
/// <summary>
/// cache for mono runtime check
/// </summary>
/// <returns></returns>
private
static
readonly
Lazy
<
bool
>
isRunningOnMonoLinux
=
new
Lazy
<
bool
>(()
=>
IsRunningOnMono
&&
(
int
)
Environment
.
OSVersion
.
Platform
==
4
);
/// <summary>
/// cache for mono runtime check
/// </summary>
/// <returns></returns>
private
static
readonly
Lazy
<
bool
>
isRunningOnMonoMac
=
new
Lazy
<
bool
>(()
=>
IsRunningOnMono
&&
(
int
)
Environment
.
OSVersion
.
Platform
==
6
);
#if NETSTANDARD2_0
/// <summary>
/// <summary>
/// cache for Windows platform check
/// cache for Windows platform check
/// </summary>
/// </summary>
...
@@ -21,17 +36,29 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -21,17 +36,29 @@ namespace Titanium.Web.Proxy.Helpers
private
static
bool
isRunningOnWindows
=>
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
);
private
static
bool
isRunningOnWindows
=>
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Windows
);
private
static
bool
isRunningOnLinux
=>
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Linux
);
private
static
bool
isRunningOnLinux
=>
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
Linux
);
private
static
bool
isRunningOnMac
=>
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
OSX
);
private
static
bool
isRunningOnMac
=>
RuntimeInformation
.
IsOSPlatform
(
OSPlatform
.
OSX
);
#endif
/// <summary>
/// <summary>
/// Is running on Mono?
/// Is running on Mono?
/// </summary>
/// </summary>
internal
static
bool
IsRunningOnMono
=>
isRunningOnMono
.
Value
;
internal
static
bool
IsRunningOnMono
=>
isRunningOnMono
.
Value
;
internal
static
bool
IsLinux
=>
isRunningOnLinux
;
#if NETSTANDARD2_0
public
static
bool
IsLinux
=>
isRunningOnLinux
;
#else
public
static
bool
IsLinux
=>
isRunningOnMonoLinux
.
Value
;
#endif
internal
static
bool
IsWindows
=>
isRunningOnWindows
;
#if NETSTANDARD2_0
public
static
bool
IsWindows
=>
isRunningOnWindows
;
#else
public
static
bool
IsWindows
=>
!
IsLinux
&&
!
IsMac
;
#endif
internal
static
bool
IsMac
=>
isRunningOnMac
;
#if NETSTANDARD2_0
public
static
bool
IsMac
=>
isRunningOnMac
;
#else
public
static
bool
IsMac
=>
isRunningOnMonoMac
.
Value
;
#endif
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment