working on host, tho there is host-node routing issue

This commit is contained in:
mykola2312 2025-01-12 02:58:54 +02:00
parent 164d23d28a
commit 0364776f81
2 changed files with 34 additions and 2 deletions

View file

@ -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
}

View file

@ -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()