Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
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
jami-daemon
Commits
10f592d5
Commit
10f592d5
authored
Oct 23, 2016
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
nameservice: resolve outgoing names
Tuleap:
#938
Change-Id: I4685a91dd7e345349855abdfbc041105bd6ae2a2
parent
f062220c
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
src/ringdht/ringaccount.cpp
+55
-12
55 additions, 12 deletions
src/ringdht/ringaccount.cpp
src/ringdht/ringaccount.h
+2
-0
2 additions, 0 deletions
src/ringdht/ringaccount.h
with
57 additions
and
12 deletions
src/ringdht/ringaccount.cpp
+
55
−
12
View file @
10f592d5
...
...
@@ -93,9 +93,9 @@ constexpr const char* const RingAccount::ACCOUNT_TYPE;
static
std
::
uniform_int_distribution
<
dht
::
Value
::
Id
>
udist
;
static
const
std
::
string
parseRingUri
(
const
std
::
string
&
toUrl
)
stripPrefix
(
const
std
::
string
&
toUrl
)
{
auto
dhtf
=
toUrl
.
find
(
"ring:"
);
auto
dhtf
=
toUrl
.
find
(
RING_URI_PREFIX
);
if
(
dhtf
!=
std
::
string
::
npos
)
{
dhtf
=
dhtf
+
5
;
}
else
{
...
...
@@ -104,16 +104,31 @@ parseRingUri(const std::string& toUrl)
}
while
(
dhtf
<
toUrl
.
length
()
&&
toUrl
[
dhtf
]
==
'/'
)
dhtf
++
;
return
toUrl
.
substr
(
dhtf
);
}
if
(
toUrl
.
length
()
-
dhtf
<
40
)
static
const
std
::
string
parseRingUri
(
const
std
::
string
&
toUrl
)
{
auto
sufix
=
stripPrefix
(
toUrl
);
if
(
sufix
.
length
()
<
40
)
throw
std
::
invalid_argument
(
"id must be a ring infohash"
);
const
std
::
string
toUri
=
toUrl
.
substr
(
dhtf
,
40
);
const
std
::
string
toUri
=
sufix
.
substr
(
0
,
40
);
if
(
std
::
find_if_not
(
toUri
.
cbegin
(),
toUri
.
cend
(),
::
isxdigit
)
!=
toUri
.
cend
())
throw
std
::
invalid_argument
(
"id must be a ring infohash"
);
return
toUri
;
}
static
bool
isRingHash
(
const
std
::
string
&
uri
)
{
if
(
uri
.
length
()
<
40
)
return
false
;
if
(
std
::
find_if_not
(
uri
.
cbegin
(),
uri
.
cbegin
()
+
40
,
::
isxdigit
)
!=
uri
.
cend
())
return
false
;
return
true
;
}
static
constexpr
const
char
*
dhtStatusStr
(
dht
::
NodeStatus
status
)
{
...
...
@@ -206,17 +221,47 @@ template <>
std
::
shared_ptr
<
SIPCall
>
RingAccount
::
newOutgoingCall
(
const
std
::
string
&
toUrl
)
{
const
std
::
string
toUri
=
parseRingUri
(
toUrl
);
RING_DBG
(
"Calling DHT peer %s"
,
toUri
.
c_str
());
auto
sufix
=
stripPrefix
(
toUrl
);
RING_DBG
(
"Calling DHT peer %s"
,
sufix
.
c_str
());
auto
&
manager
=
Manager
::
instance
();
auto
call
=
manager
.
callFactory
.
newCall
<
SIPCall
,
RingAccount
>
(
*
this
,
manager
.
getNewCallID
(),
Call
::
CallType
::
OUTGOING
);
call
->
setIPToIP
(
true
);
call
->
setSecure
(
isTlsEnabled
());
call
->
initRecFilename
(
toUr
i
);
call
->
initRecFilename
(
toUr
l
);
try
{
const
std
::
string
toUri
=
parseRingUri
(
sufix
);
startOutgoingCall
(
call
,
toUri
);
}
catch
(...)
{
#if HAVE_RINGNS
std
::
weak_ptr
<
RingAccount
>
wthis_
=
std
::
static_pointer_cast
<
RingAccount
>
(
shared_from_this
());
nameDir_
.
get
().
lookupName
(
sufix
,
[
wthis_
,
call
](
const
std
::
string
&
result
,
NameDirectory
::
Response
response
)
mutable
{
runOnMainThread
([
=
]()
mutable
{
if
(
auto
sthis
=
wthis_
.
lock
())
{
try
{
const
std
::
string
toUri
=
parseRingUri
(
result
);
sthis
->
startOutgoingCall
(
call
,
toUri
);
}
catch
(...)
{
call
->
onFailure
(
ENOENT
);
}
}
else
{
call
->
onFailure
();
}
});
});
#else
call
->
onFailure
(
ENOENT
);
#endif
}
return
call
;
}
void
RingAccount
::
startOutgoingCall
(
std
::
shared_ptr
<
SIPCall
>&
call
,
const
std
::
string
toUri
)
{
auto
sthis
=
std
::
static_pointer_cast
<
RingAccount
>
(
shared_from_this
());
// TODO: for now, we automatically trust all explicitly called peers
...
...
@@ -332,8 +377,6 @@ RingAccount::newOutgoingCall(const std::string& toUrl)
}
}
});
return
call
;
}
void
...
...
@@ -1187,7 +1230,7 @@ RingAccount::lookupName(const std::string& name)
{
auto
acc
=
getAccountID
();
nameDir_
.
get
().
lookupName
(
name
,
[
acc
,
name
](
const
std
::
string
&
result
,
NameDirectory
::
Response
response
)
{
emitSignal
<
DRing
::
ConfigurationSignal
::
RegisteredNameFound
>
(
acc
,
0
,
result
,
name
);
emitSignal
<
DRing
::
ConfigurationSignal
::
RegisteredNameFound
>
(
acc
,
(
int
)
response
,
result
,
name
);
});
}
...
...
@@ -1196,7 +1239,7 @@ RingAccount::lookupAddress(const std::string& addr)
{
auto
acc
=
getAccountID
();
nameDir_
.
get
().
lookupAddress
(
addr
,
[
acc
,
addr
](
const
std
::
string
&
result
,
NameDirectory
::
Response
response
)
{
emitSignal
<
DRing
::
ConfigurationSignal
::
RegisteredNameFound
>
(
acc
,
0
,
addr
,
result
);
emitSignal
<
DRing
::
ConfigurationSignal
::
RegisteredNameFound
>
(
acc
,
(
int
)
response
,
addr
,
result
);
});
}
...
...
This diff is collapsed.
Click to expand it.
src/ringdht/ringaccount.h
+
2
−
0
View file @
10f592d5
...
...
@@ -376,6 +376,8 @@ class RingAccount : public SIPAccountBase {
*/
virtual
void
setAccountDetails
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
details
)
override
;
void
startOutgoingCall
(
std
::
shared_ptr
<
SIPCall
>&
call
,
const
std
::
string
toUri
);
/**
* Start a SIP Call
* @param call The current call
...
...
This diff is collapsed.
Click to expand it.
Jami Bot
@RingBot
mentioned in commit
6e323fa5
·
May 15, 2018
mentioned in commit
6e323fa5
mentioned in commit 6e323fa54f29ae76c375084d3d14939529700e68
Toggle commit list
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
sign in
to comment