Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
c7d633e6
Commit
c7d633e6
authored
5 years ago
by
Seva
Committed by
Adrien Béraud
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dhtnode: separate proxy privkey, cert & pwd arguments
parent
2576d95a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/dhtnode.cpp
+4
-4
4 additions, 4 deletions
tools/dhtnode.cpp
tools/tools_common.h
+53
-24
53 additions, 24 deletions
tools/tools_common.h
with
57 additions
and
28 deletions
tools/dhtnode.cpp
+
4
−
4
View file @
c7d633e6
...
@@ -242,10 +242,10 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params
...
@@ -242,10 +242,10 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params
iss
>>
idstr
;
iss
>>
idstr
;
#endif // OPENDHT_PUSH_NOTIFICATIONS
#endif // OPENDHT_PUSH_NOTIFICATIONS
try
{
try
{
if
(
params
.
id
.
first
and
params
.
id
.
second
){
if
(
params
.
proxy_
id
.
first
and
params
.
proxy_
id
.
second
){
unsigned
int
port
=
std
::
stoi
(
idstr
);
unsigned
int
port
=
std
::
stoi
(
idstr
);
proxies
.
emplace
(
port
,
std
::
unique_ptr
<
DhtProxyServer
>
(
proxies
.
emplace
(
port
,
std
::
unique_ptr
<
DhtProxyServer
>
(
new
DhtProxyServer
(
params
.
id
,
node
,
port
new
DhtProxyServer
(
params
.
proxy_
id
,
node
,
port
#ifdef OPENDHT_PUSH_NOTIFICATIONS
#ifdef OPENDHT_PUSH_NOTIFICATIONS
,
pushServer
,
pushServer
#endif
#endif
...
@@ -575,10 +575,10 @@ main(int argc, char **argv)
...
@@ -575,10 +575,10 @@ main(int argc, char **argv)
#ifdef OPENDHT_PROXY_SERVER
#ifdef OPENDHT_PROXY_SERVER
std
::
map
<
in_port_t
,
std
::
unique_ptr
<
DhtProxyServer
>>
proxies
;
std
::
map
<
in_port_t
,
std
::
unique_ptr
<
DhtProxyServer
>>
proxies
;
#endif
#endif
if
(
params
.
proxyserverssl
and
params
.
id
.
first
and
params
.
id
.
second
){
if
(
params
.
proxyserverssl
and
params
.
proxy_
id
.
first
and
params
.
proxy_
id
.
second
){
#ifdef OPENDHT_PROXY_SERVER
#ifdef OPENDHT_PROXY_SERVER
proxies
.
emplace
(
params
.
proxyserverssl
,
std
::
unique_ptr
<
DhtProxyServer
>
(
proxies
.
emplace
(
params
.
proxyserverssl
,
std
::
unique_ptr
<
DhtProxyServer
>
(
new
DhtProxyServer
(
params
.
id
,
new
DhtProxyServer
(
params
.
proxy_
id
,
node
,
params
.
proxyserverssl
,
params
.
pushserver
,
context
.
logger
)));
node
,
params
.
proxyserverssl
,
params
.
pushserver
,
context
.
logger
)));
}
}
if
(
params
.
proxyserver
)
{
if
(
params
.
proxyserver
)
{
...
...
This diff is collapsed.
Click to expand it.
tools/tools_common.h
+
53
−
24
View file @
c7d633e6
...
@@ -127,7 +127,9 @@ struct dht_params {
...
@@ -127,7 +127,9 @@ struct dht_params {
std
::
string
devicekey
{};
std
::
string
devicekey
{};
std
::
string
persist_path
{};
std
::
string
persist_path
{};
dht
::
crypto
::
Identity
id
{};
dht
::
crypto
::
Identity
id
{};
dht
::
crypto
::
Identity
proxy_id
{};
std
::
string
privkey_pwd
{};
std
::
string
privkey_pwd
{};
std
::
string
proxy_privkey_pwd
{};
std
::
string
save_identity
{};
std
::
string
save_identity
{};
};
};
...
@@ -150,6 +152,9 @@ static const constexpr struct option long_options[] = {
...
@@ -150,6 +152,9 @@ static const constexpr struct option long_options[] = {
{
"syslog"
,
no_argument
,
nullptr
,
'L'
},
{
"syslog"
,
no_argument
,
nullptr
,
'L'
},
{
"proxyserver"
,
required_argument
,
nullptr
,
'S'
},
{
"proxyserver"
,
required_argument
,
nullptr
,
'S'
},
{
"proxyserverssl"
,
required_argument
,
nullptr
,
'e'
},
{
"proxyserverssl"
,
required_argument
,
nullptr
,
'e'
},
{
"proxy-certificate"
,
required_argument
,
nullptr
,
'w'
},
{
"proxy-privkey"
,
required_argument
,
nullptr
,
'K'
},
{
"proxy-privkey-password"
,
required_argument
,
nullptr
,
'M'
},
{
"proxyclient"
,
required_argument
,
nullptr
,
'C'
},
{
"proxyclient"
,
required_argument
,
nullptr
,
'C'
},
{
"pushserver"
,
required_argument
,
nullptr
,
'y'
},
{
"pushserver"
,
required_argument
,
nullptr
,
'y'
},
{
"devicekey"
,
required_argument
,
nullptr
,
'z'
},
{
"devicekey"
,
required_argument
,
nullptr
,
'z'
},
...
@@ -162,6 +167,7 @@ parseArgs(int argc, char **argv) {
...
@@ -162,6 +167,7 @@ parseArgs(int argc, char **argv) {
dht_params
params
;
dht_params
params
;
int
opt
;
int
opt
;
std
::
string
privkey
;
std
::
string
privkey
;
std
::
string
proxy_privkey
;
while
((
opt
=
getopt_long
(
argc
,
argv
,
"hidsvDp:n:b:f:l:"
,
long_options
,
nullptr
))
!=
-
1
)
{
while
((
opt
=
getopt_long
(
argc
,
argv
,
"hidsvDp:n:b:f:l:"
,
long_options
,
nullptr
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'p'
:
{
case
'p'
:
{
...
@@ -245,12 +251,26 @@ parseArgs(int argc, char **argv) {
...
@@ -245,12 +251,26 @@ parseArgs(int argc, char **argv) {
}
}
break
;
break
;
}
}
case
'w'
:
{
try
{
params
.
proxy_id
.
second
=
std
::
make_shared
<
dht
::
crypto
::
Certificate
>
(
loadFile
(
optarg
));
}
catch
(
const
std
::
exception
&
e
)
{
throw
std
::
runtime_error
(
std
::
string
(
"Error loading proxy certificate: "
)
+
e
.
what
());
}
break
;
}
case
'k'
:
case
'k'
:
privkey
=
optarg
;
privkey
=
optarg
;
break
;
break
;
case
'K'
:
proxy_privkey
=
optarg
;
break
;
case
'm'
:
case
'm'
:
params
.
privkey_pwd
=
optarg
;
params
.
privkey_pwd
=
optarg
;
break
;
break
;
case
'M'
:
params
.
proxy_privkey_pwd
=
optarg
;
break
;
case
'I'
:
case
'I'
:
params
.
save_identity
=
optarg
;
params
.
save_identity
=
optarg
;
break
;
break
;
...
@@ -260,11 +280,20 @@ parseArgs(int argc, char **argv) {
...
@@ -260,11 +280,20 @@ parseArgs(int argc, char **argv) {
}
}
if
(
not
privkey
.
empty
())
{
if
(
not
privkey
.
empty
())
{
try
{
try
{
params
.
id
.
first
=
std
::
make_shared
<
dht
::
crypto
::
PrivateKey
>
(
loadFile
(
privkey
),
params
.
privkey_pwd
);
params
.
id
.
first
=
std
::
make_shared
<
dht
::
crypto
::
PrivateKey
>
(
loadFile
(
privkey
),
params
.
privkey_pwd
);
}
catch
(
const
std
::
exception
&
e
)
{
}
catch
(
const
std
::
exception
&
e
)
{
throw
std
::
runtime_error
(
std
::
string
(
"Error loading private key: "
)
+
e
.
what
());
throw
std
::
runtime_error
(
std
::
string
(
"Error loading private key: "
)
+
e
.
what
());
}
}
}
}
if
(
not
proxy_privkey
.
empty
())
{
try
{
params
.
proxy_id
.
first
=
std
::
make_shared
<
dht
::
crypto
::
PrivateKey
>
(
loadFile
(
proxy_privkey
),
params
.
proxy_privkey_pwd
);
}
catch
(
const
std
::
exception
&
e
)
{
throw
std
::
runtime_error
(
std
::
string
(
"Error loading proxy private key: "
)
+
e
.
what
());
}
}
if
(
params
.
save_identity
.
empty
())
if
(
params
.
save_identity
.
empty
())
params
.
privkey_pwd
.
clear
();
params
.
privkey_pwd
.
clear
();
return
params
;
return
params
;
...
...
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