net

package
v0.0.0-...-9853328 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Center = 0b01
	Worker = 0b10
)

Variables

This section is empty.

Functions

func New

func New(opts ...NodeOption)

func NewDirect

func NewDirect(opt *YockdClientOption) yocki.YockdClient

func OptionTransportCreds

func OptionTransportCreds(c, k string, cas ...string) grpc.DialOption

func ParseProto

func ParseProto[T yocki.Protocal](msg string) T

Types

type Context

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

type DeliveryClient

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

func NewDelivery

func NewDelivery(node string, promise yocki.Promise, e chan yocki.PromiseEvent) *DeliveryClient

func (*DeliveryClient) Call

func (c *DeliveryClient) Call(node, method string, args ...string) (string, error)

func (*DeliveryClient) Close

func (c *DeliveryClient) Close()

func (*DeliveryClient) Dial

func (c *DeliveryClient) Dial(form, to *pb.NodeInfo) error

func (*DeliveryClient) Download

func (c *DeliveryClient) Download(file string) error

func (*DeliveryClient) FileSystemGet

func (c *DeliveryClient) FileSystemGet(src, dst string) error

func (*DeliveryClient) FileSystemPut

func (c *DeliveryClient) FileSystemPut(src, dst string) error

func (*DeliveryClient) Info

func (c *DeliveryClient) Info() (string, error)

func (DeliveryClient) IsPublic

func (DeliveryClient) IsPublic() bool

func (*DeliveryClient) MakeTunnel

func (c *DeliveryClient) MakeTunnel(name string, ctx context.Context, p yocki.Promise, e chan yocki.PromiseEvent) error

func (*DeliveryClient) Mark

func (c *DeliveryClient) Mark(name, addr string) error

func (*DeliveryClient) Name

func (c *DeliveryClient) Name() string

func (*DeliveryClient) Ping

func (c *DeliveryClient) Ping() error

func (*DeliveryClient) ProcessFind

func (c *DeliveryClient) ProcessFind(pid int64, cmd string) ([]*pb.Process, error)

func (*DeliveryClient) ProcessKill

func (c *DeliveryClient) ProcessKill(pid int64) error

func (*DeliveryClient) ProcessList

func (c *DeliveryClient) ProcessList() ([]*pb.Process, error)

func (*DeliveryClient) ProcessSpawn

func (c *DeliveryClient) ProcessSpawn(t pb.ProcessSpawnType, spec, cmd string) (int64, error)

func (*DeliveryClient) SignalClear

func (c *DeliveryClient) SignalClear(sigs ...string) error

func (*DeliveryClient) SignalInfo

func (c *DeliveryClient) SignalInfo(sig string) (bool, bool, error)

func (*DeliveryClient) SignalList

func (c *DeliveryClient) SignalList() ([]string, error)

func (*DeliveryClient) SignalNotify

func (c *DeliveryClient) SignalNotify(sig string) error

func (*DeliveryClient) SignalWait

func (c *DeliveryClient) SignalWait(sig string) (bool, error)

func (*DeliveryClient) Status

func (c *DeliveryClient) Status()

type DirectClient

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

func (*DirectClient) Call

func (c *DirectClient) Call(node, method string, args ...string) (string, error)

func (*DirectClient) Close

func (client *DirectClient) Close()

func (*DirectClient) Dial

func (c *DirectClient) Dial(from, to *pb.NodeInfo) error

func (*DirectClient) FileSystemDownload

func (c *DirectClient) FileSystemDownload(file string) error

Download file in other peer

func (*DirectClient) FileSystemGet

func (c *DirectClient) FileSystemGet(src, dst string) error

func (*DirectClient) FileSystemPut

func (c *DirectClient) FileSystemPut(src, dst string) error

func (*DirectClient) Info

func (c *DirectClient) Info() (string, error)

Info can obtain the meta information of the target node, including CPU, DISK, MEM and so on. You can specify it by InfoRequest, and by default only basic parameters (the name of the node, the file uploaded, and the connection information) are returned.

func (*DirectClient) IsPublic

func (c *DirectClient) IsPublic() bool

func (*DirectClient) MakeTunnel

func (c *DirectClient) MakeTunnel(name string, ctx context.Context, promise yocki.Promise, event chan yocki.PromiseEvent) error

func (*DirectClient) Mark

func (c *DirectClient) Mark(name, addr string) error

func (*DirectClient) Name

func (client *DirectClient) Name() string

func (*DirectClient) Ping

func (c *DirectClient) Ping() error

Ping is used to detect whether the connection is available

func (*DirectClient) ProcessFind

func (c *DirectClient) ProcessFind(pid int64, cmd string) ([]*pb.Process, error)

func (*DirectClient) ProcessKill

func (c *DirectClient) ProcessKill(pid int64) error

func (*DirectClient) ProcessList

func (c *DirectClient) ProcessList() ([]*pb.Process, error)

func (*DirectClient) ProcessSpawn

func (c *DirectClient) ProcessSpawn(t pb.ProcessSpawnType, spec, cmd string) (int64, error)

func (*DirectClient) Register

