Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dhtnet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
dhtnet
Commits
65a6ea8c
Commit
65a6ea8c
authored
1 year ago
by
Amna Snene
Browse files
Options
Downloads
Patches
Plain Diff
tools: fix dnc argument
Change-Id: I12ac7e224bac1f8225f50d9398a9ff755e73ba29
parent
77bb5858
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/dnc/main.cpp
+27
-6
27 additions, 6 deletions
tools/dnc/main.cpp
with
27 additions
and
6 deletions
tools/dnc/main.cpp
+
27
−
6
View file @
65a6ea8c
...
@@ -46,7 +46,7 @@ struct dhtnc_params
...
@@ -46,7 +46,7 @@ struct dhtnc_params
};
};
static
const
constexpr
struct
option
long_options
[]
=
{{
"help"
,
no_argument
,
nullptr
,
'h'
},
static
const
constexpr
struct
option
long_options
[]
=
{{
"help"
,
no_argument
,
nullptr
,
'h'
},
{
"version"
,
no_argument
,
nullptr
,
'
V
'
},
{
"version"
,
no_argument
,
nullptr
,
'
v
'
},
{
"port"
,
required_argument
,
nullptr
,
'p'
},
{
"port"
,
required_argument
,
nullptr
,
'p'
},
{
"ip"
,
required_argument
,
nullptr
,
'i'
},
{
"ip"
,
required_argument
,
nullptr
,
'i'
},
{
"listen"
,
no_argument
,
nullptr
,
'l'
},
{
"listen"
,
no_argument
,
nullptr
,
'l'
},
...
@@ -63,13 +63,12 @@ parse_args(int argc, char** argv)
...
@@ -63,13 +63,12 @@ parse_args(int argc, char** argv)
{
{
dhtnc_params
params
;
dhtnc_params
params
;
int
opt
;
int
opt
;
while
((
opt
=
getopt_long
(
argc
,
argv
,
"hVlw:r:u:t:I:b:p:i:"
,
long_options
,
nullptr
))
!=
-
1
)
{
while
((
opt
=
getopt_long
(
argc
,
argv
,
"hvlw:r:u:t:I:b:p:i:"
,
long_options
,
nullptr
))
!=
-
1
)
{
// fmt::print("opt: {} {}\n", opt, optarg);
switch
(
opt
)
{
switch
(
opt
)
{
case
'h'
:
case
'h'
:
params
.
help
=
true
;
params
.
help
=
true
;
break
;
break
;
case
'
V
'
:
case
'
v
'
:
params
.
version
=
true
;
params
.
version
=
true
;
break
;
break
;
case
'p'
:
case
'p'
:
...
@@ -106,7 +105,7 @@ parse_args(int argc, char** argv)
...
@@ -106,7 +105,7 @@ parse_args(int argc, char** argv)
}
}
// If not listening, the peer_id argument is required
// If not listening, the peer_id argument is required
if
(
!
params
.
listen
)
{
if
(
!
params
.
listen
&&
!
params
.
help
&&
!
params
.
version
)
{
if
(
optind
<
argc
)
{
if
(
optind
<
argc
)
{
params
.
peer_id
=
dht
::
InfoHash
(
argv
[
optind
]);
params
.
peer_id
=
dht
::
InfoHash
(
argv
[
optind
]);
optind
++
;
// Move to the next argument
optind
++
;
// Move to the next argument
...
@@ -152,9 +151,31 @@ setSipLogLevel()
...
@@ -152,9 +151,31 @@ setSipLogLevel()
int
int
main
(
int
argc
,
char
**
argv
)
main
(
int
argc
,
char
**
argv
)
{
{
fmt
::
print
(
"dnc 1.0
\n
"
);
setSipLogLevel
();
setSipLogLevel
();
auto
params
=
parse_args
(
argc
,
argv
);
auto
params
=
parse_args
(
argc
,
argv
);
if
(
params
.
help
){
fmt
::
print
(
"Usage: dnc [options] [PEER_ID]
\n
"
"
\n
Options:
\n
"
" -h, --help Show this help message and exit.
\n
"
" -v, --version Display the program version.
\n
"
" -p, --port Specify the port option with an argument.
\n
"
" -i, --ip Specify the ip option with an argument.
\n
"
" -l, --listen Start the program in listen mode.
\n
"
" -b, --bootstrap Specify the bootstrap option with an argument.
\n
"
" -I, --id_path Specify the id_path option with an argument.
\n
"
" -t, --turn_host Specify the turn_host option with an argument.
\n
"
" -u, --turn_user Specify the turn_user option with an argument.
\n
"
" -w, --turn_pass Specify the turn_pass option with an argument.
\n
"
" -r, --turn_realm Specify the turn_realm option with an argument.
\n
"
);
return
EXIT_SUCCESS
;
}
if
(
params
.
version
)
{
fmt
::
print
(
"dnc v1.0
\n
"
);
return
EXIT_SUCCESS
;
}
fmt
::
print
(
"dnc 1.0
\n
"
);
auto
identity
=
dhtnet
::
loadIdentity
(
params
.
path
);
auto
identity
=
dhtnet
::
loadIdentity
(
params
.
path
);
fmt
::
print
(
"Loaded identity: {} from {}
\n
"
,
identity
.
second
->
getId
(),
params
.
path
);
fmt
::
print
(
"Loaded identity: {} from {}
\n
"
,
identity
.
second
->
getId
(),
params
.
path
);
...
...
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