Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
fb90fcf3
Commit
fb90fcf3
authored
6 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[feat] ws2p1: apply param prefered pubkeys
parent
d7d9f135
No related branches found
No related tags found
1 merge request
!143
Resolve "WS2Pv1: add feature prefered pubkeys"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs
+17
-4
17 additions, 4 deletions
lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs
with
17 additions
and
4 deletions
lib/modules/ws2p-v1-legacy/src/ws_connections/mod.rs
+
17
−
4
View file @
fb90fcf3
...
@@ -28,6 +28,7 @@ use durs_network::documents::BlockchainDocument;
...
@@ -28,6 +28,7 @@ use durs_network::documents::BlockchainDocument;
use
durs_network_documents
::
network_endpoint
::
EndpointV1
;
use
durs_network_documents
::
network_endpoint
::
EndpointV1
;
use
rand
::
Rng
;
use
rand
::
Rng
;
use
states
::
WS2PConnectionState
;
use
states
::
WS2PConnectionState
;
use
std
::
cmp
::
Ordering
;
use
std
::
collections
::
HashSet
;
use
std
::
collections
::
HashSet
;
#[allow(deprecated)]
#[allow(deprecated)]
use
ws
::
Sender
;
use
ws
::
Sender
;
...
@@ -64,8 +65,10 @@ pub fn connect_to_know_endpoints(ws2p_module: &mut WS2PModule) {
...
@@ -64,8 +65,10 @@ pub fn connect_to_know_endpoints(ws2p_module: &mut WS2PModule) {
|
WS2PConnectionState
::
Close
|
WS2PConnectionState
::
Close
|
WS2PConnectionState
::
Denial
=>
{
|
WS2PConnectionState
::
Denial
=>
{
pubkeys
.insert
(
ep
.issuer
);
pubkeys
.insert
(
ep
.issuer
);
if
ws2p_module
.ssl
||
ep
.port
!=
443
{
reachable_endpoints
.push
(
ep
);
reachable_endpoints
.push
(
ep
);
}
}
}
_
=>
{
_
=>
{
pubkeys
.insert
(
ep
.issuer
);
pubkeys
.insert
(
ep
.issuer
);
unreachable_endpoints
.push
(
ep
);
unreachable_endpoints
.push
(
ep
);
...
@@ -73,6 +76,19 @@ pub fn connect_to_know_endpoints(ws2p_module: &mut WS2PModule) {
...
@@ -73,6 +76,19 @@ pub fn connect_to_know_endpoints(ws2p_module: &mut WS2PModule) {
}
}
}
}
}
}
if
!
ws2p_module
.conf.prefered_pubkeys
.is_empty
()
{
reachable_endpoints
.sort_unstable_by
(|
ep1
,
ep2
|
{
if
ws2p_module
.conf.prefered_pubkeys
.contains
(
&
ep1
.issuer
)
{
if
ws2p_module
.conf.prefered_pubkeys
.contains
(
&
ep2
.issuer
)
{
Ordering
::
Equal
}
else
{
Ordering
::
Greater
}
}
else
{
Ordering
::
Less
}
});
}
let
mut
free_outcoming_rooms
=
let
mut
free_outcoming_rooms
=
ws2p_module
.conf
.clone
()
.outcoming_quota
-
count_established_connections
;
ws2p_module
.conf
.clone
()
.outcoming_quota
-
count_established_connections
;
while
free_outcoming_rooms
>
0
{
while
free_outcoming_rooms
>
0
{
...
@@ -87,9 +103,6 @@ pub fn connect_to_know_endpoints(ws2p_module: &mut WS2PModule) {
...
@@ -87,9 +103,6 @@ pub fn connect_to_know_endpoints(ws2p_module: &mut WS2PModule) {
}
else
{
}
else
{
break
;
break
;
};
};
if
!
ws2p_module
.ssl
&&
ep
.port
==
443
{
continue
;
}
connect_to_without_checking_quotas
(
ws2p_module
,
unwrap!
(
ep
.node_full_id
()));
connect_to_without_checking_quotas
(
ws2p_module
,
unwrap!
(
ep
.node_full_id
()));
free_outcoming_rooms
-=
1
;
free_outcoming_rooms
-=
1
;
}
}
...
...
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