Skip to content

Commit

Permalink
put global listening in all places
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Oct 28, 2015
1 parent f5613fd commit 8b315d0
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 18 deletions.
59 changes: 55 additions & 4 deletions app/conode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,65 @@ section.
These are the steps to be part in the EPFL-conode-project:

1. Download the binary distribution
2. Create and send the public-key
3. Validate the installation
4. Start your conode
5. Stamp your documents
2. Create the keypair and validate the installation
3. Start your conode
4. Stamp your documents

### Download the binary distribution

Make a directory and cd into it:

```mkdir conode
cd conode```
Go to the page
https://github.com/dedis/cothority/releases/latest
and download the latest .tar.gz and untar it (replace with latest version)
```wget http:///DeDiS/cothority/releases/download/0.5/conode-0.5.2.tar.gz
tar xf conode-0.5.2.tar.gz```
### Create the keypair and validate the installation
Now you're ready to create a new private/public key pair and start to validate
the installation. Best thing to do is to open a ```screen``` for background
running:
```screen -S conode
./start-conode setup <your IP>```
This command will create a new key-pair and print the public key on the command
line. Please send that key to dev.dedis@epfl.ch and wait further instructions.
The command will wait for us to verify your installation, so please keep it
running. If you want to quit the ```screen```, you can do so by typing
```<ctrl>a + d```. To go back to your screen session, run
```screen -r conode```
### Start your conode
Once the installation has been verified, change back to the screen and abort
the running conode with ```<ctrl>c```. Now you can run the real conode:
```./start-conode run```
Because the ```config.toml``` which descsribes the other nodes is missing, it
will download the newest package and install that one.
### Stamp some documents
If everything is running correctly, you can start stamping documents:
```./stamp sign file```
Where *file* is the file you want to stamp. It will write the signature
and the inclusion-proof in ```file.sig```.
To verify whether a document is correctly stamped and still valid, run
```./stamp verify file```
## Participate in the EPFL-conode - compile your own version
Expand Down
6 changes: 4 additions & 2 deletions app/conode/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/dedis/cothority/lib/proof"
"github.com/dedis/cothority/proto/sign"
"github.com/dedis/crypto/abstract"
"github.com/dedis/cothority/lib/cliutils"
)

type Server struct {
Expand Down Expand Up @@ -89,8 +90,9 @@ func (s *Server) Close() {
// this server needs to be running on a different port
// than the Signer that is beneath it
func (s *Server) Listen() error {
dbg.Lvl3("Listening in server at", s.name)
ln, err := net.Listen("tcp4", s.name)
global, _ := cliutils.GlobalBind(s.name)
dbg.LLvl3("Listening in server at", global)
ln, err := net.Listen("tcp4", global)
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions app/conode/start-conode
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ main(){
setup)
if [ -f key.pub ]; then
echo "Key.pub already exists - if you want to re-create, please delete it first"
exit 1
else
./conode keygen $2
fi
./conode keygen $2
cat key.pub
./conode validate
;;
Expand Down Expand Up @@ -76,8 +76,8 @@ search_arch(){
#!/bin/bash
./$CONODE \$@
EOF
sed -e "s/conode/stamp/" conode > stamp
chmod a+x conode
sed -e "s/conode/stamp/" conode > stamp
chmod a+x conode stamp
echo Found $CONODE to run here
return
fi
Expand Down
3 changes: 2 additions & 1 deletion app/conode/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func Validation(keyFile string) {
// Then wait for the connection

// Accept incoming connections
ln, err := net.Listen("tcp", addr)
global, _ := cliutils.GlobalBind(addr)
ln, err := net.Listen("tcp", global)
if err != nil {
dbg.Fatal("Could not listen for validation : ", err)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/coconet/gohost.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func (h *GoHost) PutDown(ctx context.Context, view int, data []BinaryMarshaler)

// Get returns two channels. One of messages that are received, and another of errors
// associated with each message.
func (h *GoHost) Get() chan NetworkMessg {
func (h *GoHost) GetNetworkMessg() chan NetworkMessg {
return h.msgchan
}

Expand Down
2 changes: 1 addition & 1 deletion lib/coconet/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type Host interface {
// Multiple listeners will receive disjoint sets of messages.
// When receiving from the channels always recieve from both the network
// messages channel as well as the error channel.
Get() chan NetworkMessg
GetNetworkMessg() chan NetworkMessg

// Connect connects to the parent in the given view.
Connect(view int) error
Expand Down
2 changes: 1 addition & 1 deletion lib/coconet/tcphost.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ func (h *TCPHost) PutDown(ctx context.Context, view int, data []BinaryMarshaler)
//
// TODO: each of these goroutines could be spawned when we initally connect to
// them instead.
func (h *TCPHost) Get() chan NetworkMessg {
func (h *TCPHost) GetNetworkMessg() chan NetworkMessg {
return h.msgchan
}

Expand Down
4 changes: 3 additions & 1 deletion lib/network/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os"
"reflect"
"time"
"github.com/dedis/cothority/lib/cliutils"
)

/// Encoding part ///
Expand Down Expand Up @@ -288,7 +289,8 @@ func (t *TcpHost) Open(name string) Conn {
// Listen for any host trying to contact him.
// Will launch in a goroutine the srv function once a connection is established
func (t *TcpHost) Listen(addr string, fn func(Conn)) {
ln, err := net.Listen("tcp", addr)
global, _ := cliutils.GlobalBind(addr)
ln, err := net.Listen("tcp", global)
if err != nil {
fmt.Printf("error listening (host %s)\n", t.name)
}
Expand Down
4 changes: 2 additions & 2 deletions proto/sign/collectiveSigning.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
// 4. Response

// Get multiplexes all messages from TCPHost using application logic
func (sn *Node) get() error {
func (sn *Node) getMessages() error {
dbg.Lvl4(sn.Name(), "getting")
defer dbg.Lvl4(sn.Name(), "done getting")

sn.UpdateTimeout()
dbg.Lvl4("Going to get", sn.Name())
msgchan := sn.Host.Get()
msgchan := sn.Host.GetNetworkMessg()
// heartbeat for intiating viewChanges, allows intial 500s setup time
/* sn.hbLock.Lock()
sn.heartbeat = time.NewTimer(500 * time.Second)
Expand Down
2 changes: 1 addition & 1 deletion proto/sign/signingNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (sn *Node) Listen() error {
if sn.Pool() == nil {
sn.GenSetPool()
}
err := sn.get()
err := sn.getMessages()
return err
}

Expand Down

0 comments on commit 8b315d0

Please sign in to comment.