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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
ead21d24
Commit
ead21d24
authored
Jul 4, 2022
by
Kateryna Kostiuk
Committed by
Adrien Béraud
Jul 4, 2022
Browse files
Options
Downloads
Patches
Plain Diff
proxyserver: add application bundle id option
parent
53de63e8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/opendht/dht_proxy_server.h
+3
-0
3 additions, 0 deletions
include/opendht/dht_proxy_server.h
src/dht_proxy_server.cpp
+22
-1
22 additions, 1 deletion
src/dht_proxy_server.cpp
tools/dhtnode.cpp
+2
-1
2 additions, 1 deletion
tools/dhtnode.cpp
tools/tools_common.h
+5
-0
5 additions, 0 deletions
tools/tools_common.h
with
32 additions
and
2 deletions
include/opendht/dht_proxy_server.h
+
3
−
0
View file @
ead21d24
...
@@ -65,6 +65,7 @@ using RequestStatus = restinio::request_handling_status_t;
...
@@ -65,6 +65,7 @@ using RequestStatus = restinio::request_handling_status_t;
struct
ProxyServerConfig
{
struct
ProxyServerConfig
{
in_port_t
port
{
8000
};
in_port_t
port
{
8000
};
std
::
string
pushServer
{};
std
::
string
pushServer
{};
std
::
string
bundleId
{};
std
::
string
persistStatePath
{};
std
::
string
persistStatePath
{};
dht
::
crypto
::
Identity
identity
{};
dht
::
crypto
::
Identity
identity
{};
};
};
...
@@ -275,6 +276,7 @@ private:
...
@@ -275,6 +276,7 @@ private:
#ifdef OPENDHT_PUSH_NOTIFICATIONS
#ifdef OPENDHT_PUSH_NOTIFICATIONS
PushType
getTypeFromString
(
const
std
::
string
&
type
);
PushType
getTypeFromString
(
const
std
::
string
&
type
);
const
std
::
string
&
getDefaultTopic
(
PushType
type
);
/**
/**
* Subscribe to push notifications for an iOS or Android device.
* Subscribe to push notifications for an iOS or Android device.
* Method: SUBSCRIBE "/{InfoHash: .*}"
* Method: SUBSCRIBE "/{InfoHash: .*}"
...
@@ -419,6 +421,7 @@ private:
...
@@ -419,6 +421,7 @@ private:
mutable
std
::
atomic
<
time_point
>
lastStatsReset_
{
time_point
::
min
()};
mutable
std
::
atomic
<
time_point
>
lastStatsReset_
{
time_point
::
min
()};
std
::
string
pushServer_
;
std
::
string
pushServer_
;
std
::
string
bundleId_
;
#ifdef OPENDHT_PUSH_NOTIFICATIONS
#ifdef OPENDHT_PUSH_NOTIFICATIONS
struct
Listener
{
struct
Listener
{
...
...
This diff is collapsed.
Click to expand it.
src/dht_proxy_server.cpp
+
22
−
1
View file @
ead21d24
...
@@ -205,7 +205,8 @@ DhtProxyServer::DhtProxyServer(const std::shared_ptr<DhtRunner>& dht,
...
@@ -205,7 +205,8 @@ DhtProxyServer::DhtProxyServer(const std::shared_ptr<DhtRunner>& dht,
dht_
(
dht
),
persistPath_
(
config
.
persistStatePath
),
logger_
(
logger
),
dht_
(
dht
),
persistPath_
(
config
.
persistStatePath
),
logger_
(
logger
),
printStatsTimer_
(
std
::
make_unique
<
asio
::
steady_timer
>
(
*
ioContext_
,
3s
)),
printStatsTimer_
(
std
::
make_unique
<
asio
::
steady_timer
>
(
*
ioContext_
,
3s
)),
connListener_
(
std
::
make_shared
<
ConnectionListener
>
(
std
::
bind
(
&
DhtProxyServer
::
onConnectionClosed
,
this
,
std
::
placeholders
::
_1
))),
connListener_
(
std
::
make_shared
<
ConnectionListener
>
(
std
::
bind
(
&
DhtProxyServer
::
onConnectionClosed
,
this
,
std
::
placeholders
::
_1
))),
pushServer_
(
config
.
pushServer
)
pushServer_
(
config
.
pushServer
),
bundleId_
(
config
.
bundleId
)
{
{
if
(
not
dht_
)
if
(
not
dht_
)
throw
std
::
invalid_argument
(
"A DHT instance must be provided"
);
throw
std
::
invalid_argument
(
"A DHT instance must be provided"
);
...
@@ -760,6 +761,20 @@ DhtProxyServer::getTypeFromString(const std::string& type) {
...
@@ -760,6 +761,20 @@ DhtProxyServer::getTypeFromString(const std::string& type) {
return
PushType
::
None
;
return
PushType
::
None
;
}
}
const
std
::
string
&
DhtProxyServer
::
getDefaultTopic
(
PushType
type
)
{
if
(
bundleId_
.
empty
())
{
return
{};
}
if
(
type
==
PushType
::
iOSLegacy
)
{
return
bundleId_
+
".voip"
;
}
if
(
type
==
PushType
::
iOS
)
{
return
bundleId_
;
}
return
{};
}
RequestStatus
RequestStatus
DhtProxyServer
::
subscribe
(
restinio
::
request_handle_t
request
,
DhtProxyServer
::
subscribe
(
restinio
::
request_handle_t
request
,
restinio
::
router
::
route_params_t
params
)
restinio
::
router
::
route_params_t
params
)
...
@@ -788,6 +803,9 @@ DhtProxyServer::subscribe(restinio::request_handle_t request,
...
@@ -788,6 +803,9 @@ DhtProxyServer::subscribe(restinio::request_handle_t request,
}
}
auto
type
=
getTypeFromString
(
root
[
"platform"
].
asString
());
auto
type
=
getTypeFromString
(
root
[
"platform"
].
asString
());
auto
topic
=
root
[
"topic"
].
asString
();
auto
topic
=
root
[
"topic"
].
asString
();
if
(
topic
.
empty
())
{
topic
=
getDefaultTopic
(
type
);
}
auto
clientId
=
root
[
"client_id"
].
asString
();
auto
clientId
=
root
[
"client_id"
].
asString
();
auto
sessionId
=
root
[
"session_id"
].
asString
();
auto
sessionId
=
root
[
"session_id"
].
asString
();
...
@@ -1188,6 +1206,9 @@ DhtProxyServer::put(restinio::request_handle_t request,
...
@@ -1188,6 +1206,9 @@ DhtProxyServer::put(restinio::request_handle_t request,
pput
.
pushToken
=
pushToken
;
pput
.
pushToken
=
pushToken
;
pput
.
clientId
=
clientId
;
pput
.
clientId
=
clientId
;
pput
.
type
=
getTypeFromString
(
platform
);
pput
.
type
=
getTypeFromString
(
platform
);
if
(
topic
.
empty
())
{
topic
=
getDefaultTopic
(
pput
.
type
);
}
pput
.
topic
=
topic
;
pput
.
topic
=
topic
;
pput
.
sessionCtx
=
std
::
make_shared
<
PushSessionContext
>
(
sessionId
);
pput
.
sessionCtx
=
std
::
make_shared
<
PushSessionContext
>
(
sessionId
);
// notify push listen expire
// notify push listen expire
...
...
This diff is collapsed.
Click to expand it.
tools/dhtnode.cpp
+
2
−
1
View file @
ead21d24
...
@@ -43,7 +43,7 @@ void print_version() {
...
@@ -43,7 +43,7 @@ void print_version() {
}
}
void
print_usage
()
{
void
print_usage
()
{
std
::
cout
<<
"Usage: dhtnode [-v [-l logfile]] [-i] [-d] [-n network_id] [-p local_port] [-b bootstrap_host[:port]] [--proxyserver local_port] [--proxyserverssl local_port]"
<<
std
::
endl
<<
std
::
endl
;
std
::
cout
<<
"Usage: dhtnode [-v [-l logfile]] [-i] [-d] [-n network_id] [-p local_port] [-b bootstrap_host[:port]] [--proxyserver local_port] [--proxyserverssl local_port]
[--bundleid bundleid]
"
<<
std
::
endl
<<
std
::
endl
;
print_info
();
print_info
();
}
}
...
@@ -550,6 +550,7 @@ main(int argc, char **argv)
...
@@ -550,6 +550,7 @@ main(int argc, char **argv)
#ifdef OPENDHT_PROXY_SERVER
#ifdef OPENDHT_PROXY_SERVER
ProxyServerConfig
serverConfig
;
ProxyServerConfig
serverConfig
;
serverConfig
.
pushServer
=
params
.
pushserver
;
serverConfig
.
pushServer
=
params
.
pushserver
;
serverConfig
.
bundleId
=
params
.
bundle_id
;
if
(
params
.
proxyserverssl
and
params
.
proxy_id
.
first
and
params
.
proxy_id
.
second
){
if
(
params
.
proxyserverssl
and
params
.
proxy_id
.
first
and
params
.
proxy_id
.
second
){
serverConfig
.
identity
=
params
.
proxy_id
;
serverConfig
.
identity
=
params
.
proxy_id
;
serverConfig
.
port
=
params
.
proxyserverssl
;
serverConfig
.
port
=
params
.
proxyserverssl
;
...
...
This diff is collapsed.
Click to expand it.
tools/tools_common.h
+
5
−
0
View file @
ead21d24
...
@@ -133,6 +133,7 @@ struct dht_params {
...
@@ -133,6 +133,7 @@ struct dht_params {
std
::
string
proxyclient
{};
std
::
string
proxyclient
{};
std
::
string
pushserver
{};
std
::
string
pushserver
{};
std
::
string
devicekey
{};
std
::
string
devicekey
{};
std
::
string
bundle_id
{};
std
::
string
persist_path
{};
std
::
string
persist_path
{};
dht
::
crypto
::
Identity
id
{};
dht
::
crypto
::
Identity
id
{};
dht
::
crypto
::
Identity
proxy_id
{};
dht
::
crypto
::
Identity
proxy_id
{};
...
@@ -229,6 +230,7 @@ static const constexpr struct option long_options[] = {
...
@@ -229,6 +230,7 @@ static const constexpr struct option long_options[] = {
{
"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'
},
{
"bundleid"
,
required_argument
,
nullptr
,
'u'
},
{
"version"
,
no_argument
,
nullptr
,
'V'
},
{
"version"
,
no_argument
,
nullptr
,
'V'
},
{
nullptr
,
0
,
nullptr
,
0
}
{
nullptr
,
0
,
nullptr
,
0
}
};
};
...
@@ -336,6 +338,9 @@ parseArgs(int argc, char **argv) {
...
@@ -336,6 +338,9 @@ parseArgs(int argc, char **argv) {
case
'k'
:
case
'k'
:
privkey
=
optarg
;
privkey
=
optarg
;
break
;
break
;
case
'u'
:
params
.
bundle_id
=
optarg
;
break
;
case
'K'
:
case
'K'
:
proxy_privkey
=
optarg
;
proxy_privkey
=
optarg
;
break
;
break
;
...
...
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