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
f6eed713
Commit
f6eed713
authored
Oct 06, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused methods
parent
dd9befc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
106 deletions
+0
-106
TcpHelper.cs
src/Titanium.Web.Proxy/Helpers/TcpHelper.cs
+0
-106
No files found.
src/Titanium.Web.Proxy/Helpers/TcpHelper.cs
View file @
f6eed713
...
@@ -93,112 +93,6 @@ namespace Titanium.Web.Proxy.Helpers
...
@@ -93,112 +93,6 @@ namespace Titanium.Web.Proxy.Helpers
return
((
port
>>
8
)
&
0x00FF00FFu
)
|
((
port
<<
8
)
&
0xFF00FF00u
);
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>
/// <summary>
/// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers
/// relays the input clientStream to the server at the specified host name and port with the given httpCmd and headers
/// as prefix
/// as prefix
...
...
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