node

package
v0.0.0-...-de12d8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DomNameMgrInitTimeout = 3 * time.Second // TODO tune
View Source
const G_MaxNetworkTimeout = 4 * time.Second // TODO PUT IN CONSTS
View Source
const ModInitTimeout = 3 * time.Second // TODO tune

Variables

View Source
var G_ConfigMgr = newConfigMgr() // TODO use mod_init
View Source
var G_HandshakeMgr = newHandshakeMgr() // TODO USE MODINIT
View Source
var G_ValidClientDomains LocklessMap

Functions

func Boole2Byte

func Boole2Byte(b bool) (ret byte)

func Byte2Boole

func Byte2Boole(b byte) (ret bool)

func ClientDomainIsValid

func ClientDomainIsValid(domain string) (ok bool)

func FindPeer

func FindPeer(ctx context.Context, pid peer.ID) (pAddrInfo peer.AddrInfo,
	err error)

func G_pubSub

func G_pubSub() (p *pubSub)

func GenerateAndSaveKeypair

func GenerateAndSaveKeypair(filename string) (err error)

func GetDomainNames

func GetDomainNames() (names []string)

func GoodPrivKeyLen

func GoodPrivKeyLen(pk ed25519.PrivateKey) (ok bool)

func GoodPubKeyLen

func GoodPubKeyLen(pk ed25519.PublicKey) (ok bool)

func Hash

func Hash(b ...[]byte) (h []byte)

func Home_Dir

func Home_Dir() (hd string, err error)

func PubSubGetTopics

func PubSubGetTopics() (ls []string)

func PubSubTopicHashed

func PubSubTopicHashed(str string) (r string)

func Publish

func Publish(topic string, data []byte) (err error)

func SESH_Config_Path

func SESH_Config_Path() (cp string, err error)

func SESH_Path

func SESH_Path() (sp string, err error)

func SaveConfig

func SaveConfig(conf interface{}) (err error)

func ServeDomain

func ServeDomain(domainName string)

func SetStreamHandler

func SetStreamHandler()

func Sign

func Sign(pk *ed25519.PrivateKey, message []byte) (sig []byte, err error)

func StartHandshake

func StartHandshake(domainName string) chan *ConnBundle

func StartStream

func StartStream(
	ctx context.Context, pid peer.ID) (s network.Stream, err error)

func StreamHandler

func StreamHandler(s network.Stream)

func Subscribe

func Subscribe(topic, alertName string) (err error)

func VerifySig

func VerifySig(pk *ed25519.PublicKey, message, sig []byte) (ok bool)

Types

type Client

type Client struct {
	Domains []*DomainNKeyfile `json:"domains"`
}

type Config

type Config struct {
	Client *Client `json:"client"`
	Server *Server `json:"server"`
}

type Conn

type Conn struct {
	S network.Stream
}

func StreamToConn

func StreamToConn(s network.Stream) (c *Conn)

func (Conn) Close

func (c Conn) Close() (err error)

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() (addr net.Addr)

func (*Conn) Read

func (c *Conn) Read(b []byte) (int, error)

func (Conn) RemoteAddr

func (c Conn) RemoteAddr() (addr net.Addr)

func (Conn) SetDeadline

func (c Conn) SetDeadline(t time.Time) (err error)

func (Conn) SetReadDeadline

func (c Conn) SetReadDeadline(t time.Time) (err error)

func (Conn) SetWriteDeadline

func (c Conn) SetWriteDeadline(t time.Time) (err error)

func (*Conn) Write

func (c *Conn) Write(b []byte) (int, error)

type ConnBundle

type ConnBundle struct {
	Conn   net.Conn
	StopCH (chan bool)
}

type DomName

type DomName struct {
	// contains filtered or unexported fields
}

type DomNameMgr

type DomNameMgr struct {
	// contains filtered or unexported fields
}

func G_DomNameMgr

func G_DomNameMgr() (m *DomNameMgr)

type DomainNKeyfile

type DomainNKeyfile struct {
	Domain  string `json:"domain"`
	Keyfile string `json:"keyfile"`
}

type Handshake

type Handshake struct {
	DomainName   string
	Nonce        []byte
	Challenge    []byte
	PubKey       *ed25519.PublicKey
	StopChnl     (chan bool)
	LastTouch    time.Time
	ConnBundleCH (chan *ConnBundle)
}

type HandshakeMgr

type HandshakeMgr struct {
	DomainName2Handshake LocklessMap // map[string]*Handshake
	Nonce2Handshake      LocklessMap // map[string]*Handshake
}

func (*HandshakeMgr) SendStop

func (m *HandshakeMgr) SendStop(domainName string)

func (*HandshakeMgr) Stop

func (m *HandshakeMgr) Stop(domainName string) <-chan bool

type HandshakePacket

type HandshakePacket struct {
	DomainName string
	Nonce      []byte
	Hash       []byte
	Challenge  []byte
	Signature  []byte
	PubKey     *ed25519.PublicKey
}

func Slice2HandshakePacket

func Slice2HandshakePacket(b []byte) (hp *HandshakePacket, err error)

func (*HandshakePacket) Bytes

func (hp *HandshakePacket) Bytes() (b []byte)

type IpfsNode

type IpfsNode core.IpfsNode

func G_Node

func G_Node() (n *IpfsNode)

type SESH_FILETYPE

type SESH_FILETYPE byte
const (
	UNKNOWN SESH_FILETYPE = iota
	PRIV
	PUB
	CONFIG
)

type SSHMgr

type SSHMgr struct {
	Domains        *domains
	Authorized     *authorized
	PubKey2PrivKey LocklessMap
}

func (*SSHMgr) DumpPubKeys

func (s *SSHMgr) DumpPubKeys(domainName string) (pks []*ed25519.PublicKey)

func (*SSHMgr) ImportPrivKey

func (s *SSHMgr) ImportPrivKey(
	domainName string, priv ed25519.PrivateKey) (err error)

func (*SSHMgr) ImportPubKey

func (s *SSHMgr) ImportPubKey(
	domainName string, pub ed25519.PublicKey) (err error)

func (*SSHMgr) IsAuthorized

func (s *SSHMgr) IsAuthorized(pk *ed25519.PublicKey) (tf bool)

type Server

type Server struct {
	Authorized []*DomainNKeyfile `json:"authorized"`
}

type StreamStatus

type StreamStatus byte
const (
	HandshakeInitChallenge StreamStatus = iota
	HandshakeResponse
	HandshakeResult
	Shell
	Error
)

func (StreamStatus) Byte

func (ss StreamStatus) Byte() (b byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL