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
f6d45821
There was an error fetching the commit references. Please try again later.
Unverified
Commit
f6d45821
authored
4 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
add some debug logic in main
parent
796fe95b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.cc
+29
-6
29 additions, 6 deletions
src/main.cc
with
29 additions
and
6 deletions
src/main.cc
+
29
−
6
View file @
f6d45821
#include
<rlib/stdio.hpp>
#include
<rlib/opt.hpp>
#include
<rlib/sys/os.hpp>
#include
"common.hpp"
rlib
::
logger
rlog
(
std
::
cerr
);
using
namespace
rlib
::
literals
;
int
main
(
int
argc
,
char
**
argv
)
{
#if RLIB_OS_ID == OS_WINDOWS
#include
<thread>
using
namespace
std
::
chrono_literals
;
#define windows_main main
#else
#define real_main main
#endif
int
real_main
(
int
argc
,
char
**
argv
)
{
rlib
::
opt_parser
args
(
argc
,
argv
);
if
(
args
.
getBoolArg
(
"--help"
,
"-h"
))
{
rl
ib
::
println
(
"Usage: {} -i $InboundConfig -o $OutboundConfig [--log=error/info/verbose/debug]"
_rs
.
format
(
args
.
getSelf
()));
rl
ib
::
println
(
" InboundConfig and OutboundConfig are in this format: "
);
rl
ib
::
println
(
" '$method:$params', available methods: "
);
rl
ib
::
println
(
" 'plain:$addr:$port', 'misc:$addr:$portRange:$psk'"
);
rl
og
.
info
(
"Usage: {} -i $InboundConfig -o $OutboundConfig [--log=error/info/verbose/debug]"
_rs
.
format
(
args
.
getSelf
()));
rl
og
.
info
(
" InboundConfig and OutboundConfig are in this format: "
);
rl
og
.
info
(
" '$method:$params', available methods: "
);
rl
og
.
info
(
" 'plain:$addr:$port', 'misc:$addr:$portRange:$psk'"
);
return
0
;
}
auto
inboundConfig
=
args
.
getValueArg
(
"-i"
);
...
...
@@ -34,3 +42,18 @@ int main(int argc, char **argv) {
return
0
;
}
// This wrapper (maybe) makes debug easier.
int
windows_main
(
int
argc
,
char
**
argv
)
{
// fucking windows behaves strangely on exception.
// Let's catch all exceptions and print.
try
{
return
real_main
(
argc
,
argv
);
}
catch
(
std
::
exception
&
e
)
{
rlog
.
fatal
(
e
.
what
());
rlog
.
warning
(
"Sleep 5s before exit..."
);
std
::
this_thread
::
sleep_for
(
5s
);
return
2
;
}
}
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