func (c *DirectClient) Register(addrs ...string) ([]string, error)

Register tells the daemon the address of the peer.

func (*DirectClient) SignalClear

func (c *DirectClient) SignalClear(sigs ...string) error

func (*DirectClient) SignalInfo

func (c *DirectClient) SignalInfo(sig string) (bool, bool, error)

func (*DirectClient) SignalList

func (c *DirectClient) SignalList() ([]string, error)

func (*DirectClient) SignalNotify

func (c *DirectClient) SignalNotify(sig string) error

Notify pushes signal to Daemon

func (*DirectClient) SignalWait

func (c *DirectClient) SignalWait(sig string) (bool, error)

Wait is used to request signal from the daemon

func (*DirectClient) Status

func (client *DirectClient) Status()

func (*DirectClient) Unregister

func (c *DirectClient) Unregister(addrs ...string) error

Unregister tells the daemon to remove the peer according to addrs.

func (*DirectClient) Upload

func (c *DirectClient) Upload(file string) error

Upload pushes file information to peers so that peers can download files

type EstablishProtocal

type EstablishProtocal struct {
	Name  string `json:"name"`
	Delay int    `json:"delay"`
}

func (EstablishProtocal) String

func (p EstablishProtocal) String() string

func (EstablishProtocal) Type

type MethodCallProtocal

type MethodCallProtocal struct {
	Method string `json:"method"`
	Node   string `json:"node"`
}

func (MethodCallProtocal) String

func (p MethodCallProtocal) String() string

func (MethodCallProtocal) Type

type NetAddr

type NetAddr struct {
	Family uint16
	IP     string
	Port   uint16
	Zone   string
}

func TCPAddr2NetAddr

func TCPAddr2NetAddr(addr *net.TCPAddr) *NetAddr

func UDPAddr2NetAddr

func UDPAddr2NetAddr(addr *net.UDPAddr) *NetAddr

func (*NetAddr) LocalV4TCPAddr

func (info *NetAddr) LocalV4TCPAddr() *net.TCPAddr

func (*NetAddr) LocalV4UDPAddr

func (info *NetAddr) LocalV4UDPAddr() *net.UDPAddr

func (*NetAddr) String

func (info *NetAddr) String() string

func (*NetAddr) TCPAddr

func (info *NetAddr) TCPAddr() *net.TCPAddr

func (*NetAddr) UDPAddr

func (info *NetAddr) UDPAddr() *net.UDPAddr

type NetworkManager

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

func NewNetworkManager

func NewNetworkManager() *NetworkManager

func (*NetworkManager) MakeBridge

func (m *NetworkManager) MakeBridge()

func (*NetworkManager) Node

func (m *NetworkManager) Node(name string) Node

func (*NetworkManager) Nodes

func (m *NetworkManager) Nodes() map[string]Node

func (*NetworkManager) SetNode

func (m *NetworkManager) SetNode(name string, node Node)

type Node

type Node yocki.YockdClient

type NodeOption

type NodeOption func()

type P2PProtocal

type P2PProtocal interface {
	Protocal
	ParseP2P(message string) P2PProtocal
	Peer() []*NetAddr
}

type PeerAddr

type PeerAddr struct {
	NetAddr

	Peer     []string
	Attr     uint8
	ID       string
	Protocal P2PProtocal
	// contains filtered or unexported fields
}

func (*PeerAddr) CanMakeHole

func (info *PeerAddr) CanMakeHole() bool

func (*PeerAddr) IsCenter

func (info *PeerAddr) IsCenter() bool

func (*PeerAddr) IsWorker

func (info *PeerAddr) IsWorker() bool

func (*PeerAddr) String

func (info *PeerAddr) String() string

type Protocal

type Protocal interface {
	Parse(message []byte) Protocal
	Version() string
	Bytes() []byte
}

type ProxyYockdClient

type ProxyYockdClient struct {
	Addr   string
	Invoke func(p yocki.Protocal) (any, error)
	Node   string
}

func (*ProxyYockdClient) Call

func (c *ProxyYockdClient) Call(node, method string, args ...string) (string, error)

func (*ProxyYockdClient) Close

func (c *ProxyYockdClient) Close()

func (*ProxyYockdClient) Dial

func (c *ProxyYockdClient) Dial(form, to *pb.NodeInfo) error

func (*ProxyYockdClient) Download

func (c *ProxyYockdClient) Download(file string) error

func (*ProxyYockdClient) FileSystemGet

func (c *ProxyYockdClient) FileSystemGet(src, dst string) error

func (*ProxyYockdClient) FileSystemPut

func (c *ProxyYockdClient) FileSystemPut(src, dst string) error

func (*ProxyYockdClient) Info

func (c *ProxyYockdClient) Info() (string, error)

func (*ProxyYockdClient) IsPublic

func (c *ProxyYockdClient) IsPublic() bool

func (*ProxyYockdClient) MakeTunnel

func (c *ProxyYockdClient) MakeTunnel(name string, ctx context.Context, p yocki.Promise, e chan yocki.PromiseEvent) error

func (*ProxyYockdClient) Mark

