浏览代码

:art: Enhance CLI help and loglevels

Ettore Di Giacinto 3 年之前
父节点
当前提交
9d2e6df97c
共有 9 个文件被更改,包括 138 次插入48 次删除
  1. 3 0
      cmd/api.go
  2. 33 6
      cmd/file.go
  3. 2 0
      cmd/join.go
  4. 12 7
      cmd/main.go
  5. 39 9
      cmd/service.go
  6. 7 0
      cmd/util.go
  7. 9 10
      pkg/edgevpn/edgevpn.go
  8. 14 5
      pkg/edgevpn/files.go
  9. 19 11
      pkg/edgevpn/services.go

+ 3 - 0
cmd/api.go

@@ -15,11 +15,14 @@ func API() cli.Command {
 			&cli.StringFlag{
 			&cli.StringFlag{
 				Name:  "listen",
 				Name:  "listen",
 				Value: ":8080",
 				Value: ":8080",
+				Usage: "Listening address",
 			},
 			},
 		),
 		),
 		Action: func(c *cli.Context) error {
 		Action: func(c *cli.Context) error {
 			e := edgevpn.New(cliToOpts(c)...)
 			e := edgevpn.New(cliToOpts(c)...)
 
 
+			displayStart(e)
+
 			mw, err := e.MessageWriter()
 			mw, err := e.MessageWriter()
 			if err != nil {
 			if err != nil {
 				return err
 				return err

+ 33 - 6
cmd/file.go

@@ -9,14 +9,28 @@ import (
 func FileSend() cli.Command {
 func FileSend() cli.Command {
 	return cli.Command{
 	return cli.Command{
 		Name:        "file-send",
 		Name:        "file-send",
-		Description: "send a file to the network",
+		Aliases:     []string{"fs"},
+		Usage:       "Serve a file to the network",
+		Description: `Serve a file to the network without connecting over VPN`,
+		UsageText:   "edgevpn file-send --name 'unique-id' --path '/src/path'",
 		Flags: append(CommonFlags,
 		Flags: append(CommonFlags,
-			cli.StringFlag{Name: "name"},
-			cli.StringFlag{Name: "path"},
+			cli.StringFlag{
+				Name:     "name",
+				Required: true,
+				Usage: `Unique name of the file to be served over the network. 
+This is also the ID used to refer when receiving it.`,
+			},
+			cli.StringFlag{
+				Name:     "path",
+				Usage:    `File to serve`,
+				Required: true,
+			},
 		),
 		),
 		Action: func(c *cli.Context) error {
 		Action: func(c *cli.Context) error {
 			e := edgevpn.New(cliToOpts(c)...)
 			e := edgevpn.New(cliToOpts(c)...)
 
 
+			displayStart(e)
+
 			mw, err := e.MessageWriter()
 			mw, err := e.MessageWriter()
 			if err != nil {
 			if err != nil {
 				return err
 				return err
@@ -40,14 +54,27 @@ func FileSend() cli.Command {
 func FileReceive() cli.Command {
 func FileReceive() cli.Command {
 	return cli.Command{
 	return cli.Command{
 		Name:        "file-receive",
 		Name:        "file-receive",
-		Description: "receive a file locally",
+		Aliases:     []string{"fr"},
+		Usage:       "Receive a file which is served from the network",
+		Description: `Receive a file from the network without connecting over VPN`,
+		UsageText:   "edgevpn file-receive --name 'unique-id' --path '/dst/path'",
 		Flags: append(CommonFlags,
 		Flags: append(CommonFlags,
-			cli.StringFlag{Name: "name"},
-			cli.StringFlag{Name: "path"},
+			cli.StringFlag{
+				Name:     "name",
+				Usage:    `Unique name of the file to be received over the network.`,
+				Required: true,
+			},
+			cli.StringFlag{
+				Name:     "path",
+				Usage:    `Destination where to save the file`,
+				Required: true,
+			},
 		),
 		),
 		Action: func(c *cli.Context) error {
 		Action: func(c *cli.Context) error {
 			e := edgevpn.New(cliToOpts(c)...)
 			e := edgevpn.New(cliToOpts(c)...)
 
 
+			displayStart(e)
+
 			mw, err := e.MessageWriter()
 			mw, err := e.MessageWriter()
 			if err != nil {
 			if err != nil {
 				return err
 				return err

+ 2 - 0
cmd/join.go

@@ -14,6 +14,8 @@ func Join() cli.Command {
 		Action: func(c *cli.Context) error {
 		Action: func(c *cli.Context) error {
 			e := edgevpn.New(cliToOpts(c)...)
 			e := edgevpn.New(cliToOpts(c)...)
 
 
+			displayStart(e)
+
 			mw, err := e.MessageWriter()
 			mw, err := e.MessageWriter()
 			if err != nil {
 			if err != nil {
 				return err
 				return err

+ 12 - 7
cmd/main.go

@@ -1,10 +1,10 @@
 package cmd
 package cmd
 
 
 import (
 import (
+	"encoding/base64"
 	"fmt"
 	"fmt"
 	"os"
 	"os"
 
 
-	"github.com/mudler/edgevpn/internal"
 	"github.com/mudler/edgevpn/pkg/edgevpn"
 	"github.com/mudler/edgevpn/pkg/edgevpn"
 	"github.com/urfave/cli"
 	"github.com/urfave/cli"
 	"gopkg.in/yaml.v2"
 	"gopkg.in/yaml.v2"
@@ -45,6 +45,10 @@ func MainFlags() []cli.Flag {
 			Name:  "g",
 			Name:  "g",
 			Usage: "Generates a new configuration and prints it on screen",
 			Usage: "Generates a new configuration and prints it on screen",
 		},
 		},
+		&cli.BoolFlag{
+			Name:  "b",
+			Usage: "Encodes the new config in base64, so it can be used as a token",
+		},
 		&cli.StringFlag{
 		&cli.StringFlag{
 			Name:   "address",
 			Name:   "address",
 			Usage:  "VPN virtual address",
 			Usage:  "VPN virtual address",
@@ -75,17 +79,18 @@ func Main() func(c *cli.Context) error {
 				os.Exit(1)
 				os.Exit(1)
 			}
 			}
 
 
-			fmt.Println(string(bytesData))
+			if c.Bool("b") {
+				fmt.Print(base64.StdEncoding.EncodeToString(bytesData))
+			} else {
+				fmt.Println(string(bytesData))
+			}
+
 			os.Exit(0)
 			os.Exit(0)
 		}
 		}
 
 
 		e := edgevpn.New(cliToOpts(c)...)
 		e := edgevpn.New(cliToOpts(c)...)
 
 
-		e.Logger().Info(Copyright)
-
-		e.Logger().Infof("Version: %s commit: %s", internal.Version, internal.Commit)
-
-		e.Logger().Info("Start")
+		displayStart(e)
 
 
 		if err := e.Start(); err != nil {
 		if err := e.Start(); err != nil {
 			e.Logger().Fatal(err.Error())
 			e.Logger().Fatal(err.Error())

+ 39 - 9
cmd/service.go

@@ -8,15 +8,30 @@ import (
 
 
 func ServiceAdd() cli.Command {
 func ServiceAdd() cli.Command {
 	return cli.Command{
 	return cli.Command{
-		Name:        "service-add",
-		Description: "expose a service to the network",
+		Name:    "service-add",
+		Aliases: []string{"sa"},
+		Usage:   "Expose a service to the network without creating a VPN",
+		Description: `Expose a local or a remote endpoint connection as a service in the VPN. 
+		The host will act as a proxy between the service and the connection`,
+		UsageText: "edgevpn service-add --name 'unique-id' --remoteaddress 'ip:port'",
 		Flags: append(CommonFlags,
 		Flags: append(CommonFlags,
-			cli.StringFlag{Name: "name"},
-			cli.StringFlag{Name: "remoteaddress"},
+			cli.StringFlag{
+				Name:     "name",
+				Usage:    `Unique name of the service to be server over the network.`,
+				Required: true,
+			},
+			cli.StringFlag{
+				Name:     "remoteaddress",
+				Required: true,
+				Usage: `Remote address that the service is running to. That can be a remote webserver, a local SSH server, etc.
+For example, '192.168.1.1:80', or '127.0.0.1:22'.`,
+			},
 		),
 		),
 		Action: func(c *cli.Context) error {
 		Action: func(c *cli.Context) error {
 			e := edgevpn.New(cliToOpts(c)...)
 			e := edgevpn.New(cliToOpts(c)...)
 
 
+			displayStart(e)
+
 			mw, err := e.MessageWriter()
 			mw, err := e.MessageWriter()
 			if err != nil {
 			if err != nil {
 				return err
 				return err
@@ -39,16 +54,31 @@ func ServiceAdd() cli.Command {
 
 
 func ServiceConnect() cli.Command {
 func ServiceConnect() cli.Command {
 	return cli.Command{
 	return cli.Command{
-		Name:        "service-connect",
-		Description: "bind a local port to connect to a remote service",
+		Aliases: []string{"sc"},
+		Usage:   "Connects to a service in the network without creating a VPN",
+		Name:    "service-connect",
+		Description: `Bind a local port to connect to a remote service in the network.
+Creates a local listener which connects over the service in the network without creating a VPN.
+`,
+		UsageText: "edgevpn service-connect --name 'unique-id' --srcaddress '(ip):port'",
 		Flags: append(CommonFlags,
 		Flags: append(CommonFlags,
-			cli.StringFlag{Name: "name"},
-
-			cli.StringFlag{Name: "srcaddress"},
+			cli.StringFlag{
+				Name:     "name",
+				Usage:    `Unique name of the service in the network.`,
+				Required: true,
+			},
+			cli.StringFlag{
+				Name: "srcaddress",
+				Usage: `Address where to bind locally. E.g. ':8080'. A proxy will be created
+to the service over the network`,
+				Required: true,
+			},
 		),
 		),
 		Action: func(c *cli.Context) error {
 		Action: func(c *cli.Context) error {
 			e := edgevpn.New(cliToOpts(c)...)
 			e := edgevpn.New(cliToOpts(c)...)
 
 
+			displayStart(e)
+
 			mw, err := e.MessageWriter()
 			mw, err := e.MessageWriter()
 			if err != nil {
 			if err != nil {
 				return err
 				return err

+ 7 - 0
cmd/util.go

@@ -2,12 +2,19 @@ package cmd
 
 
 import (
 import (
 	"github.com/ipfs/go-log"
 	"github.com/ipfs/go-log"
+	"github.com/mudler/edgevpn/internal"
 	"github.com/mudler/edgevpn/pkg/edgevpn"
 	"github.com/mudler/edgevpn/pkg/edgevpn"
 	"github.com/mudler/edgevpn/pkg/logger"
 	"github.com/mudler/edgevpn/pkg/logger"
 	"github.com/songgao/water"
 	"github.com/songgao/water"
 	"github.com/urfave/cli"
 	"github.com/urfave/cli"
 )
 )
 
 
+func displayStart(e *edgevpn.EdgeVPN) {
+	e.Logger().Info(Copyright)
+
+	e.Logger().Infof("Version: %s commit: %s", internal.Version, internal.Commit)
+}
+
 func cliToOpts(c *cli.Context) []edgevpn.Option {
 func cliToOpts(c *cli.Context) []edgevpn.Option {
 	config := c.String("config")
 	config := c.String("config")
 	address := c.String("address")
 	address := c.String("address")

+ 9 - 10
pkg/edgevpn/edgevpn.go

@@ -59,7 +59,7 @@ func (e *EdgeVPN) Join(ledger *blockchain.Ledger) error {
 	// The ledger needs to read them and update the internal blockchain
 	// The ledger needs to read them and update the internal blockchain
 	e.config.Handlers = append(e.config.Handlers, ledger.Update)
 	e.config.Handlers = append(e.config.Handlers, ledger.Update)
 
 
-	e.config.Logger.Info("starting edgevpn")
+	e.config.Logger.Info("Starting EdgeVPN network")
 
 
 	// Startup libp2p network
 	// Startup libp2p network
 	err := e.startNetwork()
 	err := e.startNetwork()
@@ -193,7 +193,7 @@ func (e *EdgeVPN) readPackets(ledger *blockchain.Ledger, ifce *water.Interface)
 
 
 		header, err := ipv4.ParseHeader(frame)
 		header, err := ipv4.ParseHeader(frame)
 		if err != nil {
 		if err != nil {
-			e.config.Logger.Infof("could not parase ipv4 header from frame")
+			e.config.Logger.Debugf("could not parase ipv4 header from frame")
 			continue
 			continue
 		}
 		}
 
 
@@ -202,7 +202,7 @@ func (e *EdgeVPN) readPackets(ledger *blockchain.Ledger, ifce *water.Interface)
 		// Query the routing table
 		// Query the routing table
 		value, found := ledger.GetKey(MachinesLedgerKey, dst)
 		value, found := ledger.GetKey(MachinesLedgerKey, dst)
 		if !found {
 		if !found {
-			e.config.Logger.Infof("'%s' not found in the routing table", dst)
+			e.config.Logger.Debugf("'%s' not found in the routing table", dst)
 			continue
 			continue
 		}
 		}
 		machine := &types.Machine{}
 		machine := &types.Machine{}
@@ -211,14 +211,14 @@ func (e *EdgeVPN) readPackets(ledger *blockchain.Ledger, ifce *water.Interface)
 		// Decode the Peer
 		// Decode the Peer
 		d, err := peer.Decode(machine.PeerID)
 		d, err := peer.Decode(machine.PeerID)
 		if err != nil {
 		if err != nil {
-			e.config.Logger.Infof("could not decode peer '%s'", value)
+			e.config.Logger.Debugf("could not decode peer '%s'", value)
 			continue
 			continue
 		}
 		}
 
 
 		// Open a stream
 		// Open a stream
 		stream, err := e.host.NewStream(ctx, d, Protocol)
 		stream, err := e.host.NewStream(ctx, d, Protocol)
 		if err != nil {
 		if err != nil {
-			e.config.Logger.Infof("could not open stream '%s'", err.Error())
+			e.config.Logger.Debugf("could not open stream '%s'", err.Error())
 			continue
 			continue
 		}
 		}
 		stream.Write(frame)
 		stream.Write(frame)
@@ -232,7 +232,7 @@ func (e *EdgeVPN) Logger() log.StandardLogger {
 
 
 func (e *EdgeVPN) startNetwork() error {
 func (e *EdgeVPN) startNetwork() error {
 	ctx := context.Background()
 	ctx := context.Background()
-	e.config.Logger.Info("generating host data")
+	e.config.Logger.Debug("Generating host data")
 
 
 	host, err := e.genHost(ctx)
 	host, err := e.genHost(ctx)
 	if err != nil {
 	if err != nil {
@@ -245,8 +245,8 @@ func (e *EdgeVPN) startNetwork() error {
 		host.SetStreamHandler(pid, network.StreamHandler(strh))
 		host.SetStreamHandler(pid, network.StreamHandler(strh))
 	}
 	}
 
 
-	e.config.Logger.Info("Host created. We are:", host.ID())
-	e.config.Logger.Info(host.Addrs())
+	e.config.Logger.Info("Node ID:", host.ID())
+	e.config.Logger.Info("Node Addresses:", host.Addrs())
 
 
 	// create a new PubSub service using the GossipSub router
 	// create a new PubSub service using the GossipSub router
 	ps, err := pubsub.NewGossipSub(ctx, host, pubsub.WithMaxMessageSize(e.config.MaxMessageSize))
 	ps, err := pubsub.NewGossipSub(ctx, host, pubsub.WithMaxMessageSize(e.config.MaxMessageSize))
@@ -268,9 +268,8 @@ func (e *EdgeVPN) startNetwork() error {
 		}
 		}
 	}
 	}
 
 
-	e.config.Logger.Info("starting event handler")
 	go e.handleEvents(ctx)
 	go e.handleEvents(ctx)
-	e.config.Logger.Info("started event handler successfully")
 
 
+	e.Logger().Debug("Network started")
 	return nil
 	return nil
 }
 }

+ 14 - 5
pkg/edgevpn/files.go

@@ -19,6 +19,9 @@ const (
 )
 )
 
 
 func (e *EdgeVPN) SendFile(ledger *blockchain.Ledger, fileID, filepath string) error {
 func (e *EdgeVPN) SendFile(ledger *blockchain.Ledger, fileID, filepath string) error {
+
+	e.Logger().Infof("Serving '%s' as '%s", filepath, fileID)
+
 	// By announcing periodically our service to the blockchain
 	// By announcing periodically our service to the blockchain
 	ledger.Announce(
 	ledger.Announce(
 		context.Background(),
 		context.Background(),
@@ -44,7 +47,7 @@ func (e *EdgeVPN) SendFile(ledger *blockchain.Ledger, fileID, filepath string) e
 	//    which connect to the given address/Port and Send what we receive from the Stream.
 	//    which connect to the given address/Port and Send what we receive from the Stream.
 	e.config.StreamHandlers[protocol.ID(FileProtocol)] = func(stream network.Stream) {
 	e.config.StreamHandlers[protocol.ID(FileProtocol)] = func(stream network.Stream) {
 		go func() {
 		go func() {
-			e.config.Logger.Info("Received connection from", stream.Conn().RemotePeer().String())
+			e.config.Logger.Infof("(file %s) Received connection from %s", fileID, stream.Conn().RemotePeer().String())
 
 
 			// Retrieve current ID for ip in the blockchain
 			// Retrieve current ID for ip in the blockchain
 			_, found := ledger.GetKey(UsersLedgerKey, stream.Conn().RemotePeer().String())
 			_, found := ledger.GetKey(UsersLedgerKey, stream.Conn().RemotePeer().String())
@@ -63,7 +66,7 @@ func (e *EdgeVPN) SendFile(ledger *blockchain.Ledger, fileID, filepath string) e
 
 
 			stream.Close()
 			stream.Close()
 
 
-			e.config.Logger.Info("Done", stream.Conn().RemotePeer().String())
+			e.config.Logger.Infof("(file %s) Done handling %s", fileID, stream.Conn().RemotePeer().String())
 
 
 		}()
 		}()
 	}
 	}
@@ -93,6 +96,9 @@ func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path str
 	)
 	)
 	for {
 	for {
 		time.Sleep(5 * time.Second)
 		time.Sleep(5 * time.Second)
+
+		e.config.Logger.Debug("Attempting to find file in the blockchain")
+
 		_, found := ledger.GetKey(UsersLedgerKey, e.host.ID().String())
 		_, found := ledger.GetKey(UsersLedgerKey, e.host.ID().String())
 		if !found {
 		if !found {
 			continue
 			continue
@@ -102,7 +108,7 @@ func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path str
 		existingValue.Unmarshal(fi)
 		existingValue.Unmarshal(fi)
 		// If mismatch, update the blockchain
 		// If mismatch, update the blockchain
 		if !found {
 		if !found {
-			e.config.Logger.Info("file not found on blockchain")
+			e.config.Logger.Debug("file not found on blockchain, retrying in 5 seconds")
 			continue
 			continue
 		} else {
 		} else {
 			break
 			break
@@ -114,10 +120,12 @@ func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path str
 	existingValue, found := ledger.GetKey(FilesLedgerKey, fileID)
 	existingValue, found := ledger.GetKey(FilesLedgerKey, fileID)
 	fi := &types.File{}
 	fi := &types.File{}
 	existingValue.Unmarshal(fi)
 	existingValue.Unmarshal(fi)
+
 	// If mismatch, update the blockchain
 	// If mismatch, update the blockchain
 	if !found {
 	if !found {
 		return errors.New("file not found")
 		return errors.New("file not found")
 	}
 	}
+
 	// Decode the Peer
 	// Decode the Peer
 	d, err := peer.Decode(fi.PeerID)
 	d, err := peer.Decode(fi.PeerID)
 	if err != nil {
 	if err != nil {
@@ -129,7 +137,7 @@ func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path str
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	e.config.Logger.Info("Saving file")
+	e.config.Logger.Infof("Saving file %s to %s", fileID, path)
 
 
 	f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
 	f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
 	if err != nil {
 	if err != nil {
@@ -139,6 +147,7 @@ func (e *EdgeVPN) ReceiveFile(ledger *blockchain.Ledger, fileID string, path str
 	io.Copy(f, stream)
 	io.Copy(f, stream)
 
 
 	f.Close()
 	f.Close()
-	e.config.Logger.Info("received", fileID)
+
+	e.config.Logger.Infof("Received file %s to %s", fileID, path)
 	return nil
 	return nil
 }
 }

+ 19 - 11
pkg/edgevpn/services.go

@@ -19,6 +19,9 @@ const (
 )
 )
 
 
 func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress string) {
 func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress string) {
+
+	e.Logger().Infof("Exposing service '%s' (%s)", serviceID, dstaddress)
+
 	// 1) Register the ServiceID <-> PeerID Association
 	// 1) Register the ServiceID <-> PeerID Association
 	// By announcing periodically our service to the blockchain
 	// By announcing periodically our service to the blockchain
 	ledger.Announce(
 	ledger.Announce(
@@ -42,13 +45,13 @@ func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress
 	//    which connect to the given address/Port and Send what we receive from the Stream.
 	//    which connect to the given address/Port and Send what we receive from the Stream.
 	e.config.StreamHandlers[protocol.ID(ServiceProtocol)] = func(stream network.Stream) {
 	e.config.StreamHandlers[protocol.ID(ServiceProtocol)] = func(stream network.Stream) {
 		go func() {
 		go func() {
-			e.config.Logger.Info("Received connection from", stream.Conn().RemotePeer().String())
+			e.config.Logger.Infof("(service %s) Received connection from %s", serviceID, stream.Conn().RemotePeer().String())
 
 
 			// Retrieve current ID for ip in the blockchain
 			// Retrieve current ID for ip in the blockchain
 			_, found := ledger.GetKey(UsersLedgerKey, stream.Conn().RemotePeer().String())
 			_, found := ledger.GetKey(UsersLedgerKey, stream.Conn().RemotePeer().String())
 			// If mismatch, update the blockchain
 			// If mismatch, update the blockchain
 			if !found {
 			if !found {
-				e.config.Logger.Info("Reset", stream.Conn().RemotePeer().String(), "Not found in the ledger")
+				e.config.Logger.Debugf("Reset '%s': not found in the ledger", stream.Conn().RemotePeer().String())
 				stream.Reset()
 				stream.Reset()
 				return
 				return
 			}
 			}
@@ -58,7 +61,7 @@ func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress
 
 
 			c, err := net.Dial("tcp", dstaddress)
 			c, err := net.Dial("tcp", dstaddress)
 			if err != nil {
 			if err != nil {
-				e.config.Logger.Info("Reset", stream.Conn().RemotePeer().String(), err.Error())
+				e.config.Logger.Debugf("Reset %s: %s", stream.Conn().RemotePeer().String(), err.Error())
 				stream.Reset()
 				stream.Reset()
 				return
 				return
 			}
 			}
@@ -70,19 +73,19 @@ func (e *EdgeVPN) ExposeService(ledger *blockchain.Ledger, serviceID, dstaddress
 			stream.Close()
 			stream.Close()
 			c.Close()
 			c.Close()
 
 
-			e.config.Logger.Info("Done", stream.Conn().RemotePeer().String())
-
+			e.config.Logger.Info("(service %s) Handled correctly '%s'", serviceID, stream.Conn().RemotePeer().String())
 		}()
 		}()
 	}
 	}
 }
 }
 
 
 func (e *EdgeVPN) ConnectToService(ledger *blockchain.Ledger, serviceID string, srcaddr string) error {
 func (e *EdgeVPN) ConnectToService(ledger *blockchain.Ledger, serviceID string, srcaddr string) error {
+
 	// Open local port for listening
 	// Open local port for listening
 	l, err := net.Listen("tcp", srcaddr)
 	l, err := net.Listen("tcp", srcaddr)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	e.config.Logger.Info("Listening on ", srcaddr)
+	e.Logger().Info("Binding local port on", srcaddr)
 
 
 	// Announce ourselves so nodes accepts our connection
 	// Announce ourselves so nodes accepts our connection
 	ledger.Announce(
 	ledger.Announce(
@@ -110,6 +113,7 @@ func (e *EdgeVPN) ConnectToService(ledger *blockchain.Ledger, serviceID string,
 			e.config.Logger.Error("Error accepting: ", err.Error())
 			e.config.Logger.Error("Error accepting: ", err.Error())
 			continue
 			continue
 		}
 		}
+
 		e.config.Logger.Info("New connection from", l.Addr().String())
 		e.config.Logger.Info("New connection from", l.Addr().String())
 		// Handle connections in a new goroutine, forwarding to the p2p service
 		// Handle connections in a new goroutine, forwarding to the p2p service
 		go func() {
 		go func() {
@@ -119,23 +123,27 @@ func (e *EdgeVPN) ConnectToService(ledger *blockchain.Ledger, serviceID string,
 			existingValue.Unmarshal(service)
 			existingValue.Unmarshal(service)
 			// If mismatch, update the blockchain
 			// If mismatch, update the blockchain
 			if !found {
 			if !found {
-				e.config.Logger.Info("service not found on blockchain")
+				conn.Close()
+				e.config.Logger.Debugf("service '%s' not found on blockchain", serviceID)
 				return
 				return
 			}
 			}
+
 			// Decode the Peer
 			// Decode the Peer
 			d, err := peer.Decode(service.PeerID)
 			d, err := peer.Decode(service.PeerID)
 			if err != nil {
 			if err != nil {
-				e.config.Logger.Infof("could not decode peer '%s'", service.PeerID)
+				conn.Close()
+				e.config.Logger.Debugf("could not decode peer '%s'", service.PeerID)
 				return
 				return
 			}
 			}
 
 
 			// Open a stream
 			// Open a stream
 			stream, err := e.host.NewStream(context.Background(), d, ServiceProtocol)
 			stream, err := e.host.NewStream(context.Background(), d, ServiceProtocol)
 			if err != nil {
 			if err != nil {
-				e.config.Logger.Infof("could not open stream '%s'", err.Error())
+				conn.Close()
+				e.config.Logger.Debugf("could not open stream '%s'", err.Error())
 				return
 				return
 			}
 			}
-			e.config.Logger.Info("Redirecting", l.Addr().String(), "to", serviceID)
+			e.config.Logger.Debugf("(service %s) Redirecting", serviceID, l.Addr().String())
 
 
 			closer := make(chan struct{}, 2)
 			closer := make(chan struct{}, 2)
 			go copyStream(closer, stream, conn)
 			go copyStream(closer, stream, conn)
@@ -144,7 +152,7 @@ func (e *EdgeVPN) ConnectToService(ledger *blockchain.Ledger, serviceID string,
 
 
 			stream.Close()
 			stream.Close()
 			conn.Close()
 			conn.Close()
-			e.config.Logger.Info("Done handling", l.Addr().String(), "to", serviceID)
+			e.config.Logger.Infof("(service %s) Done handling %s", serviceID, l.Addr().String())
 		}()
 		}()
 	}
 	}
 }
 }