Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpcs
dfss
Commits
7dcce5ad
Commit
7dcce5ad
authored
Apr 15, 2016
by
Loïck Bonniot
Browse files
[d] Add configurable addrport and identifier
Fix
#3
- Should be merged asap in 192 branch
parent
2b63e8df
Pipeline
#642
passed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dfssc/main.go
View file @
7dcce5ad
...
...
@@ -5,10 +5,13 @@ import (
"flag"
"fmt"
"runtime"
dapi
"dfss/dfssd/api"
)
var
(
verbose
bool
demo
string
fca
string
// Path to the CA
fcert
string
// Path to the certificate
fkey
string
// Path to the private key
...
...
@@ -23,6 +26,7 @@ func init() {
flag
.
StringVar
(
&
fcert
,
"cert"
,
"cert.pem"
,
"Path to the user certificate"
)
flag
.
StringVar
(
&
fkey
,
"key"
,
"key.pem"
,
"Path to the private key"
)
flag
.
StringVar
(
&
addrPort
,
"host"
,
"localhost:9000"
,
"Host of the DFSS platform"
)
flag
.
StringVar
(
&
demo
,
"d"
,
""
,
"Demonstrator address and port (empty string disables debug)"
)
flag
.
IntVar
(
&
localPort
,
"port"
,
9005
,
"Port to use for P2P communication between clients"
)
flag
.
Usage
=
func
()
{
...
...
@@ -73,6 +77,8 @@ var commands = map[string]command{
func
main
()
{
flag
.
Parse
()
arg
:=
flag
.
Arg
(
0
)
dapi
.
Configure
(
demo
!=
""
,
demo
,
"client"
)
c
,
ok
:=
commands
[
arg
]
if
!
ok
||
flag
.
NArg
()
-
1
<
c
.
nbArgs
{
...
...
dfssd/api/client.go
View file @
7dcce5ad
package
api
import
(
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"time"
)
var
(
// theses are the default parameters
address
=
"localhost:3000"
identifier
=
"platform"
demo
=
false
address
,
identifier
string
demo
bool
// lazy initializer
dial
*
grpc
.
ClientConn
demoClient
DemonstratorClient
)
//
Switch for demo mode
//
// Should be used to pass the value of `-d` switch
func
Switch
(
activationSwitch
bool
)
{
de
mo
=
activationSwitch
return
//
Configure is used to update current parameters.
//
Call it at least one time before the first DLog call.
func
Configure
(
activated
bool
,
addrport
,
id
string
)
{
address
=
addrport
i
de
ntifier
=
id
demo
=
activated
}
// Lazy initialisation for demonstrator's connection to server
func
dInit
()
error
{
var
err
error
dial
,
err
=
grpc
.
Dial
(
address
,
grpc
.
WithInsecure
())
dial
,
err
=
grpc
.
Dial
(
address
,
grpc
.
WithInsecure
()
,
grpc
.
WithTimeout
(
10
*
time
.
Second
)
)
if
err
!=
nil
{
grpclog
.
Printf
(
"Fail to dial: %v"
,
err
)
return
err
}
demoClient
=
NewDemonstratorClient
(
dial
)
return
err
return
nil
}
// DClose close the connection with demonstrator server (if any)
...
...
@@ -45,7 +44,7 @@ func DClose() {
if
dial
!=
nil
{
err
:=
dial
.
Close
()
if
err
!=
nil
{
grpclog
.
Printf
(
"Fail to close dialing: %v"
,
err
)
grpclog
.
Printf
(
"Fail
ed
to close dialing
with demonstrator
: %v"
,
err
)
}
}
}
...
...
@@ -53,9 +52,7 @@ func DClose() {
// DLog send a message to the demonstrator
//
// The client is dialed in a lazy way
// The default demonstrator server address is localhost:3000
func
DLog
(
log
string
)
{
// check demo switch
if
!
demo
{
return
...
...
dfssp/main.go
View file @
7dcce5ad
...
...
@@ -15,16 +15,16 @@ import (
)
var
(
verbose
,
demo
bool
path
,
country
,
org
,
unit
,
cn
,
port
,
address
,
dbURI
string
keySize
,
rootValidity
,
certValidity
int
verbose
bool
path
,
country
,
org
,
unit
,
cn
,
port
,
address
,
dbURI
,
demo
string
keySize
,
rootValidity
,
certValidity
int
)
func
init
()
{
flag
.
BoolVar
(
&
verbose
,
"v"
,
false
,
"Print verbose messages"
)
flag
.
BoolVar
(
&
demo
,
"d"
,
false
,
"Enable demonstrator"
)
flag
.
StringVar
(
&
demo
,
"d"
,
""
,
"Demonstrator address and port (empty string disables debug)"
)
flag
.
StringVar
(
&
port
,
"p"
,
"9000"
,
"Default port listening"
)
flag
.
StringVar
(
&
address
,
"a"
,
"0.0.0.0"
,
"Default address to bind for listening"
)
...
...
@@ -67,7 +67,7 @@ func init() {
func
main
()
{
flag
.
Parse
()
command
:=
flag
.
Arg
(
0
)
dapi
.
Switch
(
demo
)
dapi
.
Configure
(
demo
!=
""
,
demo
,
"platform"
)
switch
command
{
case
"version"
:
...
...
dfsst/main.go
View file @
7dcce5ad
...
...
@@ -13,13 +13,14 @@ import (
)
var
(
verbose
,
demo
bool
fca
string
// Path to the CA
fcert
string
// Path to the certificate
fkey
string
// Path to the private key
address
string
dbURI
string
port
string
verbose
bool
fca
string
// Path to the CA
fcert
string
// Path to the certificate
fkey
string
// Path to the private key
address
string
dbURI
string
port
string
demo
string
)
func
init
()
{
...
...
@@ -28,7 +29,7 @@ func init() {
flag
.
StringVar
(
&
fca
,
"ca"
,
"ca.pem"
,
"Path to the root certificate"
)
flag
.
StringVar
(
&
fcert
,
"cert"
,
"cert.pem"
,
"Path to the user certificate"
)
flag
.
StringVar
(
&
fkey
,
"key"
,
"key.pem"
,
"Path to the private key"
)
flag
.
Bool
Var
(
&
demo
,
"d"
,
false
,
"Enable demonstrator
"
)
flag
.
String
Var
(
&
demo
,
"d"
,
""
,
"Demonstrator address and port (empty string disables debug)
"
)
flag
.
StringVar
(
&
port
,
"p"
,
"9020"
,
"Default port listening"
)
flag
.
StringVar
(
&
address
,
"a"
,
"0.0.0.0"
,
"Default address to bind for listening"
)
...
...
@@ -58,7 +59,7 @@ func init() {
func
main
()
{
flag
.
Parse
()
command
:=
flag
.
Arg
(
0
)
dapi
.
Switch
(
demo
)
dapi
.
Configure
(
demo
!=
""
,
demo
,
"ttp"
)
switch
command
{
case
"version"
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment