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
cbcfd1b6
Commit
cbcfd1b6
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[enh] add cli options for proxies conf
parent
005a8c2d
No related branches found
No related tags found
1 merge request
!1178
Add WS2PTOR features
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/cli.ts
+5
-0
5 additions, 0 deletions
app/cli.ts
index.ts
+25
-18
25 additions, 18 deletions
index.ts
server.ts
+4
-1
4 additions, 1 deletion
server.ts
with
34 additions
and
19 deletions
app/cli.ts
+
5
−
0
View file @
cbcfd1b6
...
...
@@ -49,6 +49,11 @@ export const ExecuteCommand = () => {
.
option
(
'
--nostdout
'
,
'
Disable stdout printing for `export-bc` command
'
)
.
option
(
'
--noshuffle
'
,
'
Disable peers shuffling for `sync` command
'
)
.
option
(
'
--proxy-socks <host:port>
'
,
'
Use Socks Proxy
'
)
.
option
(
'
--proxy-tor <host:port>
'
,
'
Use Tor Socks Proxy
'
)
.
option
(
'
--tor-always
'
,
'
Pass all outgoing requests through the tor network
'
)
.
option
(
'
--tor-mixed
'
,
'
Pass only ".onion" outgoing requests through the tor network. It
\'
s the default behavior
'
)
.
option
(
'
--timeout <milliseconds>
'
,
'
Timeout to use when contacting peers
'
,
parseInt
)
.
option
(
'
--httplogs
'
,
'
Enable HTTP logs
'
)
.
option
(
'
--nohttplogs
'
,
'
Disable HTTP logs
'
)
...
...
This diff is collapsed.
Click to expand it.
index.ts
+
25
−
18
View file @
cbcfd1b6
...
...
@@ -8,6 +8,7 @@ import {CrawlerDependency} from "./app/modules/crawler/index"
import
{
BmaDependency
}
from
"
./app/modules/bma/index
"
import
{
WS2PDependency
}
from
"
./app/modules/ws2p/index
"
import
{
Constants
}
from
"
./app/modules/prover/lib/constants
"
import
{
Proxy
}
from
'
./app/lib/proxy
'
;
const
path
=
require
(
'
path
'
);
const
_
=
require
(
'
underscore
'
);
...
...
@@ -437,10 +438,9 @@ class Stack {
}
}
function
commandLineConf
(
program
:
any
,
conf
:
any
=
{}
)
{
function
commandLineConf
(
program
:
any
,
conf
:
ConfDTO
=
ConfDTO
.
mock
()
)
{
conf
=
conf
||
{};
conf
.
sync
=
conf
.
sync
||
{};
const
cli
=
{
currency
:
program
.
currency
,
cpu
:
program
.
cpu
,
...
...
@@ -448,10 +448,11 @@ function commandLineConf(program:any, conf:any = {}) {
server
:
{
port
:
program
.
port
,
},
db
:
{
mport
:
program
.
mport
,
mdb
:
program
.
mdb
,
home
:
program
.
home
proxies
:
{
proxySocks
:
program
.
proxySocks
,
proxyTor
:
program
.
proxyTor
,
torAlways
:
program
.
torAlways
,
torMixed
:
program
.
torMixed
},
logs
:
{
http
:
program
.
httplogs
,
...
...
@@ -465,19 +466,25 @@ function commandLineConf(program:any, conf:any = {}) {
timeout
:
program
.
timeout
};
// Declare proxyConf
if
(
cli
.
proxies
.
proxySocks
||
cli
.
proxies
.
proxyTor
||
cli
.
proxies
.
torAlways
||
cli
.
proxies
.
torMixed
)
{
conf
.
proxyConf
=
Proxy
.
defaultConf
()
}
// Update conf
if
(
cli
.
currency
)
conf
.
currency
=
cli
.
currency
;
if
(
cli
.
server
.
port
)
conf
.
port
=
cli
.
server
.
port
;
if
(
cli
.
cpu
)
conf
.
cpu
=
Math
.
max
(
0.01
,
Math
.
min
(
1.0
,
cli
.
cpu
));
if
(
cli
.
prefix
)
conf
.
prefix
=
Math
.
max
(
Constants
.
MIN_PEER_ID
,
Math
.
min
(
Constants
.
MAX_PEER_ID
,
cli
.
prefix
));
if
(
cli
.
logs
.
http
)
conf
.
httplogs
=
true
;
if
(
cli
.
logs
.
nohttp
)
conf
.
httplogs
=
false
;
if
(
cli
.
db
.
mport
)
conf
.
mport
=
cli
.
db
.
mport
;
if
(
cli
.
db
.
home
)
conf
.
home
=
cli
.
db
.
home
;
if
(
cli
.
db
.
mdb
)
conf
.
mdb
=
cli
.
db
.
mdb
;
if
(
cli
.
isolate
)
conf
.
isolate
=
cli
.
isolate
;
if
(
cli
.
timeout
)
conf
.
timeout
=
cli
.
timeout
;
if
(
cli
.
forksize
!=
null
)
conf
.
forksize
=
cli
.
forksize
;
if
(
cli
.
currency
)
conf
.
currency
=
cli
.
currency
;
if
(
cli
.
server
.
port
)
conf
.
port
=
cli
.
server
.
port
;
if
(
cli
.
cpu
)
conf
.
cpu
=
Math
.
max
(
0.01
,
Math
.
min
(
1.0
,
cli
.
cpu
));
if
(
cli
.
prefix
)
conf
.
prefix
=
Math
.
max
(
Constants
.
MIN_PEER_ID
,
Math
.
min
(
Constants
.
MAX_PEER_ID
,
cli
.
prefix
));
if
(
cli
.
proxies
.
proxySocks
&&
conf
.
proxyConf
)
conf
.
proxyConf
.
proxySocksAddress
=
cli
.
proxies
.
proxySocks
;
if
(
cli
.
proxies
.
proxyTor
&&
conf
.
proxyConf
)
conf
.
proxyConf
.
proxyTorAddress
=
cli
.
proxies
.
proxyTor
;
if
(
cli
.
proxies
.
torAlways
&&
conf
.
proxyConf
)
conf
.
proxyConf
.
alwaysUseTor
=
true
;
if
(
cli
.
proxies
.
torMixed
&&
conf
.
proxyConf
)
conf
.
proxyConf
.
alwaysUseTor
=
false
;
if
(
cli
.
logs
.
http
)
conf
.
httplogs
=
true
;
if
(
cli
.
logs
.
nohttp
)
conf
.
httplogs
=
false
;
if
(
cli
.
isolate
)
conf
.
isolate
=
cli
.
isolate
;
if
(
cli
.
timeout
)
conf
.
timeout
=
cli
.
timeout
;
if
(
cli
.
forksize
!=
null
)
conf
.
forksize
=
cli
.
forksize
;
return
conf
;
}
...
...
This diff is collapsed.
Click to expand it.
server.ts
+
4
−
1
View file @
cbcfd1b6
...
...
@@ -24,6 +24,7 @@ import {PeerDTO} from "./app/lib/dto/PeerDTO"
import
{
OtherConstants
}
from
"
./app/lib/other_constants
"
import
{
WS2PCluster
}
from
"
./app/modules/ws2p/lib/WS2PCluster
"
import
{
DBBlock
}
from
"
./app/lib/db/DBBlock
"
import
{
Proxy
}
from
'
./app/lib/proxy
'
;
export
interface
HookableServer
{
generatorGetJoinData
:
(...
args
:
any
[])
=>
Promise
<
any
>
...
...
@@ -72,7 +73,7 @@ export class Server extends stream.Duplex implements HookableServer {
TransactionsService
:
TransactionService
private
documentFIFO
:
GlobalFifoPromise
constructor
(
home
:
string
,
memoryOnly
:
boolean
,
private
overrideConf
:
any
)
{
constructor
(
home
:
string
,
memoryOnly
:
boolean
,
private
overrideConf
:
ConfDTO
)
{
super
({
objectMode
:
true
})
this
.
home
=
home
;
...
...
@@ -148,6 +149,8 @@ export class Server extends stream.Duplex implements HookableServer {
logger
.
debug
(
'
Loading conf...
'
);
this
.
conf
=
await
this
.
dal
.
loadConf
(
this
.
overrideConf
,
useDefaultConf
)
// Default values
this
.
conf
.
proxyConf
=
this
.
conf
.
proxyConf
===
undefined
?
Proxy
.
defaultConf
()
:
this
.
conf
.
proxyConf
this
.
conf
.
proxyConf
.
alwaysUseTor
=
this
.
conf
.
proxyConf
.
alwaysUseTor
===
undefined
?
false
:
this
.
conf
.
proxyConf
.
alwaysUseTor
this
.
conf
.
remoteipv6
=
this
.
conf
.
remoteipv6
===
undefined
?
this
.
conf
.
ipv6
:
this
.
conf
.
remoteipv6
this
.
conf
.
remoteport
=
this
.
conf
.
remoteport
===
undefined
?
this
.
conf
.
port
:
this
.
conf
.
remoteport
this
.
conf
.
c
=
this
.
conf
.
c
===
undefined
?
constants
.
CONTRACT
.
DEFAULT
.
C
:
this
.
conf
.
c
...
...
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