func (c *ProxyYockdClient) Mark(name, addr string) error

func (*ProxyYockdClient) Name

func (c *ProxyYockdClient) Name() string

func (*ProxyYockdClient) Ping

func (c *ProxyYockdClient) Ping() error

func (*ProxyYockdClient) ProcessFind

func (c *ProxyYockdClient) ProcessFind(pid int64, cmd string) ([]*pb.Process, error)

func (*ProxyYockdClient) ProcessKill

func (c *ProxyYockdClient) ProcessKill(pid int64) error

func (*ProxyYockdClient) ProcessList

func (c *ProxyYockdClient) ProcessList() ([]*pb.Process, error)

func (*ProxyYockdClient) ProcessSpawn

func (c *ProxyYockdClient) ProcessSpawn(t pb.ProcessSpawnType, spec, cmd string) (int64, error)

func (*ProxyYockdClient) SignalClear

func (c *ProxyYockdClient) SignalClear(sigs ...string) error

func (*ProxyYockdClient) SignalInfo

func (c *ProxyYockdClient) SignalInfo(sig string) (bool, bool, error)

func (*ProxyYockdClient) SignalList

func (c *ProxyYockdClient) SignalList() ([]string, error)

func (*ProxyYockdClient) SignalNotify

func (c *ProxyYockdClient) SignalNotify(sig string) error

func (*ProxyYockdClient) SignalWait

func (c *ProxyYockdClient) SignalWait(sig string) (bool, error)

func (*ProxyYockdClient) Status

func (c *ProxyYockdClient) Status()

type RelayProtocal

type RelayProtocal interface {
	Type() pb.ProtocalType
	String() string
}

type Stun

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

func NewStun

func NewStun(opts ...StunOption) *Stun

func (*Stun) Discover

func (s *Stun) Discover() (addr PeerAddr, e error)

func (*Stun) Peer

func (s *Stun) Peer() []*PeerAddr

func (*Stun) ReadFromClient

func (s *Stun) ReadFromClient() error

func (*Stun) ReadFromServer

func (s *Stun) ReadFromServer()

func (*Stun) Run

func (s *Stun) Run(context context.Context)

func (*Stun) WriteToClient

func (s *Stun) WriteToClient()

func (*Stun) WriteToServer

func (s *Stun) WriteToServer()

type StunOption

type StunOption func(*Stun) error

func OptionEnableStunClient

func OptionEnableStunClient(laddr, raddr *NetAddr) StunOption

func OptionEnableStunServer

func OptionEnableStunServer(addr *NetAddr) StunOption

func OptionSetToken

func OptionSetToken(token string) StunOption

type StunProtocal

type StunProtocal struct {
	Hash  string      `json:"hash"`
	Ver   uint32      `json:"version"`
	Peers []*PeerAddr `json:"peer"`
	ID    string      `json:"id"`
}

func (*StunProtocal) Bytes

func (p *StunProtocal) Bytes() []byte

func (*StunProtocal) Parse

func (p *StunProtocal) Parse(message []byte) Protocal

func (*StunProtocal) Version

func (p *StunProtocal) Version() string

type TCPClient

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

type TCPListerner

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

func NewTCPListerner

func NewTCPListerner(addr *NetAddr) *TCPListerner

func (*TCPListerner) Accept

func (listen *TCPListerner) Accept()

func (*TCPListerner) Dial

func (listen *TCPListerner) Dial(addr *NetAddr)

type TCPServer

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

func ListenTCP

func ListenTCP(addr *NetAddr, protocal Protocal) *TCPServer

type UDPClient

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

func DialUDP

func DialUDP(laddr, raddr *NetAddr, protocal Protocal) *UDPClient

func (*UDPClient) Read

func (cli *UDPClient) Read() (Protocal, Context, error)

func (*UDPClient) Write

func (cli *UDPClient) Write(p Protocal) error

func (*UDPClient) WriteRaw

func (cli *UDPClient) WriteRaw(b []byte) error

type UDPConn

type UDPConn struct{}

func (*UDPConn) Read

func (conn *UDPConn) Read()

func (*UDPConn) Write

func (conn *UDPConn) Write()

type UDPListener

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

func NewUDPListener

func NewUDPListener(addr *NetAddr) *UDPListener

func (*UDPListener) Dial

func (listen *UDPListener) Dial(addr *NetAddr)

func (*UDPListener) Read

func (listen *UDPListener) Read()

func (*UDPListener) Write

func (listen *UDPListener) Write()

type UDPServer

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

func ListenUDP

func ListenUDP(addr *NetAddr, protocal Protocal) *UDPServer

func (*UDPServer) Read

func (s *UDPServer) Read() (Protocal, Context, error)

func (*UDPServer) Write

func (s *UDPServer) Write(p Protocal, addr *NetAddr) error

func (*UDPServer) WriteRaw

func (s *UDPServer) WriteRaw(b []byte, addr *NetAddr) error

type YockdClientOption

type YockdClientOption struct {
	IP     string
	Port   int
	Global *conf.YockdConf
}

Jump to

Keyboard shortcuts

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