Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
briar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
675
Issues
675
List
Boards
Labels
Service Desk
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
briar
briar
Commits
a4a45efd
Verified
Commit
a4a45efd
authored
Jun 07, 2019
by
akwizgran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Broadcast event when polling newly added contact.
parent
208ae6a4
Pipeline
#3501
passed with stage
in 7 minutes and 56 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
15 deletions
+27
-15
bramble-api/src/main/java/org/briarproject/bramble/api/rendezvous/RendezvousPoller.java
...briarproject/bramble/api/rendezvous/RendezvousPoller.java
+2
-2
bramble-core/src/main/java/org/briarproject/bramble/rendezvous/RendezvousPollerImpl.java
...briarproject/bramble/rendezvous/RendezvousPollerImpl.java
+13
-7
bramble-core/src/test/java/org/briarproject/bramble/rendezvous/RendezvousPollerImplTest.java
...rproject/bramble/rendezvous/RendezvousPollerImplTest.java
+7
-0
briar-android/src/main/java/org/briarproject/briar/android/contact/add/remote/PendingContactListViewModel.java
...droid/contact/add/remote/PendingContactListViewModel.java
+5
-6
No files found.
bramble-api/src/main/java/org/briarproject/bramble/api/rendezvous/RendezvousPoller.java
View file @
a4a45efd
package
org.briarproject.bramble.api.rendezvous
;
import
org.briarproject.bramble.api.
plugin.Transpor
tId
;
import
org.briarproject.bramble.api.
contact.PendingContac
tId
;
/**
* Interface for the poller that makes rendezvous connections to pending
...
...
@@ -8,5 +8,5 @@ import org.briarproject.bramble.api.plugin.TransportId;
*/
public
interface
RendezvousPoller
{
long
getLastPollTime
(
TransportId
t
);
long
getLastPollTime
(
PendingContactId
p
);
}
bramble-core/src/main/java/org/briarproject/bramble/rendezvous/RendezvousPollerImpl.java
View file @
a4a45efd
...
...
@@ -90,7 +90,7 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener {
private
final
Clock
clock
;
private
final
AtomicBoolean
used
=
new
AtomicBoolean
(
false
);
private
final
Map
<
Transpor
tId
,
Long
>
lastPollTimes
=
private
final
Map
<
PendingContac
tId
,
Long
>
lastPollTimes
=
new
ConcurrentHashMap
<>();
// Executor that runs one task at a time
...
...
@@ -126,8 +126,8 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener {
}
@Override
public
long
getLastPollTime
(
TransportId
t
)
{
Long
time
=
lastPollTimes
.
get
(
t
);
public
long
getLastPollTime
(
PendingContactId
p
)
{
Long
time
=
lastPollTimes
.
get
(
p
);
return
time
==
null
?
0
:
time
;
}
...
...
@@ -227,6 +227,7 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener {
private
void
removePendingContact
(
PendingContactId
p
)
{
// We can come here twice if a pending contact expires and is removed
if
(
cryptoStates
.
remove
(
p
)
==
null
)
return
;
lastPollTimes
.
remove
(
p
);
for
(
PluginState
ps
:
pluginStates
.
values
())
{
RendezvousEndpoint
endpoint
=
ps
.
endpoints
.
remove
(
p
);
if
(
endpoint
!=
null
)
tryToClose
(
endpoint
,
LOG
,
INFO
);
...
...
@@ -246,9 +247,10 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener {
Handler
h
=
new
Handler
(
e
.
getKey
(),
t
,
false
);
properties
.
add
(
new
Pair
<>(
props
,
h
));
}
lastPollTimes
.
put
(
t
,
clock
.
currentTimeMillis
());
eventBus
.
broadcast
(
new
RendezvousPollEvent
(
t
,
new
ArrayList
<>(
ps
.
endpoints
.
keySet
())));
List
<
PendingContactId
>
polled
=
new
ArrayList
<>(
ps
.
endpoints
.
keySet
());
long
now
=
clock
.
currentTimeMillis
();
for
(
PendingContactId
p
:
polled
)
lastPollTimes
.
put
(
p
,
now
);
eventBus
.
broadcast
(
new
RendezvousPollEvent
(
t
,
polled
));
ps
.
plugin
.
poll
(
properties
);
}
...
...
@@ -294,9 +296,13 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener {
for
(
PluginState
ps
:
pluginStates
.
values
())
{
RendezvousEndpoint
endpoint
=
ps
.
endpoints
.
get
(
p
);
if
(
endpoint
!=
null
)
{
TransportId
t
=
ps
.
plugin
.
getId
();
TransportProperties
props
=
endpoint
.
getRemoteTransportProperties
();
Handler
h
=
new
Handler
(
p
,
ps
.
plugin
.
getId
(),
false
);
Handler
h
=
new
Handler
(
p
,
t
,
false
);
lastPollTimes
.
put
(
p
,
clock
.
currentTimeMillis
());
eventBus
.
broadcast
(
new
RendezvousPollEvent
(
t
,
singletonList
(
p
)));
ps
.
plugin
.
poll
(
singletonList
(
new
Pair
<>(
props
,
h
)));
}
}
...
...
bramble-core/src/test/java/org/briarproject/bramble/rendezvous/RendezvousPollerImplTest.java
View file @
a4a45efd
...
...
@@ -24,6 +24,7 @@ import org.briarproject.bramble.api.rendezvous.KeyMaterialSource;
import
org.briarproject.bramble.api.rendezvous.RendezvousEndpoint
;
import
org.briarproject.bramble.api.rendezvous.event.RendezvousConnectionClosedEvent
;
import
org.briarproject.bramble.api.rendezvous.event.RendezvousConnectionOpenedEvent
;
import
org.briarproject.bramble.api.rendezvous.event.RendezvousPollEvent
;
import
org.briarproject.bramble.api.system.Clock
;
import
org.briarproject.bramble.test.BrambleMockTestCase
;
import
org.briarproject.bramble.test.CaptureArgumentAction
;
...
...
@@ -191,6 +192,9 @@ public class RendezvousPollerImplTest extends BrambleMockTestCase {
// Poll newly added pending contact
oneOf
(
rendezvousEndpoint
).
getRemoteTransportProperties
();
will
(
returnValue
(
transportProperties
));
oneOf
(
clock
).
currentTimeMillis
();
will
(
returnValue
(
beforeExpiry
));
oneOf
(
eventBus
).
broadcast
(
with
(
any
(
RendezvousPollEvent
.
class
)));
oneOf
(
plugin
).
poll
(
with
(
collectionOf
(
pairOf
(
equal
(
transportProperties
),
any
(
ConnectionHandler
.
class
)))));
...
...
@@ -242,6 +246,9 @@ public class RendezvousPollerImplTest extends BrambleMockTestCase {
// Poll newly added pending contact
oneOf
(
rendezvousEndpoint
).
getRemoteTransportProperties
();
will
(
returnValue
(
transportProperties
));
oneOf
(
clock
).
currentTimeMillis
();
will
(
returnValue
(
beforeExpiry
));
oneOf
(
eventBus
).
broadcast
(
with
(
any
(
RendezvousPollEvent
.
class
)));
oneOf
(
plugin
).
poll
(
with
(
collectionOf
(
pairOf
(
equal
(
transportProperties
),
any
(
ConnectionHandler
.
class
)))));
...
...
briar-android/src/main/java/org/briarproject/briar/android/contact/add/remote/PendingContactListViewModel.java
View file @
a4a45efd
...
...
@@ -18,7 +18,6 @@ import org.briarproject.bramble.api.event.Event;
import
org.briarproject.bramble.api.event.EventBus
;
import
org.briarproject.bramble.api.event.EventListener
;
import
org.briarproject.bramble.api.nullsafety.NotNullByDefault
;
import
org.briarproject.bramble.api.plugin.TorConstants
;
import
org.briarproject.bramble.api.rendezvous.RendezvousPoller
;
import
org.briarproject.bramble.api.rendezvous.event.RendezvousPollEvent
;
...
...
@@ -83,14 +82,14 @@ public class PendingContactListViewModel extends AndroidViewModel
private
void
loadPendingContacts
()
{
dbExecutor
.
execute
(()
->
{
try
{
long
lastPoll
=
rendezvousPoller
.
getLastPollTime
(
TorConstants
.
ID
);
Collection
<
Pair
<
PendingContact
,
PendingContactState
>>
pairs
=
contactManager
.
getPendingContacts
();
List
<
PendingContactItem
>
items
=
new
ArrayList
<>(
pairs
.
size
());
for
(
Pair
<
PendingContact
,
PendingContactState
>
p
:
pairs
)
{
items
.
add
(
new
PendingContactItem
(
p
.
getFirst
(),
p
.
getSecond
(),
lastPoll
));
for
(
Pair
<
PendingContact
,
PendingContactState
>
pair
:
pairs
)
{
PendingContact
p
=
pair
.
getFirst
();
long
lastPoll
=
rendezvousPoller
.
getLastPollTime
(
p
.
getId
());
items
.
add
(
new
PendingContactItem
(
p
,
pair
.
getSecond
(),
lastPoll
));
}
pendingContacts
.
postValue
(
items
);
}
catch
(
DbException
e
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment