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
25948585
Commit
25948585
authored
May 23, 2017
by
justcoding121
Committed by
justcoding121
May 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup firefox
parent
51ffc799
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
50 deletions
+27
-50
Firefox.cs
Titanium.Web.Proxy/Helpers/Firefox.cs
+17
-35
ProxyServer.cs
Titanium.Web.Proxy/ProxyServer.cs
+10
-15
No files found.
Titanium.Web.Proxy/Helpers/Firefox.cs
View file @
25948585
...
...
@@ -11,7 +11,7 @@ namespace Titanium.Web.Proxy.Helpers
/// <summary>
/// Add Firefox settings.
/// </summary>
internal
void
AddFirefox
()
internal
void
UseSystemProxy
()
{
try
{
...
...
@@ -19,49 +19,31 @@ namespace Titanium.Web.Proxy.Helpers
new
DirectoryInfo
(
Environment
.
GetFolderPath
(
Environment
.
SpecialFolder
.
ApplicationData
)
+
"\\Mozilla\\Firefox\\Profiles\\"
).
GetDirectories
(
"*.default"
);
var
myFfPrefFile
=
myProfileDirectory
[
0
].
FullName
+
"\\prefs.js"
;
if
(!
File
.
Exists
(
myFfPrefFile
))
return
;
// We have a pref file so let''s make sure it has the proxy setting
var
myReader
=
new
StreamReader
(
myFfPrefFile
);
var
myPrefContents
=
myReader
.
ReadToEnd
();
myReader
.
Close
();
if
(!
myPrefContents
.
Contains
(
"user_pref(\"network.proxy.type\", 0);"
))
return
;
// Add the proxy enable line and write it back to the file
myPrefContents
=
myPrefContents
.
Replace
(
"user_pref(\"network.proxy.type\", 0);"
,
""
);
File
.
Delete
(
myFfPrefFile
);
File
.
WriteAllText
(
myFfPrefFile
,
myPrefContents
);
}
catch
(
Exception
)
if
(!
File
.
Exists
(
myFfPrefFile
))
{
// Only exception should be a read/write error because the user opened up FireFox so they can be ignored.
}
return
;
}
/// <summary>
/// Remove firefox settings.
/// </summary>
internal
void
RemoveFirefox
()
{
try
{
var
myProfileDirectory
=
new
DirectoryInfo
(
Environment
.
GetFolderPath
(
Environment
.
SpecialFolder
.
ApplicationData
)
+
"\\Mozilla\\Firefox\\Profiles\\"
).
GetDirectories
(
"*.default"
);
var
myFfPrefFile
=
myProfileDirectory
[
0
].
FullName
+
"\\prefs.js"
;
if
(!
File
.
Exists
(
myFfPrefFile
))
return
;
// We have a pref file so let''s make sure it has the proxy setting
var
myReader
=
new
StreamReader
(
myFfPrefFile
);
var
myPrefContents
=
myReader
.
ReadToEnd
();
myReader
.
Close
();
if
(!
myPrefContents
.
Contains
(
"user_pref(\"network.proxy.type\", 0);"
))
for
(
int
i
=
0
;
i
<=
4
;
i
++)
{
var
searchStr
=
$"user_pref(\"network.proxy.type\",
{
i
}
);"
;
if
(
myPrefContents
.
Contains
(
searchStr
))
{
// Add the proxy enable line and write it back to the file
myPrefContents
=
myPrefContents
+
"\n\r"
+
"user_pref(\"network.proxy.type\", 0);"
;
myPrefContents
=
myPrefContents
.
Replace
(
searchStr
,
"user_pref(\"network.proxy.type\", 5);"
);
}
}
File
.
Delete
(
myFfPrefFile
);
File
.
WriteAllText
(
myFfPrefFile
,
myPrefContents
);
}
}
catch
(
Exception
)
{
// Only exception should be a read/write error because the user opened up FireFox so they can be ignored.
...
...
Titanium.Web.Proxy/ProxyServer.cs
View file @
25948585
...
...
@@ -61,12 +61,13 @@ namespace Titanium.Web.Proxy
/// </summary>
private
SystemProxyManager
systemProxySettingsManager
{
get
;
}
#if !DEBUG
/// <summary>
/// Set firefox to use default system proxy
/// </summary>
private
FireFoxProxySettingsManager
firefoxProxySettingsManager
=
new
FireFoxProxySettingsManager
();
#endif
private
FireFoxProxySettingsManager
firefoxProxySettingsManager
=
new
FireFoxProxySettingsManager
();
/// <summary>
/// Buffer size used throughout this proxy
...
...
@@ -287,9 +288,7 @@ namespace Titanium.Web.Proxy
ProxyEndPoints
=
new
List
<
ProxyEndPoint
>();
tcpConnectionFactory
=
new
TcpConnectionFactory
();
systemProxySettingsManager
=
new
SystemProxyManager
();
#if !DEBUG
new
FireFoxProxySettingsManager
();
#endif
CertificateManager
=
new
CertificateManager
(
ExceptionFunc
);
if
(
rootCertificateName
!=
null
)
...
...
@@ -363,9 +362,9 @@ namespace Titanium.Web.Proxy
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Any
)
|
Equals
(
endPoint
.
IpAddress
,
IPAddress
.
Loopback
)
?
"127.0.0.1"
:
endPoint
.
IpAddress
.
ToString
(),
endPoint
.
Port
);
endPoint
.
IsSystemHttpProxy
=
true
;
#if !DEBUG
firefoxProxySettingsManager
.
AddFirefox
();
#endif
firefoxProxySettingsManager
.
UseSystemProxy
();
Console
.
WriteLine
(
"Set endpoint at Ip {0} and port: {1} as System HTTP Proxy"
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
}
...
...
@@ -407,9 +406,8 @@ namespace Titanium.Web.Proxy
endPoint
.
IsSystemHttpsProxy
=
true
;
#if !DEBUG
firefoxProxySettingsManager
.
AddFirefox
();
#endif
firefoxProxySettingsManager
.
UseSystemProxy
();
Console
.
WriteLine
(
"Set endpoint at Ip {0} and port: {1} as System HTTPS Proxy"
,
endPoint
.
IpAddress
,
endPoint
.
Port
);
}
...
...
@@ -500,9 +498,6 @@ namespace Titanium.Web.Proxy
if
(
setAsSystemProxy
)
{
systemProxySettingsManager
.
DisableAllProxy
();
#if !DEBUG
firefoxProxySettingsManager
.
RemoveFirefox
();
#endif
}
foreach
(
var
endPoint
in
ProxyEndPoints
)
...
...
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