working on host, tho there is host-node routing issue
This commit is contained in:
parent
164d23d28a
commit
0364776f81
2 changed files with 34 additions and 2 deletions
|
|
@ -1,9 +1,37 @@
|
|||
package host
|
||||
|
||||
import (
|
||||
"lux/crypto"
|
||||
"lux/net"
|
||||
)
|
||||
|
||||
type LuxHost struct {
|
||||
router net.LuxRouter
|
||||
// interface to get data for options. may be blocking
|
||||
type LuxOptionProvider interface {
|
||||
Provide() (LuxOption, error)
|
||||
}
|
||||
|
||||
type LuxHost struct {
|
||||
hostname string
|
||||
router net.LuxRouter
|
||||
providers []LuxOptionProvider
|
||||
}
|
||||
|
||||
func NewLuxHost(hostname string, hostKey crypto.LuxKey, ks crypto.LuxKeyStore) LuxHost {
|
||||
return LuxHost{
|
||||
hostname: hostname,
|
||||
router: net.NewLuxRouter(hostKey, ks),
|
||||
providers: make([]LuxOptionProvider, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (host *LuxHost) AddNode(chType net.LuxChannelType, udpAddr string) error {
|
||||
return host.router.CreateOutboundRoute(host.router.GetThisKey().Id, chType, udpAddr)
|
||||
}
|
||||
|
||||
func (host *LuxHost) AddOptionProvider(provider LuxOptionProvider) {
|
||||
host.providers = append(host.providers, provider)
|
||||
}
|
||||
|
||||
func (host *LuxHost) CaptureState() (LuxState, error) {
|
||||
return LuxState{}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ func NewLuxRouter(key crypto.LuxKey, ks crypto.LuxKeyStore) LuxRouter {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *LuxRouter) GetThisKey() crypto.LuxKey {
|
||||
return r.thisKey
|
||||
}
|
||||
|
||||
func (r *LuxRouter) addOutboundChannel(ch LuxChannel) *LuxChannel {
|
||||
r.channelLock.Lock()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue