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
11a1b027
Commit
11a1b027
authored
7 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#1084
WS2P: UPnP code under non-UPnP environment makes Duniter crash
parent
b87e12a5
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/modules/ws2p/index.ts
+6
-4
6 additions, 4 deletions
app/modules/ws2p/index.ts
app/modules/ws2p/lib/WS2PConnection.ts
+2
-1
2 additions, 1 deletion
app/modules/ws2p/lib/WS2PConnection.ts
app/modules/ws2p/lib/ws2p-upnp.ts
+8
-5
8 additions, 5 deletions
app/modules/ws2p/lib/ws2p-upnp.ts
with
16 additions
and
10 deletions
app/modules/ws2p/index.ts
+
6
−
4
View file @
11a1b027
...
@@ -107,10 +107,12 @@ export class WS2PAPI extends stream.Transform {
...
@@ -107,10 +107,12 @@ export class WS2PAPI extends stream.Transform {
this
.
upnpAPI
.
stopRegular
();
this
.
upnpAPI
.
stopRegular
();
}
}
try
{
try
{
this
.
upnpAPI
=
await
new
WS2PUpnp
(
this
.
logger
)
this
.
upnpAPI
=
new
WS2PUpnp
(
this
.
logger
)
const
{
host
,
port
}
=
await
this
.
upnpAPI
.
startRegular
()
const
{
host
,
port
,
available
}
=
await
this
.
upnpAPI
.
startRegular
()
if
(
available
)
{
await
this
.
cluster
.
listen
(
host
,
port
)
await
this
.
cluster
.
listen
(
host
,
port
)
await
this
.
server
.
PeeringService
.
generateSelfPeer
(
this
.
server
.
conf
)
await
this
.
server
.
PeeringService
.
generateSelfPeer
(
this
.
server
.
conf
)
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
logger
.
warn
(
e
);
this
.
logger
.
warn
(
e
);
}
}
...
...
This diff is collapsed.
Click to expand it.
app/modules/ws2p/lib/WS2PConnection.ts
+
2
−
1
View file @
11a1b027
...
@@ -6,12 +6,13 @@ import {CertificationDTO} from "../../../lib/dto/CertificationDTO"
...
@@ -6,12 +6,13 @@ import {CertificationDTO} from "../../../lib/dto/CertificationDTO"
import
{
MembershipDTO
}
from
"
../../../lib/dto/MembershipDTO
"
import
{
MembershipDTO
}
from
"
../../../lib/dto/MembershipDTO
"
import
{
TransactionDTO
}
from
"
../../../lib/dto/TransactionDTO
"
import
{
TransactionDTO
}
from
"
../../../lib/dto/TransactionDTO
"
import
{
PeerDTO
}
from
"
../../../lib/dto/PeerDTO
"
import
{
PeerDTO
}
from
"
../../../lib/dto/PeerDTO
"
import
{
WS2PConstants
}
from
"
./constants
"
const
ws
=
require
(
'
ws
'
)
const
ws
=
require
(
'
ws
'
)
const
nuuid
=
require
(
'
node-uuid
'
);
const
nuuid
=
require
(
'
node-uuid
'
);
const
logger
=
require
(
'
../../../lib/logger
'
).
NewLogger
(
'
ws2p
'
)
const
logger
=
require
(
'
../../../lib/logger
'
).
NewLogger
(
'
ws2p
'
)
const
MAXIMUM_ERRORS_COUNT
=
5
const
MAXIMUM_ERRORS_COUNT
=
5
const
REQUEST_TIMEOUT_VALUE
=
1000
*
5
// 10 seconds
const
REQUEST_TIMEOUT_VALUE
=
WS2PConstants
.
REQUEST_TIMEOUT
enum
WS2P_ERR
{
enum
WS2P_ERR
{
REJECTED_PUBKEY_OR_INCORRECT_ASK_SIGNATURE_FROM_REMOTE
,
REJECTED_PUBKEY_OR_INCORRECT_ASK_SIGNATURE_FROM_REMOTE
,
...
...
This diff is collapsed.
Click to expand it.
app/modules/ws2p/lib/ws2p-upnp.ts
+
8
−
5
View file @
11a1b027
...
@@ -21,10 +21,10 @@ export class WS2PUpnp {
...
@@ -21,10 +21,10 @@ export class WS2PUpnp {
try
{
try
{
await
new
Promise
((
resolve
,
reject
)
=>
{
await
new
Promise
((
resolve
,
reject
)
=>
{
this
.
client
.
externalIp
((
err
:
any
,
res
:
any
)
=>
{
this
.
client
.
externalIp
((
err
:
any
,
res
:
any
)
=>
{
if
(
err
)
{
if
(
err
||
!
res
)
{
re
solve
(
true
)
re
ject
(
)
}
else
{
}
else
{
resolve
(
false
)
resolve
()
}
}
})
})
})
})
...
@@ -67,11 +67,14 @@ export class WS2PUpnp {
...
@@ -67,11 +67,14 @@ export class WS2PUpnp {
async
startRegular
()
{
async
startRegular
()
{
this
.
stopRegular
();
this
.
stopRegular
();
if
(
await
this
.
checkUPnPisAvailable
())
{
const
available
=
await
this
.
checkUPnPisAvailable
()
if
(
available
)
{
// Update UPnP IGD every INTERVAL seconds
// Update UPnP IGD every INTERVAL seconds
this
.
interval
=
setInterval
(()
=>
this
.
openPort
(),
1000
*
WS2PConstants
.
WS2P_UPNP_INTERVAL
)
this
.
interval
=
setInterval
(()
=>
this
.
openPort
(),
1000
*
WS2PConstants
.
WS2P_UPNP_INTERVAL
)
const
{
host
,
port
}
=
await
this
.
openPort
()
return
{
host
,
port
,
available
}
}
}
return
this
.
openPort
()
return
{
host
:
''
,
port
:
0
,
available
:
false
}
}
}
stopRegular
()
{
stopRegular
()
{
...
...
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