Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
udp-forwarder-ex
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
udp-forwarder-ex
Commits
3d99eb64
There was an error fetching the commit references. Please try again later.
Unverified
Commit
3d99eb64
authored
4 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
bug fix
parent
f7009f0d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/common.hpp
+7
-1
7 additions, 1 deletion
src/common.hpp
src/filters/base.hpp
+1
-1
1 addition, 1 deletion
src/filters/base.hpp
src/filters/xor_encryption.hpp
+1
-1
1 addition, 1 deletion
src/filters/xor_encryption.hpp
src/utils.hpp
+4
-2
4 additions, 2 deletions
src/utils.hpp
with
13 additions
and
5 deletions
src/common.hpp
+
7
−
1
View file @
3d99eb64
...
...
@@ -16,8 +16,14 @@ constexpr size_t DGRAM_BUFFER_SIZE = 20480;
// to the real openvpn server.
constexpr
size_t
SERVER_ENCRYPT_CONNECTION_TIMEOUT_SECONDS
=
60
;
#include
<random>
// MAGIC PORT NUMBER! Warning! Used for Inbound - Outbound IPC talking. Windows wepoll doesn't support PIPE, so I have to use this.
constexpr
uint16_t
TCP_TMP_PORT_NUMBER
=
50999
;
uint16_t
get_tmp_tcp_port_number
()
{
std
::
random_device
rd
;
std
::
mt19937
mt
(
rd
());
std
::
uniform_int_distribution
<
int
>
dist
(
40000
,
60000
);
return
dist
(
mt
);
}
#endif
This diff is collapsed.
Click to expand it.
src/filters/base.hpp
+
1
−
1
View file @
3d99eb64
...
...
@@ -44,7 +44,7 @@ namespace Filters {
// Usually the decrypt/decode/de-obfs function.
virtual
string
convertBackward
(
string
binaryDatagram
)
override
{
for
(
auto
iter
=
chainedFilters
.
rbegin
();
iter
!=
chainedFilters
.
rend
();
++
iter
)
{
binaryDatagram
=
(
*
iter
)
->
convert
For
ward
(
binaryDatagram
);
binaryDatagram
=
(
*
iter
)
->
convert
Back
ward
(
binaryDatagram
);
}
return
binaryDatagram
;
}
...
...
This diff is collapsed.
Click to expand it.
src/filters/xor_encryption.hpp
+
1
−
1
View file @
3d99eb64
...
...
@@ -21,7 +21,7 @@ namespace Filters {
virtual
string
convertForward
(
string
datagram
)
override
{
auto
curr_key_digit
=
0
;
for
(
auto
offset
=
0
;
offset
<
datagram
.
size
();
++
offset
)
{
datagram
[
0
]
^=
key
[
curr_key_digit
++
];
datagram
[
offset
]
^=
key
[
curr_key_digit
++
];
}
return
datagram
;
}
...
...
This diff is collapsed.
Click to expand it.
src/utils.hpp
+
4
−
2
View file @
3d99eb64
...
...
@@ -79,12 +79,14 @@ inline auto mkpipe() {
inline
auto
mk_tcp_pipe
()
{
sockfd_t
connfd_cli_side
,
connfd_srv_side
;
auto
listenfd
=
rlib
::
quick_listen
(
"::1"
,
TCP_TMP_PORT_NUMBER
);
auto
tmp_port
=
get_tmp_tcp_port_number
();
auto
listenfd
=
rlib
::
quick_listen
(
"::1"
,
tmp_port
);
// We have no UnixSocket on Windows.
auto
serverThread
=
std
::
thread
([
&
]
{
connfd_srv_side
=
rlib
::
quick_accept
(
listenfd
);
});
connfd_cli_side
=
rlib
::
quick_connect
(
"::1"
,
TCP_TMP_PORT_NUMBER
);
connfd_cli_side
=
rlib
::
quick_connect
(
"::1"
,
tmp_port
);
serverThread
.
join
();
rlib
::
sockIO
::
close_ex
(
listenfd
);
return
std
::
make_pair
(
connfd_cli_side
,
connfd_srv_side
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment