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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
3e117452
Commit
3e117452
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
proxy attribute re-encapsulation
parent
02883fa2
No related branches found
No related tags found
1 merge request
!1178
Add WS2PTOR features
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/proxy.ts
+14
-10
14 additions, 10 deletions
app/lib/proxy.ts
app/modules/ws2p/lib/WS2PConnection.ts
+3
-3
3 additions, 3 deletions
app/modules/ws2p/lib/WS2PConnection.ts
with
17 additions
and
13 deletions
app/lib/proxy.ts
+
14
−
10
View file @
3e117452
const
SocksProxyAgent
=
require
(
'
socks-proxy-agent
'
);
const
SocksProxyAgent
=
require
(
'
socks-proxy-agent
'
);
const
constants
=
require
(
'
./constants
'
);
const
WS2PConstants
=
require
(
'
../modules/ws2p/lib/constants
'
);
const
DEFAULT_PROXY_TIMEOUT
:
number
=
30000
const
DEFAULT_PROXY_TIMEOUT
:
number
=
30000
const
TOR_PROXY_TIMEOUT
:
number
=
60000
const
TOR_PROXY_TIMEOUT
:
number
=
60000
const
HTTP_ENDPOINT_ONION_REGEX
=
new
RegExp
(
'
(?:https?:
\
/
\
/)?(?:www)?(
\
S*?
\
.onion)(
\
/[-
\
w]*)*
'
)
const
HTTP_ENDPOINT_ONION_REGEX
=
new
RegExp
(
'
(?:https?:
\
/
\
/)?(?:www)?(
\
S*?
\
.onion)(
\
/[-
\
w]*)*
'
)
...
@@ -21,25 +18,32 @@ export interface ProxyConf {
...
@@ -21,25 +18,32 @@ export interface ProxyConf {
}
}
export
class
Proxy
{
export
class
Proxy
{
p
ublic
agent
:
any
p
rivate
agent
:
any
private
url
:
string
private
url
:
string
constructor
(
proxy
:
string
,
type
:
string
=
"
socks
"
,
p
ublic
timeout
:
number
=
DEFAULT_PROXY_TIMEOUT
)
{
constructor
(
proxy
:
string
,
type
:
string
=
"
socks
"
,
p
rivate
timeout
:
number
=
DEFAULT_PROXY_TIMEOUT
)
{
if
(
type
===
"
socks
"
)
{
if
(
type
===
"
socks
"
)
{
this
.
agent
=
SocksProxyAgent
(
"
socks://
"
+
proxy
)
this
.
agent
=
SocksProxyAgent
(
"
socks://
"
+
proxy
)
this
.
url
=
"
socks://
"
+
proxy
this
.
url
=
"
socks://
"
+
proxy
}
}
else
{
else
{
this
.
url
=
""
this
.
agent
=
undefined
this
.
agent
=
undefined
this
.
url
=
""
}
}
this
.
timeout
=
timeout
}
getAgent
()
{
return
this
.
agent
;
}
}
getUrl
()
{
getUrl
()
{
return
this
.
url
;
return
this
.
url
;
}
}
getTimeout
()
{
return
this
.
timeout
;
}
static
defaultConf
():
ProxyConf
{
static
defaultConf
():
ProxyConf
{
return
{
return
{
proxySocksAddress
:
undefined
,
proxySocksAddress
:
undefined
,
...
...
This diff is collapsed.
Click to expand it.
app/modules/ws2p/lib/WS2PConnection.ts
+
3
−
3
View file @
3e117452
...
@@ -279,11 +279,11 @@ export class WS2PConnection {
...
@@ -279,11 +279,11 @@ export class WS2PConnection {
expectedPub
:
string
=
""
)
{
expectedPub
:
string
=
""
)
{
if
(
proxy
!==
undefined
)
{
if
(
proxy
!==
undefined
)
{
options
=
{
options
=
{
connectionTimeout
:
proxy
.
t
imeout
,
connectionTimeout
:
proxy
.
getT
imeout
()
,
requestTimeout
:
proxy
.
t
imeout
requestTimeout
:
proxy
.
getT
imeout
()
}
}
}
}
const
websocket
=
(
proxy
!==
undefined
)
?
new
ws
(
address
,
{
agent
:
proxy
.
a
gent
}):
new
ws
(
address
)
const
websocket
=
(
proxy
!==
undefined
)
?
new
ws
(
address
,
{
agent
:
proxy
.
getA
gent
()
}):
new
ws
(
address
)
const
onWsOpened
:
Promise
<
void
>
=
new
Promise
(
res
=>
{
const
onWsOpened
:
Promise
<
void
>
=
new
Promise
(
res
=>
{
websocket
.
on
(
'
open
'
,
()
=>
res
())
websocket
.
on
(
'
open
'
,
()
=>
res
())
})
})
...
...
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