Skip to content
Snippets Groups Projects
Select Git revision
  • 2eb421ce730ff2887a8499728f84c2246dd37137
  • release default protected
  • 11-22-implement-kv-interface-defined-in-collectiveversionedkvgo
  • hotfix/TestHostPool_UpdateNdf_AddFilter
  • XX-4719/announcementChannels
  • xx-4717/logLevel
  • jonah/noob-channel
  • master protected
  • XX-4707/tagDiskJson
  • xx-4698/notification-retry
  • hotfix/notifylockup
  • syncNodes
  • hotfix/localCB
  • XX-4677/NewChanManagerMobile
  • XX-4689/DmSync
  • duplicatePrefix
  • XX-4601/HavenInvites
  • finalizedUICallbacks
  • XX-4673/AdminKeySync
  • debugNotifID
  • anne/test
  • v4.7.5
  • v4.7.4
  • v4.7.3
  • v4.7.2
  • v4.7.1
  • v4.6.3
  • v4.6.1
  • v4.5.0
  • v4.4.4
  • v4.3.11
  • v4.3.8
  • v4.3.7
  • v4.3.6
  • v4.3.5
  • v4.2.0
  • v4.3.0
  • v4.3.4
  • v4.3.3
  • v4.3.2
  • v4.3.1
41 results

manager.go

Blame
  • callbacks.go 2.60 KiB
    ///////////////////////////////////////////////////////////////////////////////
    // Copyright © 2020 xx network SEZC                                          //
    //                                                                           //
    // Use of this source code is governed by a license that can be found in the //
    // LICENSE file                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    
    // callbacks.go implements all of the required api callbacks for the cli
    package cmd
    
    import (
    	"fmt"
    
    	"github.com/spf13/viper"
    	"gitlab.com/elixxir/client/xxdk"
    
    	jww "github.com/spf13/jwalterweatherman"
    	"gitlab.com/elixxir/client/catalog"
    	"gitlab.com/elixxir/client/cmix/identity/receptionID"
    	"gitlab.com/elixxir/client/cmix/rounds"
    	"gitlab.com/elixxir/client/e2e/receive"
    	"gitlab.com/elixxir/crypto/contact"
    	"gitlab.com/xx_network/primitives/id"
    )
    
    // authCallbacks implements the auth.Callbacks interface.
    type authCallbacks struct {
    	autoConfirm bool
    	confCh      chan *id.ID
    	params      xxdk.E2EParams
    }
    
    func makeAuthCallbacks(autoConfirm bool, params xxdk.E2EParams) *authCallbacks {
    	return &authCallbacks{
    		autoConfirm: autoConfirm,
    		confCh:      make(chan *id.ID, 10),
    		params:      params,
    	}
    }
    
    func (a *authCallbacks) Request(requestor contact.Contact,
    	receptionID receptionID.EphemeralIdentity,
    	round rounds.Round, client *xxdk.E2e) {
    	msg := fmt.Sprintf("Authentication channel request from: %s\n",
    		requestor.ID)
    	jww.INFO.Printf(msg)
    	fmt.Printf(msg)
    	if a.autoConfirm {
    		jww.INFO.Printf("Channel Request: %s",
    			requestor.ID)
    		if viper.GetBool("verify-sends") { // Verify message sends were successful
    			acceptChannelVerified(client, requestor.ID, a.params)
    		} else {
    			acceptChannel(client, requestor.ID)
    		}
    
    		a.confCh <- requestor.ID
    	}
    
    }
    
    func (a *authCallbacks) Confirm(requestor contact.Contact,
    	receptionID receptionID.EphemeralIdentity,
    	round rounds.Round, client *xxdk.E2e) {
    	jww.INFO.Printf("Channel Confirmed: %s", requestor.ID)
    	a.confCh <- requestor.ID
    }
    
    func (a *authCallbacks) Reset(requestor contact.Contact,
    	receptionID receptionID.EphemeralIdentity,
    	round rounds.Round, client *xxdk.E2e) {
    	msg := fmt.Sprintf("Authentication channel reset from: %s\n",
    		requestor.ID)
    	jww.INFO.Printf(msg)
    	fmt.Printf(msg)
    }
    
    func registerMessageListener(client *xxdk.E2e) chan receive.Message {
    	recvCh := make(chan receive.Message, 10000)
    	listenerID := client.GetE2E().RegisterChannel("DefaultCLIReceiver",
    		receive.AnyUser(), catalog.NoType, recvCh)
    	jww.INFO.Printf("Message ListenerID: %v", listenerID)
    	return recvCh
    }