Documentation ¶
Index ¶
- Constants
- Variables
- func AuthCheck() func(handler Handler) Handler
- func Chain(middlewares ...Middleware) func(Handler) Handler
- func Decode() func(Handler) Handler
- func Encode() func(Handler) Handler
- func Login(username, password string, cfg *util.NodeCfg) error
- func NewClient(base string) *client
- func RunJoinNetwork(cfg *util.Config, networkId string) error
- func RunLeaveNetwork(cfg *util.Config, networkId string) error
- func Start(cfg *util.Config) error
- func Status(cfg *util.NodeCfg) error
- func Stop(cfg *util.NodeCfg) error
- type ClientManager
- func (c *ClientManager) JoinLocalFvpn(req JoinRequest) (*JoinResponse, error)
- func (c *ClientManager) JoinNetwork(networkId string) (*JoinResponse, error)
- func (c *ClientManager) LeaveFvpnLocal(req LeaveRequest) (*LeaveResponse, error)
- func (c *ClientManager) LeaveNetwork(networkId string) (*LeaveResponse, error)
- type Frame
- type Handler
- type HandlerFunc
- type InBoundQueue
- type InitResponse
- type Instance
- type Interface
- type JoinRequest
- type JoinResponse
- type LeaveRequest
- type LeaveResponse
- type LoginRequest
- type LoginResponse
- type Middleware
- type NetworkManager
- type Node
- func (n *Node) AllowNetwork() func(Handler) Handler
- func (n *Node) Close() error
- func (n *Node) HttpServer() error
- func (n *Node) NewPeer(uid, ip string, pk security.NoisePublicKey, cache Interface) *Peer
- func (n *Node) PutPktToInbound(pkt *Frame)
- func (n *Node) PutPktToOutbound(pkt *Frame)
- func (n *Node) ReadFromTun()
- func (n *Node) ReadFromUdp()
- func (n *Node) WriteToDevice()
- func (n *Node) WriteToUDP()
- type OutBoundQueue
- type Peer
- func (p *Peer) GetCodec() security.Codec
- func (p *Peer) GetEndpoint() conn.Endpoint
- func (p *Peer) GetIP() string
- func (p *Peer) GetP2P() bool
- func (p *Peer) GetStatus() bool
- func (p *Peer) PutPktToOutbound(pkt *Frame)
- func (p *Peer) SetCodec(cipherFunc security.Codec)
- func (p *Peer) SetEndpoint(ep conn.Endpoint)
- func (p *Peer) SetMode(mode int)
- func (p *Peer) SetP2P(p2p bool)
- func (p *Peer) SetStatus(status bool)
- func (p *Peer) Start()
- type PeerMap
- type Response
- type RouterManager
- type StatusResponse
- type StopResponse
- type Value
Constants ¶
View Source
const ( QueueOutboundSize = 1024 QueueInboundSize = 1024 QueueHandshakeBoundSize = 1024 )
Variables ¶
View Source
var (
AllIPs = "0.0.0.0/0"
)
View Source
var (
PREFIX = "/api/v1/"
)
Functions ¶
func AuthCheck ¶
AuthCheck Middleware auth handler to check user login, if not, return an error tell user to login first.
func Chain ¶
func Chain(middlewares ...Middleware) func(Handler) Handler
Chain wrap middleware in order execute
Types ¶
type ClientManager ¶
type ClientManager struct { ConsoleClient *client LocalClient *client }
func NewManager ¶
func NewManager(cfg *util.NodeCfg) *ClientManager
func (*ClientManager) JoinLocalFvpn ¶
func (c *ClientManager) JoinLocalFvpn(req JoinRequest) (*JoinResponse, error)
JoinLocalFvpn call fvpn to create device handle traffic
func (*ClientManager) JoinNetwork ¶
func (c *ClientManager) JoinNetwork(networkId string) (*JoinResponse, error)
func (*ClientManager) LeaveFvpnLocal ¶
func (c *ClientManager) LeaveFvpnLocal(req LeaveRequest) (*LeaveResponse, error)
func (*ClientManager) LeaveNetwork ¶
func (c *ClientManager) LeaveNetwork(networkId string) (*LeaveResponse, error)
type Frame ¶
type Handler ¶
func WithMiddlewares ¶
func WithMiddlewares(handler Handler, middlewares ...Middleware) Handler
type HandlerFunc ¶
type InBoundQueue ¶
type InBoundQueue struct {
// contains filtered or unexported fields
}
func NewInBoundQueue ¶
func NewInBoundQueue() *InBoundQueue
func (*InBoundQueue) GetPktFromInbound ¶
func (o *InBoundQueue) GetPktFromInbound() chan *Frame
func (*InBoundQueue) PutPktToInbound ¶
func (o *InBoundQueue) PutPktToInbound(pkt *Frame)
type InitResponse ¶
type Interface ¶
type JoinRequest ¶
type JoinResponse ¶
type LeaveRequest ¶
type LeaveRequest struct {
JoinRequest
}
type LeaveResponse ¶
type LeaveResponse struct {
JoinResponse
}
type LoginRequest ¶
type LoginResponse ¶
type Middleware ¶
type NetworkManager ¶
type NetworkManager interface { JoinNet(userId, cidr string) error Leave(userId, cidr string) error LeaveNet(userId, cidr string) error Access(userId, cidr string) bool }
NetworkManager Join a network like : 192.168.0.1/24 if you give 192.168.0.1, default is 24
func NewNetworkManager ¶
func NewNetworkManager(userId string) NetworkManager
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a dev in any os.
func (*Node) AllowNetwork ¶
AllowNetwork valid user can join a network or a node, so here will check
func (*Node) HttpServer ¶
func (*Node) PutPktToInbound ¶
func (*Node) PutPktToOutbound ¶
func (*Node) ReadFromTun ¶
func (n *Node) ReadFromTun()
func (*Node) ReadFromUdp ¶
func (n *Node) ReadFromUdp()
func (*Node) WriteToDevice ¶
func (n *Node) WriteToDevice()
func (*Node) WriteToUDP ¶
func (n *Node) WriteToUDP()
type OutBoundQueue ¶
type OutBoundQueue struct {
// contains filtered or unexported fields
}
func NewOutBoundQueue ¶
func NewOutBoundQueue() *OutBoundQueue
func (*OutBoundQueue) GetPktFromOutbound ¶
func (o *OutBoundQueue) GetPktFromOutbound() chan *Frame
func (*OutBoundQueue) PutPktToOutbound ¶
func (o *OutBoundQueue) PutPktToOutbound(pkt *Frame)
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
func (*Peer) GetEndpoint ¶
func (*Peer) PutPktToOutbound ¶
func (*Peer) SetEndpoint ¶
type Response ¶
type RouterManager ¶
func NewRouter ¶
func NewRouter(cidr, name, deviceIP string) RouterManager
type StatusResponse ¶
type StopResponse ¶
type StopResponse struct {
Result string `json:"result"`
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.