Formatting

This commit is contained in:
Sarah Jamie Lewis 2019-05-21 11:28:49 -07:00
parent b204353516
commit 9ed2848000
3 changed files with 3 additions and 9 deletions

View File

@ -1,6 +1,5 @@
package tapir
// Application defines the interface for all Tapir Applications
type Application interface {
NewInstance() Application

View File

@ -69,13 +69,13 @@ func client(acn connectivity.ACN, key ed25519.PublicKey) {
var client tapir.Service
client = new(tapir.BaseOnionService)
client.Start(acn, sk, id)
cid,_ := client.Connect(utils.GetTorV3Hostname(key), SimpleApp{})
cid, _ := client.Connect(utils.GetTorV3Hostname(key), SimpleApp{})
// Once connected, it shouldn't take long to authenticate and run the application. So for the purposes of this demo
// we will wait a little while then exit.
time.Sleep(time.Second * 5)
conn,_ := client.GetConnection(cid)
conn, _ := client.GetConnection(cid)
log.Debugf("Client has Auth: %v", conn.HasCapability(tapir.AuthCapability))
os.Exit(0)

View File

@ -15,7 +15,6 @@ import (
"sync"
)
// Service defines the interface for a Tapir Service
type Service interface {
Start(acn connectivity.ACN, privateKey ed25519.PrivateKey, identity identity.Identity)
@ -24,7 +23,6 @@ type Service interface {
GetConnection(connectionID string) (*Connection, error)
}
// Connection defines a Tapir Connection
type Connection struct {
hostname string
@ -99,7 +97,6 @@ func (c *Connection) SetEncryptionKey(key [32]byte) {
c.encrypted = true
}
// Send writes a given message to a Tapir packet (of 1024 bytes in length).
func (c *Connection) Send(message []byte) {
@ -129,7 +126,6 @@ type BaseOnionService struct {
privateKey ed25519.PrivateKey
}
// Start initializes a BaseOnionService with a given private key and identity
// The private key is needed to initialize the Onion listen socket, ideally we could just pass an Identity in here.
func (s *BaseOnionService) Start(acn connectivity.ACN, sk ed25519.PrivateKey, id identity.Identity) {
@ -140,10 +136,9 @@ func (s *BaseOnionService) Start(acn connectivity.ACN, sk ed25519.PrivateKey, id
s.privateKey = sk
}
// GetConnection returns a connection for a given hostname.
func (s *BaseOnionService) GetConnection(connectionID string) (*Connection, error) {
conn,ok := s.connections.Load(connectionID)
conn, ok := s.connections.Load(connectionID)
if !ok {
return nil, errors.New("no connection found")
}