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
e46e4061
Unverified
Commit
e46e4061
authored
Oct 10, 2018
by
Jehonathan Thomas
Committed by
GitHub
Oct 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #504 from justcoding121/master
3.0.708-beta+
parents
0e78fdc8
f9ef7c61
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
111 deletions
+5
-111
Titanium.Web.Proxy.Examples.Wpf.csproj
...Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
+2
-2
packages.config
examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
+1
-1
TcpHelper.cs
src/Titanium.Web.Proxy/Helpers/TcpHelper.cs
+0
-106
Titanium.Web.Proxy.csproj
src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+2
-2
No files found.
examples/Titanium.Web.Proxy.Examples.Wpf/Titanium.Web.Proxy.Examples.Wpf.csproj
View file @
e46e4061
...
...
@@ -72,8 +72,8 @@
<Prefer32Bit>
true
</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"StreamExtended, Version=1.0.1
79
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<HintPath>
..\..\
packages\StreamExtended.1.0.179
\lib\net45\StreamExtended.dll
</HintPath>
<Reference
Include=
"StreamExtended, Version=1.0.1
83
.0, Culture=neutral, PublicKeyToken=bbfa0f1d54f50043, processorArchitecture=MSIL"
>
<HintPath>
..\..\
src\packages\StreamExtended.1.0.183-beta
\lib\net45\StreamExtended.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Data"
/>
...
...
examples/Titanium.Web.Proxy.Examples.Wpf/packages.config
View file @
e46e4061
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
79
"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.1
83-beta
"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
src/Titanium.Web.Proxy/Helpers/TcpHelper.cs
View file @
e46e4061
...
...
@@ -93,112 +93,6 @@ namespace Titanium.Web.Proxy.Helpers
return
((
port
>>
8
)
&
0x00FF00FFu
)
|
((
port
<<
8
)
&
0xFF00FF00u
);
}
/// <summary>
/// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers
/// as prefix
/// Usefull for websocket requests
/// Asynchronous Programming Model, which does not throw exceptions when the socket is closed
/// </summary>
/// <param name="clientStream"></param>
/// <param name="serverStream"></param>
/// <param name="bufferSize"></param>
/// <param name="onDataSend"></param>
/// <param name="onDataReceive"></param>
/// <param name="cancellationTokenSource"></param>
/// <param name="exceptionFunc"></param>
/// <returns></returns>
internal
static
async
Task
SendRawApm
(
Stream
clientStream
,
Stream
serverStream
,
IBufferPool
bufferPool
,
int
bufferSize
,
Action
<
byte
[],
int
,
int
>
onDataSend
,
Action
<
byte
[],
int
,
int
>
onDataReceive
,
CancellationTokenSource
cancellationTokenSource
,
ExceptionHandler
exceptionFunc
)
{
var
taskCompletionSource
=
new
TaskCompletionSource
<
bool
>();
cancellationTokenSource
.
Token
.
Register
(()
=>
taskCompletionSource
.
TrySetResult
(
true
));
// Now async relay all server=>client & client=>server data
var
clientBuffer
=
bufferPool
.
GetBuffer
(
bufferSize
);
var
serverBuffer
=
bufferPool
.
GetBuffer
(
bufferSize
);
try
{
beginRead
(
clientStream
,
serverStream
,
clientBuffer
,
onDataSend
,
cancellationTokenSource
,
exceptionFunc
);
beginRead
(
serverStream
,
clientStream
,
serverBuffer
,
onDataReceive
,
cancellationTokenSource
,
exceptionFunc
);
await
taskCompletionSource
.
Task
;
}
finally
{
bufferPool
.
ReturnBuffer
(
clientBuffer
);
bufferPool
.
ReturnBuffer
(
serverBuffer
);
}
}
private
static
void
beginRead
(
Stream
inputStream
,
Stream
outputStream
,
byte
[]
buffer
,
Action
<
byte
[],
int
,
int
>
onCopy
,
CancellationTokenSource
cancellationTokenSource
,
ExceptionHandler
exceptionFunc
)
{
if
(
cancellationTokenSource
.
IsCancellationRequested
)
{
return
;
}
bool
readFlag
=
false
;
var
readCallback
=
(
AsyncCallback
)(
ar
=>
{
if
(
cancellationTokenSource
.
IsCancellationRequested
||
readFlag
)
{
return
;
}
readFlag
=
true
;
try
{
int
read
=
inputStream
.
EndRead
(
ar
);
if
(
read
<=
0
)
{
cancellationTokenSource
.
Cancel
();
return
;
}
onCopy
?.
Invoke
(
buffer
,
0
,
read
);
var
writeCallback
=
(
AsyncCallback
)(
ar2
=>
{
if
(
cancellationTokenSource
.
IsCancellationRequested
)
{
return
;
}
try
{
outputStream
.
EndWrite
(
ar2
);
beginRead
(
inputStream
,
outputStream
,
buffer
,
onCopy
,
cancellationTokenSource
,
exceptionFunc
);
}
catch
(
IOException
ex
)
{
cancellationTokenSource
.
Cancel
();
exceptionFunc
(
ex
);
}
});
outputStream
.
BeginWrite
(
buffer
,
0
,
read
,
writeCallback
,
null
);
}
catch
(
IOException
ex
)
{
cancellationTokenSource
.
Cancel
();
exceptionFunc
(
ex
);
}
});
var
readResult
=
inputStream
.
BeginRead
(
buffer
,
0
,
buffer
.
Length
,
readCallback
,
null
);
if
(
readResult
.
CompletedSynchronously
)
{
readCallback
(
readResult
);
}
}
/// <summary>
/// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers
/// as prefix
...
...
src/Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
e46e4061
...
...
@@ -14,8 +14,8 @@
<ItemGroup>
<PackageReference Include="BrotliSharpLib" Version="0.3.1" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.
2
" />
<PackageReference Include="StreamExtended" Version="1.0.1
79
" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.
3
" />
<PackageReference Include="StreamExtended" Version="1.0.1
83-beta
" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
...
...
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