Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
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
nodes
typescript
duniter
Commits
5a57cc78
Commit
5a57cc78
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' into proxy
parents
742e9397
9fe597ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1178
Add WS2PTOR features
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/modules/ws2p/lib/WS2PCluster.ts
+5
-10
5 additions, 10 deletions
app/modules/ws2p/lib/WS2PCluster.ts
with
5 additions
and
10 deletions
app/modules/ws2p/lib/WS2PCluster.ts
+
5
−
10
View file @
5a57cc78
...
@@ -373,7 +373,7 @@ export class WS2PCluster {
...
@@ -373,7 +373,7 @@ export class WS2PCluster {
if
(
api
)
{
if
(
api
)
{
try
{
try
{
// We do not connect to local host
// We do not connect to local host
if
(
!
this
.
server
.
conf
.
ws2p
||
api
.
uuid
!==
this
.
server
.
conf
.
ws2p
.
uuid
)
{
if
(
!
this
.
server
.
conf
.
ws2p
||
api
.
uuid
!==
this
.
server
.
conf
.
ws2p
.
uuid
||
p
.
pubkey
!==
this
.
server
.
conf
.
pair
.
pub
||
api
.
uuid
===
'
11111111
'
)
{
await
this
.
connectToRemoteWS
(
api
.
host
,
api
.
port
,
api
.
path
,
this
.
messageHandler
,
p
.
pubkey
,
api
.
uuid
)
await
this
.
connectToRemoteWS
(
api
.
host
,
api
.
port
,
api
.
path
,
this
.
messageHandler
,
p
.
pubkey
,
api
.
uuid
)
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -401,7 +401,7 @@ export class WS2PCluster {
...
@@ -401,7 +401,7 @@ export class WS2PCluster {
// Check if already connected to the pubkey (in any way: server or client)
// Check if already connected to the pubkey (in any way: server or client)
const
connectedPubkeys
=
this
.
getConnectedPubkeys
()
const
connectedPubkeys
=
this
.
getConnectedPubkeys
()
const
shouldAccept
=
await
this
.
acceptPubkey
(
peer
.
pubkey
,
connectedPubkeys
,
()
=>
this
.
clientsCount
(),
this
.
maxLevel1Size
,
(
this
.
server
.
conf
.
ws2p
&&
this
.
server
.
conf
.
ws2p
.
preferedNodes
||
[]),
ws2pEnpoint
.
uuid
)
const
shouldAccept
=
await
this
.
acceptPubkey
(
peer
.
pubkey
,
connectedPubkeys
,
()
=>
this
.
clientsCount
(),
this
.
maxLevel1Size
,
(
this
.
server
.
conf
.
ws2p
&&
this
.
server
.
conf
.
ws2p
.
preferedNodes
||
[]),
ws2pEnpoint
.
uuid
)
if
(
shouldAccept
)
{
if
(
shouldAccept
&&
(
!
this
.
server
.
conf
.
ws2p
||
ws2pEnpoint
.
uuid
!==
this
.
server
.
conf
.
ws2p
.
uuid
||
peer
.
pubkey
!==
this
.
server
.
conf
.
pair
.
pub
||
ws2pEnpoint
.
uuid
===
'
11111111
'
)
)
{
await
this
.
connectToRemoteWS
(
ws2pEnpoint
.
host
,
ws2pEnpoint
.
port
,
ws2pEnpoint
.
path
,
this
.
messageHandler
,
peer
.
pubkey
)
await
this
.
connectToRemoteWS
(
ws2pEnpoint
.
host
,
ws2pEnpoint
.
port
,
ws2pEnpoint
.
path
,
this
.
messageHandler
,
peer
.
pubkey
)
await
this
.
trimClientConnections
()
await
this
.
trimClientConnections
()
}
}
...
@@ -581,9 +581,8 @@ export class WS2PCluster {
...
@@ -581,9 +581,8 @@ export class WS2PCluster {
let
accept
=
priorityKeys
.
indexOf
(
pub
)
!==
-
1
let
accept
=
priorityKeys
.
indexOf
(
pub
)
!==
-
1
if
(
!
accept
&&
connectedPubkeys
.
indexOf
(
pub
)
===
-
1
)
{
if
(
!
accept
&&
connectedPubkeys
.
indexOf
(
pub
)
===
-
1
)
{
// Do we have room?
// Do we have room?
if
(
this
.
isThisNode
(
pub
,
targetWS2PUID
))
{
if
(
this
.
server
.
conf
.
pair
.
pub
===
pub
&&
this
.
server
.
conf
.
ws2p
&&
this
.
server
.
conf
.
ws2p
.
uuid
===
targetWS2PUID
)
{
// We do not connect to local host
accept
=
false
return
false
}
}
else
if
(
getConcurrentConnexionsCount
()
<
maxConcurrentConnexionsSize
)
{
else
if
(
getConcurrentConnexionsCount
()
<
maxConcurrentConnexionsSize
)
{
// Yes: just connect to it
// Yes: just connect to it
...
@@ -624,10 +623,6 @@ export class WS2PCluster {
...
@@ -624,10 +623,6 @@ export class WS2PCluster {
return
accept
return
accept
}
}
isThisNode
(
pub
:
string
,
uuid
:
string
)
{
return
!!
(
this
.
server
.
conf
.
pair
.
pub
===
pub
&&
this
.
server
.
conf
.
ws2p
&&
this
.
server
.
conf
.
ws2p
.
uuid
===
uuid
)
}
isSiblingNode
(
pub
:
string
,
uuid
:
string
)
{
isSiblingNode
(
pub
:
string
,
uuid
:
string
)
{
return
!!
(
this
.
server
.
conf
.
pair
.
pub
===
pub
&&
this
.
server
.
conf
.
ws2p
&&
this
.
server
.
conf
.
ws2p
.
uuid
!==
uuid
)
return
!!
(
this
.
server
.
conf
.
pair
.
pub
===
pub
&&
this
.
server
.
conf
.
ws2p
&&
this
.
server
.
conf
.
ws2p
.
uuid
!==
uuid
)
}
}
...
@@ -756,4 +751,4 @@ export class WS2PCluster {
...
@@ -756,4 +751,4 @@ export class WS2PCluster {
}
}
}
}
}
}
}
}
\ No newline at end of file
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