Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 4aef8e7

Browse files
authored
Merge pull request #853 from justcoding121/develop
beta
2 parents cb59b48 + 77662e8 commit 4aef8e7

File tree

3 files changed

+40
-31
lines changed

3 files changed

+40
-31
lines changed

README.md

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ A lightweight HTTP(S) proxy server written in C#.
66

77
Report bugs or raise issues here. For programming help use [StackOverflow](http://stackoverflow.com/questions/tagged/titanium-web-proxy) with the tag Titanium-Web-Proxy.
88

9-
* [API Documentation](https://justcoding121.github.io/Titanium-Web-Proxy/docs/api/Titanium.Web.Proxy.ProxyServer.html)
9+
* [API Documentation](https://justcoding121.github.io/titanium-web-proxy/docs/api/Titanium.Web.Proxy.ProxyServer.html)
1010
* [Wiki & Contribution guidelines](https://github.com/justcoding121/Titanium-Web-Proxy/wiki)
1111

1212
### Features
1313

14-
* Multi-threaded fully asynchronous proxy employing server connection pooling, certificate cache, and buffer pooling
15-
* View/modify/redirect/block requests and responses
14+
* Multithreaded and asynchronous proxy employing server connection pooling, certificate cache, and buffer pooling
15+
* View, modify, redirect and block requests or responses
1616
* Supports mutual SSL authentication, proxy authentication & automatic upstream proxy detection
17-
* Kerberos/NTLM authentication over HTTP protocols for windows domain
17+
* Supports kerberos, NTLM authentication over HTTP protocols on windows domain controlled networks
1818
* SOCKS4/5 Proxy support
1919

2020
### Installation
@@ -32,6 +32,22 @@ Supports
3232

3333
* .NET Standard 2.0 or above
3434
* .NET Framework 4.5 or above
35+
36+
### Note to contributors
37+
38+
#### Road map
39+
40+
* Fix [outstanding bugs](https://github.com/justcoding121/Titanium-Web-Proxy/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
41+
* Support reading request and response body as stream [#823](https://github.com/justcoding121/Titanium-Web-Proxy/issues/823)
42+
* Use Dispose(false) pattern to reduce possibility of memory leaks [#740](https://github.com/justcoding121/Titanium-Web-Proxy/issues/740)
43+
* Stop throwing new exceptions [#634](https://github.com/justcoding121/Titanium-Web-Proxy/issues/634)
44+
* Support HTTP 2.0
45+
46+
#### Collaborators
47+
48+
The owner of this project, [justcoding121](https://github.com/justcoding121), is considered to be inactive from this project due to his busy work schedule. However, we have a collaborator listed below who time and again shows up to maintain this project. Please create pull requests prioritizing bug fixes for the attention of collaborators.
49+
50+
* [honfika](https://github.com/honfika)
3551

3652
### Development environment
3753

@@ -150,11 +166,11 @@ public async Task OnRequest(object sender, SessionEventArgs e)
150166
{
151167
// Get/Set request body bytes
152168
byte[] bodyBytes = await e.GetRequestBody();
153-
await e.SetRequestBody(bodyBytes);
169+
e.SetRequestBody(bodyBytes);
154170

155171
// Get/Set request body as string
156172
string bodyString = await e.GetRequestBodyAsString();
157-
await e.SetRequestBodyString(bodyString);
173+
e.SetRequestBodyString(bodyString);
158174

159175
// store request
160176
// so that you can find it from response handler
@@ -195,10 +211,10 @@ public async Task OnResponse(object sender, SessionEventArgs e)
195211
if (e.HttpClient.Response.ContentType != null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
196212
{
197213
byte[] bodyBytes = await e.GetResponseBody();
198-
await e.SetResponseBody(bodyBytes);
214+
e.SetResponseBody(bodyBytes);
199215

200216
string body = await e.GetResponseBodyAsString();
201-
await e.SetResponseBodyString(body);
217+
e.SetResponseBodyString(body);
202218
}
203219
}
204220
}
@@ -227,16 +243,6 @@ public Task OnCertificateSelection(object sender, CertificateSelectionEventArgs
227243
return Task.CompletedTask;
228244
}
229245
```
230-
### Note to contributors
231-
232-
#### Road map
233-
234-
* Support HTTP 2.0
235-
236-
#### Collaborators
237-
238-
* [honfika](https://github.com/honfika)
239-
240246

241247
**Console example application screenshot**
242248

src/Titanium.Web.Proxy/Helpers/Network.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal static bool IsLocalIpAddress(IPAddress address)
2727
return localhostEntry.AddressList.Contains(address);
2828
}
2929

30-
internal static bool IsLocalIpAddress(string hostName)
30+
internal static bool IsLocalIpAddress(string hostName, bool proxyDnsRequests = false)
3131
{
3232
if (IPAddress.TryParse(hostName, out var ipAddress)
3333
&& IsLocalIpAddress(ipAddress))
@@ -52,20 +52,23 @@ internal static bool IsLocalIpAddress(string hostName)
5252
return true;
5353
}
5454

55-
try
55+
if (!proxyDnsRequests)
5656
{
57-
// do reverse DNS lookup even if hostName is an IP address
58-
var hostEntry = Dns.GetHostEntry(hostName);
59-
// if DNS resolved hostname matches local DNS name,
60-
// or if host IP address list contains any local IP address
61-
if (hostEntry.HostName.Equals(localhostEntry.HostName, StringComparison.OrdinalIgnoreCase)
62-
|| hostEntry.AddressList.Any(hostIP => localhostEntry.AddressList.Contains(hostIP)))
57+
try
58+
{
59+
// do reverse DNS lookup even if hostName is an IP address
60+
var hostEntry = Dns.GetHostEntry(hostName);
61+
// if DNS resolved hostname matches local DNS name,
62+
// or if host IP address list contains any local IP address
63+
if (hostEntry.HostName.Equals(localhostEntry.HostName, StringComparison.OrdinalIgnoreCase)
64+
|| hostEntry.AddressList.Any(hostIP => localhostEntry.AddressList.Contains(hostIP)))
65+
{
66+
return true;
67+
}
68+
}
69+
catch (SocketException)
6370
{
64-
return true;
6571
}
66-
}
67-
catch (SocketException)
68-
{
6972
}
7073

7174
return false;

src/Titanium.Web.Proxy/Network/Tcp/TcpConnectionFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ internal Task<TcpServerConnection> GetServerConnection(ProxyServer proxyServer,
318318
useUpstreamProxy1 = true;
319319

320320
// check if we need to ByPass
321-
if (externalProxy.BypassLocalhost && NetworkHelper.IsLocalIpAddress(remoteHostName))
321+
if (externalProxy.BypassLocalhost && NetworkHelper.IsLocalIpAddress(remoteHostName, externalProxy.ProxyDnsRequests))
322322
{
323323
useUpstreamProxy1 = false;
324324
}

0 commit comments

Comments
 (0)